Exemplo n.º 1
0
 def test_get_member_snap_found(self):
     snap_group = UnitySnap(_id='85899345930', cli=t_rest())
     lun = UnityLun(cli=t_rest(), _id='sv_3338')
     snap = snap_group.get_member_snap(lun)
     assert_that(snap.snap_group.get_id(), equal_to(snap_group.get_id()))
     assert_that(snap.storage_resource.get_id(), equal_to('res_19'))
     assert_that(snap.lun.get_id(), equal_to(lun.get_id()))
Exemplo n.º 2
0
 def test_lun_delete_async(self):
     lun = UnityLun(_id='sv_1535', cli=t_rest())
     resp = lun.delete(force_snap_delete=True, force_vvol_delete=True)
     lun.update()
     assert_that(resp.is_ok(), equal_to(True))
     assert_that(resp.job.existed, equal_to(True))
     assert_that(resp.job.state.index, equal_to(4))
Exemplo n.º 3
0
 def test_lun_attach_to_with_hlu(self):
     host = UnityHost(_id="Host_1", cli=t_rest())
     lun = UnityLun(_id='sv_6', cli=t_rest(version='4.4.0'))
     resp = lun.attach_to(host,
                          access_mask=HostLUNAccessEnum.BOTH,
                          hlu=1655)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 4
0
 def test_create_cg(self):
     lun1 = UnityLun(cli=t_rest(), _id='sv_3339')
     lun2 = UnityLun(cli=t_rest(), _id='sv_3340')
     unity = t_unity()
     cg = unity.create_cg('Muse', lun_add=[lun1, lun2])
     assert_that(cg.name, equal_to('Muse'))
     assert_that(len(cg.luns), equal_to(2))
Exemplo n.º 5
0
 def test_lun_modify_muitl_property_except_sp(self):
     lun = UnityLun(_id='sv_4', cli=t_rest())
     lun.modify(name="RestLun100", is_thin=True,
                description="Lun description")
     lun.update()
     assert_that(lun.name, equal_to('RestLun100'))
     assert_that(lun.description, equal_to('Lun description'))
Exemplo n.º 6
0
 def test_update_lun_add_remove(self):
     cg = UnityConsistencyGroup.get(cli=t_rest(), _id='res_21')
     lun1 = UnityLun(cli=t_rest(), _id='sv_58')
     lun2 = UnityLun(cli=t_rest(), _id='sv_59')
     lun3 = UnityLun(cli=t_rest(), _id='sv_60')
     lun4 = UnityLun(cli=t_rest(), _id='sv_61')
     resp = cg.update_lun(add_luns=[lun1, lun3], remove_luns=[lun2, lun4])
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 7
0
 def test_lun_delete_thinclone(self):
     lun = UnityLun(_id='sv_5604', cli=t_rest())
     resp = lun.delete(async_mode=False,
                       force_snap_delete=True,
                       force_vvol_delete=True)
     lun.update()
     assert_that(resp.is_ok(), equal_to(True))
     assert_that(resp.job.existed, equal_to(False))
Exemplo n.º 8
0
    def test_notify_dd_copy(self):
        lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))
        copied_lun = UnityLun.get(_id='sv_3', cli=t_rest(version='4.2.0'))

        TCHelper.notify(lun, ThinCloneActionEnum.DD_COPY, copied_lun)
        self.assertTrue(lun.get_id() in TCHelper._tc_cache)
        self.assertEqual(copied_lun, TCHelper._tc_cache[lun.get_id()])
        self.assertFalse(lun.get_id() in TCHelper._gc_candidates)
Exemplo n.º 9
0
 def test_attach_with_retry_hlu_in_use_but_no_retry(self):
     host = UnityHost(cli=t_rest(), _id='Host_24')
     lun = UnityLun(_id='sv_5610', cli=t_rest())
     lun.is_cg_member = False
     with mock.patch('storops.unity.resource.host.UnityHost.'
                     '_modify_hlu',
                     new=mock.Mock(side_effect=UnityHluNumberInUseError)):
         assert_that(host._attach_with_retry(lun, True), equal_to(1))
Exemplo n.º 10
0
 def test_thin_clone_snap_new_tc_base(self):
     TCHelper._tc_cache['sv_2'] = UnityLun.get(_id='sv_5605',
                                               cli=t_rest(version='4.2.0'))
     lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))
     cloned = TCHelper.thin_clone(lun._cli, lun, name='test_thin_clone_lun',
                                  description='description',
                                  io_limit_policy=None)
     assert_that(cloned.id, equal_to('sv_5556'))
