http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml deleted file mode 100644 index 889dcf7..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml +++ /dev/null @@ -1,318 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -data_types: - - tosca.datatypes.nfv.L2AddressData: - # TBD - _extensions: - shorthand_name: L2AddressData - type_qualified_name: tosca:L2AddressData - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.1 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896055' - - tosca.datatypes.nfv.L3AddressData: - _extensions: - shorthand_name: L3AddressData - type_qualified_name: tosca:L3AddressData - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.2 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896056' - description: >- - The L3AddressData type is a complex TOSCA data type used to describe L3AddressData information - element as defined in [ETSI GS NFV-IFA 011], it provides the information on the IP addresses - to be assigned to the connection point instantiated from the parent Connection Point - Descriptor. - derived_from: tosca.datatypes.Root - properties: - ip_address_assignment: - description: >- - Specify if the address assignment is the responsibility of management and orchestration - function or not. If it is set to True, it is the management and orchestration function - responsibility. - type: boolean - required: true - floating_ip_activated: - description: Specify if the floating IP scheme is activated on the Connection Point or not. - type: boolean - required: true - ip_address_type: - description: >- - Define address type. The address type should be aligned with the address type supported by - the layer_protocol properties of the parent VnfExtCpd. - type: string - required: false - constraints: - - valid_values: [ ipv4, ipv6 ] - number_of_ip_address: - description: >- - Minimum number of IP addresses to be assigned. - type: integer - required: false - - tosca.datatypes.nfv.AddressData: - _extensions: - shorthand_name: AddressData - type_qualified_name: tosca:AddressData - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.3 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896057' - description: >- - The AddressData type is a complex TOSCA data type used to describe AddressData information - element as defined in [ETSI GS NFV-IFA 011], it provides information on the addresses to be - assigned to the connection point(s) instantiated from a Connection Point Descriptor. - derived_from: tosca.datatypes.Root - properties: - address_type: - description: >- - Describes the type of the address to be assigned to the connection point instantiated from - the parent Connection Point Descriptor. The content type shall be aligned with the address - type supported by the layerProtocol property of the parent Connection Point Descriptor. - type: string - required: true - constraints: - - valid_values: [ mac_address, ip_address ] - l2_address_data: - # Shall be present when the addressType is mac_address. - description: >- - Provides the information on the MAC addresses to be assigned to the connection point(s) - instantiated from the parent Connection Point Descriptor. - type: tosca.datatypes.nfv.L2AddressData # Empty in "GS NFV IFA011 V0.7.3" - required: false - l3_address_data: - # Shall be present when the addressType is ip_address. - description: >- - Provides the information on the IP addresses to be assigned to the connection point - instantiated from the parent Connection Point Descriptor. - type: tosca.datatypes.nfv.L3AddressData - required: false - - tosca.datatypes.nfv.VirtualNetworkInterfaceRequirements: - _extensions: - shorthand_name: VirtualNetworkInterfaceRequirements - type_qualified_name: tosca:VirtualNetworkInterfaceRequirements - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.4 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896058' - description: >- - The VirtualNetworkInterfaceRequirements type is a complex TOSCA data type used to describe - VirtualNetworkInterfaceRequirements information element as defined in [ETSI GS NFV-IFA 011], - it provides the information to specify requirements on a virtual network interface realising the - CPs instantiated from this CPD. - derived_from: tosca.datatypes.Root - properties: - name: - description: >- - Provides a human readable name for the requirement. - type: string - required: false - description: - description: >- - Provides a human readable description for the requirement. - type: string - required: false - support_mandatory: - description: >- - Indicates whether fulfilling the constraint is mandatory (TRUE) for successful operation - or desirable (FALSE). - type: boolean - required: false - requirement: - description: >- - Specifies a requirement such as the support of SR-IOV, a particular data plane - acceleration library, an API to be exposed by a NIC, etc. - type: string # ARIA NOTE: the spec says "not specified", but TOSCA requires a type - required: true - - tosca.datatypes.nfv.ConnectivityType: - _extensions: - shorthand_name: ConnectivityType - type_qualified_name: tosca:ConnectivityType - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.5 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896059' - description: >- - The TOSCA ConnectivityType type is a complex TOSCA data type used to describe ConnectivityType - information element as defined in [ETSI GS NFV-IFA 011]. - derived_from: tosca.datatypes.Root - properties: - layer_protocol: - description: >- - Identifies the protocol this VL gives access to (ethernet, mpls, odu2, ipv4, ipv6, - pseudo_wire). - type: string - required: true - constraints: - - valid_values: [ ethernet, mpls, odu2, ipv4, ipv6, pseudo_wire ] - flow_pattern: - description: >- - Identifies the flow pattern of the connectivity (Line, Tree, Mesh). - type: string - required: false - - tosca.datatypes.nfv.RequestedAdditionalCapability: - _extensions: - shorthand_name: RequestedAdditionalCapability - type_qualified_name: tosca:RequestedAdditionalCapability - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.6 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896060' - description: >- - RequestAdditionalCapability describes additional capability for a particular VDU. - derived_from: tosca.datatypes.Root - properties: - request_additional_capability_name: - description: >- - Identifies a requested additional capability for the VDU. - type: string - required: true - support_mandatory: - description: >- - Indicates whether the requested additional capability is mandatory for successful - operation. - type: string - required: true - min_requested_additional_capability_version: - description: >- - Identifies the minimum version of the requested additional capability. - type: string - required: false - preferred_requested_additional_capability_version: - description: >- - Identifies the preferred version of the requested additional capability. - type: string - required: false - target_performance_parameters: - description: >- - Identifies specific attributes, dependent on the requested additional capability type. - type: map - entry_schema: - type: string - required: true - - tosca.datatypes.nfv.VirtualMemory: - _extensions: - shorthand_name: VirtualMemory - type_qualified_name: tosca:VirtualMemory - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.7 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896061' - description: >- - VirtualMemory describes virtual memory for a particular VDU. - derived_from: tosca.datatypes.Root - properties: - virtual_mem_size: - description: Amount of virtual memory. - type: scalar-unit.size - required: true - virtual_mem_oversubscription_policy: - description: >- - The memory core oversubscription policy in terms of virtual memory to physical memory on - the platform. The cardinality can be 0 during the allocation request, if no particular - value is requested. - type: string - required: false - numa_enabled: - description: >- - It specifies the memory allocation to be cognisant of the relevant process/core - allocation. The cardinality can be 0 during the allocation request, if no particular value - is requested. - type: boolean - required: false - - tosca.datatypes.nfv.VirtualCpu: - _extensions: - shorthand_name: VirtualCpu - type_qualified_name: tosca:VirtualCpu - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.8 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896062' - description: >- - VirtualMemory describes virtual memory for a particular VDU. - derived_from: tosca.datatypes.Root - properties: - cpu_architecture: - description: >- - CPU architecture type. Examples are x86, ARM. - type: string - required: false - num_virtual_cpu: - description: >- - Number of virtual CPUs. - type: integer - required: true - virtual_cpu_clock: - description: >- - Minimum virtual CPU clock rate. - type: scalar-unit.frequency - required: false - virtual_cpu_oversubscription_policy: - description: >- - CPU core oversubscription policy. - type: string - required: false - virtual_cpu_pinning: - description: >- - The virtual CPU pinning configuration for the virtualized compute resource. - type: tosca.datatypes.nfv.VirtualCpuPinning - required: false - - tosca.datatypes.nfv.VirtualCpuPinning: - _extensions: - shorthand_name: VirtualCpuPinning - type_qualified_name: tosca:VirtualCpuPinning - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.9 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896064' - description: >- - VirtualCpuPinning describes CPU pinning configuration for a particular CPU. - derived_from: tosca.datatypes.Root - properties: - cpu_pinning_policy: - description: >- - Indicates the policy for CPU pinning. - type: string - constraints: - - valid_values: [ static, dynamic ] - required: false - cpu_pinning_map: - description: >- - If cpuPinningPolicy is defined as "static", the cpuPinningMap provides the map of pinning - virtual CPU cores to physical CPU cores/threads. - type: map - entry_schema: - type: string - required: false - - tosca.datatypes.nfv.VnfcConfigurableProperties: - _extensions: - shorthand_name: VnfcconfigurableProperties - type_qualified_name: tosca:VnfcconfigurableProperties - specification: tosca-simple-nfv-1.0 - specification_section: 5.3.10 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896065' - # ARIA NOTE: description is mangled in spec - description: >- - VnfcConfigurableProperties describes additional configurable properties of a VNFC. - derived_from: tosca.datatypes.Root - properties: - additional_vnfc_configurable_properties: - description: >- - Describes additional configuration for VNFC. - type: map - entry_schema: - type: string - required: false
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml deleted file mode 100644 index 73f0ecd..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml +++ /dev/null @@ -1,260 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -node_types: - - tosca.nodes.nfv.VDU.Compute: - _extensions: - shorthand_name: VDU.Compute - type_qualified_name: tosca:VDU.Compute - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.2 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896079' - description: >- - The TOSCA nfv.VDU.Compute node type represents the virtual compute part of a VDU entity which - it mainly describes the deployment and operational behavior of a VNF component (VNFC), as - defined by [ETSI NFV IFA011]. - derived_from: tosca.nodes.Compute - properties: - name: - description: >- - Human readable name of the VDU. - type: string - required: true - description: - description: >- - Human readable description of the VDU. - type: string - required: true - boot_order: - description: >- - The key indicates the boot index (lowest index defines highest boot priority). - The Value references a descriptor from which a valid boot device is created e.g. - VirtualStorageDescriptor from which a VirtualStorage instance is created. If no boot order - is defined the default boot order defined in the VIM or NFVI shall be used. - type: list # ARIA NOTE: an explicit index (boot index) is unnecessary, contrary to IFA011 - entry_schema: - type: string - required: false - nfvi_constraints: - description: >- - Describes constraints on the NFVI for the VNFC instance(s) created from this VDU. - For example, aspects of a secure hosting environment for the VNFC instance that involve - additional entities or processes. More software images can be attached to the - virtualization container using virtual_storage. - type: list - entry_schema: - type: string - required: false - configurable_properties: - description: >- - Describes the configurable properties of all VNFC instances based on this VDU. - type: map - entry_schema: - type: tosca.datatypes.nfv.VnfcConfigurableProperties - required: true - attributes: - # ARIA NOTE: The attributes are only described in section [5.9.2.5 Definition], but are not - # mentioned in section [5.9.2.2 Attributes]. Additionally, it does not seem to make sense to - # deprecate inherited attributes, as it breaks the inheritence contract. - private_address: - type: string - status: deprecated - public_address: - type: string - status: deprecated - networks: - type: map - entry_schema: - type: tosca.datatypes.network.NetworkInfo - status: deprecated - ports: - type: map - entry_schema: - type: tosca.datatypes.network.PortInfo - status: deprecated - capabilities: - virtual_compute: - description: >- - Describes virtual compute resources capabilities. - type: tosca.capabilities.nfv.VirtualCompute - virtual_binding: - description: >- - Defines ability of VirtualBindable. - type: tosca.capabilities.nfv.VirtualBindable - monitoring_parameter: - # ARIA NOTE: commented out in 5.9.2.5 - description: >- - Monitoring parameter, which can be tracked for a VNFC based on this VDU. Examples include: - memory-consumption, CPU-utilisation, bandwidth-consumption, VNFC downtime, etc. - type: tosca.capabilities.nfv.Metric - #requirements: - # ARIA NOTE: virtual_storage is TBD - - # ARIA NOTE: csd04 attempts to deprecate the inherited local_storage requirement, but this - # is not possible in TOSCA - artifacts: - sw_image: - description: >- - Describes the software image which is directly loaded on the virtualization container - realizing this virtual storage. - file: '' # ARIA NOTE: missing value even though it is required in TOSCA - type: tosca.artifacts.nfv.SwImage - - tosca.nodes.nfv.VDU.VirtualStorage: - _extensions: - shorthand_name: VirtualStorage # ARIA NOTE: seems wrong in spec - type_qualified_name: tosca:VirtualStorage # ARIA NOTE: seems wrong in spec - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.3 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896080' - description: >- - The NFV VirtualStorage node type represents a virtual storage entity which it describes the - deployment and operational behavior of a virtual storage resources, as defined by - [ETSI NFV IFA011]. - derived_from: tosca.nodes.Root - properties: - type_of_storage: - description: >- - Type of virtualized storage resource. - type: string - required: true - size_of_storage: - description: >- - Size of virtualized storage resource (in GB). - type: scalar-unit.size - required: true - rdma_enabled: - description: >- - Indicate if the storage support RDMA. - type: boolean - required: false - artifacts: - sw_image: - description: >- - Describes the software image which is directly loaded on the virtualization container - realizing this virtual storage. - file: '' # ARIA NOTE: missing in spec - type: tosca.artifacts.nfv.SwImage - - tosca.nodes.nfv.Cpd: - _extensions: - shorthand_name: Cpd - type_qualified_name: tosca:Cpd - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.4 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896081' - description: >- - The TOSCA nfv.Cpd node represents network connectivity to a compute resource or a VL as defined - by [ETSI GS NFV-IFA 011]. This is an abstract type used as parent for the various Cpd types. - derived_from: tosca.nodes.Root - properties: - layer_protocol: - description: >- - Identifies which protocol the connection point uses for connectivity purposes. - type: string - constraints: - - valid_values: [ ethernet, mpls, odu2, ipv4, ipv6, pseudo_wire ] - required: false - role: # Name in ETSI NFV IFA011 v0.7.3 cpRole - description: >- - Identifies the role of the port in the context of the traffic flow patterns in the VNF or - parent NS. For example a VNF with a tree flow pattern within the VNF will have legal - cpRoles of ROOT and LEAF. - type: string - constraints: - - valid_values: [ root, leaf ] - required: false - description: - description: >- - Provides human-readable information on the purpose of the connection point - (e.g. connection point for control plane traffic). - type: string - required: false - address_data: - description: >- - Provides information on the addresses to be assigned to the connection point(s) instantiated - from this Connection Point Descriptor. - type: list - entry_schema: - type: tosca.datatypes.nfv.AddressData - required: false - - tosca.nodes.nfv.VduCpd: - _extensions: - shorthand_name: VduCpd - type_qualified_name: tosca:VduCpd - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.5 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896082' - description: >- - The TOSCA nfv.VduCpd node type represents a type of TOSCA Cpd node and describes network - connectivity between a VNFC instance (based on this VDU) and an internal VL as defined by - [ETSI GS NFV-IFA 011]. - derived_from: tosca.nodes.nfv.Cpd - properties: - bitrate_requirement: - description: >- - Bitrate requirement on this connection point. - type: integer - required: false - virtual_network_interface_requirements: - description: >- - Specifies requirements on a virtual network interface realising the CPs instantiated from - this CPD. - type: list - entry_schema: - type: VirtualNetworkInterfaceRequirements - required: false - requirements: - # ARIA NOTE: seems to be a leftover from csd03 - # - virtual_link: - # description: Describes the requirements for linking to virtual link - # capability: tosca.capabilities.nfv.VirtualLinkable - # relationship: tosca.relationships.nfv.VirtualLinksTo - # node: tosca.nodes.nfv.VnfVirtualLinkDesc - - virtual_binding: - capability: tosca.capabilities.nfv.VirtualBindable - relationship: tosca.relationships.nfv.VirtualBindsTo - node: tosca.nodes.nfv.VDU.Compute # ARIA NOTE: seems wrong in spec - - tosca.nodes.nfv.VnfVirtualLinkDesc: - _extensions: - shorthand_name: VnfVirtualLinkDesc - type_qualified_name: tosca:VnfVirtualLinkDesc - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.6 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896083' - description: >- - The TOSCA nfv.VnfVirtualLinkDesc node type represents a logical internal virtual link as - defined by [ETSI GS NFV-IFA 011]. - derived_from: tosca.nodes.Root - properties: - connectivity_type: - description: >- - specifies the protocol exposed by the VL and the flow pattern supported by the VL. - type: tosca.datatypes.nfv.ConnectivityType - required: true - description: - description: >- - Provides human-readable information on the purpose of the VL (e.g. control plane traffic). - type: string - required: false - test_access: - description: >- - Test access facilities available on the VL (e.g. none, passive, monitoring, or active - (intrusive) loopbacks at endpoints. - type: string - required: false http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml deleted file mode 100644 index 4cf99a2..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -relationship_types: - - tosca.relationships.nfv.VirtualBindsTo: - _extensions: - shorthand_name: VirtualBindsTo - type_qualified_name: tosca:VirtualBindsTo - specification: tosca-simple-nfv-1.0 - specification_section: 5.7.1 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896074' - description: >- - This relationship type represents an association relationship between VDU and CP node types. - derived_from: tosca.relationships.DependsOn - valid_target_types: [ tosca.capabilities.nfv.VirtualBindable ] - - # ARIA NOTE: csd04 lacks the definition of tosca.relationships.nfv.Monitor (the derived_from and - # valid_target_types), so we are using the definition in csd03 section 8.4.2. - tosca.relationships.nfv.Monitor: - _extensions: - shorthand_name: Monitor - type_qualified_name: tosca:Monitor - specification: tosca-simple-nfv-1.0 - specification_section: 5.7.2 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896075' - description: >- - This relationship type represents an association relationship to the Metric capability of VDU - node types. - derived_from: tosca.relationships.ConnectsTo - valid_target_types: [ tosca.capabilities.nfv.Metric ] http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/tosca-simple-nfv-1.0.yaml ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/tosca-simple-nfv-1.0.yaml b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/tosca-simple-nfv-1.0.yaml deleted file mode 100644 index 764c739..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/tosca-simple-nfv-1.0.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -imports: - - artifacts.yaml - - capabilities.yaml - - data.yaml - - nodes.yaml - - relationships.yaml http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_nfv_v1_0/presenter.py ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_nfv_v1_0/presenter.py b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_nfv_v1_0/presenter.py deleted file mode 100644 index 64178aa..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_nfv_v1_0/presenter.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from aria.utils.collections import FrozenList -from aria.utils.caching import cachedmethod - -from ..simple_v1_0 import ToscaSimplePresenter1_0 - - -class ToscaSimpleNfvPresenter1_0(ToscaSimplePresenter1_0): # pylint: disable=invalid-name,abstract-method - """ - ARIA presenter for the `TOSCA Simple Profile for NFV v1.0 csd04 <http://docs.oasis-open.org - /tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html>`__. - - Supported ``tosca_definitions_version`` values: - - * ``tosca_simple_profile_for_nfv_1_0`` - """ - - DSL_VERSIONS = ('tosca_simple_profile_for_nfv_1_0',) - ALLOWED_IMPORTED_DSL_VERSIONS = ('tosca_simple_yaml_1_0', 'tosca_simple_profile_for_nfv_1_0') - SIMPLE_PROFILE_FOR_NFV_LOCATION = 'tosca-simple-nfv-1.0/tosca-simple-nfv-1.0.yaml' - - # Presenter - - @cachedmethod - def _get_import_locations(self, context): - import_locations = super(ToscaSimpleNfvPresenter1_0, self)._get_import_locations(context) - if context.presentation.import_profile: - return FrozenList([self.SIMPLE_PROFILE_FOR_NFV_LOCATION] + import_locations) - return import_locations http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/assignments.py ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/assignments.py b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/assignments.py deleted file mode 100644 index 0590527..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/assignments.py +++ /dev/null @@ -1,440 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from aria.utils.collections import FrozenDict -from aria.utils.caching import cachedmethod -from aria.parser import implements_specification -from aria.parser.presentation import (AsIsPresentation, has_fields, allow_unknown_fields, - short_form_field, primitive_field, object_field, - object_dict_field, object_dict_unknown_fields, - field_validator, type_validator) - -from .filters import NodeFilter -from .misc import Description, OperationImplementation -from .modeling.parameters import get_assigned_and_defined_parameter_values -from .presentation.extensible import ExtensiblePresentation -from .presentation.field_validators import (node_template_or_type_validator, - relationship_template_or_type_validator, - capability_definition_or_type_validator, - node_filter_validator) -from .presentation.types import (convert_shorthand_to_full_type_name, - get_type_by_full_or_shorthand_name) - -@implements_specification('3.5.9', 'tosca-simple-1.0') -class PropertyAssignment(AsIsPresentation): - """ - This section defines the grammar for assigning values to named properties within TOSCA Node and - Relationship templates that are defined in their corresponding named types. - - 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_PROPERTY_VALUE_ASSIGNMENT>`__ - """ - -@short_form_field('implementation') -@has_fields -@implements_specification('3.5.13-2', 'tosca-simple-1.0') -class OperationAssignment(ExtensiblePresentation): - """ - An operation definition defines a named function or procedure that can be bound to an - implementation artifact (e.g., a script). - - 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_OPERATION_DEF>`__ - """ - - @object_field(Description) - def description(self): - """ - The optional description string for the associated named operation. - - :type: :class:`Description` - """ - - @object_field(OperationImplementation) - def implementation(self): - """ - The optional implementation artifact name (e.g., a script file name within a TOSCA CSAR - file). - - :type: :class:`OperationImplementation` - """ - - @object_dict_field(PropertyAssignment) - def inputs(self): - """ - The optional list of input property assignments (i.e., parameters assignments) for operation - definitions that are within TOSCA Node or Relationship Template definitions. This includes - when operation definitions are included as part of a Requirement assignment in a Node - Template. - - :type: {:obj:`basestring`: :class:`PropertyAssignment`} - """ - - @cachedmethod - def _get_extensions(self, context): - def update_inherited_extensions(extensions, interface_type): - parent = interface_type._get_parent(context) - if parent is not None: - update_inherited_extensions(extensions, parent) - operation_definition = interface_type.operations.get(self._name) - if operation_definition is not None: - if operation_definition._extensions: - extensions.update(operation_definition._extensions) - - extensions = {} - update_inherited_extensions(extensions, self._container._get_type(context)) - if self._container._extensions: - extensions.update(self._container._extensions) - if self._extensions: - extensions.update(self._extensions) - return extensions - -@allow_unknown_fields -@has_fields -@implements_specification('3.5.14-2', 'tosca-simple-1.0') -class InterfaceAssignment(ExtensiblePresentation): - """ - An interface definition defines a named interface that can be associated with a Node or - Relationship Type. - - 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_INTERFACE_DEF>`__ - """ - - @object_dict_field(PropertyAssignment) - def inputs(self): - """ - The optional list of input property assignments (i.e., parameters assignments) for interface - definitions that are within TOSCA Node or Relationship Template definitions. This includes - when interface definitions are referenced as part of a Requirement assignment in a Node - Template. - - :type: {:obj:`basestring`: :class:`PropertyAssignment`} - """ - - @object_dict_unknown_fields(OperationAssignment) - def operations(self): - """ - :type: {:obj:`basestring`: :class:`OperationAssignment`} - """ - - @cachedmethod - def _get_type(self, context): - the_type = self._container._get_type(context) - - if isinstance(the_type, tuple): - # In RelationshipAssignment - the_type = the_type[0] # This could be a RelationshipTemplate - - interface_definitions = the_type._get_interfaces(context) \ - if the_type is not None else None - interface_definition = interface_definitions.get(self._name) \ - if interface_definitions is not None else None - return interface_definition._get_type(context) \ - if interface_definition is not None else None - - def _validate(self, context): - super(InterfaceAssignment, self)._validate(context) - if self.operations: - for operation in self.operations.itervalues(): # pylint: disable=no-member - operation._validate(context) - -@short_form_field('type') -@has_fields -class RelationshipAssignment(ExtensiblePresentation): - """ - Relationship assignment. - """ - - @field_validator(relationship_template_or_type_validator) - @primitive_field(str) - def type(self): - """ - The optional reserved keyname used to provide the name of the Relationship Type for the - requirement assignment's relationship keyname. - - :type: :obj:`basestring` - """ - - @object_dict_field(PropertyAssignment) - def properties(self): - """ - ARIA NOTE: This field is not mentioned in the spec, but is implied. - - :type: {:obj:`basestring`: :class:`PropertyAssignment`} - """ - - @object_dict_field(InterfaceAssignment) - def interfaces(self): - """ - The optional reserved keyname used to reference declared (named) interface definitions of - the corresponding Relationship Type in order to provide Property assignments for these - interfaces or operations of these interfaces. - - :type: {:obj:`basestring`: :class:`InterfaceAssignment`} - """ - - @cachedmethod - def _get_type(self, context): - type_name = self.type - if type_name is not None: - the_type = context.presentation.get_from_dict('service_template', 'topology_template', - 'relationship_templates', type_name) - if the_type is not None: - return the_type, 'relationship_template' - the_type = get_type_by_full_or_shorthand_name(context, type_name, 'relationship_types') - if the_type is not None: - return the_type, 'relationship_type' - return None, None - -@short_form_field('node') -@has_fields -@implements_specification('3.7.2', 'tosca-simple-1.0') -class RequirementAssignment(ExtensiblePresentation): - """ - A Requirement assignment allows template authors to provide either concrete names of TOSCA - templates or provide abstract selection criteria for providers to use to find matching TOSCA - templates that are used to fulfill a named requirement's declared TOSCA Node Type. - - 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_REQUIREMENT_ASSIGNMENT>`__ - """ - - # The example in 3.7.2.2.2 shows unknown fields in addition to these, but is this a mistake? - - @field_validator(capability_definition_or_type_validator) - @primitive_field(str) - def capability(self): - """ - The optional reserved keyname used to provide the name of either a: - - * Capability definition within a target node template that can fulfill the requirement. - * Capability Type that the provider will use to select a type-compatible target node - template to fulfill the requirement at runtime. - - :type: :obj:`basestring` - """ - - @field_validator(node_template_or_type_validator) - @primitive_field(str) - def node(self): - """ - The optional reserved keyname used to identify the target node of a relationship. - Specifically, it is used to provide either a: - - * Node Template name that can fulfill the target node requirement. - * Node Type name that the provider will use to select a type-compatible node template to - fulfill the requirement at runtime. - - :type: :obj:`basestring` - """ - - @object_field(RelationshipAssignment) - def relationship(self): - """ - The optional reserved keyname used to provide the name of either a: - - * Relationship Template to use to relate the source node to the (capability in the) target - node when fulfilling the requirement. - * Relationship Type that the provider will use to select a type-compatible relationship - template to relate the source node to the target node at runtime. - - :type: :class:`RelationshipAssignment` - """ - - @field_validator(node_filter_validator) - @object_field(NodeFilter) - def node_filter(self): - """ - The optional filter definition that TOSCA orchestrators or providers would use to select a - type-compatible target node that can fulfill the associated abstract requirement at runtime. - - :type: :class:`NodeFilter` - """ - - @cachedmethod - def _get_node(self, context): - node = self.node - - if node is not None: - node_template = context.presentation.get_from_dict('service_template', - 'topology_template', - 'node_templates', node) - if node_template is not None: - return node_template, 'node_template' - node_type = get_type_by_full_or_shorthand_name(context, node, 'node_types') - if node_type is not None: - return node_type, 'node_type' - - return None, None - - @cachedmethod - def _get_capability(self, context): - capability = self.capability - - if capability is not None: - node, node_variant = self._get_node(context) - if node_variant == 'node_template': - capabilities = node._get_capabilities(context) - if capability in capabilities: - return capabilities[capability], 'capability_assignment' - capability_type = get_type_by_full_or_shorthand_name(context, capability, - 'capability_types') - if capability_type is not None: - return capability_type, 'capability_type' - - return None, None - -@implements_specification('3.5.11', 'tosca-simple-1.0') -class AttributeAssignment(AsIsPresentation): - """ - This section defines the grammar for assigning values to named attributes within TOSCA Node and - Relationship templates which are defined in their corresponding named types. - - 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_ATTRIBUTE_VALUE_ASSIGNMENT>`__ - """ - -@has_fields -@implements_specification('3.7.1', 'tosca-simple-1.0') -class CapabilityAssignment(ExtensiblePresentation): - """ - A capability assignment allows node template authors to assign values to properties and - attributes for a named capability definition that is part of a Node Template's type definition. - - 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_ASSIGNMENT>`__ - """ - - @object_dict_field(PropertyAssignment) - def properties(self): - """ - An optional list of property definitions for the Capability definition. - - :type: {:obj:`basestring`: :class:`PropertyAssignment`} - """ - - @object_dict_field(AttributeAssignment) - def attributes(self): - """ - An optional list of attribute definitions for the Capability definition. - - :type: {:obj:`basestring`: :class:`AttributeAssignment`} - """ - - @cachedmethod - def _get_definition(self, context): - node_type = self._container._get_type(context) - capability_definitions = node_type._get_capabilities(context) \ - if node_type is not None else None - return capability_definitions.get(self._name) \ - if capability_definitions is not None else None - - @cachedmethod - def _get_type(self, context): - capability_definition = self._get_definition(context) - return capability_definition._get_type(context) \ - if capability_definition is not None else None - -@has_fields -@implements_specification('3.5.6', 'tosca-simple-1.0') -class ArtifactAssignment(ExtensiblePresentation): - """ - An artifact definition defines a named, typed file that can be associated with Node Type or Node - Template and used by orchestration engine to facilitate deployment and implementation of - interface operations. - - 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_ARTIFACT_DEF>`__ - """ - - @field_validator(type_validator('artifact type', convert_shorthand_to_full_type_name, - 'artifact_types')) - @primitive_field(str, required=True) - def type(self): - """ - The required artifact type for the artifact definition. - - :type: :obj:`basestring` - """ - - @primitive_field(str, required=True) - def file(self): - """ - The required URI string (relative or absolute) which can be used to locate the artifact's - file. - - :type: :obj:`basestring` - """ - - @field_validator(type_validator('repository', 'repositories')) - @primitive_field(str) - def repository(self): - """ - The optional name of the repository definition which contains the location of the external - repository that contains the artifact. The artifact is expected to be referenceable by its - file URI within the repository. - - :type: :obj:`basestring` - """ - - @object_field(Description) - def description(self): - """ - The optional description for the artifact definition. - - :type: :class:`Description` - """ - - @primitive_field(str) - def deploy_path(self): - """ - The file path the associated file would be deployed into within the target node's container. - - :type: :obj:`basestring` - """ - - @object_dict_field(PropertyAssignment) - def properties(self): - """ - ARIA NOTE: This field is not mentioned in the spec, but is implied. - - :type: {:obj:`basestring`: :class:`PropertyAssignment`} - """ - - @cachedmethod - def _get_type(self, context): - return get_type_by_full_or_shorthand_name(context, self.type, 'artifact_types') - - @cachedmethod - def _get_repository(self, context): - return context.presentation.get_from_dict('service_template', 'repositories', - self.repository) - - @cachedmethod - def _get_property_values(self, context): - return FrozenDict(get_assigned_and_defined_parameter_values(context, self, 'property')) - - @cachedmethod - def _validate(self, context): - super(ArtifactAssignment, self)._validate(context) - self._get_property_values(context) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca-website/blob/23d6ba76/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/data_types.py ---------------------------------------------------------------------- diff --git a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/data_types.py b/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/data_types.py deleted file mode 100644 index c385f78..0000000 --- a/apache-ariatosca-0.1.1/extensions/aria_extension_tosca/simple_v1_0/data_types.py +++ /dev/null @@ -1,540 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import re -from datetime import datetime, tzinfo, timedelta -try: - from functools import total_ordering -except ImportError: - from total_ordering import total_ordering - -from aria.parser import implements_specification -from aria.utils.collections import StrictDict, OrderedDict -from aria.utils.formatting import safe_repr - -from .modeling.data_types import (coerce_to_data_type_class, report_issue_for_bad_format, - coerce_value) - - -class Timezone(tzinfo): - """ - Timezone as fixed offset in hours and minutes east of UTC. - """ - - def __init__(self, hours=0, minutes=0): - super(Timezone, self).__init__() - self._offset = timedelta(hours=hours, minutes=minutes) - - def utcoffset(self, dt): # pylint: disable=unused-argument - return self._offset - - def tzname(self, dt): # pylint: disable=unused-argument - return str(self._offset) - - def dst(self, dt): # pylint: disable=unused-argument - return Timezone._ZERO - - _ZERO = timedelta(0) - -UTC = Timezone() - -@total_ordering -@implements_specification('timestamp', 'yaml-1.1') -class Timestamp(object): - ''' - TOSCA timestamps follow the YAML specification, which in turn is a variant of ISO8601. - - Long forms and short forms (without time of day and assuming UTC timezone) are supported for - parsing. The canonical form (for rendering) matches the long form at the UTC timezone. - - See the `Timestamp Language-Independent Type for YAML Version 1.1 (Working Draft 2005-01-18) - <http://yaml.org/type/timestamp.html>`__ - ''' - - REGULAR_SHORT = r'^(?P<year>[0-9][0-9][0-9][0-9])-(?P<month>[0-9][0-9])-(?P<day>[0-9][0-9])$' - REGULAR_LONG = \ - r'^(?P<year>[0-9][0-9][0-9][0-9])-(?P<month>[0-9][0-9]?)-(?P<day>[0-9][0-9]?)' + \ - r'([Tt]|[ \t]+)' \ - r'(?P<hour>[0-9][0-9]?):(?P<minute>[0-9][0-9]):(?P<second>[0-9][0-9])' + \ - r'(?P<fraction>\.[0-9]*)?' + \ - r'(([ \t]*)Z|(?P<tzhour>[-+][0-9][0-9])?(:(?P<tzminute>[0-9][0-9])?)?)?$' - CANONICAL = '%Y-%m-%dT%H:%M:%S' - - def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - value = str(value) - match = re.match(Timestamp.REGULAR_SHORT, value) - if match is not None: - # Parse short form - year = int(match.group('year')) - month = int(match.group('month')) - day = int(match.group('day')) - self.value = datetime(year, month, day, tzinfo=UTC) - else: - match = re.match(Timestamp.REGULAR_LONG, value) - if match is not None: - # Parse long form - year = int(match.group('year')) - month = int(match.group('month')) - day = int(match.group('day')) - hour = match.group('hour') - if hour is not None: - hour = int(hour) - minute = match.group('minute') - if minute is not None: - minute = int(minute) - second = match.group('second') - if second is not None: - second = int(second) - fraction = match.group('fraction') - if fraction is not None: - fraction = int(float(fraction) * 1000000.0) # convert to microseconds - tzhour = match.group('tzhour') - if tzhour is not None: - tzhour = int(tzhour) - else: - tzhour = 0 - tzminute = match.group('tzminute') - if tzminute is not None: - tzminute = int(tzminute) - else: - tzminute = 0 - self.value = datetime(year, month, day, hour, minute, second, fraction, - Timezone(tzhour, tzminute)) - else: - raise ValueError( - 'timestamp must be formatted as YAML ISO8601 variant or "YYYY-MM-DD": %s' - % safe_repr(value)) - - @property - def as_datetime_utc(self): - return self.value.astimezone(UTC) - - @property - def as_raw(self): - return self.__str__() - - def __str__(self): - the_datetime = self.as_datetime_utc - return '%s%sZ' \ - % (the_datetime.strftime(Timestamp.CANONICAL), Timestamp._fraction_as_str(the_datetime)) - - def __repr__(self): - return repr(self.__str__()) - - def __eq__(self, timestamp): - if not isinstance(timestamp, Timestamp): - return False - return self.value == timestamp.value - - def __lt__(self, timestamp): - return self.value < timestamp.value - - @staticmethod - def _fraction_as_str(the_datetime): - return '{0:g}'.format(the_datetime.microsecond / 1000000.0).lstrip('0') - -@total_ordering -@implements_specification('3.2.2', 'tosca-simple-1.0') -class Version(object): - """ - TOSCA supports the concept of "reuse" of type definitions, as well as template definitions which - could be version and change over time. It is important to provide a reliable, normative means to - represent a version string which enables the comparison and management of types and templates - over time. Therefore, the TOSCA TC intends to provide a normative version type (string) for this - purpose in future Working Drafts of this specification. - - 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 - #TYPE_TOSCA_VERSION>`__ - """ - - REGULAR = \ - r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<fix>\d+)' + \ - r'((\.(?P<qualifier>\d+))(\-(?P<build>\d+))?)?)?$' - - @staticmethod - def key(version): - """ - Key method for fast sorting. - """ - return (version.major, version.minor, version.fix, version.qualifier, version.build) - - def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - str_value = str(value) - match = re.match(Version.REGULAR, str_value) - if match is None: - raise ValueError( - 'version must be formatted as <major_version>.<minor_version>' - '[.<fix_version>[.<qualifier>[-<build_version]]]: %s' - % safe_repr(value)) - - self.value = str_value - - self.major = match.group('major') - self.major = int(self.major) - self.minor = match.group('minor') - self.minor = int(self.minor) - self.fix = match.group('fix') - if self.fix is not None: - self.fix = int(self.fix) - self.qualifier = match.group('qualifier') - if self.qualifier is not None: - self.qualifier = int(self.qualifier) - self.build = match.group('build') - if self.build is not None: - self.build = int(self.build) - - @property - def as_raw(self): - return self.value - - def __str__(self): - return self.value - - def __repr__(self): - return repr(self.__str__()) - - def __eq__(self, version): - if not isinstance(version, Version): - return False - return (self.major, self.minor, self.fix, self.qualifier, self.build) == \ - (version.major, version.minor, version.fix, version.qualifier, version.build) - - def __lt__(self, version): - if self.major < version.major: - return True - elif self.major == version.major: - if self.minor < version.minor: - return True - elif self.minor == version.minor: - if self.fix < version.fix: - return True - elif self.fix == version.fix: - if self.qualifier < version.qualifier: - return True - elif self.qualifier == version.qualifier: - if self.build < version.build: - return True - return False - -@implements_specification('3.2.3', 'tosca-simple-1.0') -class Range(object): - """ - The range type can be used to define numeric ranges with a lower and upper boundary. For - example, this allows for specifying a range of ports to be opened in a firewall. - - 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 - #TYPE_TOSCA_RANGE>`__ - """ - - def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - if not isinstance(value, list): - raise ValueError('range value is not a list: %s' % safe_repr(value)) - if len(value) != 2: - raise ValueError('range value does not have exactly 2 elements: %s' % safe_repr(value)) - - def is_int(v): - return isinstance(v, int) and (not isinstance(v, bool)) # In Python bool is an int - - if not is_int(value[0]): - raise ValueError('lower bound of range is not a valid integer: %s' - % safe_repr(value[0])) - - if value[1] != 'UNBOUNDED': - if not is_int(value[1]): - raise ValueError('upper bound of range is not a valid integer or "UNBOUNDED": %s' - % safe_repr(value[0])) - - if value[0] >= value[1]: - raise ValueError( - 'upper bound of range is not greater than the lower bound: %s >= %s' - % (safe_repr(value[0]), safe_repr(value[1]))) - - self.value = value - - def is_in(self, value): - if value < self.value[0]: - return False - if (self.value[1] != 'UNBOUNDED') and (value > self.value[1]): - return False - return True - - @property - def as_raw(self): - return list(self.value) - -@implements_specification('3.2.4', 'tosca-simple-1.0') -class List(list): - """ - The list type allows for specifying multiple values for a parameter of property. For example, if - an application allows for being configured to listen on multiple ports, a list of ports could be - configured using the list data type. - - 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 - #TYPE_TOSCA_LIST>`__ - """ - - @staticmethod - def _create(context, presentation, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - if not isinstance(value, list): - raise ValueError('"list" data type value is not a list: %s' % safe_repr(value)) - - entry_schema_type = entry_schema._get_type(context) - entry_schema_constraints = entry_schema.constraints - - the_list = List() - for v in value: - v = coerce_value(context, presentation, entry_schema_type, None, - entry_schema_constraints, v, aspect) - if v is not None: - the_list.append(v) - - return the_list - - # Can't define as property because it's old-style Python class - def as_raw(self): - return list(self) - -@implements_specification('3.2.5', 'tosca-simple-1.0') -class Map(StrictDict): - """ - The map type allows for specifying multiple values for a parameter of property as a map. In - contrast to the list type, where each entry can only be addressed by its index in the list, - entries in a map are named elements that can be addressed by their keys. - - 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 - #TYPE_TOSCA_MAP>`__ - """ - - @staticmethod - def _create(context, presentation, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - if not isinstance(value, dict): - raise ValueError('"map" data type value is not a dict: %s' % safe_repr(value)) - - if entry_schema is None: - raise ValueError('"map" data type does not define "entry_schema"') - - entry_schema_type = entry_schema._get_type(context) - entry_schema_constraints = entry_schema.constraints - - the_map = Map() - for k, v in value.iteritems(): - v = coerce_value(context, presentation, entry_schema_type, None, - entry_schema_constraints, v, aspect) - if v is not None: - the_map[k] = v - - return the_map - - def __init__(self, items=None): - super(Map, self).__init__(items, key_class=str) - - # Can't define as property because it's old-style Python class - def as_raw(self): - return OrderedDict(self) - -@total_ordering -@implements_specification('3.2.6', 'tosca-simple-1.0') -class Scalar(object): - """ - The scalar-unit type can be used to define scalar values along with a unit from the list of - recognized units. - - 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 - #TYPE_TOSCA_SCALAR_UNIT>`__ - """ - - @staticmethod - def key(scalar): - """ - Key method for fast sorting. - """ - return scalar.value - - def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - str_value = str(value) - match = re.match(self.REGULAR, str_value) # pylint: disable=no-member - if match is None: - raise ValueError('scalar must be formatted as <scalar> <unit>: %s' % safe_repr(value)) - - self.factor = float(match.group('scalar')) - self.unit = match.group('unit') - - unit_lower = self.unit.lower() - unit_size = None - for k, v in self.UNITS.iteritems(): # pylint: disable=no-member - if k.lower() == unit_lower: - self.unit = k - unit_size = v - break - if unit_size is None: - raise ValueError('scalar specified with unsupported unit: %s' % safe_repr(self.unit)) - - self.value = self.TYPE(self.factor * unit_size) # pylint: disable=no-member - - @property - def as_raw(self): - return OrderedDict(( - ('value', self.value), - ('factor', self.factor), - ('unit', self.unit), - ('unit_size', self.UNITS[self.unit]))) # pylint: disable=no-member - - def __str__(self): - return '%s %s' % (self.value, self.UNIT) # pylint: disable=no-member - - def __repr__(self): - return repr(self.__str__()) - - def __eq__(self, scalar): - if isinstance(scalar, Scalar): - value = scalar.value - else: - value = self.TYPE(scalar) # pylint: disable=no-member - return self.value == value - - def __lt__(self, scalar): - if isinstance(scalar, Scalar): - value = scalar.value - else: - value = self.TYPE(scalar) # pylint: disable=no-member - return self.value < value - -@implements_specification('3.2.6.4', 'tosca-simple-1.0') -class ScalarSize(Scalar): - """ - Integer scalar for counting bytes. - - 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 - #TYPE_TOSCA_SCALAR_UNIT_SIZE>`__ - """ - - # See: http://www.regular-expressions.info/floatingpoint.html - REGULAR = \ - r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>B|kB|KiB|MB|MiB|GB|GiB|TB|TiB)$' - - UNITS = { - 'B': 1, - 'kB': 1000, - 'KiB': 1024, - 'MB': 1000000, - 'MiB': 1048576, - 'GB': 1000000000, - 'GiB': 1073741824, - 'TB': 1000000000000, - 'TiB': 1099511627776} - - TYPE = int - UNIT = 'bytes' - -@implements_specification('3.2.6.5', 'tosca-simple-1.0') -class ScalarTime(Scalar): - """ - Floating point scalar for counting seconds. - - 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 - #TYPE_TOSCA_SCALAR_UNIT_TIME>`__ - """ - - # See: http://www.regular-expressions.info/floatingpoint.html - REGULAR = r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>ns|us|ms|s|m|h|d)$' - - UNITS = { - 'ns': 0.000000001, - 'us': 0.000001, - 'ms': 0.001, - 's': 1.0, - 'm': 60.0, - 'h': 3600.0, - 'd': 86400.0} - - TYPE = float - UNIT = 'seconds' - -@implements_specification('3.2.6.6', 'tosca-simple-1.0') -class ScalarFrequency(Scalar): - """ - Floating point scalar for counting cycles per second (Hz). - - 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 - #TYPE_TOSCA_SCALAR_UNIT_FREQUENCY>`__ - """ - - # See: http://www.regular-expressions.info/floatingpoint.html - REGULAR = r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>Hz|kHz|MHz|GHz)$' - - UNITS = { - 'Hz': 1.0, - 'kHz': 1000.0, - 'MHz': 1000000.0, - 'GHz': 1000000000.0} - - TYPE = float - UNIT = 'Hz' - -# -# The following are hooked in the YAML as 'coerce_value' extensions -# - -def coerce_timestamp(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - return coerce_to_data_type_class(context, presentation, Timestamp, entry_schema, constraints, - value, aspect) - -def coerce_version(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - return coerce_to_data_type_class(context, presentation, Version, entry_schema, constraints, - value, aspect) - -def coerce_range(context, presentation, the_type, entry_schema, constraints, value, aspect): - if aspect == 'in_range': - # When we're in a "in_range" constraint, the values are *not* themselves ranges, but numbers - try: - return float(value) - except ValueError as e: - report_issue_for_bad_format(context, presentation, the_type, value, aspect, e) - except TypeError as e: - report_issue_for_bad_format(context, presentation, the_type, value, aspect, e) - else: - return coerce_to_data_type_class(context, presentation, Range, entry_schema, constraints, - value, aspect) - -def coerce_list(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - return coerce_to_data_type_class(context, presentation, List, entry_schema, constraints, - value, aspect) - -def coerce_map_value(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument - return coerce_to_data_type_class(context, presentation, Map, entry_schema, constraints, value, - aspect) - -def coerce_scalar_unit_size(context, presentation, the_type, entry_schema, constraints, value, # pylint: disable=unused-argument - aspect): - return coerce_to_data_type_class(context, presentation, ScalarSize, entry_schema, constraints, - value, aspect) - -def coerce_scalar_unit_time(context, presentation, the_type, entry_schema, constraints, value, # pylint: disable=unused-argument - aspect): - return coerce_to_data_type_class(context, presentation, ScalarTime, entry_schema, constraints, - value, aspect) - -def coerce_scalar_unit_frequency(context, presentation, the_type, entry_schema, constraints, value, # pylint: disable=unused-argument - aspect): - return coerce_to_data_type_class(context, presentation, ScalarFrequency, entry_schema, - constraints, value, aspect)
