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)
 def get_volume_mappings(self, volume_id):
     logger.debug("Getting volume mappings for volume {}".format(volume_id))
     try:
         host_name_to_lun_id = {}
         for host in self.client.get_hosts():
             host_mappings = host.mappings_briefs
             for mapping in host_mappings:
                 if volume_id == mapping["volume_id"]:
                     host_name_to_lun_id[host.name] = scsilun_to_int(mapping["lunid"])
                     break
         logger.debug("Found volume mappings: {}".format(host_name_to_lun_id))
         return host_name_to_lun_id
     except exceptions.ClientException as ex:
         logger.error(
             "Failed to get volume mappings. Reason is: {}".format(ex.details)
         )
         raise ex