Exemplo n.º 11
0
    def test_notify_tc_delete_base_lun_snap_under_destroying(self):
        lun = UnityLun.get(_id='sv_5606', cli=t_rest(version='4.2.0'))
        base_lun = UnityLun.get(_id='sv_5607', cli=t_rest(version='4.2.0'))
        TCHelper._gc_candidates[base_lun.get_id()] = base_lun.get_id()

        TCHelper.notify(lun, ThinCloneActionEnum.TC_DELETE)
        self.assertFalse(lun.get_id() in TCHelper._tc_cache)
        self.assertFalse(lun.get_id() in TCHelper._gc_candidates)
        self.assertTrue(base_lun.get_id() in TCHelper._gc_candidates)
Exemplo n.º 12
0
 def test_lun_modify_host_access(self):
     host = UnityHost(_id="Host_1", cli=t_rest())
     lun = UnityLun(_id='sv_4', cli=t_rest())
     host_access = [{'host': host, 'accessMask': HostLUNAccessEnum.BOTH}]
     lun.modify(host_access=host_access)
     lun.update()
     assert_that(lun.host_access[0].host, equal_to(host))
     assert_that(lun.host_access[0].access_mask,
                 equal_to(HostLUNAccessEnum.BOTH))
Exemplo n.º 13
0
 def test_attach_with_retry_hlu_in_use(self):
     host = UnityHost(cli=t_rest(), _id='Host_23')
     lun = UnityLun(_id='sv_5610', cli=t_rest())
     lun.is_cg_member = False
     with mock.patch('storops.unity.resource.host.UnityHost.'
                     '_modify_hlu',
                     new=mock.Mock(side_effect=UnityHluNumberInUseError)):
         assert_that(
             calling(host._attach_with_retry).with_args(lun, True),
             raises(UnityHluNumberInUseError))
Exemplo n.º 14
0
    def test_notify_tc_delete_base_lun_ready_for_gc(self, lun_delete):
        lun = UnityLun.get(_id='sv_5600', cli=t_rest(version='4.2.0'))
        base_lun = UnityLun.get(_id='sv_5601', cli=t_rest(version='4.2.0'))
        TCHelper._gc_candidates[base_lun.get_id()] = base_lun.get_id()

        TCHelper.notify(lun, ThinCloneActionEnum.TC_DELETE)
        self.assertFalse(lun.get_id() in TCHelper._tc_cache)
        self.assertFalse(lun.get_id() in TCHelper._gc_candidates)
        self.assertFalse(base_lun.get_id() in TCHelper._gc_candidates)
        lun_delete.assert_called_once()
Exemplo n.º 15
0
    def test_notify_lun_attach_gc(self, mocked_put):
        lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))
        old_lun = UnityLun.get(_id='sv_4', cli=t_rest(version='4.2.0'))
        TCHelper._tc_cache[lun.get_id()] = old_lun

        TCHelper.notify(lun, ThinCloneActionEnum.LUN_ATTACH)
        self.assertFalse(lun.get_id() in TCHelper._tc_cache)
        self.assertTrue(old_lun.get_id() in TCHelper._gc_candidates)
        mocked_put.assert_called_with(TCHelper._delete_base_lun,
                                      base_lun=old_lun)
Exemplo n.º 16
0
 def test_migrate_deduplicated_lun_success(self):
     with mock.patch.object(UnitySystem,
                            'model',
                            create=True,
                            return_value='Unity 650F',
                            new_callable=mock.PropertyMock):
         lun = UnityLun('sv_5620', cli=t_rest('4.5'))
         dest_pool = UnityPool('pool_5', cli=t_rest('4.5'))
         r = lun.migrate(dest_pool)
         assert_that(r, equal_to(True))
Exemplo n.º 17
0
    def test_create_cg_with_initial_member(self):
        lun1 = UnityLun(cli=t_rest(), _id='sv_3339')
        lun2 = UnityLun(cli=t_rest(), _id='sv_3340')
        cg = UnityConsistencyGroup.create(t_rest(), 'Muse',
                                          lun_add=[lun1, lun2])
        assert_that(cg.name, equal_to('Muse'))

        members = cg.luns
        assert_that(len(members), equal_to(2))
        lun_id_list = map(lambda lun: lun.get_id(), members)
        assert_that(lun_id_list, has_items('sv_3339', 'sv_3340'))
