• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tenant.Tenant类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tenant.Tenant的典型用法代码示例。如果您正苦于以下问题:Python Tenant类的具体用法?Python Tenant怎么用?Python Tenant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Tenant类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: varray_list

    def varray_list(self, vdcname=None, tenant=None):
        '''
        Returns all the varrays in a vdc
        Parameters:
        Returns:
                JSON payload of varray list
        '''
        vdcuri = None
        vdcrestapi = None

        if(tenant != None):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            tenanturi = tenant_obj.tenant_query(tenant)
            if(vdcname != None):
                vdcrestapi = VirtualArray.URI_VIRTUALARRAY_BY_VDC_ID_AND_TENANT_ID.format(vdcname, tenanturi)
            else:
                vdcrestapi = VirtualArray.URI_VIRTUALARRAY_BY_TENANT_ID.format(tenanturi)
        else:
            if(vdcname != None):
                vdcrestapi = VirtualArray.URI_VIRTUALARRAY_BY_VDC_ID.format(vdcname)
            else:
                vdcrestapi = VirtualArray.URI_VIRTUALARRAY

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            vdcrestapi, None)

        o = common.json_decode(s)

        returnlst = []
        for item in o['varray']:
            returnlst.append(item['id'])

        return returnlst
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:35,代码来源:virtualarray.py


示例2: project_query

 def project_query(self, name):
     '''
     Retrieves UUID of project based on its name
     Parameters:
         name: name of project
     Returns: UUID of project
     Throws:
         SOSError - when project name is not found 
     '''
     if (common.is_uri(name)):
         return name
     (tenant_name, project_name) = common.get_parent_child_from_xpath(name)
     
     from tenant import Tenant
     tenant_obj = Tenant(self.__ipAddr, self.__port)
     
     try:
         tenant_uri = tenant_obj.tenant_query(tenant_name)
         projects = self.project_list(tenant_uri)
         if(projects and len(projects) > 0):
             for project in projects:
                 if (project):
                     project_detail = self.project_show_by_uri(project['id'])
                     if(project_detail and project_detail['name'] == project_name):
                         return project_detail['id']
         raise SOSError(SOSError.NOT_FOUND_ERR, 'Project: ' + project_name + ' not found')
     except SOSError as e:
         raise e
开发者ID:tylerbaker,项目名称:controller-openstack-cinder,代码行数:28,代码来源:project.py


示例3: keypool_show

    def keypool_show(self, keypool, tenant, uid, secret):
        '''
        show keypool
        parameters:
            keypool:  	label of the keypool
            tenant:  	tenant name
            uid:	user id
            secret:	secret key
        Returns:
            JSON payload response
        '''
        #uri = self.keypool_query(label)

        if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace = tenant_obj.namespace_get(tenant)

        try:
            if(apitype == 's3'):
                return s3_bucket_show(namespace, keypool, uid, secretkey)
            elif(apitype == 'swift'):
                return swift_container_show(namespace, keypool, uid, secretkey)
            elif(apitype == 'atmos'):
                return atmos_subtenant_show(namespace, keypool, uid, secretkey)
            else:
                raise SOSError(SOSError.VALUE_ERR,
                               "Wrong API type " + apitype + " specified")
        except SOSError as e:
            raise e
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:30,代码来源:keypool.py


示例4: cluster_create

    def cluster_create(self, label, tenant, datacenter, vcenter):
        tenant_obj = Tenant(self.__ipAddr, self.__port)
        vdatacenterobj = VcenterDatacenter(self.__ipAddr, self.__port)

        if(tenant is None):
            tenant_uri = tenant_obj.tenant_getid()
        else:
            tenant_uri = tenant_obj.tenant_query(tenant)

        parms = {'name': label}

        # datacenter
        if(datacenter):
            # on failure, query raise exception
            parms['vcenter_data_center'] = \
                vdatacenterobj.vcenterdatacenter_query(
                    datacenter, vcenter, tenant)

        body = json.dumps(parms)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port,
            "POST",
            Cluster.URI_TENANTS_CLUSTERS.format(tenant_uri),
            body)
        o = common.json_decode(s)
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:26,代码来源:cluster.py


