Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion plugins-base/XSFeatureInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self):
self.nic=None
self.converting = False
currentPIF = None
self.oldPIF = None
choiceArray = []
for i in range(len(data.host.PIFs([]))):
pif = data.host.PIFs([])[i]
Expand All @@ -45,6 +46,7 @@ def __init__(self):

choiceDefs.append(ChoiceDef(choiceName, lambda: self.HandleNICChoice(self.nicMenu.ChoiceIndex())))

self.oldPIF = currentPIF
if len(choiceDefs) == 0:
XSLog('Configure Management Interface found no PIFs to present')
choiceDefs.append(ChoiceDef(Lang("<Couldn't retrieve data about existing interfaces>"), None))
Expand Down Expand Up @@ -81,11 +83,14 @@ def __init__(self):
self.netmask = '0.0.0.0'
self.gateway = '0.0.0.0'
self.hostname = data.host.hostname('')
self.oldIP = self.IP

if currentPIF is not None:
if 'ip_configuration_mode' in currentPIF: self.mode = currentPIF['ip_configuration_mode']
if self.mode.lower().startswith('static'):
if 'IP' in currentPIF: self.IP = currentPIF['IP']
if 'IP' in currentPIF:
self.IP = currentPIF['IP']
self.oldIP = self.IP
if 'netmask' in currentPIF: self.netmask = currentPIF['netmask']
if 'gateway' in currentPIF: self.gateway = currentPIF['gateway']

Expand Down Expand Up @@ -445,6 +450,11 @@ def Commit(self):
else:
data.HostnameSet(self.hostname)
data.ReconfigureManagement(pif, self.mode, self.IP, self.netmask, self.gateway, dns)

# Reset old PIF in order to prevent network conflicts
if self.oldPIF != pif and self.IP == self.oldIP:
data.ReconfigureManagement(self.oldPIF, 'static', self.oldIP, '0.0.0.0', '0.0.0.0', '')

data.Update()
self.hostname = data.host.hostname('') # Hostname may have changed. Must be after data.Update()

Expand Down