Exemplo n.º 18
0
 def test_attach_with_retry_skip_hlu_0(self):
     host = UnityHost(cli=t_rest(), _id='Host_23')
     lun = UnityLun(_id='sv_5610', cli=t_rest())
     lun.is_cg_member = False
     with mock.patch(
             'storops.unity.resource.host.UnityHost.'
             '_random_hlu_number',
             new=lambda _: 12781):
         hlu = host._attach_with_retry(lun, True)
         assert_that(hlu, is_not(equal_to(0)))
         assert_that(hlu, equal_to(12781))
Exemplo n.º 19
0
 def test_attach_with_retry_no_hlu_available(self):
     host = UnityHost(cli=t_rest(), _id='Host_23')
     lun = UnityLun(_id='sv_5610', cli=t_rest())
     lun.is_cg_member = False
     with mock.patch(
             'storops.unity.resource.host.UnityHost.'
             '_random_hlu_number',
             new=mock.Mock(side_effect=UnityNoHluAvailableError)):
         assert_that(
             calling(host._attach_with_retry).with_args(lun, True),
             raises(UnityNoHluAvailableError))
Exemplo n.º 20
0
    def test_notify_tc_delete_base_lun_having_thinclone(
            self, mocked_put, lun_delete):
        lun = UnityLun.get(_id='sv_5602', cli=t_rest(version='4.2.0'))
        base_lun = UnityLun.get(_id='sv_5603', cli=t_rest(version='4.2.0'))
        TCHelper._gc_candidates[base_lun.get_id()] = base_lun.get_id()

        TCHelper.notify(lun, ThinCloneActionEnum.TC_DELETE)
        self.assertFalse(lun.get_id() in TCHelper._tc_cache)
        self.assertFalse(lun.get_id() in TCHelper._gc_candidates)
        self.assertTrue(base_lun.get_id() in TCHelper._gc_candidates)
        lun_delete.assert_not_called()
Exemplo n.º 21
0
 def test_migrate_lun_source_deduplicated_dest_thin(self):
     lun = UnityLun('sv_5621', cli=t_rest('4.5'))
     dest_pool = UnityPool('pool_5', cli=t_rest('4.5'))
     # If dest LUN is not compressed (is_compressed == False),
     # is_advanced_dedup_enabled parameter will be changed to
     # False in lun.migrate()
     r = lun.migrate(dest_pool,
                     is_thin=True,
                     is_compressed=False,
                     is_advanced_dedup_enabled=True)
     assert_that(r, equal_to(True))
Exemplo n.º 22
0
 def test_migrate_lun_source_thin_dest_thick(self):
     lun = UnityLun('sv_2', cli=t_rest())
     dest_pool = UnityPool('pool_4', cli=t_rest())
     # If dest LUN is thick (is_thin == False), is_compressed and
     # is_advanced_dedup_enabled parameters will be changed to
     # False in lun.migrate()
     r = lun.migrate(dest_pool,
                     is_thin=False,
                     is_compressed=True,
                     is_advanced_dedup_enabled=True)
     assert_that(r, equal_to(True))
Exemplo n.º 23
0
    def test_notify_dd_copy_gc(self, mocked_put):
        lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))
        copied_lun = UnityLun.get(_id='sv_3', cli=t_rest(version='4.2.0'))
        old_lun = UnityLun.get(_id='sv_4', cli=t_rest(version='4.2.0'))
        TCHelper._tc_cache[lun.get_id()] = old_lun

        TCHelper.notify(lun, ThinCloneActionEnum.DD_COPY, copied_lun)
        self.assertTrue(lun.get_id() in TCHelper._tc_cache)
        self.assertEqual(copied_lun, TCHelper._tc_cache[lun.get_id()])
        self.assertTrue(old_lun.get_id() in TCHelper._gc_candidates)
        mocked_put.assert_called_with(TCHelper._delete_base_lun,
                                      base_lun=old_lun)