示例5: cluster_create

    def cluster_create(self, label, tenant, project, datacenter, vcenter):
        tenant_obj = Tenant(self.__ipAddr, self.__port)
        vdatacenterobj = VcenterDatacenter(self.__ipAddr, self.__port)
        projectobj = Project(self.__ipAddr, self.__port)

        if(tenant == None):
            tenant_uri = tenant_obj.tenant_getid()
        else:
            tenant_uri = tenant_obj.tenant_query(tenant)
                
        parms = { 'name'            : label
                   }
        #project
        if(project):
            if(tenant):
                projectname = tenant + "/" + project
            else:
                projectname = "" + "/" + project
            #on failure, query raise exception
            parms['project'] = projectobj.project_query(projectname)
            
        #datacenter
        if(datacenter):
            #on failure, query raise exception
            parms['vcenter_data_center'] = vdatacenterobj.vcenterdatacenter_query(datacenter, vcenter)

        body = json.dumps(parms)

        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "POST",
                                             Cluster.URI_TENANTS_CLUSTERS.format(tenant_uri),
                                             body)
        o = common.json_decode(s)
开发者ID:tylerbaker,项目名称:controller-openstack-cinder,代码行数:33,代码来源:cluster.py


示例6: keypool_update

    def keypool_update(
            self, keypool, tenant, versioning, apitype, uid, secret):
        '''
        update keypool versioning
        parameters:
            keypool:  	label of the keypool
            project:  	project name
            tenant:  	tenant  name
            uid:	user id
            secret:	secret key
        Returns:
            JSON payload response
        '''

        if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace = tenant_obj.namespace_get(tenant)

        try:
            if(apitype == 's3'):
                return s3_bucket_update(
                    namespace, keypool, versioning, uid, secretkey)
            else:
                raise SOSError(SOSError.VALUE_ERR,
                               "Wrong API type " + apitype + " specified")

        except SOSError as e:
            raise e
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:29,代码来源:keypool.py


示例7: varray_disallow_tenant

    def varray_disallow_tenant(self, varray, tenant):
        '''
        Makes a REST API call to retrieve details of a varray
        based on its UUID
        '''
        uri = self.varray_query(varray)

        from tenant import Tenant
        tenant_obj = Tenant(self.__ipAddr, self.__port)
        tenanturi = tenant_obj.tenant_query(tenant)

        parms = {
            'remove': [{
                'privilege': ['USE'],
                'tenant': tenanturi,
            }]
        }

        body = json.dumps(parms)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "PUT",
            self.URI_VIRTUALARRAY_ACLS.format(uri),
            body)
        return s
开发者ID:antaryelkawar,项目名称:coprhd-controller,代码行数:25,代码来源:virtualarray.py


示例8: key_write

    def key_write(self, key, filepath , keypool, tenant, apitype,  uid, secret, type):
        '''
        write a key
        parameters:    
            key:  	key
            keypool:  	keypool
            tenant:   	tenant  name
            value:   	value
	    apitype:    api to be used
	    uid:	user id
	    secret:	secret
        Returns:
            JSON payload response
        '''

	if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace =  tenant_obj.namespace_get(tenant)

	if(apitype == 's3'):
            s3_key_write(namespace, keypool, key, filepath, uid, secret )
        elif(apitype == 'swift'):
            swift_object_write(namespace, keypool, key, filepath, uid, secret )
        elif(apitype == 'atmos'):
            atmos_object_write(namespace, keypool, key, filepath, uid, secret, type )
        else:
            raise SOSError(SOSError.VALUE_ERR,
                  "Wrong API type " + apitype + " specified")
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:29,代码来源:key.py


