Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
0
    def test_notify_tc_delete_base_lun(self, mocked_put):
        base_lun = UnityLun.get(_id='sv_5608', cli=t_rest(version='4.2.0'))

        TCHelper.notify(base_lun, ThinCloneActionEnum.BASE_LUN_DELETE)
        self.assertTrue(base_lun.get_id() in TCHelper._gc_candidates)
        mocked_put.assert_called_with(TCHelper._delete_base_lun,
                                      base_lun=base_lun)
Exemplo n.º 9
0
 def test_modify_vmfs_name_major_version_block_size(self):
     vmfs = UnityLun.get(cli=t_rest(), _id='sv_5613')
     resp = vmfs.modify(name='vmfs_new_name',
                        sp=1,
                        major_version=ESXFilesystemMajorVersionEnum.VMFS_6,
                        block_size=ESXFilesystemBlockSizeEnum._4MB)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 10
0
    def test_notify_tc_delete_base_lun_still_using(self, lun_delete):
        lun = UnityLun.get(_id='sv_5600', cli=t_rest(version='4.2.0'))

        TCHelper.notify(lun, ThinCloneActionEnum.TC_DELETE)
        self.assertFalse(lun.get_id() in TCHelper._tc_cache)
        self.assertFalse(lun.get_id() in TCHelper._gc_candidates)
        lun_delete.assert_not_called()
Exemplo n.º 11
0
 def test_thin_clone_lun(self):
     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_5555'))
Exemplo n.º 12
0
    def test_thin_clone_limit_exceeded(self):
        lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))

        def _inner():
            lun.thin_clone(name='test_thin_clone_limit_exceeded',
                           description='This is description.',
                           io_limit_policy=None)

        assert_that(_inner, raises(UnityThinCloneLimitExceededError))
Exemplo n.º 13
0
 def test_replicate(self, rep_name, rep_existing_snaps, remote_system):
     if remote_system:
         remote_system = UnityRemoteSystem(_id=remote_system, cli=t_rest())
     lun = UnityLun.get(cli=t_rest(), _id='sv_2498')
     rep_session = lun.replicate(
         'sv_5',
         60,
         replication_name=rep_name,
         replicate_existing_snaps=rep_existing_snaps,
         remote_system=remote_system)
     assert_that(rep_session.name, equal_to('remote-sv_2498-sv_5'))
Exemplo n.º 14
0
    def get_volume_details(self, vol_name=None, vol_id=None):
        """Get the details of a volume.
            :param vol_name: The name of the volume
            :param vol_id: The id of the volume
            :return: Dict containing volume details if exists
        """

        id_or_name = vol_id if vol_id else vol_name

        try:
            lun = self.unity_conn.get_lun(name=vol_name, _id=vol_id)

            cg = None
            if lun.existed:
                lunid = lun.get_id()
                unitylun = UnityLun.get(self.unity_conn._cli, lunid)
                if unitylun.cg is not None:
                    cg = unitylun.cg
            else:
                errormsg = "The volume {0} not found.".format(id_or_name)
                LOG.error(errormsg)
                self.module.fail_json(msg=errormsg)

            cg_details = self.get_details(
                cg_id=self.module.params['cg_id'],
                cg_name=self.module.params['cg_name'])

            # Check if volume is already part of another consistency group
            if cg is None:
                return lun._get_properties()['id']

            errormsg = "The volume {0} is already part of consistency group" \
                       " {1}".format(id_or_name, cg.name)

            if cg_details is None:
                LOG.error(errormsg)
                self.module.fail_json(msg=errormsg)

            if cg.id != cg_details['id']:
                LOG.error(errormsg)
                self.module.fail_json(msg=errormsg)

            return lun._get_properties()['id']

        except Exception as e:
            msg = "Failed to get the volume {0} with error {1}".format(
                id_or_name, str(e))
            LOG.error(msg)
            self.module.fail_json(msg=msg)
Exemplo n.º 15
0
 def test_create_move_session(self):
     cli = t_rest()
     lun = UnityLun.get(cli=cli, _id='sv_18')
     dest_pool = UnityPool.get(cli=cli, _id='pool_5')
     move_session = UnityMoveSession.create(cli=cli,
                                            source_storage_resource=lun,
                                            destination_pool=dest_pool,
                                            is_dest_thin=True,
                                            is_data_reduction_applied=True,
                                            priority=5)
     assert_that(move_session.id, equal_to('move_32'))
     assert_that(move_session.state, equal_to(MoveSessionStateEnum.RUNNING))
     assert_that(move_session.status,
                 equal_to(MoveSessionStatusEnum.INITIALIZING))
     assert_that(move_session.priority,
                 equal_to(MoveSessionPriorityEnum.HIGH))
