@@ -910,7 +910,21 @@ def ReconfigureManagement(self, inPIF, inMode, inIP, inNetmask, inGateway, in
910910 Auth .Inst ().AssertAuthenticated ()
911911 try :
912912 self .RequireSession ()
913- self .session .xenapi .PIF .reconfigure_ip (inPIF ['opaqueref' ], inMode , inIP , inNetmask , inGateway , FirstValue (inDNS , '' ))
913+ if inPIF ['primary_address_type' ].lower () == 'ipv4' :
914+ self .session .xenapi .PIF .reconfigure_ip (inPIF ['opaqueref' ], inMode , inIP , inNetmask , inGateway , FirstValue (inDNS , '' ))
915+ if inPIF ['ipv6_configuration_mode' ].lower () == 'static' :
916+ # Update IPv6 DNS as well
917+ self .session .xenapi .PIF .reconfigure_ipv6 (
918+ inPIF ['opaqueref' ], inPIF ['ipv6_configuration_mode' ], ',' .join (inPIF ['IPv6' ]), inPIF ['ipv6_gateway' ], FirstValue (inDNS , '' )
919+ )
920+ else :
921+ inIPv6 = inIP + '/' + inNetmask
922+ self .session .xenapi .PIF .reconfigure_ipv6 (inPIF ['opaqueref' ], inMode , inIPv6 , inGateway , FirstValue (inDNS , '' ))
923+ if inPIF ['ip_configuration_mode' ].lower () == 'static' :
924+ # Update IPv4 DNS as well
925+ self .session .xenapi .PIF .reconfigure_ip (
926+ inPIF ['opaqueref' ], inPIF ['ip_configuration_mode' ], inPIF ['IP' ], inPIF ['netmask' ], inPIF ['gateway' ], FirstValue (inDNS , '' )
927+ )
914928 self .session .xenapi .host .management_reconfigure (inPIF ['opaqueref' ])
915929 status , output = commands .getstatusoutput ('%s host-signal-networking-change' % (Config .Inst ().XECLIPath ()))
916930 if status != 0 :
@@ -930,6 +944,7 @@ def DisableManagement(self):
930944 # Disable the PIF that the management interface was using
931945 for pif in self .derived .managementpifs ([]):
932946 self .session .xenapi .PIF .reconfigure_ip (pif ['opaqueref' ], 'None' ,'' ,'' ,'' ,'' )
947+ self .session .xenapi .PIF .reconfigure_ipv6 (pif ['opaqueref' ], 'None' ,'' ,'' ,'' )
933948 finally :
934949 # Network reconfigured so this link is potentially no longer valid
935950 self .session = Auth .Inst ().CloseSession (self .session )
@@ -965,10 +980,12 @@ def ManagementNetmask(self, inDefault = None):
965980
966981 # FIXME: Address should come from API, but not available at present. For DHCP this is just a guess at the gateway address
967982 for pif in self .derived .managementpifs ([]):
968- if pif ['ip_configuration_mode' ].lower ().startswith ('static' ):
983+ ipv6 = pif ['primary_address_type' ].lower () == 'ipv6'
984+ configuration_mode = pif ['ipv6_configuration_mode' ] if ipv6 else pif ['ip_configuration_mode' ]
985+ if configuration_mode .lower ().startswith ('static' ):
969986 # For static IP the API address is correct
970- retVal = pif ['netmask' ]
971- elif pif [ 'ip_configuration_mode' ] .lower ().startswith ('dhcp' ):
987+ retVal = pif ['IPv6' ][ 0 ]. split ( '/' )[ 1 ] if ipv6 else pif [ ' netmask' ]
988+ elif configuration_mode .lower ().startswith ('dhcp' ):
972989 # For DHCP, find the gateway address by parsing the output from the 'route' command
973990 if 'bridge' in pif ['network' ]:
974991 device = pif ['network' ]['bridge' ]
@@ -995,10 +1012,12 @@ def ManagementGateway(self, inDefault = None):
9951012
9961013 # FIXME: Address should come from API, but not available at present. For DHCP this is just a guess at the gateway address
9971014 for pif in self .derived .managementpifs ([]):
998- if pif ['ip_configuration_mode' ].lower ().startswith ('static' ):
1015+ ipv6 = pif ['primary_address_type' ].lower () == 'ipv6'
1016+ configuration_mode = pif ['ipv6_configuration_mode' ] if ipv6 else pif ['ip_configuration_mode' ]
1017+ if configuration_mode .lower ().startswith ('static' ):
9991018 # For static IP the API address is correct
1000- retVal = pif ['gateway' ]
1001- elif pif [ 'ip_configuration_mode' ] .lower ().startswith ('dhcp' ):
1019+ retVal = pif ['ipv6_gateway' ] if ipv6 else pif [ ' gateway' ]
1020+ elif configuration_mode .lower ().startswith ('dhcp' ):
10021021 # For DHCP, find the gateway address by parsing the output from the 'route' command
10031022 if 'bridge' in pif ['network' ]:
10041023 device = pif ['network' ]['bridge' ]
0 commit comments