コード例 #1
0
class PolicyTemplate(Presentation):
    """
    Policies provide a way of configuring reusable behavior by referencing groups for which a policy applies.
    
    See the `Cloudify DSL v1.3 specification <http://docs.getcloudify.org/3.4.0/blueprints/spec-policies/>`__.    
    """
    @field_validator(policy_type_validator)
    @primitive_field(str, required=True)
    def type(self):
        """
        The policy type.
        
        :rtype: str
        """

    @object_dict_field(PropertyAssignment)
    def properties(self):
        """
        The specific policy properties. The properties schema is defined by the policy type.
        
        :rtype: dict of str, :class:`PropertyAssignment`
        """

    @field_validator(list_type_validator('group', 'groups'))
    @primitive_list_field(str, required=True)
    def targets(self):
        """
        A list of group names. The policy will be applied on the groups specified in this list. 
        
        :rtype: list of str
        """

    @cachedmethod
    def _get_type(self, context):
        return context.presentation.get_from_dict('service_template',
                                                  'policy_types', self.type)

    @cachedmethod
    def _get_targets(self, context):
        r = []
        targets = self.targets
        if targets:
            for target in targets:
                target = context.presentation.get_from_dict(
                    'service_template', 'groups', target)
                if target is not None:
                    r.append(target)
        return FrozenList(r)

    def _validate(self, context):
        super(PolicyTemplate, self)._validate(context)
        self._get_targets(context)
