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 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 delete_blueprint_instance(self, environment_instance):
        url = "%s/%s/%s/%s/%s" % (
            self.paasmanager_url, "envInst/org/FIWARE/vdc", self.vdc, "environmentInstance", environment_instance)

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

        response = http.delete(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 delete the environment ' + str(response.status) + " " + data
            sys.exit(1)
        else:
            http.processTask(headers, json.loads(response.read()))
    def add_application_instance(self, environment_instance_name, application_instance):
        url = "%s/%s/%s/%s/%s/%s" % (
            self.paasmanager_url, "envInst/org/FIWARE/vdc", self.vdc, "environmentInstance", environment_instance_name,
            "applicationInstance")
        headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc, 'Content-Type': "application/xml",
                   'Accept': "application/json"}
        print url
        print headers
        payload = tostring(application_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:
            print 'error to deploy the application instance ' + str(response.status)
            sys.exit(1)
        else:
            http.processTask(headers, json.loads(response.read()))
    def delete_blueprint_instance(self, environment_instance):
        url = "%s/%s/%s/%s/%s" % (self.paasmanager_url,
                                  "envInst/org/FIWARE/vdc", self.vdc,
                                  "environmentInstance", environment_instance)

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

        response = http.delete(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 delete the environment ' + str(
                response.status) + " " + data
            sys.exit(1)
        else:
            http.processTask(headers, json.loads(response.read()))
    def add_application_instance(self, environment_instance_name,
                                 application_instance):
        url = "%s/%s/%s/%s/%s/%s" % (
            self.paasmanager_url, "envInst/org/FIWARE/vdc", self.vdc,
            "environmentInstance", environment_instance_name,
            "applicationInstance")
        headers = {
            'X-Auth-Token': self.token,
            'Tenant-Id': self.vdc,
            'Content-Type': "application/xml",
            'Accept': "application/json"
        }
        print url
        print headers
        payload = tostring(application_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:
            print 'error to deploy the application instance ' + str(
                response.status)
            sys.exit(1)
        else:
            http.processTask(headers, json.loads(response.read()))