@@ -965,56 +965,20 @@ def ManagementIP(self, inDefault = None):
965
965
def ManagementNetmask (self , inDefault = None ):
966
966
retVal = inDefault
967
967
968
- # FIXME: Address should come from API, but not available at present. For DHCP this is just a guess at the gateway address
969
968
for pif in self .derived .managementpifs ([]):
970
- if pif ['ip_configuration_mode' ].lower ().startswith ('static' ):
971
- # For static IP the API address is correct
972
- retVal = pif ['netmask' ]
973
- elif pif ['ip_configuration_mode' ].lower ().startswith ('dhcp' ):
974
- # For DHCP, find the gateway address by parsing the output from the 'route' command
975
- if 'bridge' in pif ['network' ]:
976
- device = pif ['network' ]['bridge' ]
977
- else :
978
- device = pif ['device' ]
979
-
980
- device = ShellUtils .MakeSafeParam (device )
981
-
982
- ipre = r'[0-9a-f.:]+'
983
- ifRE = re .compile (r'\s*inet\s+' + ipre + '\s+netmask\s+(' + ipre + r')\s+broadcast\s+(' + ipre + r')\s*$' ,
984
- re .IGNORECASE )
985
-
986
- ifconfig = commands .getoutput ("/sbin/ifconfig '" + device + "'" ).split ("\n " )
987
- for line in ifconfig :
988
- match = ifRE .match (line )
989
- if match :
990
- retVal = match .group (1 )
991
- break
969
+ retVal = pif ['netmask' ]
970
+ if retVal :
971
+ break
992
972
993
973
return retVal
994
974
995
975
def ManagementGateway (self , inDefault = None ):
996
976
retVal = inDefault
997
977
998
- # FIXME: Address should come from API, but not available at present. For DHCP this is just a guess at the gateway address
999
978
for pif in self .derived .managementpifs ([]):
1000
- if pif ['ip_configuration_mode' ].lower ().startswith ('static' ):
1001
- # For static IP the API address is correct
1002
- retVal = pif ['gateway' ]
1003
- elif pif ['ip_configuration_mode' ].lower ().startswith ('dhcp' ):
1004
- # For DHCP, find the gateway address by parsing the output from the 'route' command
1005
- if 'bridge' in pif ['network' ]:
1006
- device = pif ['network' ]['bridge' ]
1007
- else :
1008
- device = pif ['device' ]
1009
- routeRE = re .compile (r'([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+UG\s+\d+\s+\d+\s+\d+\s+' + device ,
1010
- re .IGNORECASE )
1011
-
1012
- routes = commands .getoutput ("/sbin/route -n" ).split ("\n " )
1013
- for line in routes :
1014
- match = routeRE .match (line )
1015
- if match :
1016
- retVal = match .group (2 )
1017
- break
979
+ retVal = pif ['gateway' ]
980
+ if retVal :
981
+ break
1018
982
1019
983
return retVal
1020
984
0 commit comments