コード例 #2
0
class GroupTemplate(Presentation):
    """
    Groups provide a way of configuring shared behavior for different sets of :code:`node_templates`.
    
    See the `Cloudify DSL v1.2 specification <http://docs.getcloudify.org/3.3.1/blueprints/spec-groups/>`__.
    """
    @field_validator(list_type_validator('node template', 'node_templates'))
    @primitive_list_field(str, required=True)
    def members(self):
        """
        A list of group members. Members are node template names. 
        
        :rtype: list of str
        """

    @object_dict_field(GroupPolicyAssignment)
    def policies(self):
        """
コード例 #3
0
ファイル: templates.py プロジェクト: Tosca-Projects/aria-ng
class GroupTemplate(ExtensiblePresentation):
    """
    A group definition defines a logical grouping of node templates, typically for management
    purposes, but is separate from the application's topology template.

    See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca
    /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html
    #DEFN_ELEMENT_GROUP_DEF>`__
    """
    @field_validator(
        type_validator('group type', convert_shorthand_to_full_type_name,
                       'group_types'))
    @primitive_field(str, required=True)
    def type(self):
        """
        The required name of the group type the group definition is based upon.

        :rtype: str
        """

    @object_field(Description)
    def description(self):
        """
        The optional description for the group definition.

        :rtype: :class:`Description`
        """

    @object_dict_field(PropertyAssignment)
    def properties(self):
        """
        An optional list of property value assignments for the group definition.

        :rtype: dict of str, :class:`PropertyAssignment`
        """

    @field_validator(
        list_type_validator('node template', 'topology_template',
                            'node_templates'))
    @primitive_list_field(str)
    def members(self):
        """
        The optional list of one or more node template names that are members of this group
        definition.

        :rtype: list of str
        """

    @object_dict_field(InterfaceAssignment)
    def interfaces(self):
        """
        An optional list of named interface definitions for the group definition.

        :rtype: dict of str, :class:`InterfaceDefinition`
        """

    @cachedmethod
    def _get_type(self, context):
        return get_type_by_full_or_shorthand_name(context, self.type,
                                                  'group_types')

    @cachedmethod
    def _get_property_values(self, context):
        return FrozenDict(
            get_assigned_and_defined_property_values(context, self))

    @cachedmethod
    def _get_interfaces(self, context):
        return FrozenDict(
            get_template_interfaces(context, self, 'group definition'))

    def _validate(self, context):
        super(GroupTemplate, self)._validate(context)
        self._get_property_values(context)
        self._get_interfaces(context)
コード例 #4
0
class CapabilityDefinition(ExtensiblePresentation):
    """
    A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes.
    
    See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_ELEMENT_CAPABILITY_DEFN>`__
    """
    @field_validator(
        type_validator('capability type', convert_shorthand_to_full_type_name,
                       'capability_types'))
    @primitive_field(str, required=True)
    def type(self):
        """
        The required name of the Capability Type the capability definition is based upon.
        
        :rtype: str
        """

    @object_field(Description)
    def description(self):
        """
        The optional description of the Capability definition.
        
        :rtype: :class:`Description`
        """

    @object_dict_field(PropertyDefinition)
    def properties(self):
        """
        An optional list of property definitions for the Capability definition.
        
        :rtype: dict of str, :class:`PropertyDefinition`
        """

    @object_dict_field(AttributeDefinition)
    def attributes(self):
        """
        An optional list of attribute definitions for the Capability definition.
        
        :rtype: dict of str, :class:`AttributeDefinition`
        """

    @field_validator(
        list_type_validator('node type', convert_shorthand_to_full_type_name,
                            'node_types'))
    @primitive_list_field(str)
    def valid_source_types(self):
        """
        An optional list of one or more valid names of Node Types that are supported as valid sources of any relationship established to the declared Capability Type.
        
        :rtype: list of str
        """

    @field_getter(data_type_class_getter(Range))
    @primitive_field()
    def occurrences(self):
        """
        The optional minimum and maximum occurrences for the capability. By default, an exported Capability should allow at least one relationship to be formed with it with a maximum of UNBOUNDED relationships.

        Note: the keyword UNBOUNDED is also supported to represent any positive integer.
        
        ARIA NOTE: The spec seems wrong here: the implied default should be [0,UNBOUNDED], not [1,UNBOUNDED], otherwise it would imply that at 1 least one relationship *must* be formed.
        
        :rtype: :class:`Range`
        """

    @cachedmethod
    def _get_type(self, context):
        return get_type_by_full_or_shorthand_name(context, self.type,
                                                  'capability_types')

    @cachedmethod
    def _get_parent(self, context):
        container_parent = self._container._get_parent(context)
        container_parent_capabilities = container_parent._get_capabilities(
            context) if container_parent is not None else None
        return container_parent_capabilities.get(
            self._name) if container_parent_capabilities is not None else None
コード例 #5
0
ファイル: types.py プロジェクト: NewLionwang/aria-ng
class GroupType(ExtensiblePresentation):
    """
    A Group Type defines logical grouping types for nodes, typically for different management purposes. Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology of an application, yet can have capabilities and the ability to attach policies and interfaces that can be applied (depending on the group type) to its member nodes.

    Conceptually, group definitions allow the creation of logical "membership" relationships to nodes in a service template that are not a part of the application's explicit requirement dependencies in the topology template (i.e. those required to actually get the application deployed and running). Instead, such logical membership allows for the introduction of things such as group management and uniform application of policies (i.e., requirements that are also not bound to the application itself) to the group's members.
    
    See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_ENTITY_GROUP_TYPE>`__
    """
    @field_validator(
        derived_from_validator(convert_shorthand_to_full_type_name,
                               'group_types'))
    @primitive_field(str)
    def derived_from(self):
        """
        An optional parent Group Type name the Group Type derives from.
        
        :rtype: str
        """

    @object_field(Version)
    def version(self):
        """
        An optional version for the Group Type definition.
        
        :rtype: :class:`Version`
        """

    @object_field(Description)
    def description(self):
        """
        The optional description for the Group Type.
        
        :rtype: :class:`Description`
        """

    @object_dict_field(PropertyDefinition)
    def properties(self):
        """
        An optional list of property definitions for the Group Type.
        
        :rtype: dict of str, :class:`PropertyDefinition`
        """

    @field_validator(
        list_type_validator('node type', convert_shorthand_to_full_type_name,
                            'node_types'))
    @primitive_list_field(str)
    def members(self):
        """
        An optional list of one or more names of Node Types that are valid (allowed) as members of the Group Type. 

        Note: This can be viewed by TOSCA Orchestrators as an implied relationship from the listed members nodes to the group, but one that does not have operational lifecycle considerations. For example, if we were to name this as an explicit Relationship Type we might call this "MemberOf" (group).
        
        :rtype: list of str
        """

    @object_dict_field(InterfaceDefinition)
    def interfaces(self):
        """
        An optional list of interface definitions supported by the Group Type.
        
        :rtype: dict of str, :class:`InterfaceDefinition`
        """

    @cachedmethod
    def _get_parent(self, context):
        return get_parent_presentation(context, self,
                                       convert_shorthand_to_full_type_name,
                                       'group_types')

    @cachedmethod
    def _is_descendant(self, context, the_type):
        if the_type is None:
            return False
        elif the_type._name == self._name:
            return True
        return self._is_descendant(context, the_type._get_parent(context))

    @cachedmethod
    def _get_properties(self, context):
        return FrozenDict(
            get_inherited_property_definitions(context, self, 'properties'))

    @cachedmethod
    def _get_interfaces(self, context):
        return FrozenDict(
            get_inherited_interface_definitions(context, self, 'group type'))

    def _validate(self, context):
        super(GroupType, self)._validate(context)
        self._get_properties(context)
        self._get_interfaces(context)

    def _dump(self, context):
        self._dump_content(context, ('description', 'version', 'derived_from',
                                     'members', 'properties', 'interfaces'))
コード例 #6
0
ファイル: types.py プロジェクト: NewLionwang/aria-ng
class RelationshipType(ExtensiblePresentation):
    """
    A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates.
    
    See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_ENTITY_RELATIONSHIP_TYPE>`__
    """
    @field_validator(
        derived_from_validator(convert_shorthand_to_full_type_name,
                               'relationship_types'))
    @primitive_field(str)
    def derived_from(self):
        """
        An optional parent Relationship Type name the Relationship Type derives from.
        
        :rtype: str
        """

    @object_field(Version)
    def version(self):
        """
        An optional version for the Relationship Type definition.
        
        :rtype: :class:`Version`
        """

    @object_field(Description)
    def description(self):
        """
        An optional description for the Relationship Type.
        
        :rtype: :class:`Description`
        """

    @object_dict_field(PropertyDefinition)
    def properties(self):
        """
        An optional list of property definitions for the Relationship Type.
        
        :rtype: dict of str, :class:`PropertyDefinition`
        """

    @object_dict_field(AttributeDefinition)
    def attributes(self):
        """
        An optional list of attribute definitions for the Relationship Type.
        
        :rtype: dict of str, :class:`AttributeDefinition`
        """

    @object_dict_field(InterfaceDefinition)
    def interfaces(self):
        """
        An optional list of interface definitions interfaces supported by the Relationship Type.
        
        :rtype: dict of str, :class:`InterfaceDefinition`
        """

    @field_validator(
        list_type_validator('capability type',
                            convert_shorthand_to_full_type_name,
                            'capability_types'))
    @primitive_list_field(str)
    def valid_target_types(self):
        """
        An optional list of one or more names of Capability Types that are valid targets for this relationship.
        
        :rtype: list of str
        """

    @cachedmethod
    def _get_parent(self, context):
        return get_parent_presentation(context, self,
                                       convert_shorthand_to_full_type_name,
                                       'relationship_types')

    @cachedmethod
    def _get_properties(self, context):
        return FrozenDict(
            get_inherited_property_definitions(context, self, 'properties'))

    @cachedmethod
    def _get_attributes(self, context):
        return FrozenDict(
            get_inherited_property_definitions(context, self, 'attributes'))

    @cachedmethod
    def _get_interfaces(self, context):
        return FrozenDict(
            get_inherited_interface_definitions(context, self,
                                                'relationship type'))

    def _validate(self, context):
        super(RelationshipType, self)._validate(context)
        self._get_properties(context)
        self._get_attributes(context)
        self._get_interfaces(context)

    def _dump(self, context):
        self._dump_content(
            context,
            ('description', 'version', 'derived_from', 'valid_target_types',
             'properties', 'attributes', 'interfaces'))
コード例 #7
0
ファイル: types.py プロジェクト: NewLionwang/aria-ng
class CapabilityType(ExtensiblePresentation):
    """
    A Capability Type is a reusable entity that describes a kind of capability that a Node Type can declare to expose. Requirements (implicit or explicit) that are declared as part of one node can be matched to (i.e., fulfilled by) the Capabilities declared by another node.
    
    See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_ENTITY_CAPABILITY_TYPE>`__
    """
    @field_validator(
        derived_from_validator(convert_shorthand_to_full_type_name,
                               'capability_types'))
    @primitive_field(str)
    def derived_from(self):
        """
        An optional parent capability type name this new Capability Type derives from.
        
        :rtype: str
        """

    @object_field(Version)
    def version(self):
        """
        An optional version for the Capability Type definition.
        
        :rtype: :class:`Version`
        """

    @object_field(Description)
    def description(self):
        """
        An optional description for the Capability Type.
        
        :rtype: :class:`Description`
        """

    @object_dict_field(PropertyDefinition)
    def properties(self):
        """
        An optional list of property definitions for the Capability Type.

        ARIA NOTE: The spec says 'list', but the examples are all of dicts.
        
        :rtype: dict of str, :class:`PropertyDefinition`
        """

    @object_dict_field(AttributeDefinition)
    def attributes(self):
        """
        An optional list of attribute definitions for the Capability Type.
        
        :rtype: dict of str, :class:`AttributeDefinition`
        """

    @field_validator(
        list_type_validator('node type', convert_shorthand_to_full_type_name,
                            'node_types'))
    @primitive_list_field(str)
    def valid_source_types(self):
        """
        An optional list of one or more valid names of Node Types that are supported as valid sources of any relationship established to the declared Capability Type.
        
        :rtype: list of str
        """

    @cachedmethod
    def _get_parent(self, context):
        return get_parent_presentation(context, self,
                                       convert_shorthand_to_full_type_name,
                                       'capability_types')

    @cachedmethod
    def _is_descendant(self, context, the_type):
        if the_type is None:
            return False
        elif the_type._name == self._name:
            return True
        return self._is_descendant(context, the_type._get_parent(context))

    @cachedmethod
    def _get_properties(self, context):
        return FrozenDict(
            get_inherited_property_definitions(context, self, 'properties'))

    @cachedmethod
    def _get_valid_source_types(self, context):
        return get_inherited_valid_source_types(context, self)

    def _validate(self, context):
        super(CapabilityType, self)._validate(context)
        self._get_properties(context)

    def _dump(self, context):
        self._dump_content(context,
                           ('description', 'version', 'derived_from',
                            'valid_source_types', 'properties', 'attributes'))