Exemplo n.º 24
0
 def test_make_body_complex(self):
     service_levels = [ServiceLevelEnum.BASIC, ServiceLevelEnum.BRONZE]
     param = {
         'a': 1,
         'b': UnityLun(_id='lun1'),
         'c': UnityLunList(cli=t_rest()),
         'd': [UnityLun(_id='lun10'),
               UnityLun(_id='lun11'), 0.1],
         'e': {
             'f': UnityLun(_id='lun12')
         },
         'g': 'string',
         'h': 0.2,
         'i': service_levels,
         'j': ServiceLevelEnumList.parse(service_levels)
     }
     ret = UnityClient.make_body(param)
     expected = {
         'a':
         1,
         'b': {
             'id': 'lun1'
         },
         'c': [{
             'id': 'sv_2'
         }, {
             'id': 'sv_3'
         }, {
             'id': 'sv_5'
         }, {
             'id': 'sv_6'
         }, {
             'id': 'sv_7'
         }],
         'd': [{
             'id': 'lun10'
         }, {
             'id': 'lun11'
         }, 0.1],
         'e': {
             'f': {
                 'id': 'lun12'
             }
         },
         'g':
         'string',
         'h':
         0.2,
         'i': [0, 1],
         'j': [0, 1]
     }
     assert_that(ret, equal_to(expected))
Exemplo n.º 25
0
 def test_create_local_replicate_cg_session(self):
     # Create the session in local when the remote system is empty
     cg = UnityConsistencyGroup.get(cli=t_rest(), _id='res_21')
     lun1 = UnityLun(cli=t_rest(), _id='sv_58')
     lun2 = UnityLun(cli=t_rest(), _id='sv_59')
     luns = [lun1, lun2]
     rep_session = cg.replicate_cg_with_dst_resource_provisioning(
         60, luns, 'pool_2', dst_cg_name=cg.name, remote_system=None)
     assert_that(
         rep_session.id,
         equal_to(
             '81604378625_APM00192210744_0000_81604378629_APM00192210744_0000'
         ))
Exemplo n.º 26
0
 def detach(self, lun_or_snap):
     if self.host_luns:
         # To detach the `dummy luns` which are attached via legacy storops.
         dummy_lun_ids = [lun.get_id() for lun in self.host_luns.lun
                          if lun.name == DUMMY_LUN_NAME]
         if dummy_lun_ids:
             from storops.unity.resource.lun import UnityLun
             dummy_lun = UnityLun(cli=self._cli, _id=dummy_lun_ids[0])
             try:
                 dummy_lun.delete(None)
             except ex.UnityException:
                 pass
     return lun_or_snap.detach_from(self)
Exemplo n.º 27
0
 def test_create_replicate_cg_session_without_dst_cg(self):
     cg = UnityConsistencyGroup.get(cli=t_rest(), _id='res_21')
     rs = UnityRemoteSystem.get(cli=t_rest(), _id='RS_0')
     lun1 = UnityLun(cli=t_rest(), _id='sv_58')
     lun2 = UnityLun(cli=t_rest(), _id='sv_59')
     luns = [lun1, lun2]
     rep_session = cg.replicate_cg_with_dst_resource_provisioning(
         60, luns, 'pool_2', dst_cg_name=None, remote_system=rs)
     assert_that(
         rep_session.id,
         equal_to(
             '81866043753_A9221PM0010744_0604000_81378689_FNM84900101113_0000'
         ))
Exemplo n.º 28
0
 def test_get_lun_sv2_simple_property(self):
     lun = UnityLun(_id='sv_2', cli=t_rest())
     assert_that(lun.existed, equal_to(True))
     assert_that(lun.id, equal_to('sv_2'))
     assert_that(lun.name, equal_to('openstack_lun'))
     assert_that(lun.description, equal_to('sample'))
     assert_that(lun.size_total, equal_to(107374182400))
     assert_that(lun.total_size_gb, equal_to(100))
     assert_that(lun.size_allocated, equal_to(0))
     assert_that(lun.per_tier_size_used, only_contains(2952790016, 0, 0))
     assert_that(lun.is_thin_enabled, equal_to(True))
     assert_that(
         lun.wwn,
         equal_to('60:06:01:60:17:50:3C:00:C2:0A:D5:56:92:D1:BA:12'))
     assert_that(lun.is_replication_destination, equal_to(False))
     assert_that(lun.is_snap_schedule_paused, equal_to(False))
     assert_that(lun.metadata_size, equal_to(5100273664))
     assert_that(lun.metadata_size_allocated, equal_to(2684354560))
     assert_that(
         lun.snap_wwn,
         equal_to('60:06:01:60:17:50:3C:00:C4:0A:D5:56:00:95:DE:11'))
     assert_that(lun.snaps_size, equal_to(0))
     assert_that(lun.snaps_size_allocated, equal_to(0))
     assert_that(lun.snap_count, equal_to(0))
     assert_that(lun.storage_resource, instance_of(UnityStorageResource))
     assert_that(lun.pool, instance_of(UnityPool))
     assert_that(lun.io_limit_rule, none())
     assert_that(lun.is_compression_enabled, equal_to(False))
     assert_that(lun.is_data_reduction_enabled, equal_to(False))
