Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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