Пример #1
0
    def modify(self, default_access=None, min_security=None,
               no_access_hosts=None, read_only_hosts=None,
               read_write_hosts=None, root_access_hosts=None,
               read_only_root_access_hosts=None, no_access_hosts_string=None,
               read_only_hosts_string=None, read_write_hosts_string=None,
               read_only_root_hosts_string=None,
               root_access_hosts_string=None,
               anonymous_uid=None, anonymous_gid=None, export_option=None,
               host_config=None, description=None):
        if host_config is not None:
            no_access_hosts = host_config.no_access
            root_access_hosts = host_config.root
            read_only_root_access_hosts = host_config.root_ro
            read_only_hosts = host_config.ro
            read_write_hosts = host_config.rw

        NFSShareDefaultAccessEnum.verify(default_access)
        NFSShareSecurityEnum.verify(min_security)
        clz = storops.unity.resource.host.UnityHostList
        no_access_hosts = clz.get_list(self._cli, no_access_hosts)
        read_only_hosts = clz.get_list(self._cli, read_only_hosts)
        read_write_hosts = clz.get_list(self._cli, read_write_hosts)
        root_access_hosts = clz.get_list(self._cli, root_access_hosts)
        read_only_root_access_hosts = clz.get_list(
            self._cli, read_only_root_access_hosts)

        nfs_share_param = self.prepare_nfs_share_parameters(
            default_access=default_access,
            min_security=min_security,
            no_access_hosts=no_access_hosts,
            read_only_hosts=read_only_hosts,
            read_write_hosts=read_write_hosts,
            root_access_hosts=root_access_hosts,
            read_only_root_access_hosts=read_only_root_access_hosts,
            no_access_hosts_string=no_access_hosts_string,
            read_only_hosts_string=read_only_hosts_string,
            read_write_hosts_string=read_write_hosts_string,
            read_only_root_hosts_string=read_only_root_hosts_string,
            root_access_hosts_string=root_access_hosts_string,
            anonymous_uid=anonymous_uid,
            anonymous_gid=anonymous_gid,
            export_option=export_option,
            description=description)

        if nfs_share_param:
            # different api for different type of share
            if self.type == NFSTypeEnum.NFS_SHARE:
                resp = self._modify_fs_share(nfs_share_param)
            elif self.type == NFSTypeEnum.NFS_SNAPSHOT:
                resp = self._modify_snap_share(nfs_share_param)
            else:
                raise UnityShareTypeNotSupportAccessControlError()
        else:
            resp = RestResponse('', self._cli)
        resp.raise_if_err()
        return resp
Пример #2
0
 def test_get_properties(self):
     body = read_error_json('409.json')
     resp = RestResponse(body)
     assert_that(resp.has_error(), equal_to(True))
     err = resp.error
     assert_that(err.existed, equal_to(True))
     assert_that(str(err.created),
                 equal_to('2016-03-16 15:13:45.977000+00:00'))
     assert_that(err.get_messages(), only_contains(
         'The name of NAS server is already in use. '
         '(Error Code:0x6702024)'))
     assert_that(err.http_status_code, equal_to(409))
     assert_that(err.error_code, equal_to(108011556))
Пример #3
0
 def test_get_properties(self):
     body = read_error_json('409.json')
     resp = RestResponse(body)
     assert_that(resp.has_error(), equal_to(True))
     err = resp.error
     assert_that(err.existed, equal_to(True))
     assert_that(str(err.created),
                 equal_to('2016-03-16 15:13:45.977000+00:00'))
     assert_that(
         err.get_messages(),
         only_contains('The name of NAS server is already in use. '
                       '(Error Code:0x6702024)'))
     assert_that(err.http_status_code, equal_to(409))
     assert_that(err.error_code, equal_to(108011556))
