fix(Common):修正"testClentIP"变量获取
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
Resource ../../03-Variable/BifangApiVariable.txt
|
Resource ../../03-Variable/BifangApiVariable.txt
|
||||||
Library REST http://${host}:${port}
|
Library REST http://${host}:${port}
|
||||||
Library Collections
|
Library Collections
|
||||||
|
Library ExtensionLibrary
|
||||||
Resource ../tsg_bfapi/LoginLogout.robot
|
Resource ../tsg_bfapi/LoginLogout.robot
|
||||||
Resource ../tsg_ui/Logout/Logout.robot
|
Resource ../tsg_ui/Logout/Logout.robot
|
||||||
Resource ../tsg_ui/Login/Login.robot
|
Resource ../tsg_ui/Login/Login.robot
|
||||||
@@ -9,8 +10,10 @@ Resource ../tsg_ui/Login/Login.robot
|
|||||||
*** Keywords ***
|
*** Keywords ***
|
||||||
LoginAndAddLocalIP
|
LoginAndAddLocalIP
|
||||||
# 获取主机IP
|
# 获取主机IP
|
||||||
#${ip} Get Host IP
|
${ip} Get Host IP
|
||||||
#Set Global Variable ${testClentIP} ${ip}
|
Set Global Variable ${testClentIP} ${ip}
|
||||||
|
Should Not Be Empty ${testClentIP}
|
||||||
|
|
||||||
Run Keyword If '${loginType}' == 'api' ApiLoginAndAddLocalIP aa
|
Run Keyword If '${loginType}' == 'api' ApiLoginAndAddLocalIP aa
|
||||||
... ELSE IF '${loginType}' == 'cli' CliLogin
|
... ELSE IF '${loginType}' == 'cli' CliLogin
|
||||||
... ELSE UiLoginAndAaddLocalIP bb
|
... ELSE UiLoginAndAaddLocalIP bb
|
||||||
|
|||||||
@@ -6,11 +6,21 @@ class mytool():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_host_IP(self):
|
def get_host_IP(self, flag="50"):
|
||||||
try:
|
#try:
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
#s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
s.connect(('8.8.8.8', 80))
|
#s.connect(('8.8.8.8', 80))
|
||||||
ip = s.getsockname()[0]
|
#ip = s.getsockname()[0]
|
||||||
finally:
|
#finally:
|
||||||
s.close()
|
#s.close()
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
ipTriple = socket.gethostbyname_ex(hostname)
|
||||||
|
ips = list(ipTriple[2:])
|
||||||
|
ip = ""
|
||||||
|
for i in ips:
|
||||||
|
ipList = list(i)
|
||||||
|
for ip1 in ipList:
|
||||||
|
if "."+flag+"." in ip1:
|
||||||
|
ip = ip1
|
||||||
|
break
|
||||||
return ip
|
return ip
|
||||||
Reference in New Issue
Block a user