Exemplo n.º 29
0
 def test_get_lun_doc(self):
     lun = UnityLun(_id='sv_2', cli=t_rest())
     doc = lun.doc
     assert_that(doc,
                 contains_string('Represents Volume, LUN, Virtual Disk.'))
     assert_that(doc, contains_string('current_node'))
     assert_that(doc, contains_string('Current SP'))
Exemplo n.º 30
0
 def test_is_perf_monitored_resource(self):
     cli = self.perf_mon()
     cli._rsc_clz_list = [UnityDisk]
     assert_that(cli._is_perf_monitored(UnityDisk('', cli=cli)),
                 equal_to(True))
     assert_that(cli._is_perf_monitored(UnityLun('', cli=cli)),
                 equal_to(False))
Exemplo n.º 31
0
 def create_lun(self,
                lun_name=None,
                size_gb=1,
                sp=None,
                host_access=None,
                is_thin=None,
                description=None,
                tiering_policy=None,
                is_repl_dst=None,
                snap_schedule=None,
                is_snap_schedule_paused=None,
                skip_sync_to_remote_system=None,
                io_limit_policy=None,
                is_compression=None,
                is_advanced_dedup_enabled=None):
     size = int(bitmath.GiB(size_gb).to_Byte().value)
     return UnityLun.create(
         self._cli,
         lun_name,
         self,
         size,
         sp=sp,
         host_access=host_access,
         is_thin=is_thin,
         description=description,
         is_repl_dst=is_repl_dst,
         tiering_policy=tiering_policy,
         snap_schedule=snap_schedule,
         is_snap_schedule_paused=is_snap_schedule_paused,
         skip_sync_to_remote_system=skip_sync_to_remote_system,
         io_limit_policy=io_limit_policy,
         is_compression=is_compression,
         is_advanced_dedup_enabled=is_advanced_dedup_enabled)
Exemplo n.º 32
0
 def test_dict_to_filter_unity_resource(self):
     ret = UnityClient.dict_to_filter_string({
         'a': 1,
         'b': UnityLun(_id='lun_1')
     })
     assert_that(
         ret, any_of('a eq 1 and b eq "lun_1"', 'b eq "lun_1" and a eq 1'))
Exemplo n.º 33
0
 def test_lun_delete(self):
     lun = UnityLun(_id='sv_4', cli=t_rest())
     resp = lun.delete(force_snap_delete=True, force_vvol_delete=True)
     lun.update()
     assert_that(resp.is_ok(), equal_to(True))
     assert_that(resp.job.existed, equal_to(False))
Exemplo n.º 34
0
 def test_lun_attch_to_new_host(self):
     host = UnityHost(_id="Host_10", cli=t_rest())
     lun = UnityLun(_id='sv_4', cli=t_rest())
     resp = lun.attach_to(host)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 35
0
 def test_lun_attch_to_same_host(self):
     host = UnityHost(_id="Host_1", cli=t_rest())
     lun = UnityLun(_id='sv_4', cli=t_rest())
     resp = lun.attach_to(host, access_mask=HostLUNAccessEnum.BOTH)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 36
0
 def test_lun_modify_wipe_host_access(self):
     lun = UnityLun(_id='sv_4', cli=t_rest())
     resp = lun.modify(host_access=[])
     lun.update()
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 37
0
 def test_lun_modify_sp(self):
     lun = UnityLun(_id='sv_4', cli=t_rest())
     sp = UnityStorageProcessor(_id='spb', cli=t_rest())
     lun.modify(sp=sp)
     lun.update()
     assert_that(sp.to_node_enum(), equal_to(NodeEnum.SPB))
Exemplo n.º 38
0
 def test_lun_detach_from_host(self):
     host = UnityHost(_id="Host_1", cli=t_rest())
     lun = UnityLun(_id='sv_4', cli=t_rest())
     resp = lun.detach_from(host)
     assert_that(resp.is_ok(), equal_to(True))