Merge pull request 'Virtualmachine corrections' (#279) from obeone/virtualmachine_corrections into master
Reviewed-on: #279
This commit is contained in:
commit
c1a7f661a3
3 changed files with 16 additions and 4 deletions
|
@ -47,7 +47,7 @@ def run(config):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
return run(config)
|
return 0 if run(config) else 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -213,7 +213,7 @@ class Network(object):
|
||||||
def reset_vlan_on_interface(self, nic, interface):
|
def reset_vlan_on_interface(self, nic, interface):
|
||||||
update = False
|
update = False
|
||||||
vlan_id = nic['vlan']
|
vlan_id = nic['vlan']
|
||||||
lldp_vlan = self.lldp.get_switch_vlan(nic['name']) if config.network.lldp else None
|
lldp_vlan = self.lldp.get_switch_vlan(nic['name']) if config.network.lldp and isinstance(self, ServerNetwork) else None
|
||||||
# For strange reason, we need to get the object from scratch
|
# For strange reason, we need to get the object from scratch
|
||||||
# The object returned by pynetbox's save isn't always working (since pynetbox 6)
|
# The object returned by pynetbox's save isn't always working (since pynetbox 6)
|
||||||
interface = self.nb_net.interfaces.get(id=interface.id)
|
interface = self.nb_net.interfaces.get(id=interface.id)
|
||||||
|
@ -301,7 +301,7 @@ class Network(object):
|
||||||
interface.save()
|
interface.save()
|
||||||
|
|
||||||
# cable the interface
|
# cable the interface
|
||||||
if config.network.lldp:
|
if config.network.lldp and isinstance(self, ServerNetwork):
|
||||||
switch_ip = self.lldp.get_switch_ip(interface.name)
|
switch_ip = self.lldp.get_switch_ip(interface.name)
|
||||||
switch_interface = self.lldp.get_switch_port(interface.name)
|
switch_interface = self.lldp.get_switch_port(interface.name)
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ class Network(object):
|
||||||
interface.lag = None
|
interface.lag = None
|
||||||
|
|
||||||
# cable the interface
|
# cable the interface
|
||||||
if config.network.lldp:
|
if config.network.lldp and isinstance(self, ServerNetwork):
|
||||||
switch_ip = self.lldp.get_switch_ip(interface.name)
|
switch_ip = self.lldp.get_switch_ip(interface.name)
|
||||||
switch_interface = self.lldp.get_switch_port(interface.name)
|
switch_interface = self.lldp.get_switch_port(interface.name)
|
||||||
if switch_ip and switch_interface:
|
if switch_ip and switch_interface:
|
||||||
|
|
|
@ -7,6 +7,7 @@ from netbox_agent.location import Tenant
|
||||||
from netbox_agent.logging import logging # NOQA
|
from netbox_agent.logging import logging # NOQA
|
||||||
from netbox_agent.misc import create_netbox_tags, get_hostname, get_device_platform
|
from netbox_agent.misc import create_netbox_tags, get_hostname, get_device_platform
|
||||||
from netbox_agent.network import VirtualNetwork
|
from netbox_agent.network import VirtualNetwork
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
|
||||||
def is_vm(dmi):
|
def is_vm(dmi):
|
||||||
|
@ -138,3 +139,14 @@ class VirtualMachine(object):
|
||||||
|
|
||||||
if updated:
|
if updated:
|
||||||
vm.save()
|
vm.save()
|
||||||
|
|
||||||
|
def print_debug(self):
|
||||||
|
self.network = VirtualNetwork(server=self)
|
||||||
|
print('Cluster:', self.get_netbox_cluster(config.virtual.cluster_name))
|
||||||
|
print('Platform:', self.device_platform)
|
||||||
|
print('VM:', self.get_netbox_vm())
|
||||||
|
print('vCPU:', self.get_vcpus())
|
||||||
|
print('Memory:', f"{self.get_memory()} MB")
|
||||||
|
print('NIC:',)
|
||||||
|
pprint(self.network.get_network_cards())
|
||||||
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue