def deploy_product(self, ip, product_name, product_version,
                       attributes_string):
        url = "%s/%s/%s/%s" % (self.sdc_url, "vdc", self.vdc,
                               "productInstance")
        headers = {
            'X-Auth-Token': self.token,
            'Tenant-Id': self.vdc,
            'Accept': "application/json",
            'Content-Type': "application/xml"
        }

        productrequest = ProductRequest(self.keystone_url, self.sdc_url,
                                        self.tenant, self.user, self.password)

        productrequest.get_product_info(product_name)
        attributes = self.__process_attributes(attributes_string)

        product_release = ProductReleaseDto(product_name, product_version)

        productInstanceDto = ProductInstanceDto(ip, product_release,
                                                attributes)
        payload = productInstanceDto.to_xml()
        print url
        print headers
        print tostring(payload)
        response = http.post(url, headers, tostring(payload))

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200:
            print 'error to add the product sdc ' + str(response.status)
            sys.exit(1)
        else:
            http.processTask(headers, json.loads(response.read()))
Exemplo n.º 2
0
    def deploy_product(self, ip, product_name, product_version, attributes_string):
        url = "%s/%s/%s/%s" % (self.sdc_url, "vdc", self.vdc, "productInstance")
        headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc,
                   'Accept': "application/json", 'Content-Type':  "application/xml"}

        productrequest = ProductRequest(self.keystone_url, self.sdc_url, self.tenant, self.user, self.password)

        productrequest.get_product_info(product_name)
        attributes = self.__process_attributes(attributes_string)

        product_release = ProductReleaseDto(product_name, product_version)

        productInstanceDto = ProductInstanceDto(ip, product_release, attributes)
        payload = productInstanceDto.to_xml()
        print url
        print headers
        print tostring(payload)
        response = http.post(url, headers, tostring(payload))

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200:
            print 'error to add the product sdc ' + str(response.status)
            sys.exit(1)
        else:
            http.processTask(headers, json.loads(response.read()))
    def add_blueprint_instance(self, environment_instance):
        url = "%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"}
        print url
        print headers
        payload = tostring(environment_instance.to_xml())
        response = http.post(url, headers, payload)

        ## 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:
            http.processTask(headers, json.loads(response.read()))
    def add_instance(self, environment_instance):
        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"}
        payload = tostring(environment_instance.to_xml())
        world.response = http.post(url, headers, payload)

        """Store it in the world to tear it down later"""
        try:
            world.instances.append(environment_instance.blueprint_name)
        except AttributeError:
            world.instances = [environment_instance.blueprint_name]

        if world.response.status == 200:
            """Wait for the associated task to finish and store its data"""
            world.task_data = http.wait_for_task(json.loads(world.response.read()), headers)
Exemplo n.º 5
0
    def add_instance(self, environment_instance):
        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"
        }
        payload = tostring(environment_instance.to_xml())
        world.response = http.post(url, headers, payload)
        """Store it in the world to tear it down later"""
        try:
            world.instances.append(environment_instance.blueprint_name)
        except AttributeError:
            world.instances = [environment_instance.blueprint_name]

        if world.response.status == 200:
            """Wait for the associated task to finish and store its data"""
            world.task_data = http.wait_for_task(
                json.loads(world.response.read()), headers)
    def add_blueprint_instance(self, environment_instance):
        url = "%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"
        }
        print url
        print headers
        payload = tostring(environment_instance.to_xml())
        response = http.post(url, headers, payload)

        ## 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:
            http.processTask(headers, json.loads(response.read()))