当前位置: 首页>>代码示例>>Python>>正文


Python Tenant.tenant_query方法代码示例

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


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

示例1: cluster_create

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:35,代码来源:cluster.py

示例2: project_query

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
 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,代码行数:30,代码来源:project.py

示例3: varray_disallow_tenant

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:27,代码来源:virtualarray.py

示例4: varray_list

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:37,代码来源:virtualarray.py

示例5: cluster_create

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:28,代码来源:cluster.py

示例6: add_or_remove_vcenter_acls

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:28,代码来源:vcenter.py

示例7: get_tenant_uri_from_name

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:15,代码来源:vcenter.py

示例8: policy_list

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:16,代码来源:schedulepolicy.py

示例9: create

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:52,代码来源:schedulepolicy.py

示例10: get_vcenter_uri_with_tenant_param

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:17,代码来源:vcenter.py

示例11: create

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:50,代码来源:executionwindow.py

示例12: vcenter_create

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    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,代码行数:48,代码来源:vcenter.py

示例13: vcenterdatacenter_update

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    def vcenterdatacenter_update(self, label, vcenter, tenantname, newtenantname):
        '''
        updates a vcenterdatacenter
        parameters:
            label:  label of the vcenterdatacenter
        Returns:
            JSON payload response
        '''
        try:
            check = self.vcenterdatacenter_show(label, vcenter, tenantname)
            if check:
                raise SOSError(SOSError.NOT_FOUND_ERR,
                               "vcenterdatacenter " + label + ": found")

        except SOSError as e:
            if e.err_code == SOSError.NOT_FOUND_ERR:

                uri = self.vcenterdatacenter_query(label, vcenter, VcenterDatacenter.DATACENTERS_FROM_ALL_TENANTS)

                params = dict()
                params['name'] = label
                
                if newtenantname is not None and newtenantname != 'null':
                    from tenant import Tenant
                    obj = Tenant(self.__ipAddr, self.__port)
                    params['tenant'] = obj.tenant_query(newtenantname)
                elif newtenantname is not None:
                     params['tenant'] = newtenantname

                body = json.dumps(params)

                (s, h) = common.service_json_request(
                    self.__ipAddr, self.__port, "PUT",
                    VcenterDatacenter.URI_DATACENTER.format(uri), body)

                o = common.json_decode(s)

                return o
            else:
                raise e

        if not check:
            raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR,
                           "vcenterdatacenter with name " + label +
                           " dost not exist")
开发者ID:seagle0128,项目名称:coprhd-controller,代码行数:47,代码来源:vcenterdatacenter.py

示例14: vcenter_query

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    def vcenter_query(self, name, tenantname):
        '''
        Returns the UID of the vcenter specified by the name
        '''
        if (common.is_uri(name)):
            return name

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

        tenanturi = obj.tenant_query(tenantname)

        vcenters = self.vcenter_list(tenanturi)
        for vcenter in vcenters:
            if (vcenter['name'] == name):
                return vcenter['id']

        raise SOSError(SOSError.NOT_FOUND_ERR,
                       "vcenter " + name + ": not found")
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:21,代码来源:vcenter.py

示例15: vcenter_list

# 需要导入模块: from tenant import Tenant [as 别名]
# 或者: from tenant.Tenant import tenant_query [as 别名]
    def vcenter_list(self, tenant):
        '''
        Returns all the vcenters associated with a tenant
        Parameters:
        Returns:
                JSON payload of vcenter list
        '''
        from tenant import Tenant
        obj = Tenant(self.__ipAddr, self.__port)

        uri = obj.tenant_query(tenant)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            VCenter.URI_TENANTS_VCENTERS.format(uri), None)

        o = common.json_decode(s)

        return o['vcenter']
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:21,代码来源:vcenter.py


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