Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
ARIA-88 Add TOSCA use-case examples
  • Loading branch information
tliron committed Feb 16, 2017
1 parent b619335 commit 787d7e7e6d210adba96dc0057fdf43f4c0034658
Show file tree
Hide file tree
Showing 58 changed files with 1,882 additions and 129 deletions.
@@ -1 +1,2 @@
include requirements.txt
recursive-include examples *
@@ -451,8 +451,8 @@ def __init__(self, name=None,
template_name=None):
if name is not None and not isinstance(name, basestring):
raise ValueError('name must be a string or None')
if (source_requirement_index is not None and
(not isinstance(source_requirement_index, int) or (source_requirement_index < 0))):
if source_requirement_index is not None and \
(not isinstance(source_requirement_index, int) or (source_requirement_index < 0)):
raise ValueError('source_requirement_index must be int > 0')
if type_name is not None and not isinstance(type_name, basestring):
raise ValueError('type_name must be a string or None')
@@ -296,9 +296,8 @@ def __init__(self, name=None,
if target_capability_name is not None and not isinstance(target_capability_name,
basestring):
raise ValueError('target_capability_name must be a string or None')
if target_node_type_name is not None and target_node_template_name is not None \
or target_node_type_name is None and target_node_template_name is None:
raise ValueError('must set either target_node_type_name or target_node_template_name')
if target_node_type_name is not None and target_node_template_name is not None:
raise ValueError('can set either target_node_type_name or target_node_template_name')
if target_capability_type_name is not None and target_capability_name is not None:
raise ValueError('can set either target_capability_type_name or target_capability_name')

@@ -552,8 +551,7 @@ def __init__(self, type_name=None, template_name=None):
raise ValueError('type_name must be a string or None')
if (template_name is not None) and (not isinstance(template_name, basestring)):
raise ValueError('template_name must be a string or None')
if type_name is not None and template_name is not None \
or type_name is None and template_name is None:
if (type_name is None) and (template_name is None):
raise ValueError('must set either type_name or template_name')

self.type_name = type_name
@@ -576,7 +574,7 @@ def as_raw(self):
('target_interface_templates', as_raw_list(self.target_interface_templates))))

def instantiate(self, context, container):
relationship = Relationship(self.type_name, self.template_name)
relationship = Relationship(name=self.template_name, type_name=self.type_name)
instantiate_dict(context, container,
relationship.properties, self.properties)
instantiate_dict(context, container,
@@ -0,0 +1,68 @@
tosca_definitions_version: tosca_simple_yaml_1_0

description: >-
TOSCA simple profile with server and attached block storage using the normative AttachesTo
Relationship Type.
metadata:
template_name: block-storage-1
template_author: TOSCA Simple Profile in YAML
template_version: '1.0'

topology_template:

inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: scalar-unit.size
description: Size of the storage to be created.
default: 1 GB
storage_snapshot_id:
type: string
description: >-
Optional identifier for an existing snapshot to use when creating storage.
storage_location:
type: string
description: Block storage mount point (filesystem path).

node_templates:

my_server:
type: Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 1 GB
os:
properties:
architecture: x86_64
type: linux
distribution: fedora
version: 18.0
requirements:
- local_storage:
node: my_storage
relationship:
type: AttachesTo
properties:
location: { get_input: storage_location }

my_storage:
type: BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }

outputs:
private_ip:
description: The private IP address of the newly created compute instance.
value: { get_attribute: [ my_server, private_address ] }
volume_id:
description: The volume id of the block storage instance.
value: { get_attribute: [ my_storage, volume_id ] }
@@ -0,0 +1,75 @@
tosca_definitions_version: tosca_simple_yaml_1_0

description: >-
TOSCA simple profile with server and attached block storage using a custom AttachesTo Relationship
Type.
metadata:
template_name: block-storage-2
template_author: TOSCA Simple Profile in YAML
template_version: '1.0'

relationship_types:

MyCustomAttachesTo:
derived_from: AttachesTo

topology_template:

inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: scalar-unit.size
description: Size of the storage to be created.
default: 1 GB
storage_snapshot_id:
type: string
description: >-
Optional identifier for an existing snapshot to use when creating storage.
storage_location:
type: string
description: Block storage mount point (filesystem path).

node_templates:

my_server:
type: Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4 GB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
requirements:
- local_storage:
node: my_storage
# Declare custom AttachesTo type using the 'relationship' keyword
relationship:
type: MyCustomAttachesTo
properties:
location: { get_input: storage_location }

my_storage:
type: BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }

outputs:
private_ip:
description: The private IP address of the newly created compute instance.
value: { get_attribute: [ my_server, private_address ] }

volume_id:
description: The volume id of the block storage instance.
value: { get_attribute: [ my_storage, volume_id ] }
@@ -0,0 +1,68 @@
tosca_definitions_version: tosca_simple_yaml_1_0

description: >-
TOSCA simple profile with server and attached block storage using a named Relationship Template
for the storage attachment.
metadata:
template_name: block-storage-3
template_author: TOSCA Simple Profile in YAML
template_version: '1.0'

topology_template:

inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: scalar-unit.size
description: Size of the storage to be created.
default: 1 GB
storage_location:
type: string
description: Block storage mount point (filesystem path).

node_templates:

my_server:
type: Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4 GB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
requirements:
- local_storage:
node: my_storage
# Declare template to use with 'relationship' keyword
relationship: storage_attachment

my_storage:
type: BlockStorage
properties:
size: { get_input: storage_size }

relationship_templates:

storage_attachment:
type: AttachesTo
properties:
location: { get_input: storage_location }

outputs:
private_ip:
description: The private IP address of the newly created compute instance.
value: { get_attribute: [ my_server, private_address ] }
volume_id:
description: The volume id of the block storage instance.
value: { get_attribute: [ my_storage, volume_id ] }
@@ -0,0 +1,96 @@
tosca_definitions_version: tosca_simple_yaml_1_0

description: >-
TOSCA simple profile with a Single Block Storage node shared by 2-Tier Application with custom
AttachesTo Type and implied relationships.
metadata:
template_name: block-storage-4
template_author: TOSCA Simple Profile in YAML
template_version: '1.0'

relationship_types:

MyAttachesTo:
derived_from: tosca.relationships.AttachesTo
properties:
location:
type: string
default: /default_location

topology_template:

inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: scalar-unit.size
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >-
Optional identifier for an existing snapshot to use when creating storage.
node_templates:

my_web_app_tier_1:
type: tosca.nodes.Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
requirements:
- local_storage:
node: my_storage
relationship: MyAttachesTo

my_web_app_tier_2:
type: tosca.nodes.Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
requirements:
- local_storage:
node: my_storage
relationship:
type: MyAttachesTo
properties:
location: /some_other_data_location

my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }

outputs:
private_ip_1:
description: The private IP address of the application's first tier.
value: { get_attribute: [ my_web_app_tier_1, private_address ] }
private_ip_2:
description: The private IP address of the application's second tier.
value: { get_attribute: [ my_web_app_tier_2, private_address ] }
volume_id:
description: The volume id of the block storage instance.
value: { get_attribute: [ my_storage, volume_id ] }

0 comments on commit 787d7e7

Please sign in to comment.