+ 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}