예제 #1
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()
예제 #2
0
    def delete(self,
               async_mode=False,
               force_snap_delete=False,
               force_vvol_delete=False):
        sr = self.storage_resource
        if not self.existed or sr is None:
            raise UnityResourceNotFoundError('cannot find lun {}.'.format(
                self.get_id()))
        resp = self._cli.delete(sr.resource_class,
                                self.get_id(),
                                forceSnapDeletion=force_snap_delete,
                                forceVvolDeletion=force_vvol_delete,
                                async_mode=async_mode)
        try:
            resp.raise_if_err()
        except UnityBaseHasThinCloneError:
            log.warning(
                'cannot delete the lun: %s, because it is a base lun '
                'of a thin-clone.', self.get_id())
            TCHelper.notify(self, ThinCloneActionEnum.BASE_LUN_DELETE)
            return RESP_OK

        if self.is_thin_clone:
            TCHelper.notify(self, ThinCloneActionEnum.TC_DELETE)
        return resp
예제 #3
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)
예제 #4
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)
예제 #5
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)
예제 #6
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()
예제 #7
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)
예제 #8
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()
예제 #9
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)
예제 #10
0
파일: lun.py 프로젝트: zhangdaolong/storops
    def attach_to(self, host, access_mask=HostLUNAccessEnum.PRODUCTION):
        host_access = [{'host': host, 'accessMask': access_mask}]
        # If this lun has been attached to other host, don't overwrite it.
        if self.host_access:
            host_access += [{'host': item.host,
                             'accessMask': item.access_mask} for item
                            in self.host_access if host.id != item.host.id]

        resp = self.modify(host_access=host_access)
        resp.raise_if_err()
        log.debug('Notify TCHelper the attaching action of lun: %s.',
                  self.get_id())
        TCHelper.notify(self, ThinCloneActionEnum.LUN_ATTACH)
        return resp
예제 #11
0
 def test_thin_clone_snap(self):
     snap = UnitySnap.get(_id='38654700002', cli=t_rest(version='4.2.0'))
     cloned = TCHelper.thin_clone(snap._cli, snap,
                                  name='test_thin_clone_snap',
                                  description='description',
                                  io_limit_policy=None)
     assert_that(cloned.id, equal_to('sv_5557'))
예제 #12
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'))
예제 #13
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'))
예제 #14
0
파일: lun.py 프로젝트: qingfeng0820/storops
    def thin_clone(self, name, io_limit_policy=None, description=None):
        if self.is_cg_member:
            raise UnityCGMemberActionNotSupportError()

        if not self.is_thin_enabled:
            raise UnityThinCloneNotAllowedError()

        return TCHelper.thin_clone(self._cli, self, name, io_limit_policy,
                                   description)
예제 #15
0
    def thin_clone(self, name, io_limit_policy=None, description=None):
        """Creates a new thin clone from this snapshot.
        .. note:: this snapshot should not enable Auto-Delete.
        """
        if self.is_member_snap():
            raise UnityCGMemberActionNotSupportError()

        if self.lun and not self.lun.is_thin_enabled:
            raise UnityThinCloneNotAllowedError()

        return TCHelper.thin_clone(self._cli, self, name, io_limit_policy,
                                   description)
예제 #16
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)
예제 #17
0
파일: lun.py 프로젝트: qingfeng0820/storops
        sr = self.storage_resource
        if not self.existed or sr is None:
            raise UnityResourceNotFoundError('cannot find lun {}.'.format(
                self.get_id()))
        resp = self._cli.delete(sr.resource_class,
                                self.get_id(),
                                forceSnapDeletion=force_snap_delete,
                                forceVvolDeletion=force_vvol_delete,
                                async=async)
        try:
            resp.raise_if_err()
        except UnityBaseHasThinCloneError:
            log.warning(
                'cannot delete the lun: %s, because it is a base lun '
                'of a thin-clone.', self.get_id())
            TCHelper.notify(self, ThinCloneActionEnum.BASE_LUN_DELETE)
            return RESP_OK

        if self.is_thin_clone:
            TCHelper.notify(self, ThinCloneActionEnum.TC_DELETE)
        return resp

    def _attach_to(self, host, access_mask, hlu):
        host_access = [{'host': host, 'accessMask': access_mask}]
        if hlu is not None:
            host_access[0]['hlu'] = hlu
        # If this lun has been attached to other host, don't overwrite it.
        if self.host_access:
            host_access += [{
                'host': item.host,
                'accessMask': item.access_mask
예제 #18
0
파일: lun.py 프로젝트: rtjust/storops
 def thin_clone(self, name, io_limit_policy=None, description=None):
     return TCHelper.thin_clone(self._cli, self, name, io_limit_policy,
                                description)
예제 #19
0
파일: lun.py 프로젝트: remixtj/storops
 def thin_clone(self, name, io_limit_policy=None, description=None):
     if self.is_cg_member:
         raise UnityCGLunActionNotSupportError()
     return TCHelper.thin_clone(self._cli, self, name, io_limit_policy,
                                description)
예제 #20
0
 def thin_clone(self, name, io_limit_policy=None, description=None):
     """Creates a new thin clone from this snapshot.
     .. note:: this snapshot should not enable Auto-Delete.
     """
     return TCHelper.thin_clone(self._cli, self, name, io_limit_policy,
                                description)
예제 #21
0
 def setUp(self):
     self.path = tempfile.mkdtemp(suffix='storops')
     TCHelper.set_up(self.path)
     TCHelper._gc_background.set_interval(0.10)
     TCHelper._gc_background.MAX_RETRIES = 1
예제 #22
0
 def _inner():
     TCHelper.thin_clone(lun._cli,
                         lun,
                         name='test_thin_clone_limit_exceeded',
                         description='This is description.',
                         io_limit_policy=None)
예제 #23
0
 def tearDown(self):
     shutil.rmtree(self.path, ignore_errors=True)
     TCHelper.clean_up()