尽管收到api的200个请求,但我无法更改HP Gen10服务器的端口状态
我正在从运行CentOS 7.5的服务器上运行python3代码。我一直在参考https://hewlettpackard.github.io/ilo-rest-api-docs/ilo5/?python来表示应该使用的数据类型/调用。我已经对SharedNetwork接口端口的Oem.Hpe.NICEnabled属性和InterfaceEnabled属性进行了修补,当我收到200并通过专用端口失去连接时,共享端口无法联机。
# On successful login, return link to session & session token
def login(ip,uname,pwd):
# url
baseurl = "http://" + ip + "/redfish/v1/"
loginurl = baseurl + "SessionService/Sessions/"
# data
payload = {"UserName":uname, "Password":pwd}
jdata = json.dumps(payload)
# header
header = {"content-type":"application/json"}
print("Attempting login")
r = requests.post(url=loginurl,data=jdata,headers=header,verify=False)
if r.status_code == 201 or r.status_code == 200:
print("Session created successfully")
else:
return False
myToken = r.headers['X-Auth-Token']
mySessionLink = r.headers['Location']
return myToken,mySessionLink
# Enable Shared ILO
def sharedILO(ip,uname,pwd):
header = {}
myToken,mySessionLink = login(ip,uname,pwd)
header = {"content-type":"application/json"}
# update header with token
header['X-Auth-Token'] = myToken
baseurl = "http://"+ip+"/redfish/v1/"
managerurl = baseurl+"Managers/1/EthernetInterfaces/"
r = requests.get(url=managerurl,headers=header,verify=False)
for m in r.json()['Members']:
localurl = "http://"+ip+m['@odata.id']
j = requests.get(url=localurl,headers=header,verify=False)
j = j.json()
if j['Oem']['Hpe']['InterfaceType'] == 'Shared':
simplest = {'NICEnabled': True}
simpler = {'Hpe': simplest}
payload = {'Oem':simpler}
payload['InterfaceEnabled':True]
jdata = json.dumps(payload)
k = requests.patch(url=localurl,data=jdata,headers=header,verify=False)
reseturl = baseurl+"Managers/1/Actions/Manager.Reset/"
payload={}
jdata = json.dumps(payload)
k = requests.post(url=reseturl,data=jdata,headers=header,verify=False)
我希望启用接口会禁用专用端口,然后允许通过共享网络端口进行ilo连接。从代码中,我收到一条消息,提示需要重设ilo(因此为什么要执行帖子重设) 随后的那一行代码正在执行以重置ilo的操作,表明它已经通过了(我从物理上看机器重置了ilo)。
但是,在ilo重启后,我无法通过共享端口访问服务器。如果我以物理方式引导到服务器上的ilo,则可以看到在“网络选项”下,“网络接口适配器选项”仍然选择了“专用”端口。谁能想到我可能需要执行哪些其他步骤来确保ILO端口更改为使用共享nic?