Skip to content

Add autoconf to the management interface in IPv6 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,8 @@ def ReconfigureManagement(self, inPIF, inMode, inIP, inNetmask, inGateway, in
inPIF['opaqueref'], inPIF['ipv6_configuration_mode'], ','.join(inPIF['IPv6']), inPIF['ipv6_gateway'], FirstValue(inDNS, '')
)
else:
inIPv6 = inIP + '/' + inNetmask
inIPv6 = '' if inIP == '0.0.0.0' else inIP + '/' + inNetmask
inGateway = '' if inGateway == '0.0.0.0' else inGateway
self.session.xenapi.PIF.reconfigure_ipv6(inPIF['opaqueref'], inMode, inIPv6, inGateway, FirstValue(inDNS, ''))
if inPIF['ip_configuration_mode'].lower() == 'static':
# Update IPv4 DNS as well
Expand Down
20 changes: 14 additions & 6 deletions plugins-base/XSFeatureInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ def __init__(self):

self.nicMenu = Menu(self, None, "Configure Management Interface", choiceDefs)

self.modeMenu = Menu(self, None, Lang("Select IP Address Configuration Mode"), [
ChoiceDef(Lang("DHCP"), lambda: self.HandleModeChoice('DHCP2') ),
ChoiceDef(Lang("DHCP with Manually Assigned Hostname"), lambda: self.HandleModeChoice('DHCPMANUAL') ),
ChoiceDef(Lang("Static"), lambda: self.HandleModeChoice('STATIC') )
])
mode_choicedefs = []
if(currentPIF['primary_address_type'].lower() == 'ipv6'):
mode_choicedefs.append(ChoiceDef(Lang("Autoconf"), lambda : self.HandleModeChoice("AUTOCONF") ))
mode_choicedefs.append(ChoiceDef(Lang("DHCP"), lambda: self.HandleModeChoice('DHCP2') ))
mode_choicedefs.append(ChoiceDef(Lang("DHCP with Manually Assigned Hostname"),
lambda: self.HandleModeChoice('DHCPMANUAL') ))
mode_choicedefs.append(ChoiceDef(Lang("Static"), lambda: self.HandleModeChoice('STATIC') ))
self.modeMenu = Menu(self, None, Lang("Select IP Address Configuration Mode"), mode_choicedefs)

self.postDHCPMenu = Menu(self, None, Lang("Accept or Edit"), [
ChoiceDef(Lang("Continue With DHCP Enabled"), lambda: self.HandlePostDHCPChoice('CONTINUE') ),
Expand Down Expand Up @@ -175,8 +178,10 @@ def UpdateFieldsPRECOMMIT(self):
pane.AddStatusField(Lang("Netmask", 16), self.netmask)
pane.AddStatusField(Lang("Gateway", 16), self.gateway)

if self.mode != 'Static' and self.hostname == '':
if self.mode == 'DHCP' and self.hostname == '':
pane.AddStatusField(Lang("Hostname", 16), Lang("Assigned by DHCP"))
elif self.mode == 'Autoconf' and self.hostname == '':
pane.AddStatusField(Lang("Hostname", 16), Lang("Automatically assigned"))
else:
pane.AddStatusField(Lang("Hostname", 16), self.hostname)

Expand Down Expand Up @@ -382,6 +387,9 @@ def HandleModeChoice(self, inChoice):
self.hostname = Data.Inst().host.hostname('')
self.mode = 'Static'
self.ChangeState('STATICIP')
elif inChoice == 'AUTOCONF':
self.mode = 'Autoconf'
self.ChangeState('PRECOMMIT')

def HandlePostDHCPChoice(self, inChoice):
if inChoice == 'CONTINUE':
Expand Down