File tree 1 file changed +18
-4
lines changed
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -1293,10 +1293,24 @@ def get_my_ip_from_host_perspective(self):
1293
1293
log .debug ("Processing in Exception path, e={}" .format (e ))
1294
1294
raw_pty .sendcontrol ('c' ) # to avoid incase nc command hangs
1295
1295
time .sleep (2 ) # give it time to recover
1296
- log .debug ("Exception path sleeping 2 seconds to recover" )
1297
- # Petitboot does not support hostname -I
1298
- log .warning (
1299
- "Using my_ip={} from Exception path handling, this may not work" .format (my_ip ))
1296
+ try :
1297
+ ip = subprocess .check_output (['hostname' , '-i' ]).decode ('utf-8' ).strip ()
1298
+ ip_lst = subprocess .check_output (['hostname' , '-I' ]).decode ('utf-8' ).strip ().split ()
1299
+ # Let's validate the IP
1300
+ for item in ip_lst :
1301
+ if item == ip :
1302
+ my_ip = ip
1303
+ break
1304
+ if not my_ip :
1305
+ if len (ip_lst ) == 1 :
1306
+ my_ip = ip_lst [0 ]
1307
+ else :
1308
+ log .warning ("Unable to get server ip, "
1309
+ "hostname -i does not provide valid IP, "
1310
+ "correct and proceed with installation" )
1311
+ except subprocess .CalledProcessError as e :
1312
+ log .warning ("Unable to get server ip, hostname -i/-I "
1313
+ "commands not supported in server" )
1300
1314
1301
1315
return my_ip
1302
1316
You can’t perform that action at this time.
0 commit comments