mirror of
https://opendev.org/x/pyghmi
synced 2025-06-02 11:37:10 +00:00
Update generic redfish remote media for eject/insert
Certain redfish implementation only allow manipulation of remote media through Actions. Detect when relevant Actions are indicated and use them if offered. Change-Id: I4eac9e5f4edb111f45551280fd98cdbc9c10c178
This commit is contained in:
parent
e2b2f6806b
commit
51eebd39fc
@ -1535,14 +1535,21 @@ class Command(object):
|
||||
vminfo = self._do_web_request(vmurl, cache=False)
|
||||
if vminfo.get('ConnectedVia', None) != 'NotConnected':
|
||||
continue
|
||||
try:
|
||||
self._do_web_request(vmurl, {'Image': url, 'Inserted': True},
|
||||
'PATCH')
|
||||
except exc.RedfishError as re:
|
||||
if re.msgid.endswith(u'PropertyUnknown'):
|
||||
self._do_web_request(vmurl, {'Image': url}, 'PATCH')
|
||||
else:
|
||||
raise
|
||||
inserturl = vminfo.get(
|
||||
'Actions', {}).get(
|
||||
'#VirtualMedia.InsertMedia', {}).get('target', None)
|
||||
if inserturl:
|
||||
self._do_web_request(inserturl, {'Image': url})
|
||||
else:
|
||||
try:
|
||||
self._do_web_request(vmurl,
|
||||
{'Image': url, 'Inserted': True},
|
||||
'PATCH')
|
||||
except exc.RedfishError as re:
|
||||
if re.msgid.endswith(u'PropertyUnknown'):
|
||||
self._do_web_request(vmurl, {'Image': url}, 'PATCH')
|
||||
else:
|
||||
raise
|
||||
break
|
||||
|
||||
def detach_remote_media(self):
|
||||
@ -1558,17 +1565,23 @@ class Command(object):
|
||||
for vminfo in self._do_bulk_requests(vmurls):
|
||||
vminfo, currl = vminfo
|
||||
if vminfo['Image']:
|
||||
try:
|
||||
self._do_web_request(currl,
|
||||
{'Image': None,
|
||||
'Inserted': False},
|
||||
method='PATCH')
|
||||
except exc.RedfishError as re:
|
||||
if re.msgid.endswith(u'PropertyUnknown'):
|
||||
self._do_web_request(currl, {'Image': None},
|
||||
ejurl = vminfo.get(
|
||||
'Actions', {}).get(
|
||||
'#VirtualMedia.EjectMedia', {}).get('target', None)
|
||||
if ejurl:
|
||||
self._do_web_request(ejurl, {})
|
||||
else:
|
||||
try:
|
||||
self._do_web_request(currl,
|
||||
{'Image': None,
|
||||
'Inserted': False},
|
||||
method='PATCH')
|
||||
else:
|
||||
raise
|
||||
except exc.RedfishError as re:
|
||||
if re.msgid.endswith(u'PropertyUnknown'):
|
||||
self._do_web_request(currl, {'Image': None},
|
||||
method='PATCH')
|
||||
else:
|
||||
raise
|
||||
|
||||
def upload_media(self, filename, progress=None, data=None):
|
||||
"""Upload a file to be hosted on the target BMC
|
||||
|
Loading…
x
Reference in New Issue
Block a user