def add_property_value(self, resource_name, property_name, input_value):
        """Updates an property value on a resource attached to a Service

        :resource_name: Name of a resource attached to a service
        :property_name: property name to update
        :input_value: value to update property with

        """
        resource = self.attributes.get(resource_name)
        if not resource:
            raise exceptions.ResourceNotFoundException(
                "Resource {} was not found on Service {}".format(
                    resource_name, self.service_name
                )
            )
        resource_id = resource["id"]

        instance_inputs = self.tosca.get("componentInstancesProperties", {}).get(
            resource_id, []
        )
        for prop in instance_inputs:
            if prop.get("name") == property_name:
                unique_id = prop.get("uniqueId")
                parent_unique_id = prop.get("parentUniqueId")
                owner_id = prop.get("ownerId")
                schemaType = prop.get("schemaType", "")
                property_type = prop.get("type")
                return self.oc.sdc.service.add_catalog_service_property(
                    **self.attributes,
                    unique_id=unique_id,
                    parent_unique_id=parent_unique_id,
                    owner_id=owner_id,
                    catalog_resource_instance_id=resource_id,
                    input_name=property_name,
                    input_value=input_value,
                    schema_type=schemaType,
                    property_type=property_type,
                )

        raise exceptions.PropertyNotFoundException(
            "Property {} was not found in VF Instance {}".format(
                property_name, resource_id
            )
        )
Beispiel #2
0
    def update_resource_deployment_properties(self, resource_name,
                                              deployment_properties):
        vnf_instance = {}
        for component_instance in self.tosca.get("componentInstances", []):
            if component_instance.get("componentName") == resource_name:
                vnf_instance = component_instance
                break

        if not vnf_instance:
            raise exceptions.ResourceNotFoundException(
                "Resource {} was not found on Service {}".format(
                    resource_name, self.service_name))

        for deployment_artifact_name, deployment_artifact in vnf_instance.get(
                "deploymentArtifacts").items():
            if deployment_artifact.get("artifactType") == "HEAT_ENV":
                deployment_artifact.update(deployment_properties)
                self.oc.sdc.service.update_module_deployment_properties(
                    catalog_service_id=self.catalog_service_id,
                    catalog_resource_instance_id=vnf_instance.get("uniqueId"),
                    module_id=deployment_artifact.get("uniqueId"),
                    payload_data=deployment_artifact,
                )