示例9: keypool_delete

    def keypool_delete(self, keypool, tenant, uid, secret):
        '''Makes a REST API call to delete a keypool by its name,
        project and tenant
        '''

        if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace = tenant_obj.namespace_get(tenant)

        try:
            if(apitype == 's3'):
                return s3_bucket_delete(namespace, keypool, uid, secretkey)
            elif(apitype == 'swift'):
                return swift_container_delete(namespace,
                                              keypool,
                                              uid,
                                              secretkey)
            elif(apitype == 'atmos'):
                return atmos_subtenant_delete(namespace,
                                              keypool,
                                              uid,
                                              secretkey)
            else:
                raise SOSError(SOSError.VALUE_ERR,
                               "Wrong API type " + apitype + " specified")
        except SOSError as e:
            raise e
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:28,代码来源:keypool.py


示例10: key_delete

    def key_delete(self, key, keypool, tenant, apitype, version, uid, secret):
        '''
        Makes a REST API call to delete a key by its name
        Parameters:           
            key:  label of the key
            keypool:  label of the keypool
            project:  project name
            tenant:  tenant  name
	    apitype:    api to be used
	    uid:	user id
	    secret:	secret
        Returns:
                JSON payload of key list
        '''
	if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace =  tenant_obj.namespace_get(tenant)

	if(apitype == 's3'):
            s3_key_delete(namespace, keypool, key, version, uid, secret )
        elif(apitype == 'swift'):
            swift_object_delete(namespace, keypool, key, version, uid, secret )
        elif(apitype == 'atmos'):
            atmos_object_delete(namespace, keypool, key, uid, secret )
        else:
            raise SOSError(SOSError.VALUE_ERR,
                  "Wrong API type " + apitype + " specified")
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:28,代码来源:key.py


示例11: key_list_versions

    def key_list_versions(self, keypool, key, tenant, apitype,  uid, secret):
        '''
        Returns versions of the key`
        Parameters:           
            key:  label of the key
            keypool:  label of the keypool
            project:  project name
            tenant:  tenant  name
	    apitype:    api to be used
	    uid:	user id
	    secret:	secret
        Returns:
                JSON payload of key list
        '''

	if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace =  tenant_obj.namespace_get(tenant)

	if(apitype == 's3'):
            s3_key_list_versions(namespace, keypool, key, uid, secret )
	elif ( (apitype =='swift') or (apitype=='atmos')) :
            raise SOSError(SOSError.NOT_FOUND_ERR,
                  "Versioning not available with  API type " + apitype)
        else:
            raise SOSError(SOSError.VALUE_ERR,
                  "Wroing API type " + apitype + " specified")
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:28,代码来源:key.py


示例12: add_or_remove_vcenter_acls

    def add_or_remove_vcenter_acls(self, vcenter_name, tenants, operation):
        vcenter_uri = self.vcenter_query(vcenter_name, VCenter.VCENTERS_FROM_ALL_TENANTS)

        tenants_array = []
        tenants_array = tenants.split(',')

        from tenant import Tenant
        obj = Tenant(self.__ipAddr, self.__port)

        acl_entries = []
        for tenant in tenants_array:
            acl_entry = dict()
            acl_entry['privilege'] = ['USE']
            acl_entry['tenant'] = str(obj.tenant_query(tenant))
            acl_entries.append(acl_entry)

        request = {operation: acl_entries}

        body = json.dumps(request)

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "PUT",
                        VCenter.URI_VCENTER_ACL.format(vcenter_uri), body)

        o = common.json_decode(s)

        return o
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:26,代码来源:vcenter.py


示例13: get_tenant_id

    def get_tenant_id(self, tenantName):
        """
         Fetch the tenant id
        """
        tenantObj = Tenant(self.__ipAddr, self.__port)
        tenantId = tenantObj.get_tenant_by_name(tenantName)

        return tenantId
