Virtual Machine feature #122

Merged
Solvik merged 13 commits from vm into master 2020-04-19 12:28:49 +02:00
Showing only changes of commit 4ee9325c7e - Show all commits

View file

@ -359,18 +359,19 @@ class Network(object):
nic.delete() nic.delete()
# delete IP on netbox that are not known on this server # delete IP on netbox that are not known on this server
netbox_ips = nb.ipam.ip_addresses.filter( if len(nb_nics):
interface_id=[x.id for x in nb_nics], netbox_ips = nb.ipam.ip_addresses.filter(
) interface_id=[x.id for x in nb_nics],
all_local_ips = list(chain.from_iterable([ )
x['ip'] for x in self.nics if x['ip'] is not None all_local_ips = list(chain.from_iterable([
])) x['ip'] for x in self.nics if x['ip'] is not None
for netbox_ip in netbox_ips: ]))
if netbox_ip.address not in all_local_ips: for netbox_ip in netbox_ips:
logging.info('Unassigning IP {ip} from {interface}'.format( if netbox_ip.address not in all_local_ips:
ip=netbox_ip.address, interface=netbox_ip.interface)) logging.info('Unassigning IP {ip} from {interface}'.format(
netbox_ip.interface = None ip=netbox_ip.address, interface=netbox_ip.interface))
netbox_ip.save() netbox_ip.interface = None
netbox_ip.save()
# update each nic # update each nic
for nic in self.nics: for nic in self.nics: