diff --git a/XSConsoleData.py b/XSConsoleData.py index d059f10..a7a0784 100644 --- a/XSConsoleData.py +++ b/XSConsoleData.py @@ -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 diff --git a/plugins-base/XSFeatureInterface.py b/plugins-base/XSFeatureInterface.py index f884ecc..09873ad 100644 --- a/plugins-base/XSFeatureInterface.py +++ b/plugins-base/XSFeatureInterface.py @@ -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') ), @@ -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) @@ -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':