Fixed XEN/XCP-NG network moving on service

This commit is contained in:
Adolfo Gómez García 2022-08-18 13:56:07 +02:00
parent c34fc41f56
commit 83394f0d34

View File

@ -477,21 +477,27 @@ class XenServer: # pylint: disable=too-many-public-methods
# If requested mac address change
try:
if mac is not None:
for vifId in self.VM.get_VIFs(vmId):
all_VIFs = self.VM.get_VIFs(vmId)
if not all_VIFs:
raise XenException('No Network interfaces found!')
found = (all_VIFs[0], self.VIF.get_record(all_VIFs[0]))
for vifId in all_VIFs:
vif = self.VIF.get_record(vifId)
logger.info('VIF: %s', vif)
if vif['network'] == mac['network']:
logger.debug('Found VIF: %s', vif['network'])
found = (vifId, vif)
break
logger.debug('Found VIF: %s', found[1])
vifId, vif = found
self.VIF.destroy(vifId)
# for k in ['status_code', 'status_detail', 'uuid']:
# try:
# del vif[k]
# except:
# logger.exception('Erasing property {0}'.format(k))
vif['MAC'] = mac['mac']
vif['network'] = mac['network']
vif['MAC_autogenerated'] = False
self.VIF.create(vif)
# If requested memory change
if memory:
logger.debug('Setting up memory to %s MB', memory)