Exemplo n.º 16
0
 def test_create_move_session_to_thick(self):
     cli = t_rest()
     lun = UnityLun.get(cli=cli, _id='sv_19')
     dest_pool = UnityPool.get(cli=cli, _id='pool_6')
     move_session = UnityMoveSession.create(cli=cli,
                                            source_storage_resource=lun,
                                            destination_pool=dest_pool,
                                            is_dest_thin=False,
                                            is_data_reduction_applied=False,
                                            priority=5)
     assert_that(move_session.id, equal_to('move_35'))
     assert_that(move_session.state,
                 equal_to(MoveSessionStateEnum.COMPLETED))
     assert_that(move_session.status,
                 equal_to(MoveSessionStatusEnum.INITIALIZING))
     assert_that(move_session.priority,
                 equal_to(MoveSessionPriorityEnum.NORMAL))
Exemplo n.º 17
0
 def test_replicate_with_dst_resource_provisioning(
         self, dst_lun_name, remote_system, rep_name, dst_size, dst_sp,
         is_dst_thin, dst_tiering_policy, is_dst_compression):
     lun = UnityLun.get(cli=t_rest(), _id='sv_1876')
     if remote_system:
         remote_system = UnityRemoteSystem(_id=remote_system, cli=t_rest())
     rep_session = lun.replicate_with_dst_resource_provisioning(
         60,
         'pool_2',
         dst_lun_name=dst_lun_name,
         remote_system=remote_system,
         replication_name=rep_name,
         dst_size=dst_size,
         dst_sp=dst_sp,
         is_dst_thin=is_dst_thin,
         dst_tiering_policy=dst_tiering_policy,
         is_dst_compression=is_dst_compression)
     assert_that(
         rep_session.id,
         equal_to(
             '42949675780_FNM00150600267_0000_42949678642_FNM00152000052_0000'
         ))
Exemplo n.º 18
0
 def test_update_hosts(self):
     lun = UnityLun.get(cli=t_rest(), _id="sv_4")
     r = lun.update_hosts(host_names=["ubuntu-server7"])
     assert_that(r, instance_of(RestResponse))
Exemplo n.º 19
0
 def test_update_hosts_no_change(self):
     lun = UnityLun.get(cli=t_rest(), _id="sv_4")
     r = lun.update_hosts(host_names=["10.244.209.90"])
     assert_that(r, none())
Exemplo n.º 20
0
 def test_thin_clone(self):
     lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))
     clone = lun.thin_clone(name='test_thin_clone',
                            description='This is description.',
                            io_limit_policy=None)
     assert_that(clone.id, equal_to('sv_4678'))
Exemplo n.º 21
0
 def test_is_vmware_vmfs_false(self):
     vmfs = UnityLun.get(cli=t_rest(), _id='sv_4')
     assert_that(vmfs.is_vmware_vmfs, equal_to(False))
Exemplo n.º 22
0
 def test_delete_vmfs(self):
     vmfs = UnityLun.get(cli=t_rest(), _id='sv_5613')
     resp = vmfs.delete(async_mode=False)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 23
0
 def test_is_vmware_vmfs_true(self):
     vmfs = UnityLun.get(cli=t_rest(), _id='sv_5613')
     assert_that(vmfs.is_vmware_vmfs, equal_to(True))
Exemplo n.º 24
0
 def test_expand_lun_in_cg(self):
     lun_in_cg = UnityLun.get(cli=t_rest(), _id='sv_15')
     old_size = lun_in_cg.size_total
     resp = lun_in_cg.expand(100 * 1024**3)
     assert_that(resp, equal_to(old_size))
Exemplo n.º 25
0
 def test_detach_lun_from_all(self):
     lun_in_cg = UnityLun.get(cli=t_rest(), _id='sv_15')
     resp = lun_in_cg.detach_from(None)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 26
0
 def test_modify_lun_compression_enabled_in_cg(self):
     lun_in_cg = UnityLun.get(cli=t_rest(version='4.3'), _id='sv_18')
     resp = lun_in_cg.modify(is_compression=True)
     assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 27
0
    def test_notify_lun_attach(self):
        lun = UnityLun.get(_id='sv_2', cli=t_rest(version='4.2.0'))

        TCHelper.notify(lun, ThinCloneActionEnum.LUN_ATTACH)
        self.assertFalse(lun.get_id() in TCHelper._tc_cache)
        self.assertFalse(lun.get_id() in TCHelper._gc_candidates)
Exemplo n.º 28
0
    def test_detach_lun_nothing(self):
        lun_in_cg = UnityLun.get(cli=t_rest(), _id='sv_3')
        host = UnityHost(cli=t_rest(), _id='Host_2')

        r = lun_in_cg.detach_from(host)
        assert_that(r, none())
Exemplo n.º 29
0
    def test_detach_lun_in_cg(self):
        lun_in_cg = UnityLun.get(cli=t_rest(), _id='sv_15')
        host = UnityHost(cli=t_rest(), _id='Host_2')

        resp = lun_in_cg.detach_from(host)
        assert_that(resp.is_ok(), equal_to(True))
Exemplo n.º 30
0
 def test_modify_lun_in_cg(self):
     lun_in_cg = UnityLun.get(cli=t_rest(), _id='sv_15')
     resp = lun_in_cg.modify(size=15 * 1024**3)
     assert_that(resp.is_ok(), equal_to(True))