當前位置: 首頁>>代碼示例>>Python>>正文


Python tenant.Tenant類代碼示例

本文整理匯總了Python中tenant.Tenant的典型用法代碼示例。如果您正苦於以下問題:Python Tenant類的具體用法?Python Tenant怎麽用?Python Tenant使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Tenant類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的tenant.Tenant類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。