Пример #4
0
    def modify(self,
               default_access=None,
               min_security=None,
               no_access_hosts=None,
               read_only_hosts=None,
               read_write_hosts=None,
               root_access_hosts=None,
               host_config=None):
        if host_config is not None:
            no_access_hosts = host_config.no_access
            root_access_hosts = host_config.root
            read_only_hosts = host_config.ro
            read_write_hosts = host_config.rw

        NFSShareDefaultAccessEnum.verify(default_access)
        NFSShareSecurityEnum.verify(min_security)
        clz = storops.unity.resource.host.UnityHostList
        no_access_hosts = clz.get_list(self._cli, no_access_hosts)
        read_only_hosts = clz.get_list(self._cli, read_only_hosts)
        read_write_hosts = clz.get_list(self._cli, read_write_hosts)
        root_access_hosts = clz.get_list(self._cli, root_access_hosts)

        nfs_share_param = self._cli.make_body(
            allow_empty=True,
            defaultAccess=default_access,
            minSecurity=min_security,
            noAccessHosts=no_access_hosts,
            readOnlyHosts=read_only_hosts,
            readWriteHosts=read_write_hosts,
            rootAccessHosts=root_access_hosts)

        if nfs_share_param:
            # different api for different type of share
            if self.type == NFSTypeEnum.NFS_SHARE:
                resp = self._modify_fs_share(nfs_share_param)
            elif self.type == NFSTypeEnum.NFS_SNAPSHOT:
                resp = self._modify_snap_share(default_access,
                                               min_security,
                                               nfs_share_param)
            else:
                raise UnityShareTypeNotSupportAccessControlError()
        else:
            resp = RestResponse('', self._cli)
        resp.raise_if_err()
        return resp
Пример #5
0
    def modify(self,
               default_access=None,
               min_security=None,
               no_access_hosts=None,
               read_only_hosts=None,
               read_write_hosts=None,
               root_access_hosts=None,
               host_config=None):
        if host_config is not None:
            no_access_hosts = host_config.no_access
            root_access_hosts = host_config.root
            read_only_hosts = host_config.ro
            read_write_hosts = host_config.rw

        NFSShareDefaultAccessEnum.verify(default_access)
        NFSShareSecurityEnum.verify(min_security)
        clz = storops.unity.resource.host.UnityHostList
        no_access_hosts = clz.get_list(self._cli, no_access_hosts)
        read_only_hosts = clz.get_list(self._cli, read_only_hosts)
        read_write_hosts = clz.get_list(self._cli, read_write_hosts)
        root_access_hosts = clz.get_list(self._cli, root_access_hosts)

        nfs_share_param = self._cli.make_body(
            allow_empty=True,
            defaultAccess=default_access,
            minSecurity=min_security,
            noAccessHosts=no_access_hosts,
            readOnlyHosts=read_only_hosts,
            readWriteHosts=read_write_hosts,
            rootAccessHosts=root_access_hosts)

        if nfs_share_param:
            # different api for different type of share
            if self.type == NFSTypeEnum.NFS_SHARE:
                resp = self._modify_fs_share(nfs_share_param)
            elif self.type == NFSTypeEnum.NFS_SNAPSHOT:
                resp = self._modify_snap_share(default_access,
                                               min_security,
                                               nfs_share_param)
            else:
                raise UnityShareTypeNotSupportAccessControlError()
        else:
            resp = RestResponse('', self._cli)
        resp.raise_if_err()
        return resp
