File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -68,14 +68,14 @@ def save(self):
6868 for entry in self .entries :
6969 if entry .op == "add" :
7070 if entry .separator == "=" :
71- matchString = "^\ *" + entry .name + ".*"
71+ matchString = r "^\ *" + entry .name + ".*"
7272 elif entry .separator == " " :
73- matchString = "^\ *" + entry .name + "\ *" + entry .value
73+ matchString = r "^\ *" + entry .name + r "\ *" + entry .value
7474 else :
7575 if entry .separator == "=" :
76- matchString = "^\ *" + entry .name + "\ *=\ *" + entry .value
76+ matchString = r "^\ *" + entry .name + r "\ *=\ *" + entry .value
7777 else :
78- matchString = "^\ *" + entry .name + "\ *" + entry .value
78+ matchString = r "^\ *" + entry .name + r "\ *" + entry .value
7979
8080 match = re .match (matchString , line )
8181 if match is not None :
Original file line number Diff line number Diff line change @@ -45,8 +45,11 @@ def getDefaultNetwork():
4545 if not cmd .isSuccess ():
4646 logging .debug ("Failed to get default route" )
4747 raise CloudRuntimeException ("Failed to get default route" )
48-
49- result = cmd .getStdout ().split (" " )
48+ output = cmd .getStdout ().strip ()
49+ result = output .split (" " )
50+ if len (result ) < 2 :
51+ logging .debug ("Output for the default route incomplete: %s. It should have been '<GATEWAY> <DEVICE>'" % output )
52+ raise CloudRuntimeException ("Output for the default route incomplete" )
5053 gateway = result [0 ]
5154 dev = result [1 ]
5255
@@ -150,10 +153,10 @@ def getDevInfo(dev):
150153 if line .find ("HWaddr" ) != - 1 :
151154 macAddr = line .split ("HWaddr " )[1 ].strip (" " )
152155 elif line .find ("inet " ) != - 1 :
153- m = re .search ("addr:(.*)\ *Bcast:(.*)\ *Mask:(.* )" , line )
156+ m = re .search (r "addr:([^\s]+)\s *Bcast:([^\s]+)\s *Mask:([^\s]+ )" , line )
154157 if m is not None :
155- ipAddr = m .group (1 ).rstrip ( " " )
156- netmask = m .group (3 ).rstrip ( " " )
158+ ipAddr = m .group (1 ).strip ( )
159+ netmask = m .group (3 ).strip ( )
157160
158161 if networkConfig .isBridgePort (dev ):
159162 type = "brport"
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ def getStdout(self):
6363 return self .stdout .decode ('utf-8' ).strip ('\n ' )
6464
6565 def getLines (self ):
66- return self .stdout .decode ('utf-8' ).strip ('\n ' )
66+ return self .stdout .decode ('utf-8' ).strip ('\n ' ). split ( ' \n ' )
6767
6868 def getStderr (self ):
6969 return self .stderr .decode ('utf-8' ).strip ('\n ' )
You can’t perform that action at this time.
0 commit comments