Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix virtual guests command #350

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions netbox_agent/hypervisor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import shlex
import subprocess

from netbox_agent.config import config
Expand Down Expand Up @@ -44,8 +43,12 @@ def create_netbox_virtual_guest(self, name):
return guest

def get_virtual_guests(self):
output = subprocess.check_output(shlex.split(config.virtual.list_guests_cmd))
return output.decode("utf-8").split()
status, output = subprocess.getstatusoutput(config.virtual.list_guests_cmd)

if status == 0:
return output.split()
else:
raise Exception(f"Error occurred while executing the command: {output}")

def create_or_update_device_virtual_machines(self):
nb_guests = self.get_netbox_virtual_guests()
Expand Down
Loading