Example #1
0
 def create_cloned_volume(self, volume, src_vref):
     """Create a clone of the specified volume and return its properties."""
     ldev = utils.get_ldev(src_vref)
     # When 'ldev' is 0, it should be true.
     # Therefore, it cannot remove 'is not None'.
     if ldev is None:
         msg = utils.output_log(MSG.INVALID_LDEV_FOR_VOLUME_COPY,
                                type='volume',
                                id=src_vref['id'])
         raise exception.VSPError(msg)
     size = volume['size']
     metadata = utils.get_volume_metadata(volume)
     if size < src_vref['size']:
         msg = utils.output_log(MSG.INVALID_VOLUME_SIZE_FOR_COPY,
                                type='volume',
                                volume_id=volume['id'])
         raise exception.VSPError(msg)
     elif (size > src_vref['size'] and not self.check_vvol(ldev)
           and self.get_copy_method(metadata) == "THIN"):
         msg = utils.output_log(MSG.INVALID_VOLUME_SIZE_FOR_TI,
                                copy_method=utils.THIN,
                                type='volume',
                                volume_id=volume['id'])
         raise exception.VSPError(msg)
     sync = size > src_vref['size']
     new_ldev = self._copy_ldev(ldev, src_vref['size'], metadata, sync)
     if sync:
         self.delete_pair(new_ldev)
         self.extend_ldev(new_ldev, src_vref['size'], size)
     return {
         'provider_location': six.text_type(new_ldev),
     }
Example #2
0
 def create_cloned_volume(self, volume, src_vref):
     """Create a clone of the specified volume and return its properties."""
     ldev = utils.get_ldev(src_vref)
     # When 'ldev' is 0, it should be true.
     # Therefore, it cannot remove 'is not None'.
     if ldev is None:
         msg = utils.output_log(MSG.INVALID_LDEV_FOR_VOLUME_COPY,
                                type='volume', id=src_vref['id'])
         raise exception.VSPError(msg)
     size = volume['size']
     metadata = utils.get_volume_metadata(volume)
     if size < src_vref['size']:
         msg = utils.output_log(MSG.INVALID_VOLUME_SIZE_FOR_COPY,
                                type='volume', volume_id=volume['id'])
         raise exception.VSPError(msg)
     elif (size > src_vref['size'] and not self.check_vvol(ldev) and
           self.get_copy_method(metadata) == "THIN"):
         msg = utils.output_log(MSG.INVALID_VOLUME_SIZE_FOR_TI,
                                copy_method=utils.THIN, type='volume',
                                volume_id=volume['id'])
         raise exception.VSPError(msg)
     sync = size > src_vref['size']
     new_ldev = self._copy_ldev(ldev, src_vref['size'], metadata, sync)
     if sync:
         self.delete_pair(new_ldev)
         self.extend_ldev(new_ldev, src_vref['size'], size)
     return {
         'provider_location': six.text_type(new_ldev),
     }
Example #3
0
 def create_snapshot(self, snapshot):
     """Create a snapshot from a volume and return its properties."""
     src_vref = snapshot.volume
     ldev = utils.get_ldev(src_vref)
     # When 'ldev' is 0, it should be true.
     # Therefore, it cannot remove 'is None'.
     if ldev is None:
         msg = utils.output_log(MSG.INVALID_LDEV_FOR_VOLUME_COPY,
                                type='volume', id=src_vref['id'])
         raise exception.VSPError(msg)
     size = snapshot['volume_size']
     metadata = utils.get_volume_metadata(src_vref)
     new_ldev = self._copy_ldev(ldev, size, metadata)
     return {
         'provider_location': six.text_type(new_ldev),
     }
Example #4
0
 def create_snapshot(self, snapshot):
     """Create a snapshot from a volume and return its properties."""
     src_vref = snapshot.volume
     ldev = utils.get_ldev(src_vref)
     # When 'ldev' is 0, it should be true.
     # Therefore, it cannot remove 'is None'.
     if ldev is None:
         msg = utils.output_log(MSG.INVALID_LDEV_FOR_VOLUME_COPY,
                                type='volume', id=src_vref['id'])
         raise exception.VSPError(msg)
     size = snapshot['volume_size']
     metadata = utils.get_volume_metadata(src_vref)
     new_ldev = self._copy_ldev(ldev, size, metadata)
     return {
         'provider_location': six.text_type(new_ldev),
     }