2
0
mirror of https://opendev.org/x/pyghmi synced 2025-03-20 18:37:45 +00:00

Try generic method for media attach

If OEM does not handle the mount, try a generic way instead.

Change-Id: I19ce70796d270f32718e1d41c01388afe9795a0d
This commit is contained in:
Jarrod Johnson 2019-07-01 14:26:05 -04:00
parent ea676265a1
commit 77daf6817e
2 changed files with 12 additions and 2 deletions

View File

@ -1390,7 +1390,16 @@ class Command(object):
if vmcoll:
vmlist = self._do_web_request(vmcoll)
vmurls = [x['@odata.id'] for x in vmlist.get('Members', [])]
return self.oem.attach_remote_media(url, username, password, vmurls)
try:
self.oem.attach_remote_media(url, username, password, vmurls)
except exc.BypassGenericBehavior:
return
for vmurl in vmurls:
vminfo = self._do_web_request(vmurl, cache=False)
if vminfo['ConnectedVia'] != 'NotConnected':
continue
self._do_web_request(vmurl, {'Image': url, 'Inserted': True}, 'PATCH')
break
def detach_remote_media(self):
bmcinfo = self._do_web_request(self._bmcurl)
@ -1401,7 +1410,7 @@ class Command(object):
for vminfo in self._do_bulk_requests(vmurls):
vminfo, currl = vminfo
if vminfo['Image']:
self._do_web_request(currl, {'Image': None}, method='PATCH')
self._do_web_request(currl, {'Image': None, 'Inserted': False}, method='PATCH')
def upload_media(self, filename, progress=None):
"""Upload a file to be hosted on the target BMC

View File

@ -436,6 +436,7 @@ class OEMHandler(generic.OEMHandler):
if vminfo['ConnectedVia'] != 'NotConnected':
continue
self._do_web_request(vmurl, {'Image': url, 'Inserted': True}, 'PATCH')
raise pygexc.BypassGenericBehavior()
break
def upload_media(self, filename, progress=None):