Beispiel #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()))
Beispiel #2
0
 def test_thin_clone(self):
     snap = UnitySnap(_id='38654705847', cli=t_rest(version='4.2.0'))
     policy = UnityIoLimitPolicy(_id='qp_2', cli=t_rest())
     clone = snap.thin_clone(name='test_thin_clone',
                             description='This is description.',
                             io_limit_policy=policy)
     assert_that(clone.id, equal_to('sv_4678'))
Beispiel #3
0
    def test_delete_attached_snap_with_force(self):
        snap = UnitySnap(_id='38654705845', cli=t_rest())

        def fake_detach_from(host):
            snap._id = '171798691885'

        with mock.patch.object(UnitySnap,
                               'detach_from',
                               side_effect=fake_detach_from):
            resp = snap.delete(even_attached=True)
            assert_that(snap._id, equal_to('171798691885'))
            assert_that(resp.is_ok(), equal_to(True))
Beispiel #4
0
 def create_snap(self, name=None, description=None, is_auto_delete=None,
                 retention_duration=None):
     return UnitySnap.create(self._cli, self.storage_resource,
                             name=name, description=description,
                             is_auto_delete=is_auto_delete,
                             retention_duration=retention_duration,
                             is_read_only=None, fs_access_type=None)
Beispiel #5
0
    def test_snap_cifs_share_create_success(self):
        snap = UnitySnap(cli=t_rest(), _id='171798700365')

        offline_availability = CifsShareOfflineAvailabilityEnum.DOCUMENTS
        umask = '222'
        description = 'Test snap cifs share.'

        share = UnityCifsShare.create_from_snap(
            t_rest(),
            snap,
            'cs71',
            is_read_only=True,
            is_encryption_enabled=True,
            is_con_avail_enabled=True,
            is_abe_enabled=True,
            is_branch_cache_enabled=True,
            offline_availability=offline_availability,
            umask=umask,
            description=description)

        assert_that(share.name, equal_to('cs71'))
        assert_that(share.is_encryption_enabled, equal_to(True))
        assert_that(share.is_continuous_availability_enabled, equal_to(True))
        assert_that(share.is_abe_enabled, equal_to(True))
        assert_that(share.is_branch_cache_enabled, equal_to(True))
        assert_that(share.offline_availability, equal_to(offline_availability))
        assert_that(share.umask, equal_to(umask))
        assert_that(share.description, equal_to(description))
Beispiel #6
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'))
Beispiel #7
0
    def test_thin_clone_auto_delete(self):
        snap = UnitySnap(_id='38654709077', cli=t_rest(version='4.2.0'))

        def _inner():
            snap.thin_clone(name='test_thin_clone',
                            description='This is description.',
                            io_limit_policy=None)
        assert_that(_inner, raises(UnityException, "Error Code:0x670166b"))
Beispiel #8
0
 def test_attach_with_retry_snap_not_skip_hlu_0_5_0_0(self):
     host = UnityHost(cli=t_rest(), _id='Host_27')
     snap = UnitySnap(_id='38654705831', cli=t_rest(version='5.0.0'))
     with mock.patch('storops.unity.resource.host.UnityHost.'
                     '_modify_hlu') as mock_modify_hlu:
         hlu = host._attach_with_retry(snap, False)
         assert_that(mock_modify_hlu.called, equal_to(False))
         assert_that(hlu, equal_to(0))
Beispiel #9
0
 def test_attach_with_retry_snap_not_skip_hlu_0(self):
     host = UnityHost(cli=t_rest(), _id='Host_27')
     snap = UnitySnap(_id='38654705831', cli=t_rest())
     with mock.patch(
             'storops.unity.resource.host.UnityHost.'
             '_random_hlu_number',
             new=lambda _: 12781):
         hlu = host._attach_with_retry(snap, False)
         assert_that(hlu, equal_to(0))
Beispiel #10
0
 def test_properties(self):
     snap = UnitySnap(_id=171798691852, cli=t_rest())
     assert_that(snap.existed, equal_to(True))
     assert_that(snap.state, equal_to(SnapStateEnum.READY))
     assert_that(snap.name, equal_to('esa_nfs1_2016-03-15_10:56:29'))
     assert_that(snap.is_system_snap, equal_to(False))
     assert_that(snap.is_modifiable, equal_to(False))
     assert_that(snap.is_read_only, equal_to(False))
     assert_that(snap.is_modified, equal_to(False))
     assert_that(snap.is_auto_delete, equal_to(True))
     assert_that(snap.size, equal_to(5368709120))
     assert_that(str(snap.creation_time),
                 equal_to('2016-03-15 02:57:27.092000+00:00'))
     assert_that(snap.storage_resource, instance_of(UnityStorageResource))
     assert_that(snap.creator_type,
                 equal_to(SnapCreatorTypeEnum.USER_CUSTOM))
     assert_that(snap.access_type,
                 equal_to(FilesystemSnapAccessTypeEnum.CHECKPOINT))
     assert_that(snap.is_cg_snap(), equal_to(False))
