Example #1
0
 def test_thin_clone_downgraded_wo_src_lun(self):
     lun_id = 'lun_60'
     src_snap_id = 'snap_62'
     volume = MockOSResource(name=lun_id, id=lun_id, size=1,
                             provider_location=get_snap_lun_pl(lun_id))
     src_snap = test_client.MockResource(name=src_snap_id, _id=src_snap_id)
     new_dd_lun = test_client.MockResource(name='lun_63')
     with patch_storops() as mocked_storops, \
             patch_dd_copy(new_dd_lun) as dd:
         ret = self.adapter._thin_clone(
             adapter.VolumeParams(self.adapter, volume), src_snap)
         vol_params = adapter.VolumeParams(self.adapter, volume)
         vol_params.name = 'hidden-{}'.format(volume.name)
         vol_params.description = 'hidden-{}'.format(volume.description)
         dd.assert_called_with(vol_params, src_snap, src_lun=None)
         mocked_storops.TCHelper.notify.assert_called_with(src_snap,
                                                           'DD_COPY',
                                                           new_dd_lun)
     self.assertEqual(IdMatcher(test_client.MockResource(_id=lun_id)), ret)
Example #2
0
 def test_create_volume_from_snapshot(self):
     lun_id = 'lun_50'
     volume = MockOSResource(name=lun_id, id=lun_id, host='unity#pool1')
     snap_id = 'snap_50'
     snap = MockOSResource(name=snap_id)
     with patch_thin_clone(test_client.MockResource(_id=lun_id)) as tc:
         ret = self.adapter.create_volume_from_snapshot(volume, snap)
         self.assertEqual(get_snap_lun_pl(lun_id), ret['provider_location'])
         tc.assert_called_with(adapter.VolumeParams(self.adapter, volume),
                               snap_id)
Example #3
0
 def test_thin_clone_thick(self):
     lun_id = 'lun_70'
     src_snap_id = 'snap_71'
     volume = MockOSResource(name=lun_id, id=lun_id, size=1,
                             provider_location=get_snap_lun_pl(lun_id))
     src_snap = test_client.MockResource(name=src_snap_id, _id=src_snap_id)
     new_dd_lun = test_client.MockResource(name='lun_73')
     with patch_storops(), patch_dd_copy(new_dd_lun) as dd:
         vol_params = adapter.VolumeParams(self.adapter, volume)
         ret = self.adapter._thin_clone(vol_params, src_snap)
         dd.assert_called_with(vol_params, src_snap, src_lun=None)
     self.assertEqual(ret, new_dd_lun)
Example #4
0
 def test_create_cloned_volume_attached(self):
     lun_id = 'lun_51'
     src_lun_id = 'lun_53'
     volume = MockOSResource(name=lun_id, id=lun_id, host='unity#pool1')
     src_vref = MockOSResource(id=src_lun_id, name=src_lun_id,
                               provider_location=get_lun_pl(src_lun_id),
                               volume_attachment=['not_care'])
     with patch_dd_copy(test_client.MockResource(_id=lun_id)) as dd:
         ret = self.adapter.create_cloned_volume(volume, src_vref)
         dd.assert_called_with(
             adapter.VolumeParams(self.adapter, volume),
             IdMatcher(test_client.MockResource(
                 _id='snap_clone_{}'.format(src_lun_id))),
             src_lun=IdMatcher(test_client.MockResource(_id=src_lun_id)))
         self.assertEqual(get_lun_pl(lun_id), ret['provider_location'])
Example #5
0
 def test_dd_copy_wo_src_lun(self):
     lun_id = 'lun_58'
     src_lun_id = 'lun_59'
     src_snap_id = 'snap_59'
     volume = MockOSResource(name=lun_id, id=lun_id, host='unity#pool1',
                             provider_location=get_lun_pl(lun_id))
     src_snap = test_client.MockResource(name=src_snap_id, _id=src_snap_id)
     src_snap.storage_resource = test_client.MockResource(name=src_lun_id,
                                                          _id=src_lun_id)
     with patch_copy_volume() as copy_volume:
         ret = self.adapter._dd_copy(
             adapter.VolumeParams(self.adapter, volume), src_snap)
         copy_volume.assert_called_with('dev', 'dev', 5120, '1M',
                                        sparse=True)
         self.assertEqual(IdMatcher(test_client.MockResource(_id=lun_id)),
                          ret)
Example #6
0
 def test_create_cloned_volume_available(self):
     lun_id = 'lun_54'
     src_lun_id = 'lun_55'
     volume = MockOSResource(id=lun_id, host='unity#pool1', size=3,
                             provider_location=get_lun_pl(lun_id))
     src_vref = MockOSResource(id=src_lun_id, name=src_lun_id,
                               provider_location=get_lun_pl(src_lun_id),
                               volume_attachment=None)
     with patch_thin_clone(test_client.MockResource(_id=lun_id)) as tc:
         ret = self.adapter.create_cloned_volume(volume, src_vref)
         tc.assert_called_with(
             adapter.VolumeParams(self.adapter, volume),
             IdMatcher(test_client.MockResource(
                 _id='snap_clone_{}'.format(src_lun_id))),
             src_lun=IdMatcher(test_client.MockResource(_id=src_lun_id)))
         self.assertEqual(get_snap_lun_pl(lun_id), ret['provider_location'])
Example #7
0
 def test_dd_copy_with_src_lun(self):
     lun_id = 'lun_56'
     src_lun_id = 'lun_57'
     src_snap_id = 'snap_57'
     volume = MockOSResource(name=lun_id, id=lun_id, host='unity#pool1',
                             provider_location=get_lun_pl(lun_id))
     src_snap = test_client.MockResource(name=src_snap_id, _id=src_snap_id)
     src_lun = test_client.MockResource(name=src_lun_id, _id=src_lun_id)
     src_lun.size_total = 6 * units.Gi
     with patch_copy_volume() as copy_volume:
         ret = self.adapter._dd_copy(
             adapter.VolumeParams(self.adapter, volume), src_snap,
             src_lun=src_lun)
         copy_volume.assert_called_with('dev', 'dev', 6144, '1M',
                                        sparse=True)
         self.assertEqual(IdMatcher(test_client.MockResource(_id=lun_id)),
                          ret)