Exemple #1
0
    def add_policy_property(self, policy_id, property_name, property_value):
        """Updates a policy property on a polic attached to a VNF

        :policy_id: ID of a policy attached to a VNF
        :property_name: property name to update
        :property_value: value to update property with

        """
        policies = (
            self.tosca.get("policies", {}).get(policy_id, {}).get("properties", {})
        )

        for prop in policies:
            if prop.get("name") == property_name:
                unique_id = prop.get("uniqueId")
                property_type = prop.get("type")
                description = prop.get("description")
                value = prop.get("value", "")
                if value != property_value:
                    return self.oc.sdc.vnf.add_catalog_policy_property(
                        catalog_resource_id=self.catalog_resource_id,
                        unique_id=unique_id,
                        catalog_policy_id=policy_id,
                        property_name=property_name,
                        property_default_value=property_value,
                        description=description,
                        property_type=property_type,
                    )
                else:
                    return None

        raise exceptions.PropertyNotFoundException(
            "Property {} was not found in policy {}".format(property_name, policy_id)
        )
Exemple #2
0
    def add_policy_property(self, policy_id, property_name, property_value):
        """Updates a policy property on a polic attached to a VNF

        :policy_id: ID of a policy attached to a VNF
        :property_name: property name to update
        :property_value: value to update property with

        """
        self._refresh()

        policies = (self.tosca.get("policies",
                                   {}).get(policy_id,
                                           {}).get("properties", {}))

        for prop in policies:
            if prop.get("name") == property_name:
                unique_id = prop.get("uniqueId")
                property_type = prop.get("type")
                description = prop.get("description")
                return vnf_client.add_catalog_policy_property(
                    **self.attributes,
                    unique_id=unique_id,
                    catalog_policy_id=policy_id,
                    property_name=property_name,
                    property_default_value=property_value,
                    description=description,
                    property_type=property_type,
                )

        raise exceptions.PropertyNotFoundException(
            "Property {} was not found in policy {}".format(
                property_name, policy_id))
    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
            )
        )
Exemple #4
0
    def add_instance_property_non_vf(self, instance_id, property_name, property_value, origin_section="componentInstancesProperties"):
        """Updates an instance property on a abstract instance attached to a VNF

        :instance_id: ID of a instance attached to a VNF
        :property_name: property name to update
        :property_value: value to update property with

        """
        instance_inputs = self.tosca.get(origin_section, {}).get(
            instance_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")
                value = prop.get("value", "")
                if value != property_value:
                    return self.oc.sdc.vnf.add_catalog_resource_property_non_vf(
                        **self.attributes,
                        unique_id=unique_id,
                        parent_unique_id=parent_unique_id,
                        owner_id=owner_id,
                        catalog_resource_instance_id=instance_id,
                        property_name=property_name,
                        property_default_value=property_value,
                        schema_type=schemaType,
                        property_type=property_type,
                    )
                else:
                    return None

        raise exceptions.PropertyNotFoundException(
            "Property {} was not found in Instance {}".format(
                property_name, instance_id
            )
        )