Beispiel #11
0
 def test_attach_with_retry_snap_skip_hlu_0_5_0_0(self):
     host = UnityHost(cli=t_rest(), _id='Host_27')
     snap = UnitySnap(_id='38654705831', cli=t_rest(version='5.0.0'))
     with mock.patch(
             'storops.unity.resource.host.UnityHost.'
             '_random_hlu_number',
             new=lambda _: 12782):
         with mock.patch('storops.unity.resource.host.UnityHost.'
                         '_modify_hlu') as mock_modify_hlu:
             hlu = host._attach_with_retry(snap, True)
             host_lun = host.get_host_lun(snap)
             mock_modify_hlu.assert_called_with(host_lun, 12782)
             assert_that(hlu, equal_to(12782))
Beispiel #12
0
 def create_snap(self,
                 name=None,
                 description=None,
                 is_auto_delete=None,
                 retention_duration=None):
     if self.is_cg_member:
         raise UnityCGMemberActionNotSupportError()
     return UnitySnap.create(self._cli,
                             self.storage_resource,
                             name=name,
                             description=description,
                             is_auto_delete=is_auto_delete,
                             retention_duration=retention_duration,
                             is_read_only=None,
                             fs_access_type=None)
    def test_create_nfs_share_from_snap_success(self):
        snap = UnitySnap(cli=t_rest(), _id='171798692125')

        default_access = NFSShareDefaultAccessEnum.READ_WRITE
        min_security = NFSShareSecurityEnum.KERBEROS
        description = 'Test snap nfs share.'

        share = UnityNfsShare.create_from_snap(
            t_rest(),
            snap,
            'ns51',
            default_access=default_access,
            min_security=min_security,
            no_access_hosts_string='Host_42',
            read_only_hosts_string='Host_41',
            read_write_hosts_string='Host_19,Host_18',
            read_only_root_hosts_string='Host_17',
            root_access_hosts_string='Host_16,Host_13',
            anonymous_uid=10001,
            anonymous_gid=10002,
            export_option=1,
            description=description)

        assert_that(share.name, equal_to('ns51'))
        assert_that(share.id, equal_to('NFSShare_51'))
        assert_that(share.path, equal_to('/'))
        assert_that(share.default_access, equal_to(default_access))
        assert_that(share.min_security, equal_to(min_security))
        assert_that(share.no_access_hosts_string, equal_to('Host_42'))
        assert_that(share.read_only_hosts_string, equal_to('Host_41'))
        assert_that(share.read_write_hosts_string, equal_to('Host_18,Host_19'))
        assert_that(share.read_only_root_hosts_string, equal_to('Host_17'))
        assert_that(share.read_write_root_hosts_string,
                    equal_to('Host_13,Host_16'))
        assert_that(share.anonymous_uid, equal_to(10001))
        assert_that(share.anonymous_gid, equal_to(10002))
        assert_that(share.export_option, equal_to(1))
        assert_that(share.description, equal_to(description))
Beispiel #14
0
 def f():
     snap = UnitySnap(_id='85899345930', cli=t_rest())
     lun = UnityLun(cli=t_rest(), _id='sv_3342')
     snap.get_member_snap(lun)
Beispiel #15
0
 def test_is_cg_snap(self):
     snap = UnitySnap(_id='85899345930', cli=t_rest())
     assert_that(snap.is_cg_snap(), equal_to(True))
Beispiel #16
0
 def f():
     snap = UnitySnap(_id='38654705676', cli=t_rest())
     host = UnityHost(_id="Host_13", cli=t_rest())
     snap.attach_to(host)
Beispiel #17
0
 def test_detach_snap_success(self):
     snap = UnitySnap(_id='38654705676', cli=t_rest())
     host = UnityHost(_id="Host_12", cli=t_rest())
     resp = snap.detach_from(host)
     assert_that(resp.is_ok(), equal_to(True))
Beispiel #18
0
 def test_thinclone_of_thick_lun_snap_not_allowed(self):
     snap = UnitySnap(cli=t_rest(version='4.3'), _id='38654707273')
     assert_that(
         calling(snap.thin_clone).with_args('not-allowed'),
         raises(UnityThinCloneNotAllowedError))