开发者ID:uemurs,项目名称:controller-openstack-cinder,代码行数:8,代码来源:host.py


示例14: get_tenant_uri_from_name

    def get_tenant_uri_from_name(self, tenantname):
        if (tenantname is None or
            tenantname == "" or
            tenantname.lower() == VCenter.VCENTERS_FROM_ALL_TENANTS.lower() or
            tenantname.lower() == VCenter.VCENTERS_WITH_NO_TENANTS.lower()):
            tenanturi = tenantname
        else:
            from tenant import Tenant
            obj = Tenant(self.__ipAddr, self.__port)

            tenanturi = obj.tenant_query(tenantname)

        return tenanturi
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:13,代码来源:vcenter.py


示例15: create

    def create(
        self,
        tenant,
        policyname,
        policytype,
        schedulefrequency,
        schedulerepeat,
        scheduletime,
        scheddom,
        scheddow,
        expiretype,
        expirevalue,
    ):

        tenant_obj = Tenant(self.__ipAddr, self.__port)
        tenant_uri = tenant_obj.tenant_query(tenant)

        schedule = dict()
        schedule = {
            "schedule_frequency": schedulefrequency,
            "schedule_repeat": schedulerepeat,
            "schedule_time": scheduletime,
        }

        if schedulefrequency == "weeks":
            schedule["schedule_day_of_week"] = scheddow
        elif schedulefrequency == "months":
            schedule["schedule_day_of_month"] = scheddom

        parms = {"policy_type": policytype, "policy_name": policyname}

        body = None
        parms["schedule"] = schedule

        snapshot_expire = dict()
        if expiretype or expirevalue:
            snapshot_expire = {"expire_type": expiretype, "expire_value": expirevalue}
            parms["snapshot_expire"] = snapshot_expire

        body = json.dumps(parms)

        (s, h) = common.service_json_request(
            self.__ipAddr,
            self.__port,
            "POST",
            Schedulepolicy.URI_SNAPSHOT_SCHEDULE_POLICY_CREATE.format(tenant_uri),
            body,
        )

        return
开发者ID:santymk,项目名称:coprhd-controller,代码行数:50,代码来源:schedulepolicy.py


示例16: policy_list

    def policy_list(self, tenantname):
        tenant_obj = Tenant(self.__ipAddr, self.__port)
        tenant_uri = tenant_obj.tenant_query(tenantname)

        (s, h) = common.service_json_request(
            self.__ipAddr,
            self.__port,
            "GET",
            Schedulepolicy.URI_SNAPSHOT_SCHEDULE_POLICY_CREATE.format(tenant_uri),
            None,
        )

        res = common.json_decode(s)
        return res["schedule_policy"]
开发者ID:santymk,项目名称:coprhd-controller,代码行数:14,代码来源:schedulepolicy.py


示例17: get_vcenter_uri_with_tenant_param

    def get_vcenter_uri_with_tenant_param(self, tenant):
        uri = ""
        if (tenant is None or
            tenant == "" or
            tenant.lower() == VCenter.VCENTERS_FROM_ALL_TENANTS.lower()):
            uri = VCenter.URI_VCENTERS_WITH_TENANT_PARAM.format(VCenter.VCENTERS_FROM_ALL_TENANTS)
        elif tenant.lower() == VCenter.VCENTERS_WITH_NO_TENANTS.lower():
            uri = VCenter.URI_VCENTERS_WITH_TENANT_PARAM.format(tenant)
        else:
            from tenant import Tenant
            obj = Tenant(self.__ipAddr, self.__port)

            tenant_uri = obj.tenant_query(tenant)
            uri = VCenter.URI_VCENTERS_WITH_TENANT_PARAM.format(tenant_uri)
        return uri
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:15,代码来源:vcenter.py


