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

Python singletonURIHelperInstance.getUri函数代码示例

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

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



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

示例1: execute

    def execute(self, path, uri, params):

        if (path is not None):
            command = singletonURIHelperInstance.getUri(
                self.COMPONENT_TYPE, "catalog")
            requestUrl = command.format(path)
        else:
            command = singletonURIHelperInstance.getUri(
                self.COMPONENT_TYPE, "get-service")
            requestUrl = command.format(uri)

        paramsDict = common.toDict(params)
        #If the label object is null, then it shows an error
        if(not(paramsDict.has_key("label"))):
            paramsDict["label"]=""        

        query = None
        if (params is not None):
            for key, value in paramsDict.iteritems():
                if (query is None):
                    query = "?" + key + "=" + value
                else:
                    query = query + "&" + key + "=" + value
            if (query is not None):
                requestUrl = requestUrl + query
        # The requestUrl has '' as a  string instead of an empty string.
        requestUrl=requestUrl.replace("''","")  

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "POST", requestUrl, None, None)
        o = common.json_decode(s)

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


示例2: update

    def update(self, uri, name, type, hourOfDay, length, lengthType, dayOfWeek, dayOfMonth, lastDayOfMonth=False):

        request = dict()

        if name is not None:
            request["label"] = name

        if type is not None:
            request["executionWindowType"] = type

        if hourOfDay is not None:
            request["hourOfDayInUTC"] = hourOfDay

        if length is not None:
            request["executionWindowLength"] = length

        if lengthType is not None:
            request["executionWindowLengthType"] = lengthType

        if dayOfWeek is not None:
            request["dayOfWeek"] = dayOfWeek

        if dayOfMonth is not None:
            request["dayOfMonth"] = dayOfMonth

        if lastDayOfMonth is not None:
            request["lastDayOfMonth"] = lastDayOfMonth

        body = json.dumps(request)

        command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE, "show")
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "PUT", command.format(uri), body)
        o = common.json_decode(s)
        return o
开发者ID:cloudscaling,项目名称:coprhd-controller,代码行数:34,代码来源:executionwindow.py


示例3: get_catalog

    def get_catalog(self, uriPath, xml=False):

        if (uriPath is None):
            uriPath = ""
        elif (uriPath.startswith("/") is False):
            uriPath = "/" + uriPath

        command = singletonURIHelperInstance.getUri(
            self.COMPONENT_TYPE, "catalog")
        port = self.__port
        if(len(uriPath) == 0):
            port = common.getenv('VIPR_UI_PORT')
        (s, h) = common.service_json_request(self.__ipAddr, port, "GET",
                                             command.format(uriPath),
                                             None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')

        if (inactive):
            return None
        if (xml):
            (s, h) = common.service_json_request(self.__ipAddr, port, "GET",
                                                 command.format(uriPath),
                                                 None, None, xml)
            return s
        else:
            return o
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:27,代码来源:catalog.py


示例4: rollback_task_by_uri

 def rollback_task_by_uri(self, taskid):
     command = singletonURIHelperInstance.getUri(
         self.COMPONENT_TYPE,
         "rollback")
     (s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST",
                                          command.format(taskid),
                                          None)
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:7,代码来源:task.py


示例5: reject

 def reject(self, uri):
     command = singletonURIHelperInstance.getUri(
         self.COMPONENT_TYPE, "reject")
     (s, h) = common.service_json_request(
         self.__ipAddr, self.__port, "POST",
         command.format(uri), None, None)
     return s
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:7,代码来源:approval.py


示例6: __get_quota_uri

 def __get_quota_uri(self, resource_type, resource_uri):
     return (
         singletonURIHelperInstance.getUri(
             resource_type,
             "quota").format(
             resource_uri)
     )
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:7,代码来源:quota.py


示例7: delete

 def delete(self, uri):
     command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE,
                                                 "show")
     (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                          "DELETE",
                                          command.format(uri),
                                          None)
     return s
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:8,代码来源:executionwindow.py


示例8: list

    def list(self):
        command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE,
                                                    "list")
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             command,
                                             None)
        o = common.json_decode(s)

        return o
开发者ID:Lujoel,项目名称:coprhd-controller,代码行数:9,代码来源:executionwindow.py


示例9: get_descriptor

    def get_descriptor(self, uri):
        command = singletonURIHelperInstance.getUri(
            self.COMPONENT_TYPE, "get-descriptor")
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             command.format(uri),
                                             None, None)
        o = common.json_decode(s)

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


示例10: get_tasks_by_taskid

def get_tasks_by_taskid(componentType, task_id, ipAddr, port):
      
            task_uri_constant = singletonURIHelperInstance.getUri(
                componentType, "task_by_id")
            (s, h) = service_json_request(
                ipAddr, port, "GET",
                task_uri_constant.format(task_id), None)
            if (not s):
                return None
            o = json_decode(s)
            return o
