From: Janne Suominen Date: Wed, 12 Jun 2019 06:15:57 +0000 (+0300) Subject: Add missing support for HP Gen10 X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fironic-virtmedia-driver.git;a=commitdiff_plain;h=038fbf4be08107cacca24de5912d1f470425fa1f Add missing support for HP Gen10 Gen10 has slightly changed the paths of the unmount and mount for virtual media because of the new version of ILO. Change-Id: I4e9c6383be3e96477323e8f0af15b87213ea7a4d --- diff --git a/src/ironic_virtmedia_driver/vendors/hp/hp.py b/src/ironic_virtmedia_driver/vendors/hp/hp.py index a1ff242..3882a89 100644 --- a/src/ironic_virtmedia_driver/vendors/hp/hp.py +++ b/src/ironic_virtmedia_driver/vendors/hp/hp.py @@ -83,10 +83,35 @@ class HP(IronicVirtMediaHW): error = message["error"]["@Message.ExtendedInfo"][0]["MessageId"].split(".") return error + def _get_eject_media(self, response): + try: + r_dict = response.dict + ops = r_dict.get("Oem", {}).get(self.typepath.defs.oemhp, {}).get("Actions") + if ops: + for key in ops.keys(): + if "EjectVirtualMedia" in key: + return ops[key]['target'] + except Exception as err: + self.log.error("Failure in finding eject action from response") + return None + + def _umount_virtual_cd(self, connection, response): + unmount_path = None + unmount_body = None + if self.typepath.defs.isgen10 or \ + self.typepath.defs.isgen9: + unmount_path = self._get_eject_media(response) + unmount_body = {} + if not unmount_path: + operation = _("Failed to unmount image") + error = _("Failed to find unmount path") + raise virtmedia_exception.VirtmediaOperationError( + operation=operation, error=error) + else: + unmount_path = response.dict.get("@odata.id", "") + unmount_body = {"Action": "EjectVirtualMedia", + "Target": self.typepath.defs.oempath} - def _umount_virtual_cd(self, connection, cd_location): - unmount_path = cd_location - unmount_body = {"Action": "EjectVirtualMedia", "Target": self.typepath.defs.oempath} resp = connection.post(path=unmount_path, body=unmount_body) if resp.status != 200: self.log.error("Unmounting cd failed: %r, cd location: %r", resp, unmount_path) @@ -109,7 +134,7 @@ class HP(IronicVirtMediaHW): if response.status == 200 and "DVD" in response.dict["MediaTypes"]: if response.dict['Inserted']: - self._umount_virtual_cd(connection, vmlink["@odata.id"]) + self._umount_virtual_cd(connection, response) body = {"Image": image_location} @@ -140,7 +165,7 @@ class HP(IronicVirtMediaHW): response = connection.get(vmlink["@odata.id"]) if response.status == 200 and "DVD" in response.dict["MediaTypes"]: if response.dict['Inserted']: - self._umount_virtual_cd(connection, vmlink["@odata.id"]) + self._umount_virtual_cd(connection, response) connection.logout() return True