def get_product_instances(self):
        url = "%s/%s/%s/%s" % (self.sdc_url, "vdc", self.vdc, "productInstance")
        print url

        headers = {'X-Auth-Token': self.token,
                   'Accept': "application/json"}
        response = http.get(url, headers)

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200:
            print 'error to obtain the token'
            sys.exit(1)
        else:
            data = json.loads(response.read())

            products = data["productInstance"]
            print products

            if isinstance(products, list):
                for product in products:
                    print product
                    product_release = ProductRelease(product['productRelease']['product']['name'],
                        product['productRelease']['version'], product['productRelease']['product']['description'])
                    productInstance = ProductInstance(product['vm']['hostname'], product['status'], product['vm']['ip'],
                        product_release)
                    productInstance.to_string()
            else:
                product_release = ProductRelease(products['productRelease']['product']['name'],
                    products['productRelease']['version'], products['productRelease']['product']['description'])
                productInstance = ProductInstance(products['vm']['hostname'], products['status'], products['vm']['ip'],
                    product_release)
                productInstance.to_string()
    def get_product_instances(self):
        url = "%s/%s/%s/%s" % (self.sdc_url, "vdc", self.vdc, "productInstance")
        print url

        headers = {'X-Auth-Token': self.token,
                   'Accept': "application/json"}
        response = http.get(url, headers)

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200:
            print 'error to obtain the token'
            sys.exit(1)
        else:
            data = json.loads(response.read())

            products = data["productInstance"]
            print products

            if isinstance(products, list):
                for product in products:
                    print product
                    product_release = ProductRelease(product['productRelease']['product']['name'],
                        product['productRelease']['version'], product['productRelease']['product']['description'])
                    productInstance = ProductInstance(product['vm']['hostname'], product['status'], product['vm']['ip'],
                        product_release)
                    productInstance.to_string()
            else:
                product_release = ProductRelease(products['productRelease']['product']['name'],
                    products['productRelease']['version'], products['productRelease']['product']['description'])
                productInstance = ProductInstance(products['vm']['hostname'], products['status'], products['vm']['ip'],
                    product_release)
                productInstance.to_string()
示例#3
0
 def get_instances(self):
     url = "%s/%s/%s/%s/%s" % (self.paasmanager_url, "envInst/org/FIWARE",
                               "vdc", self.vdc, "environmentInstance")
     headers = {
         'X-Auth-Token': self.token,
         'Tenant-Id': self.vdc,
         'Content-Type': "application/xml",
         'Accept': "application/json"
     }
     world.response = http.get(url, headers)
    def get_blueprint_instance(self, environment_instance_name):
        url = "%s/%s/%s/%s/%s" % (
            self.paasmanager_url, "envInst/org/FIWARE/vdc", self.vdc, "environmentInstance", environment_instance_name)

        print url
        headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc, 'Content-Type': "application/xml",
                   'Accept': "application/json"}

        response = http.get(url, headers)

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200 and response.status != 204:
            data = response.read()
            print 'error to deploy the environment ' + str(response.status) + " " + data
            sys.exit(1)
        else:
            envInstance = self.__process_env_inst(json.loads(response.read()))
            envInstance.to_string()
    def get_blueprint_instance(self, environment_instance_name):
        url = "%s/%s/%s/%s/%s" % (
            self.paasmanager_url, "envInst/org/FIWARE/vdc", self.vdc,
            "environmentInstance", environment_instance_name)

        print url
        headers = {
            'X-Auth-Token': self.token,
            'Tenant-Id': self.vdc,
            'Content-Type': "application/xml",
            'Accept': "application/json"
        }

        response = http.get(url, headers)

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200 and response.status != 204:
            data = response.read()
            print 'error to deploy the environment ' + str(
                response.status) + " " + data
            sys.exit(1)
        else:
            envInstance = self.__process_env_inst(json.loads(response.read()))
            envInstance.to_string()
 def get_instance(self, instance_name):
     url = "%s/%s/%s/%s/%s/%s" % (self.paasmanager_url, "envInst/org/FIWARE",
                                  "vdc", self.vdc, "environmentInstance", instance_name)
     headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc,
                'Content-Type': "application/xml", 'Accept': "application/json"}
     world.response = http.get(url, headers)