Merge 76b2d253ce into ba4cdb217b
This commit is contained in:
commit
687c0127ac
4 changed files with 31 additions and 12 deletions
|
|
@ -47,7 +47,7 @@ def run(config):
|
|||
|
||||
|
||||
def main():
|
||||
return run(config)
|
||||
return 0 if run(config) else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class Network(object):
|
|||
#
|
||||
for addr in ip6_addr:
|
||||
addr["addr"] = addr["addr"].replace('%{}'.format(interface), '')
|
||||
addr["netmask"] = addr["netmask"].split('/')[0]
|
||||
addr["mask"] = addr["mask"].split('/')[0]
|
||||
ip_addr.append(addr)
|
||||
|
||||
mac = open('/sys/class/net/{}/address'.format(interface), 'r').read().strip()
|
||||
|
|
@ -109,7 +109,7 @@ class Network(object):
|
|||
'ip': [
|
||||
'{}/{}'.format(
|
||||
x['addr'],
|
||||
IPAddress(x['netmask']).netmask_bits()
|
||||
IPAddress(x['mask']).netmask_bits()
|
||||
) for x in ip_addr
|
||||
] if ip_addr else None, # FIXME: handle IPv6 addresses
|
||||
'ethtool': Ethtool(interface).parse(),
|
||||
|
|
@ -213,7 +213,7 @@ class Network(object):
|
|||
def reset_vlan_on_interface(self, nic, interface):
|
||||
update = False
|
||||
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
|
||||
# The object returned by pynetbox's save isn't always working (since pynetbox 6)
|
||||
interface = self.nb_net.interfaces.get(id=interface.id)
|
||||
|
|
@ -301,7 +301,7 @@ class Network(object):
|
|||
interface.save()
|
||||
|
||||
# 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_interface = self.lldp.get_switch_port(interface.name)
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ class Network(object):
|
|||
interface.lag = None
|
||||
|
||||
# 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_interface = self.lldp.get_switch_port(interface.name)
|
||||
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.misc import create_netbox_tags, get_hostname, get_device_platform
|
||||
from netbox_agent.network import VirtualNetwork
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
def is_vm(dmi):
|
||||
|
|
@ -130,3 +131,14 @@ class VirtualMachine(object):
|
|||
|
||||
if updated:
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
pynetbox==6.1.2
|
||||
netaddr==0.8.0
|
||||
netifaces==0.11.0
|
||||
pyyaml==6.0.1
|
||||
jsonargparse==3.11.2
|
||||
python-slugify==8.0.1
|
||||
packaging==23.1
|
||||
certifi==2023.7.22
|
||||
charset-normalizer==3.2.0
|
||||
distro==1.8.0
|
||||
idna==3.4
|
||||
jsonargparse==4.23.1
|
||||
netaddr==0.8.0
|
||||
netifaces2==0.0.18
|
||||
packaging==23.1
|
||||
pynetbox==7.0.1
|
||||
python-slugify==8.0.1
|
||||
PyYAML==6.0.1
|
||||
requests==2.31.0
|
||||
text-unidecode==1.3
|
||||
typing_extensions==4.7.1
|
||||
urllib3==2.0.4
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue