Oob ip #307

Open
CllaudiaB wants to merge 3 commits from CllaudiaB/oob_ip into main
2 changed files with 18 additions and 8 deletions

View file

@ -39,12 +39,10 @@ class IPMI():
def __init__(self):
self.ret, self.output = subprocess.getstatusoutput('ipmitool lan print')
if self.ret != 0:
logging.error('Cannot get ipmi info: {}'.format(self.output))
logging.warning('IPMI command failed: {}'.format(self.output))
def parse(self):
_ipmi = {}
if self.ret != 0:
return _ipmi
for line in self.output.splitlines():
key = line.split(':')[0].strip()
@ -57,11 +55,15 @@ class IPMI():
ret['name'] = 'IPMI'
ret["mtu"] = 1500
ret['bonding'] = False
ret['mac'] = _ipmi['MAC Address']
ret['vlan'] = int(_ipmi['802.1q VLAN ID']) \
if _ipmi['802.1q VLAN ID'] != 'Disabled' else None
ip = _ipmi['IP Address']
netmask = _ipmi['Subnet Mask']
try:
ret['mac'] = _ipmi['MAC Address']
ret['vlan'] = int(_ipmi['802.1q VLAN ID']) \
if _ipmi['802.1q VLAN ID'] != 'Disabled' else None
ip = _ipmi['IP Address']
netmask = _ipmi['Subnet Mask']
except KeyError as e:
logging.error("IPMI decoding failed, missing: ", e.args[0])
return {}
address = str(IPNetwork('{}/{}'.format(ip, netmask)))
ret['ip'] = [address]

View file

@ -482,6 +482,14 @@ class ServerBase():
update += 1
if update:
expansion.save()
myips = nb.ipam.ip_addresses.filter(device_id=server.id)
for ip in myips:
if ip.assigned_object.display == "IPMI":
server.update({'oob_ip': ip.id})
break
logging.debug('Finished updating Server!')
def print_debug(self):