开发者ID:th3architect,项目名称:coprhd-controller,代码行数:11,代码来源:common.py


示例11: get_tasks_by_resourceuri

def get_tasks_by_resourceuri(componentType, resource_uri, ipAddr, port):

            task_list_uri_constant = singletonURIHelperInstance.getUri(
                componentType, "tasks_list")
            (s, h) = service_json_request(
                ipAddr, port, "GET",
                task_list_uri_constant.format(resource_uri), None)
            if (not s):
                return []
            o = json_decode(s)
            res = o["task"]
            return res
开发者ID:th3architect,项目名称:coprhd-controller,代码行数:12,代码来源:common.py


示例12: show_execution_by_uri

    def show_execution_by_uri(self, uri, xml):
        command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE, "show-execution")
        if xml is True:
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET", command.format(uri), None, None, xml
            )
            return s
        else:
            (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", command.format(uri), None, None)
            o = common.json_decode(s)

            return o
开发者ID:cloudscaling,项目名称:coprhd-controller,代码行数:12,代码来源:order.py


示例13: 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


示例14: get_service

    def get_service(self, uri, xml=False):
        command = singletonURIHelperInstance.getUri(
            self.COMPONENT_TYPE, "get-service")
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             command.format(uri),
                                             None, None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')

        if (inactive):
            return None
        if (xml):
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET", command.format(uri),
                None, None, xml)
            return s
        else:
            return o
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:18,代码来源:catalog.py


示例15: list_unmanaged_tasks

def list_unmanaged_tasks(ipAddr, port, componentType, project_name,
               resource_name=None, task_id=None):

    resourceSearchUri = singletonURIHelperInstance.getUri(
        componentType, "search_by_project")

    uris = search_by_project(project_name, resourceSearchUri, ipAddr, port)

    if(resource_name):
        for uri in uris:
            resource = show_resource(ipAddr, port, componentType,
                                     uri, True)
            if(resource['name'] == resource_name):
                if(not task_id):
                    return get_unmanaged_tasks_by_resourceuri(
                        componentType, resource["id"], ipAddr, port)

                else:
                    res = get_unmanaged_task_by_resourceuri_and_taskId(
                        componentType, resource["id"], task_id, ipAddr, port)
                    if(res):
                        return res
        raise SOSError(SOSError.NOT_FOUND_ERR, "Resource with name: " +
                       resource_name + " not found")
    elif(task_id):
        for uri in uris:
            res = get_tasks_by_taskid(componentType, task_id, ipAddr, port)
            if(res):
                return res
            raise SOSError(SOSError.NOT_FOUND_ERR, "Task Id: " + task_id + "not found")
    
    else:
        # resourec_name is not given, get all tasks
        all_tasks = []
        for uri in uris:
            res = get_tasks_by_resourceuri(componentType, uri, ipAddr, port)
            if(res and len(res) > 0):
                all_tasks += res
        return all_tasks
开发者ID:th3architect,项目名称:coprhd-controller,代码行数:39,代码来源:common.py


示例16: list

    def list(self, type, params):
        command = singletonURIHelperInstance.getUri(
            self.COMPONENT_TYPE, "list")
        requestUrl = command.format(type)

        paramsDict = common.toDict(params)

        query = None
        if (params is not None):
            for key, value in paramsDict.iteritems():
                if (query is None):
                    query = "?" + key + "=" + value
                else:
                    query = query + "&" + key + "=" + value
            if (query is not None):
                requestUrl = requestUrl + query

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             requestUrl,
                                             None, None)
        o = common.json_decode(s)
        return o
开发者ID:Lidaja,项目名称:coprhd-controller,代码行数:22,代码来源:assetoptions.py


示例17: show_resource

def show_resource(ipAddr, port, componentType, uri,
                  show_inactive=False, xml=False):

        showUriConstant = singletonURIHelperInstance.getUri(
            componentType, "show")
        if(xml):
            (s, h) = service_json_request(ipAddr, port,
                                          "GET",
                                          showUriConstant.format(uri),
                                          None, None, xml)
            return s

        (s, h) = service_json_request(ipAddr, port,
                                      "GET",
                                      showUriConstant.format(uri),
                                      None)
        o = json_decode(s)
        if(show_inactive):
            return o
        inactive = get_node_value(o, 'inactive')
        if(inactive):
            return None
        return o
开发者ID:th3architect,项目名称:coprhd-controller,代码行数:23,代码来源:common.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python uritemplate.expand函数代码示例发布时间:2022-05-27
下一篇:
Python urdf.URDF类代码示例发布时间: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