Пример #6
0
    def modify(self, is_read_only=None, is_ace_enabled=None, add_ace=None,
               delete_ace=None, is_encryption_enabled=None,
               is_con_avail_enabled=None, is_abe_enabled=None,
               is_branch_cache_enabled=None, offline_availability=None,
               umask=None, description=None):
        if self.type == CIFSTypeEnum.CIFS_SHARE:
            share_param = self.prepare_cifs_share_parameters(
                is_read_only=is_read_only,
                is_encryption_enabled=is_encryption_enabled,
                is_con_avail_enabled=is_con_avail_enabled,
                is_ace_enabled=is_ace_enabled,
                add_ace=add_ace, delete_ace=delete_ace,
                is_abe_enabled=is_abe_enabled,
                is_branch_cache_enabled=is_branch_cache_enabled,
                offline_availability=offline_availability,
                umask=umask, description=description)
            if share_param:
                resp = self._modify_fs_share(share_param)
            else:
                resp = RestResponse('', self._cli)
        if self.type == CIFSTypeEnum.CIFS_SNAPSHOT:
            share_param = self.prepare_cifs_share_parameters(
                is_encryption_enabled=is_encryption_enabled,
                is_con_avail_enabled=is_con_avail_enabled,
                is_abe_enabled=is_abe_enabled,
                is_branch_cache_enabled=is_branch_cache_enabled,
                offline_availability=offline_availability,
                umask=umask, description=description)
            if share_param:
                resp = self._modify_snap_share(share_param)
            else:
                resp = RestResponse('', self._cli)

        resp.raise_if_err()
        return resp
Пример #7
0
    def modify(self,
               size=None,
               is_thin=None,
               tiering_policy=None,
               user_cap=False,
               is_compression=None,
               access_policy=None,
               locking_policy=None,
               description=None,
               cifs_fs_parameters=None):
        sr = self.storage_resource
        if sr is None:
            raise ValueError(
                'storage resource for filesystem {} not found.'.format(
                    self.name))

        if size:
            size = supplement_filesystem(size, user_cap)

        fs_param = self.prepare_fs_parameters(is_thin_enabled=is_thin,
                                              size=size,
                                              tiering_policy=tiering_policy,
                                              is_compression=is_compression,
                                              access_policy=access_policy,
                                              locking_policy=locking_policy)

        params = {}
        if fs_param:
            params['fsParameters'] = fs_param
        if cifs_fs_parameters:
            params['cifsFsParameters'] = cifs_fs_parameters
        if description is not None:
            params['description'] = description

        if not params:
            return RestResponse('', self._cli)

        req_body = self._cli.make_body(allow_empty=True, **params)
        resp = sr.modify_fs(**req_body)
        resp.raise_if_err()
        return resp
Пример #8
0
 def rest_get(self, url, fields=None, **params):
     if fields is None:
         fields = []
     params['fields'] = ','.join(map(str, sorted(fields)))
     url = self.assemble_url(url, **params)
     return RestResponse(self._rest.get(url))
Пример #9
0
 def test_unity_exception_error_code(self):
     resp = RestResponse(read_error_json('409.json'))
     ex = UnityException(resp.error)
     assert_that(ex.error_code, equal_to(108011556))
Пример #10
0
 def test_raise_if_err_nothing(self):
     body = read_error_json('200.json')
     resp = RestResponse(body)
     resp.raise_if_err()
Пример #11
0
 def f():
     body = read_error_json('409.json')
     resp = RestResponse(body)
     resp.raise_if_err()
Пример #12
0
 def f():
     body = read_error_json('409.json')
     resp = RestResponse(body)
     resp.raise_if_err()
Пример #13
0
 def _wrap(*args, **kwargs):
     try:
         ret = func(*args, **kwargs)
     except UnityResourceNotSupportedError:
         ret = RestResponse(inputs="")
     return ret
Пример #14
0
 def rest_delete(self, url, body=None, **params):
     url = self.assemble_url(url, **params)
     return RestResponse(self._rest.delete(url, body=body))
Пример #15
0
 def rest_post(self, url, body=None, files=None, **params):
     url = self.assemble_url(url, **params)
     return RestResponse(self._rest.post(url, files=files, body=body))
Пример #16
0
 def test_has_current_page(self):
     resp = RestResponse(read_json('metric', 'metrics_page_1.json'))
     assert_that(resp.current_page, equal_to(1))
Пример #17
0
 def test_has_next_page(self):
     resp = RestResponse(read_json('metric', 'metrics_page_1.json'))
     assert_that(resp.next_page, equal_to(2))
     assert_that(resp.has_next_page, equal_to(True))
Пример #18
0
 def test_raise_if_err_nothing(self):
     body = read_error_json('200.json')
     resp = RestResponse(body)
     resp.raise_if_err()