Beispiel #19
0
 def test_snap_restore_auto_delete_false(self):
     snap = UnitySnap(cli=t_rest(), _id='38654705785')
     backup = snap.restore(backup="backup_snap")
     assert_that(backup.id, equal_to("38654700002"))
Beispiel #20
0
 def test_copy_snap_success(self):
     snap = UnitySnap(cli=t_rest(), _id='38654705785')
     snap = snap.copy('s3')
     assert_that(snap.existed, equal_to(True))
     assert_that(snap, instance_of(UnitySnap))
Beispiel #21
0
 def f():
     snap = UnitySnap(cli=t_rest(), _id='171798691852')
     snap.create_nfs_share('sns1')
Beispiel #22
0
 def test_create_snap_success(self):
     snap = UnitySnap(_id='171798691884', cli=t_rest())
     sos = snap.create_snap(name='snap_over_snap')
     assert_that(sos.name, equal_to('snap_over_snap'))
     assert_that(sos.existed, equal_to(True))
Beispiel #23
0
 def test_copy_snap_success(self):
     snap = UnitySnap(cli=t_rest(), _id='38654705785')
     snap = snap.copy('s3')
     assert_that(snap.existed, equal_to(True))
     assert_that(snap, instance_of(UnitySnap))
Beispiel #24
0
 def test_create_cifs_share_success(self):
     snap = UnitySnap(cli=t_rest(), _id='171798691899')
     share = snap.create_cifs_share('sns2')
     assert_that(share.snap, equal_to(snap))
     assert_that(share.name, equal_to('sns2'))
     assert_that(share.type, equal_to(CIFSTypeEnum.CIFS_SNAPSHOT))
Beispiel #25
0
 def test_delete_snap(self):
     snap = UnitySnap(_id='171798691885', cli=t_rest())
     resp = snap.delete()
     assert_that(resp.is_ok(), equal_to(True))
Beispiel #26
0
 def test_create_snap_success(self):
     snap = UnitySnap(_id='171798691884', cli=t_rest())
     sos = snap.create_snap(name='snap_over_snap')
     assert_that(sos.existed, equal_to(True))
     assert_that(sos.storage_resource, equal_to(snap.storage_resource))
     assert_that(sos.name, equal_to('snap_over_snap'))
Beispiel #27
0
 def test_delete_attached_snap(self):
     snap = UnitySnap(_id='38654705845', cli=t_rest())
     assert_that(lambda: snap.delete(),
                 raises(UnityDeleteAttachedSnapError))
Beispiel #28
0
 def test_thinclone_of_member_snap_not_support(self):
     snap = UnitySnap(cli=t_rest(version='4.3'), _id='38654707282')
     assert_that(
         calling(snap.thin_clone).with_args('not-support'),
         raises(UnityCGMemberActionNotSupportError))
Beispiel #29
0
 def f():
     snap = UnitySnap(cli=t_rest(), _id='171798691852')
     snap.create_nfs_share('sns1')
Beispiel #30
0
 def test_destroying_snap_existed(self):
     snap = UnitySnap(cli=t_rest(), _id='171798691953')
     assert_that(snap.existed, equal_to(False))
Beispiel #31
0
 def test_attach_second_snap_success(self):
     snap = UnitySnap(_id='38654705670', cli=t_rest())
     host = UnityHost(_id="Host_19", cli=t_rest())
     resp = snap.attach_to(host)
     assert_that(resp.is_ok(), equal_to(True))
Beispiel #32
0
 def test_delete_snap(self):
     snap = UnitySnap(_id='171798691885', cli=t_rest())
     resp = snap.delete()
     assert_that(resp.is_ok(), equal_to(True))
Beispiel #33
0
 def test_not_found_snap_existed(self):
     snap = UnitySnap(cli=t_rest(), _id='12345')
     assert_that(snap.existed, equal_to(False))
Beispiel #34
0
 def test_create_cifs_share_success(self):
     snap = UnitySnap(cli=t_rest(), _id='171798691899')
     share = snap.create_cifs_share('sns2')
     assert_that(share.snap, equal_to(snap))
     assert_that(share.name, equal_to('sns2'))
     assert_that(share.type, equal_to(CIFSTypeEnum.CIFS_SNAPSHOT))
Beispiel #35
0
 def test_delete_not_exist_snap(self):
     snap = UnitySnap(_id='38654705844', cli=t_rest())
     assert_that(lambda: snap.delete(), raises(UnityResourceNotFoundError))