@@ -53,11 +53,14 @@ def __init__(self):
5353
5454 self .nicMenu = Menu (self , None , "Configure Management Interface" , choiceDefs )
5555
56- self .modeMenu = Menu (self , None , Lang ("Select IP Address Configuration Mode" ), [
57- ChoiceDef (Lang ("DHCP" ), lambda : self .HandleModeChoice ('DHCP2' ) ),
58- ChoiceDef (Lang ("DHCP with Manually Assigned Hostname" ), lambda : self .HandleModeChoice ('DHCPMANUAL' ) ),
59- ChoiceDef (Lang ("Static" ), lambda : self .HandleModeChoice ('STATIC' ) )
60- ])
56+ mode_choicedefs = []
57+ if (currentPIF and currentPIF ['primary_address_type' ].lower () == 'ipv6' ):
58+ mode_choicedefs .append (ChoiceDef (Lang ("Autoconf" ), lambda : self .HandleModeChoice ("AUTOCONF" ) ))
59+ mode_choicedefs .append (ChoiceDef (Lang ("DHCP" ), lambda : self .HandleModeChoice ('DHCP2' ) ))
60+ mode_choicedefs .append (ChoiceDef (Lang ("DHCP with Manually Assigned Hostname" ),
61+ lambda : self .HandleModeChoice ('DHCPMANUAL' ) ))
62+ mode_choicedefs .append (ChoiceDef (Lang ("Static" ), lambda : self .HandleModeChoice ('STATIC' ) ))
63+ self .modeMenu = Menu (self , None , Lang ("Select IP Address Configuration Mode" ), mode_choicedefs )
6164
6265 self .postDHCPMenu = Menu (self , None , Lang ("Accept or Edit" ), [
6366 ChoiceDef (Lang ("Continue With DHCP Enabled" ), lambda : self .HandlePostDHCPChoice ('CONTINUE' ) ),
@@ -83,11 +86,17 @@ def __init__(self):
8386 self .hostname = data .host .hostname ('' )
8487
8588 if currentPIF is not None :
86- if 'ip_configuration_mode' in currentPIF : self .mode = currentPIF ['ip_configuration_mode' ]
89+ ipv6 = currentPIF ['primary_address_type' ].lower () == 'ipv6'
90+ configuration_mode_key = 'ipv6_configuration_mode' if ipv6 else 'ip_configuration_mode'
91+ if configuration_mode_key in currentPIF :
92+ self .mode = currentPIF [configuration_mode_key ]
8793 if self .mode .lower ().startswith ('static' ):
88- if 'IP' in currentPIF : self .IP = currentPIF ['IP' ]
89- if 'netmask' in currentPIF : self .netmask = currentPIF ['netmask' ]
90- if 'gateway' in currentPIF : self .gateway = currentPIF ['gateway' ]
94+ if 'IP' in currentPIF :
95+ self .IP = currentPIF ['IPv6' ][0 ].split ('/' )[0 ] if ipv6 else currentPIF ['IP' ]
96+ if 'netmask' in currentPIF :
97+ self .netmask = currentPIF ['IPv6' ][0 ].split ('/' )[1 ] if ipv6 else currentPIF ['netmask' ]
98+ if 'gateway' in currentPIF :
99+ self .gateway = currentPIF ['ipv6_gateway' ] if ipv6 else currentPIF ['gateway' ]
91100
92101 # Make the menu current choices point to our best guess of current choices
93102 if self .nic is not None :
@@ -169,8 +178,10 @@ def UpdateFieldsPRECOMMIT(self):
169178 pane .AddStatusField (Lang ("Netmask" , 16 ), self .netmask )
170179 pane .AddStatusField (Lang ("Gateway" , 16 ), self .gateway )
171180
172- if self .mode != 'Static ' and self .hostname == '' :
181+ if self .mode == 'DHCP ' and self .hostname == '' :
173182 pane .AddStatusField (Lang ("Hostname" , 16 ), Lang ("Assigned by DHCP" ))
183+ elif self .mode == 'Autoconf' and self .hostname == '' :
184+ pane .AddStatusField (Lang ("Hostname" , 16 ), Lang ("Automatically assigned" ))
174185 else :
175186 pane .AddStatusField (Lang ("Hostname" , 16 ), self .hostname )
176187
@@ -376,6 +387,9 @@ def HandleModeChoice(self, inChoice):
376387 self .hostname = Data .Inst ().host .hostname ('' )
377388 self .mode = 'Static'
378389 self .ChangeState ('STATICIP' )
390+ elif inChoice == 'AUTOCONF' :
391+ self .mode = 'Autoconf'
392+ self .ChangeState ('PRECOMMIT' )
379393
380394 def HandlePostDHCPChoice (self , inChoice ):
381395 if inChoice == 'CONTINUE' :
@@ -463,11 +477,13 @@ def StatusUpdateHandler(cls, inPane):
463477 inPane .AddWrappedTextField (Lang ("<No interface configured>" ))
464478 else :
465479 for pif in data .derived .managementpifs ([]):
480+ ipv6 = pif ['primary_address_type' ].lower () == 'ipv6'
481+ configuration_mode = pif ['ipv6_configuration_mode' ] if ipv6 else pif ['ip_configuration_mode' ]
466482 inPane .AddStatusField (Lang ('Device' , 16 ), pif ['device' ])
467483 if int (pif ['VLAN' ]) >= 0 :
468484 inPane .AddStatusField (Lang ('VLAN' , 16 ), pif ['VLAN' ])
469485 inPane .AddStatusField (Lang ('MAC Address' , 16 ), pif ['MAC' ])
470- inPane .AddStatusField (Lang ('DHCP/Static IP' , 16 ), pif [ 'ip_configuration_mode' ] )
486+ inPane .AddStatusField (Lang ('DHCP/Static IP' , 16 ), configuration_mode )
471487
472488 inPane .AddStatusField (Lang ('IP address' , 16 ), data .ManagementIP ('' ))
473489 inPane .AddStatusField (Lang ('Netmask' , 16 ), data .ManagementNetmask ('' ))
0 commit comments