示例18: keypool_list

    def keypool_list(self, projectname, tenant, apitype, uid, secret):
        '''
        Returns all the keypools in a vdc
        Parameters:
            keypool:  label of the keypool
            project:  project name
            tenant:  tenant  name
            apitype:    api type(s3, swift or atmos)
            uid:	user id
            secret:	secret key
        Returns:
                JSON payload of keypool list
        '''

        if (not common.is_uri(tenant)):
            from tenant import Tenant
            tenant_obj = Tenant(self.__ipAddr, self.__port)
            namespace = tenant_obj.namespace_get(tenant)

        kplst = []

        try:
            if((not apitype) or (apitype == 's3')):
                kplst.append(
                    s3_bucket_list(
                        namespace,
                        projectname,
                        uid,
                        secretkey))
            if((not apitype) or (apitype == 'swift')):
                kplst.append(
                    swift_container_list(
                        namespace,
                        projectname,
                        uid,
                        secretkey))
            if((not apitype) or (apitype == 'atmos')):
                kplst.append(
                    atmos_subtenant_list(
                        namespace,
                        projectname,
                        uid,
                        secretkey))

            # need to convert to table format
            return kplst
        except SOSError as e:
            raise e
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:48,代码来源:keypool.py


示例19: create

    def create(
        self,
        name,
        tenantname,
        type,
        hourOfDay,
        length,
        lengthType,
        dayOfWeek,
        dayOfMonth,
        minuteOfHour,
        lastDayOfMonth=False,
    ):

        new_request = {
            "tenant": tenantname,
            "hour_of_day_in_utc": hourOfDay,
            "minute_of_hour_in_utc": minuteOfHour,
            "execution_window_length": length,
            "execution_window_length_type": lengthType,
            "execution_window_type": type,
            "day_of_week": dayOfWeek,
            "day_of_month": dayOfMonth,
            "last_day_of_month": lastDayOfMonth,
            "name": name,
        }

        if minuteOfHour is not None:
            new_request["minute_of_hour_in_utc"] = minuteOfHour

        if tenantname is not None:
            from tenant import Tenant

            tenant_obj = Tenant(self.__ipAddr, self.__port)
            try:
                tenant_uri = tenant_obj.tenant_query(None)
            except SOSError as e:
                raise e

            new_request["tenant"] = tenant_uri

        body = json.dumps(new_request)

        command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE, "create")

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST", command, body)
        o = common.json_decode(s)
        return o
开发者ID:cloudscaling,项目名称:coprhd-controller,代码行数:48,代码来源:executionwindow.py


示例20: vcenter_create

    def vcenter_create(self, label, tenant, ipaddress, devport,
                       username, password, osversion, usessl):
        '''
        creates a vcenter
        parameters:
            label:  label of the vcenter
        Returns:
            JSON payload response
        '''
        try:
            check = self.vcenter_show(label, tenant)
            if(not check):
                raise SOSError(SOSError.NOT_FOUND_ERR,
                               "vcenter " + label + ": not found")

        except SOSError as e:
            if(e.err_code == SOSError.NOT_FOUND_ERR):
                from tenant import Tenant
                obj = Tenant(self.__ipAddr, self.__port)

                uri = obj.tenant_query(tenant)

                var = dict()
                params = dict()
                params = {'name': label,
                          'ip_address': ipaddress,
                          'os_version': osversion,
                          'port_number': devport,
                          'user_name': username,
                          'password': password,
                          'use_ssl': usessl
                          }

                body = json.dumps(params)
                (s, h) = common.service_json_request(
                    self.__ipAddr, self.__port, "POST",
                    VCenter.URI_TENANTS_VCENTERS.format(uri), body)
                o = common.json_decode(s)
                return o

            else:
                raise e

        if(check):
            raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR,
                           "vcenter with name " + label + " already exists")
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:46,代码来源:vcenter.py



注:本文中的tenant.Tenant类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Tenant类代码示例发布时间:2022-05-27
下一篇:
Python tempodb.Client类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap