def is_volume_has_snapshots(self, volume_id):
     try:
         volume_name = self._get_vol_by_wwn(volume_id)
         return bool(self.client.cmd.snapshot_list(vol=volume_name).as_list)
     except xcli_errors.IllegalValueForArgumentError as ex:
         logger.exception(ex)
         raise controller_errors.IllegalObjectID(ex.status)
示例#2
0
 def _get_cli_object_by_wwn(self, volume_id, not_exist_err=False):
     try:
         cli_object = self.client.cmd.vol_list(
             wwn=volume_id).as_single_element
     except xcli_errors.IllegalValueForArgumentError as ex:
         logger.exception(ex)
         raise array_errors.IllegalObjectID(ex.status)
     if not cli_object and not_exist_err:
         raise array_errors.ObjectNotFoundError(volume_id)
     return cli_object
 def _get_api_volume_by_id(self, volume_id, not_exist_err=True):
     try:
         volume = self.client.get_volume(volume_id)
         volume.flashcopy = self.client.get_flashcopies_by_volume(volume.id)
         return volume
     except exceptions.NotFound:
         if not_exist_err:
             raise array_errors.ObjectNotFoundError(volume_id)
     except (exceptions.ClientError, exceptions.InternalServerError) as ex:
         if INCORRECT_ID in str(ex.message).upper():
             raise array_errors.IllegalObjectID(volume_id)
 def get_snapshot_by_id(self, snapshot_id):
     try:
         cli_snapshot = self.client.cmd.vol_list(wwn=snapshot_id).as_single_element
     except xcli_errors.IllegalValueForArgumentError as ex:
         logger.exception(ex)
         raise controller_errors.IllegalObjectID(ex.status)
     if not cli_snapshot:
         return None
     if not cli_snapshot.master_name:
         raise controller_errors.SnapshotIdBelongsToVolumeError(snapshot_id, self.endpoint)
     return self._generate_snapshot_response(cli_snapshot)
示例#5
0
 def _get_cli_volume_by_wwn(self, volume_id, not_exist_err=False):
     filter_value = 'vdisk_UID=' + volume_id
     try:
         cli_volume = self.client.svcinfo.lsvdisk(
             bytes=True, filtervalue=filter_value).as_single_element
     except (svc_errors.CommandExecutionError, CLIFailureError) as ex:
         if not is_warning_message(ex.my_message):
             if any(msg_id in ex.my_message
                    for msg_id in (NON_ASCII_CHARS, INVALID_FILTER_VALUE)):
                 raise array_errors.IllegalObjectID(ex.my_message)
             raise ex
     if not cli_volume and not_exist_err:
         raise array_errors.ObjectNotFoundError(volume_id)
     return cli_volume
 def get_object_by_id(self, object_id, object_type):
     try:
         cli_object = self._get_cli_object_by_wwn(object_id)
     except xcli_errors.IllegalValueForArgumentError as ex:
         logger.exception(ex)
         raise controller_errors.IllegalObjectID(ex.status)
     if not cli_object:
         return None
     if object_type is controller_config.SNAPSHOT_TYPE_NAME:
         if not cli_object.master_name:
             raise controller_errors.ExpectedSnapshotButFoundVolumeError(
                 object_id, self.endpoint)
         return self._generate_snapshot_response(cli_object)
     return self._generate_volume_response(cli_object)
 def _expand_cli_volume(self, cli_volume, increase_in_blocks):
     try:
         self.client.cmd.vol_resize(vol=cli_volume.name,
                                    size_blocks=increase_in_blocks)
     except xcli_errors.IllegalNameForObjectError as ex:
         logger.exception(ex)
         raise controller_errors.IllegalObjectID(ex.status)
     except xcli_errors.VolumeBadNameError as ex:
         logger.exception(ex)
         raise controller_errors.ObjectNotFoundError(cli_volume.id)
     except xcli_errors.CommandFailedRuntimeError as ex:
         logger.exception(ex)
         if NO_ALLOCATION_SPACE_ERROR in ex.status:
             raise controller_errors.NotEnoughSpaceInPool(
                 cli_volume.pool_name)
         else:
             raise ex