def map_volume(self, volume_id, host_name): logger.debug("mapping volume : {0} to host : " "{1}".format(volume_id, host_name)) vol_name = self._get_volume_name_by_wwn(volume_id) cli_kwargs = {'host': host_name, 'object_id': vol_name, 'force': True} try: lun = self.get_first_free_lun(host_name) cli_kwargs.update({'scsi': lun}) self.client.svctask.mkvdiskhostmap(**cli_kwargs) except (svc_errors.CommandExecutionError, CLIFailureError) as ex: if not is_warning_message(ex.my_message): logger.error(msg="Map volume {0} to host {1} failed. Reason " "is: {2}".format(vol_name, host_name, ex)) if NAME_NOT_EXIST_OR_MEET_RULES in ex.my_message: raise array_errors.HostNotFoundError(host_name) if SPECIFIED_OBJ_NOT_EXIST in ex.my_message: raise array_errors.ObjectNotFoundError(vol_name) if LUN_ALREADY_IN_USE in ex.my_message: raise array_errors.LunAlreadyInUseError(lun, host_name) raise array_errors.MappingError(vol_name, host_name, ex) except Exception as ex: logger.exception(ex) raise ex return str(lun)
def map_volume(self, volume_id, host_name): logger.debug("mapping volume : {0} to host : {1}".format( volume_id, host_name)) vol_name = self._get_object_name_by_wwn(volume_id) lun = self._get_next_available_lun(host_name) try: self.client.cmd.map_vol(host=host_name, vol=vol_name, lun=lun) except xcli_errors.OperationForbiddenForUserCategoryError as ex: logger.exception(ex) raise controller_errors.PermissionDeniedError( "map volume : {0} to host : {1}".format(volume_id, host_name)) except xcli_errors.VolumeBadNameError as ex: logger.exception(ex) raise controller_errors.ObjectNotFoundError(vol_name) except xcli_errors.HostBadNameError as ex: logger.exception(ex) raise controller_errors.HostNotFoundError(host_name) except xcli_errors.CommandFailedRuntimeError as ex: logger.exception(ex) if LUN_IS_ALREADY_IN_USE_ERROR in ex.status: raise controller_errors.LunAlreadyInUseError(lun, host_name) else: raise controller_errors.MappingError(vol_name, host_name, ex) return str(lun)
def test_publish_volume_map_volume_excpetions(self, enter): context = utils.FakeContext() self.mediator.map_volume.side_effect = [ array_errors.PermissionDeniedError("msg") ] enter.return_value = self.mediator self.servicer.ControllerPublishVolume(self.request, context) self.assertEqual(context.code, grpc.StatusCode.PERMISSION_DENIED) self.mediator.map_volume.side_effect = [ array_errors.VolumeNotFoundError("vol") ] enter.return_value = self.mediator self.servicer.ControllerPublishVolume(self.request, context) self.assertEqual(context.code, grpc.StatusCode.NOT_FOUND) self.mediator.map_volume.side_effect = [ array_errors.HostNotFoundError("host") ] enter.return_value = self.mediator self.servicer.ControllerPublishVolume(self.request, context) self.assertEqual(context.code, grpc.StatusCode.NOT_FOUND) self.mediator.map_volume.side_effect = [ array_errors.MappingError("", "", "") ] enter.return_value = self.mediator self.servicer.ControllerPublishVolume(self.request, context) self.assertEqual(context.code, grpc.StatusCode.INTERNAL)
def map_volume(self, volume_id, host_name, connectivity_type): logger.debug("Mapping volume {} to host {}".format(volume_id, host_name)) try: mapping = self.client.map_volume_to_host(host_name, volume_id) lun = scsilun_to_int(mapping.lunid) logger.debug("Successfully mapped volume to host with lun {}".format(lun)) return lun except exceptions.NotFound: raise array_errors.HostNotFoundError(host_name) except exceptions.ClientException as ex: if ERROR_CODE_MAP_VOLUME_NOT_ENOUGH_EXTENTS in str(ex.message).upper(): raise array_errors.NoAvailableLunError(volume_id) if ERROR_CODE_VOLUME_NOT_FOUND_FOR_MAPPING in str(ex.message).upper(): raise array_errors.ObjectNotFoundError(volume_id) raise array_errors.MappingError(volume_id, host_name, ex.details)
def map_volume(self, volume_id, host_name): logger.debug("Mapping volume {} to host {}".format( volume_id, host_name)) try: mapping = self.client.map_volume_to_host(host_name, volume_id) lun = scsilun_to_int(mapping.lunid) logger.debug( "Successfully mapped volume to host with lun {}".format(lun)) return lun except exceptions.NotFound: raise array_errors.HostNotFoundError(host_name) except exceptions.ClientException as ex: # [BE586015] addLunMappings Volume group operation failure: volume does not exist. if ERROR_CODE_VOLUME_NOT_FOUND_FOR_MAPPING in str( ex.message).upper(): raise array_errors.ObjectNotFoundError(volume_id) raise array_errors.MappingError(volume_id, host_name, ex.details)