Apply topology_template to tosca_template

Using TopologyTemplate in tosca_template to replace Input, Output,
NodeTemplates and RelationshipTemplates.
But keeping the functions to allow users to get above resources from
ToscaTemplate.
Modified testing templates with 'topology_template' section.

partially implements: bp tosca-topology-template

Change-Id: If3007c81d51f271a53c9940924f46e79a7648021
This commit is contained in:
huruifeng 2015-04-29 10:59:45 +08:00 committed by Huruifeng
parent b6832923b2
commit eef7cc5e36
36 changed files with 1267 additions and 1301 deletions

View File

@ -208,7 +208,8 @@ class TranslateNodeTemplates(object):
relationship_tpl = req
elif rkey == 'template':
relationship_tpl = \
self.tosca._tpl_relationship_templates()[rval]
(self.tosca.topology_template.
_tpl_relationship_templates()[rval])
else:
continue
if relationship_tpl:

View File

@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile for Compute.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
node_templates:
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10
num_cpus: { get_input: cpus }
mem_size: 4096
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
node_templates:
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10
num_cpus: { get_input: cpus }
mem_size: 4096
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
outputs:
server_address:
description: IP address of server instance.
value: { get_attribute: [server, private_address] }
outputs:
server_address:
description: IP address of server instance.
value: { get_attribute: [server, private_address] }

View File

@ -6,103 +6,104 @@ description: >
imports:
- wordpress.yaml
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
db_name:
type: string
description: The name of the database.
db_user:
type: string
description: The user name of the DB user.
db_pwd:
type: string
description: The WordPress database admin account password.
db_root_pwd:
type: string
description: Root password for MySQL.
db_port:
type: integer
description: Port for the MySQL database.
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
db_name:
type: string
description: The name of the database.
db_user:
type: string
description: The user name of the DB user.
db_pwd:
type: string
description: The WordPress database admin account password.
db_root_pwd:
type: string
description: Root password for MySQL.
db_port:
type: integer
description: Port for the MySQL database.
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: Scripts/WordPress/install.sh
configure:
implementation: Scripts/WordPress/configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, db_password ] }
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: Scripts/WordPress/install.sh
configure:
implementation: Scripts/WordPress/configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, db_password ] }
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
requirements:
- host: mysql_dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: Scripts/MYSQLDatabase/configure.sh
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
requirements:
- host: mysql_dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: Scripts/MYSQLDatabase/configure.sh
inputs:
db_name: { get_property: [ SELF, db_name ] }
db_user: { get_property: [ SELF, db_user ] }
db_password: { get_property: [ SELF, db_password ] }
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
mysql_dbms:
type: tosca.nodes.DBMS
properties:
dbms_root_password: { get_input: db_root_pwd }
dbms_port: { get_input: db_port }
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: Scripts/MYSQLDBMS/install.sh
start: Scripts/MYSQLDBMS/start.sh
configure:
implementation: Scripts/MYSQLDBMS/configure.sh
inputs:
db_name: { get_property: [ SELF, db_name ] }
db_user: { get_property: [ SELF, db_user ] }
db_password: { get_property: [ SELF, db_password ] }
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
mysql_dbms:
type: tosca.nodes.DBMS
properties:
dbms_root_password: { get_input: db_root_pwd }
dbms_port: { get_input: db_port }
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: Scripts/MYSQLDBMS/install.sh
start: Scripts/MYSQLDBMS/start.sh
configure:
implementation: Scripts/MYSQLDBMS/configure.sh
inputs:
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
webserver:
type: tosca.nodes.WebServer
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: Scripts/WebServer/install.sh
start: Scripts/WebServer/start.sh
webserver:
type: tosca.nodes.WebServer
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: Scripts/WebServer/install.sh
start: Scripts/WebServer/start.sh
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
outputs:
website_url:
description: IP address for Wordpress wiki.
value: { get_attribute: [server, private_address] }
outputs:
website_url:
description: IP address for Wordpress wiki.
value: { get_attribute: [server, private_address] }

View File

@ -47,18 +47,19 @@ datatype_definitions:
contact_phone:
type: string
node_templates:
positive:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: {Home: 1 foo street, Office: 9 bar avenue}
contacts:
- {contact_name: Tom,
contact_email: tom@email.com,
contact_phone: '123456789'}
- {contact_name: Jerry,
contact_email: jerry@email.com,
contact_phone: '321654987'}
topology_template:
node_templates:
positive:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: {Home: 1 foo street, Office: 9 bar avenue}
contacts:
- {contact_name: Tom,
contact_email: tom@email.com,
contact_phone: '123456789'}
- {contact_name: Jerry,
contact_email: jerry@email.com,
contact_phone: '321654987'}

View File

@ -6,19 +6,20 @@ description: >
imports:
- custom_datatype_def.yaml
node_templates:
# 123456789 is not a string
error in nested datatype:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: {Home: 1 foo street, Office: 9 bar avenue}
contacts:
- {contact_name: Tom,
contact_email: tom@email.com,
contact_phone: 123456789}
- {contact_name: Jerry,
contact_email: jerry@email.com,
contact_phone: '321654987'}
topology_template:
node_templates:
# 123456789 is not a string
error in nested datatype:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: {Home: 1 foo street, Office: 9 bar avenue}
contacts:
- {contact_name: Tom,
contact_email: tom@email.com,
contact_phone: 123456789}
- {contact_name: Jerry,
contact_email: jerry@email.com,
contact_phone: '321654987'}

View File

@ -6,18 +6,19 @@ description: >
imports:
- custom_datatype_def.yaml
node_templates:
positive:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: {Home: 1 foo street, Office: 9 bar avenue}
contacts:
- {contact_name: Tom,
contact_email: tom@email.com,
contact_phone: '123456789'}
- {contact_name: Jerry,
contact_email: jerry@email.com,
contact_phone: '321654987'}
topology_template:
node_templates:
positive:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: {Home: 1 foo street, Office: 9 bar avenue}
contacts:
- {contact_name: Tom,
contact_email: tom@email.com,
contact_phone: '123456789'}
- {contact_name: Jerry,
contact_email: jerry@email.com,
contact_phone: '321654987'}

View File

@ -6,12 +6,13 @@ description: >
imports:
- custom_datatype_def.yaml
node_templates:
# addresses is not a map
error in field value:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: [1 foo street, 9 bar avenue]
topology_template:
node_templates:
# addresses is not a map
error in field value:
type: tosca.nodes.my.SomeNode
properties:
people:
name: Mike
gender: male
addresses: [1 foo street, 9 bar avenue]

View File

@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA template for testing get_attribute with HOST keyword.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
dbms:
type: tosca.nodes.DBMS
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: configure.sh
inputs:
ip_address: { get_attribute: [ HOST, private_address ] }
dbms:
type: tosca.nodes.DBMS
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: configure.sh
inputs:
ip_address: { get_attribute: [ HOST, private_address ] }
database:
type: tosca.nodes.Database
requirements:
- host: dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: configure.sh
inputs:
ip_address: { get_attribute: [ HOST, private_address ] }
database:
type: tosca.nodes.Database
requirements:
- host: dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: configure.sh
inputs:
ip_address: { get_attribute: [ HOST, private_address ] }

View File

@ -3,14 +3,15 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA template for testing get_attribute with HOST keyword.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: configure.sh
inputs:
ip_address: { get_attribute: [ HOST, private_address ] }
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: configure.sh
inputs:
ip_address: { get_attribute: [ HOST, private_address ] }

View File

@ -3,12 +3,13 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA template for testing get_attribute with HOST keyword.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
outputs:
ip_address:
value: { get_attribute: [ HOST, private_address ] }
outputs:
ip_address:
value: { get_attribute: [ HOST, private_address ] }

View File

@ -4,22 +4,23 @@ description: >
Tosca template for testing unknown attribute name in get_attribute
function.
inputs:
image_id:
type: string
topology_template:
inputs:
image_id:
type: string
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: start_server.sh
inputs:
image_id: { get_input: image_id }
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: start_server.sh
inputs:
image_id: { get_input: image_id }
outputs:
ip_address:
value: { get_attribute: [ server, unknown_attribute ] }
outputs:
ip_address:
value: { get_attribute: [ server, unknown_attribute ] }

View File

@ -4,22 +4,23 @@ description: >
Tosca template for testing unknown node template name in get_attribute
function.
inputs:
image_id:
type: string
topology_template:
inputs:
image_id:
type: string
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: start_server.sh
inputs:
image_id: { get_input: image_id }
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: start_server.sh
inputs:
image_id: { get_input: image_id }
outputs:
ip_address:
value: { get_attribute: [ unknown_node_template, private_address ] }
outputs:
ip_address:
value: { get_attribute: [ unknown_node_template, private_address ] }

View File

@ -3,32 +3,33 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
Tosca template for testing an unknown capability property.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
dbms:
type: tosca.nodes.DBMS
properties:
dbms_root_password: 1234
dbms_port: 3672
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
dbms:
type: tosca.nodes.DBMS
properties:
dbms_root_password: 1234
dbms_port: 3672
database:
type: tosca.nodes.Database
properties:
db_name: my_db
db_user: abcd
db_password: 1234
capabilities:
database_endpoint:
properties:
port: { get_property: [ dbms, dbms_port ] }
requirements:
- host: dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: database_configure.sh
inputs:
db_port: { get_property: [ SELF, database_endpoint, unknown ] }
database:
type: tosca.nodes.Database
properties:
db_name: my_db
db_user: abcd
db_password: 1234
capabilities:
database_endpoint:
properties:
port: { get_property: [ dbms, dbms_port ] }
requirements:
- host: dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: database_configure.sh
inputs:
db_port: { get_property: [ SELF, database_endpoint, unknown ] }

View File

@ -4,14 +4,15 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
Tosca template for testing an unknown input.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: start_server.sh
inputs:
image_id: { get_input: image_id }
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: start_server.sh
inputs:
image_id: { get_input: image_id }

View File

@ -3,8 +3,9 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
Tosca template for testing an unknown input.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: { get_input: cpus }
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: { get_input: cpus }

View File

@ -3,39 +3,39 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with 1 network and 1 attached server
inputs:
network_name:
type: string
description: Network name
topology_template:
inputs:
network_name:
type: string
description: Network name
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
my_network:
type: tosca.nodes.network.Network
properties:
ip_version: 4
cidr: '192.168.0.0/24'
network_name: { get_input: network_name }
start_ip: '192.168.0.50'
end_ip: '192.168.0.200'
gateway_ip: '192.168.0.1'
my_port:
type: tosca.nodes.network.Port
requirements:
- binding: my_server
- link: my_network
my_network:
type: tosca.nodes.network.Network
properties:
ip_version: 4
cidr: '192.168.0.0/24'
network_name: { get_input: network_name }
start_ip: '192.168.0.50'
end_ip: '192.168.0.200'
gateway_ip: '192.168.0.1'
my_port:
type: tosca.nodes.network.Port
requirements:
- binding: my_server
- link: my_network

View File

@ -3,60 +3,60 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with 3 networks and 1 attached server
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
topology_template:
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
my_network1:
type: tosca.nodes.network.Network
properties:
cidr: '192.168.1.0/24'
network_name: net1
my_network1:
type: tosca.nodes.network.Network
properties:
cidr: '192.168.1.0/24'
network_name: net1
my_network2:
type: tosca.nodes.network.Network
properties:
cidr: '192.168.2.0/24'
network_name: net2
my_network2:
type: tosca.nodes.network.Network
properties:
cidr: '192.168.2.0/24'
network_name: net2
my_network3:
type: tosca.nodes.network.Network
properties:
cidr: '192.168.3.0/24'
network_name: net3
my_network3:
type: tosca.nodes.network.Network
properties:
cidr: '192.168.3.0/24'
network_name: net3
my_port1:
type: tosca.nodes.network.Port
properties:
order: 0
requirements:
- binding: my_server
- link: my_network1
my_port1:
type: tosca.nodes.network.Port
properties:
order: 0
requirements:
- binding: my_server
- link: my_network1
my_port2:
type: tosca.nodes.network.Port
properties:
order: 1
requirements:
- binding: my_server
- link: my_network2
my_port3:
type: tosca.nodes.network.Port
properties:
order: 2
requirements:
- binding: my_server
- link: my_network3
my_port2:
type: tosca.nodes.network.Port
properties:
order: 1
requirements:
- binding: my_server
- link: my_network2
my_port3:
type: tosca.nodes.network.Port
properties:
order: 2
requirements:
- binding: my_server
- link: my_network3

View File

@ -3,34 +3,34 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with 1 server attached to existing network
inputs:
network_name:
type: string
description: Network name
topology_template:
inputs:
network_name:
type: string
description: Network name
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
my_network:
type: tosca.nodes.network.Network
properties:
network_name: { get_input: network_name }
my_port:
type: tosca.nodes.network.Port
requirements:
- binding: my_server
- link: my_network
my_network:
type: tosca.nodes.network.Network
properties:
network_name: { get_input: network_name }
my_port:
type: tosca.nodes.network.Port
requirements:
- binding: my_server
- link: my_network

View File

@ -3,70 +3,70 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with 1 network and 2 attached servers
inputs:
network_name:
type: string
description: Network name
network_cidr:
type: string
default: 10.0.0.0/24
description: CIDR for the network
network_start_ip:
type: string
default: 10.0.0.100
description: Start IP for the allocation pool
network_end_ip:
type: string
default: 10.0.0.150
description: End IP for the allocation pool
topology_template:
inputs:
network_name:
type: string
description: Network name
network_cidr:
type: string
default: 10.0.0.0/24
description: CIDR for the network
network_start_ip:
type: string
default: 10.0.0.100
description: Start IP for the allocation pool
network_end_ip:
type: string
default: 10.0.0.150
description: End IP for the allocation pool
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
my_server2:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
my_server2:
type: tosca.nodes.Compute
properties:
disk_size: 10
num_cpus: 1
mem_size: 512
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: CirrOS
version: 0.3.2
my_network:
type: tosca.nodes.network.Network
properties:
ip_version: 4
cidr: { get_input: network_cidr }
network_name: { get_input: network_name }
start_ip: { get_input: network_start_ip }
end_ip: { get_input: network_end_ip }
my_network:
type: tosca.nodes.network.Network
properties:
ip_version: 4
cidr: { get_input: network_cidr }
network_name: { get_input: network_name }
start_ip: { get_input: network_start_ip }
end_ip: { get_input: network_end_ip }
my_port:
type: tosca.nodes.network.Port
requirements:
- binding: my_server
- link: my_network
my_port2:
type: tosca.nodes.network.Port
requirements:
- binding: my_server2
- link: my_network
my_port:
type: tosca.nodes.network.Port
requirements:
- binding: my_server
- link: my_network
my_port2:
type: tosca.nodes.network.Port
requirements:
- binding: my_server2
- link: my_network

View File

@ -3,55 +3,56 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with server and attached block storage.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >
Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: >
The relative location (e.g., path on the file system), which provides the root location to address an attached node.
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >
Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: >
The relative location (e.g., path on the file system), which provides the root location to address an attached node.
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: AttachesTo
properties:
location: { get_input: storage_location }
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: AttachesTo
properties:
location: { get_input: storage_location }
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
outputs:
private_ip:
description: 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] }
outputs:
private_ip:
description: 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] }

View File

@ -3,69 +3,70 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with server and attached block storage.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >
Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: >
The relative location (e.g., path on the file system), which provides the root location to address an attached node.
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >
Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: >
The relative location (e.g., path on the file system), which provides the root location to address an attached node.
node_templates:
my_web_app_tier_1:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: MyAttachTo
node_templates:
my_web_app_tier_1:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: MyAttachTo
my_web_app_tier_2:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: MyAttachTo
properties:
location: /some_other_data_location
my_web_app_tier_2:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: MyAttachTo
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 }
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
relationship_types:
MyAttachTo:

View File

@ -3,78 +3,79 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with server and attached block storage.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >
Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: >
The relative location (e.g., path on the file system), which provides the root location to address an attached node.
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: >
Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: >
The relative location (e.g., path on the file system), which provides the root location to address an attached node.
node_templates:
my_web_app_tier_1:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
template: storage_attachesto_1
node_templates:
my_web_app_tier_1:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
template: storage_attachesto_1
my_web_app_tier_2:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
template: storage_attachesto_2
my_web_app_tier_2:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
template: storage_attachesto_2
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
relationship_templates:
storage_attachesto_1:
type: MyAttachTo
properties:
location: /my_data_location
relationship_templates:
storage_attachesto_1:
type: MyAttachTo
properties:
location: /my_data_location
storage_attachesto_2:
type: MyAttachTo
properties:
location: /some_other_data_location
storage_attachesto_2:
type: MyAttachTo
properties:
location: /some_other_data_location
relationship_types:
MyAttachTo:

View File

@ -3,75 +3,76 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with server and attached block storage.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: The relative location (e.g., path on the file system), which provides the root location to address an attached node.
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
storage_size:
type: integer
default: 1 GB
description: Size of the storage to be created.
storage_snapshot_id:
type: string
description: Some identifier that represents an existing snapshot that should be used when creating the block storage.
storage_location:
type: string
description: The relative location (e.g., path on the file system), which provides the root location to address an attached node.
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: AttachesTo
properties:
location: { get_input: storage_location }
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
node_templates:
my_server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage
type: AttachesTo
properties:
location: { get_input: storage_location }
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
my_server2:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage2
type: AttachesTo
properties:
location: { get_input: storage_location }
my_storage2:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
my_server2:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
requirements:
- attachment: my_storage2
type: AttachesTo
properties:
location: { get_input: storage_location }
my_storage2:
type: tosca.nodes.BlockStorage
properties:
size: { get_input: storage_size }
snapshot_id: { get_input: storage_snapshot_id }
outputs:
private_ip:
description: Private IP address of the newly created compute instance.
value: { get_attribute: [my_server, private_address] }
outputs:
private_ip:
description: Private IP address of the newly created compute instance.
value: { get_attribute: [my_server, private_address] }

View File

@ -3,14 +3,15 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
Tosca template for testing a objectstorage template.
inputs:
objectstore_name:
type: string
topology_template:
inputs:
objectstore_name:
type: string
node_templates:
obj_store_server:
type: tosca.nodes.ObjectStorage
properties:
store_name: { get_input: objectstore_name }
store_size: 1024
store_maxsize: 1 GB
node_templates:
obj_store_server:
type: tosca.nodes.ObjectStorage
properties:
store_name: { get_input: objectstore_name }
store_size: 1024
store_maxsize: 1 GB

View File

@ -3,8 +3,9 @@ tosca_definitions_version: tosca_xyz
description: >
Test template with an invalid template version.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2

View File

@ -3,10 +3,11 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
Tosca template for testing a template with no inputs.
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
topology_template:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
outputs:
outputs:

View File

@ -3,10 +3,11 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
Tosca template for testing a template with no outputs.
inputs:
topology_template:
inputs:
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2
node_templates:
server:
type: tosca.nodes.Compute
properties:
num_cpus: 2

View File

@ -6,48 +6,49 @@ description: >
imports:
- custom_types/wordpress.yaml
node_templates:
my_app:
description: >
Specify multiple requirement via node and relationship keyword,
as an explicit relationship. Also demonstrates relationship with
type keyword and without it as an in-line reference.
type: tosca.nodes.WebApplication.WordPress
requirements:
- req1:
node: my_webserver
relationship: tosca.relationships.HostedOn
- req2:
node: mysql_database
relationship:
type: tosca.relationships.ConnectsTo
mysql_database:
description: Specify requirement via a capability as an implicit relationship.
type: tosca.nodes.Database
requirements:
- host: my_dbms
my_dbms:
type: tosca.nodes.DBMS
my_webserver:
type: tosca.nodes.WebServer
my_server:
description: >
Specify requirement via a relationship template, as an explicit relationship.
type: tosca.nodes.Compute
properties:
num_cpus: 2
requirements:
- req1:
node: my_storage
relationship: storage_attachment
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: 1
snapshot_id: id
topology_template:
node_templates:
my_app:
description: >
Specify multiple requirement via node and relationship keyword,
as an explicit relationship. Also demonstrates relationship with
type keyword and without it as an in-line reference.
type: tosca.nodes.WebApplication.WordPress
requirements:
- req1:
node: my_webserver
relationship: tosca.relationships.HostedOn
- req2:
node: mysql_database
relationship:
type: tosca.relationships.ConnectsTo
mysql_database:
description: Specify requirement via a capability as an implicit relationship.
type: tosca.nodes.Database
requirements:
- host: my_dbms
my_dbms:
type: tosca.nodes.DBMS
my_webserver:
type: tosca.nodes.WebServer
my_server:
description: >
Specify requirement via a relationship template, as an explicit relationship.
type: tosca.nodes.Compute
properties:
num_cpus: 2
requirements:
- req1:
node: my_storage
relationship: storage_attachment
my_storage:
type: tosca.nodes.BlockStorage
properties:
size: 1
snapshot_id: id
relationship_templates:
storage_attachment:
type: tosca.relationships.AttachesTo
properties:
location: /temp
relationship_templates:
storage_attachment:
type: tosca.relationships.AttachesTo
properties:
location: /temp

View File

@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with short type name for Compute.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
node_templates:
server:
type: Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
node_templates:
server:
type: Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
outputs:
server_address:
description: IP address of server instance.
value: { get_attribute: [server, private_address] }
outputs:
server_address:
description: IP address of server instance.
value: { get_attribute: [server, private_address] }

View File

@ -1,30 +1,31 @@
description: >
TOSCA simple profile missing version section.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
node_templates:
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
node_templates:
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
outputs:
server_address:
description: IP address of server instance.
value: { get_property: [server, private_address] }
outputs:
server_address:
description: IP address of server instance.
value: { get_property: [server, private_address] }

View File

@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0
description: >
TOSCA simple profile with invalid top-level key: 'node_template'.
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
node_template:
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
node_template:
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
outputs:
server_address:
description: IP address of server instance.
value: { get_property: [server, private_address] }
outputs:
server_address:
description: IP address of server instance.
value: { get_property: [server, private_address] }

View File

@ -37,181 +37,183 @@ dsl_definitions:
implementation: rsyslog/pre_configure_source.py
inputs:
host: { get_attribute: [ TARGET, private_address ]}
inputs:
my_cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
github_url:
type: string
description: The URL to download nodejs.
default: https://github.com/mmm/testnode.git
search_api_port:
type: integer
description: The default elasticsearch http client port.
default: 9200
constraints:
- in_range: [ 9200, 9300 ]
node_templates:
nodejs:
type: tosca.nodes.SoftwareComponent.Nodejs
properties:
github_url: { get_input: github_url }
requirements:
- host: app_server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: nodejs/create.sh
configure:
implementation: nodejs/config.sh
inputs:
github_url: { get_property: [ SELF, github_url ] }
start: nodejs/start.sh
mongo_db:
type: tosca.nodes.Database
requirements:
- host: mongo_dbms
mongo_dbms:
type: tosca.nodes.DBMS
requirements:
- host: mongo_server
properties:
dbms_port: 27017
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: mongodb/create.sh
configure: mongodb/config.sh
start: mongodb/start.sh
elasticsearch:
type: tosca.nodes.SoftwareComponent.Elasticsearch
requirements:
- host: elasticsearch_server
properties:
search_api_port: { get_input: search_api_port }
capabilities:
search_endpoint:
properties:
port: { get_input: search_api_port }
kibana:
type: tosca.nodes.SoftwareComponent.Kibana
requirements:
- host: kibana_server
- search_endpoint: elasticsearch
logstash:
type: tosca.nodes.SoftwareComponent.Logstash
requirements:
- host: logstash_server
- search_endpoint: elasticsearch
interfaces:
tosca.interfaces.relationship.Configure:
pre_configure_source:
implementation: pre_configure_source.py
inputs:
host: { get_attribute: [ TARGET, private_address ] }
port: { get_attribute: [ TARGET, port ] }
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: lostash/create.sh
configure: logstash/config.sh
start: logstash/start.sh
app_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: app_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
app_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: app_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
mongodb_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: mongo_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
mongodb_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: mongo_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
elasticsearch_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: elasticsearch_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
elasticsearch_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: logstash_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
logstash_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: logstash_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
logstash_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: elasticsearch_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
topology_template:
inputs:
my_cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
github_url:
type: string
description: The URL to download nodejs.
default: https://github.com/mmm/testnode.git
search_api_port:
type: integer
description: The default elasticsearch http client port.
default: 9200
constraints:
- in_range: [ 9200, 9300 ]
mongo_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
app_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
elasticsearch_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
logstash_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
kibana_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
node_templates:
nodejs:
type: tosca.nodes.SoftwareComponent.Nodejs
properties:
github_url: { get_input: github_url }
requirements:
- host: app_server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: nodejs/create.sh
configure:
implementation: nodejs/config.sh
inputs:
github_url: { get_property: [ SELF, github_url ] }
start: nodejs/start.sh
mongo_db:
type: tosca.nodes.Database
requirements:
- host: mongo_dbms
mongo_dbms:
type: tosca.nodes.DBMS
requirements:
- host: mongo_server
properties:
dbms_port: 27017
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: mongodb/create.sh
configure: mongodb/config.sh
start: mongodb/start.sh
elasticsearch:
type: tosca.nodes.SoftwareComponent.Elasticsearch
requirements:
- host: elasticsearch_server
properties:
search_api_port: { get_input: search_api_port }
capabilities:
search_endpoint:
properties:
port: { get_input: search_api_port }
kibana:
type: tosca.nodes.SoftwareComponent.Kibana
requirements:
- host: kibana_server
- search_endpoint: elasticsearch
logstash:
type: tosca.nodes.SoftwareComponent.Logstash
requirements:
- host: logstash_server
- search_endpoint: elasticsearch
interfaces:
tosca.interfaces.relationship.Configure:
pre_configure_source:
implementation: pre_configure_source.py
inputs:
host: { get_attribute: [ TARGET, private_address ] }
port: { get_attribute: [ TARGET, port ] }
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: lostash/create.sh
configure: logstash/config.sh
start: logstash/start.sh
app_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: app_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
app_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: app_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
mongodb_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: mongo_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
mongodb_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: mongo_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
elasticsearch_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: elasticsearch_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
elasticsearch_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: logstash_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
logstash_collectd:
type: tosca.nodes.SoftwareComponent.Collectd
requirements:
- host: logstash_server
- collectd_endpoint: logstash
interfaces: *collectd_interface
logstash_rsyslog:
type: tosca.nodes.SoftwareComponent.Rsyslog
requirements:
- host: elasticsearch_server
- rsyslog_endpoint: logstash
interfaces: *rsyslog_interface
outputs:
nodejs_url:
description: URL for the nodejs server.
value: { get_attribute: [ app_server, private_address ] }
mongodb_url:
description: URL for the mongodb server.
value: { get_attribute: [ mongo_server, private_address ] }
mongodb_port:
description: Port for the mongodb server.
value: { get_property: [ mongo_dbms, dbms_port ] }
elasticsearch_url:
description: URL for the elasticsearch server.
value: { get_attribute: [ elasticsearch_server, private_address ] }
logstash_url:
description: URL for the logstash server.
value: { get_attribute: [ logstash_server, private_address ] }
kibana_url:
description: URL for the kibana server.
value: { get_attribute: [ kibana_server, private_address ] }
mongo_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
app_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
elasticsearch_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
logstash_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
kibana_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
outputs:
nodejs_url:
description: URL for the nodejs server.
value: { get_attribute: [ app_server, private_address ] }
mongodb_url:
description: URL for the mongodb server.
value: { get_attribute: [ mongo_server, private_address ] }
mongodb_port:
description: Port for the mongodb server.
value: { get_property: [ mongo_dbms, dbms_port ] }
elasticsearch_url:
description: URL for the elasticsearch server.
value: { get_attribute: [ elasticsearch_server, private_address ] }
logstash_url:
description: URL for the logstash server.
value: { get_attribute: [ logstash_server, private_address ] }
kibana_url:
description: URL for the kibana server.
value: { get_attribute: [ kibana_server, private_address ] }

View File

@ -18,68 +18,68 @@ dsl_definitions:
distribution: Ubuntu
version: 14.04
inputs:
my_cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
default: 1
github_url:
type: string
description: The URL to download nodejs.
default: https://github.com/sample.git
topology_template:
inputs:
my_cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
default: 1
github_url:
type: string
description: The URL to download nodejs.
default: https://github.com/sample.git
node_templates:
nodejs:
type: tosca.nodes.SoftwareComponent.Nodejs
properties:
github_url: https://github.com/sample.git
requirements:
- host: app_server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: nodejs/create.sh
configure:
implementation: nodejs/config.sh
inputs:
github_url: { get_property: [ SELF, github_url ] }
mongodb_ip: { get_attribute: [mongo_server, private_address] }
start: nodejs/start.sh
node_templates:
nodejs:
type: tosca.nodes.SoftwareComponent.Nodejs
properties:
github_url: https://github.com/sample.git
requirements:
- host: app_server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: nodejs/create.sh
configure:
implementation: nodejs/config.sh
inputs:
github_url: { get_property: [ SELF, github_url ] }
mongodb_ip: { get_attribute: [mongo_server, private_address] }
start: nodejs/start.sh
mongo_dbms:
type: tosca.nodes.DBMS
requirements:
- host: mongo_server
properties:
dbms_port: 27017
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: mongodb/create.sh
configure:
implementation: mongodb/config.sh
inputs:
mongodb_ip: { get_attribute: [mongo_server, private_address] }
start: mongodb/start.sh
mongo_dbms:
type: tosca.nodes.DBMS
requirements:
- host: mongo_server
properties:
dbms_port: 27017
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: mongodb/create.sh
configure:
implementation: mongodb/config.sh
inputs:
mongodb_ip: { get_attribute: [mongo_server, private_address] }
start: mongodb/start.sh
mongo_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
app_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
outputs:
nodejs_url:
description: URL for the nodejs server, http://<IP>:3000
value: { get_attribute: [app_server, private_address] }
mongodb_url:
description: URL for the mongodb server.
value: { get_attribute: [mongo_server, private_address] }
mongo_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
app_server:
type: tosca.nodes.Compute
properties: *ubuntu_node
capabilities:
os:
properties: *os_capabilities
outputs:
nodejs_url:
description: URL for the nodejs server, http://<IP>:3000
value: { get_attribute: [app_server, private_address] }
mongodb_url:
description: URL for the mongodb server.
value: { get_attribute: [mongo_server, private_address] }

View File

@ -6,111 +6,112 @@ description: >
imports:
- custom_types/wordpress.yaml
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
db_name:
type: string
description: The name of the database.
default: wordpress
db_user:
type: string
description: The user name of the DB user.
db_pwd:
type: string
description: The WordPress database admin account password.
db_root_pwd:
type: string
description: Root password for MySQL.
db_port:
type: integer
description: Port for the MySQL database.
default: 3306
topology_template:
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraints:
- valid_values: [ 1, 2, 4, 8 ]
db_name:
type: string
description: The name of the database.
default: wordpress
db_user:
type: string
description: The user name of the DB user.
db_pwd:
type: string
description: The WordPress database admin account password.
db_root_pwd:
type: string
description: Root password for MySQL.
db_port:
type: integer
description: Port for the MySQL database.
default: 3306
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: wordpress/wordpress_install.sh
configure:
implementation: wordpress/wordpress_configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, db_password ] }
wp_db_port: { get_property: [ SELF, database_endpoint, port ] }
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: wordpress/wordpress_install.sh
configure:
implementation: wordpress/wordpress_configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, db_password ] }
wp_db_port: { get_property: [ SELF, database_endpoint, port ] }
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
capabilities:
database_endpoint:
properties:
port: { get_input: db_port }
requirements:
- host: mysql_dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: mysql/mysql_database_configure.sh
inputs:
db_name: { get_property: [ SELF, db_name ] }
db_user: { get_property: [ SELF, db_user ] }
db_password: { get_property: [ SELF, db_password ] }
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
db_port: { get_property: [ SELF, database_endpoint, port ] }
mysql_dbms:
type: tosca.nodes.DBMS
properties:
dbms_root_password: { get_input: db_root_pwd }
dbms_port: { get_input: db_port }
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: mysql/mysql_dbms_install.sh
start: mysql/mysql_dbms_start.sh
configure:
implementation: mysql/mysql_dbms_configure.sh
inputs:
db_user: { get_input: db_user }
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
capabilities:
database_endpoint:
properties:
port: { get_input: db_port }
requirements:
- host: mysql_dbms
interfaces:
tosca.interfaces.node.lifecycle.Standard:
configure:
implementation: mysql/mysql_database_configure.sh
inputs:
db_name: { get_property: [ SELF, db_name ] }
db_user: { get_property: [ SELF, db_user ] }
db_password: { get_property: [ SELF, db_password ] }
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
db_port: { get_property: [ SELF, database_endpoint, port ] }
mysql_dbms:
type: tosca.nodes.DBMS
properties:
dbms_root_password: { get_input: db_root_pwd }
dbms_port: { get_input: db_port }
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: mysql/mysql_dbms_install.sh
start: mysql/mysql_dbms_start.sh
configure:
implementation: mysql/mysql_dbms_configure.sh
inputs:
db_user: { get_input: db_user }
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
webserver:
type: tosca.nodes.WebServer
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: webserver/webserver_install.sh
start: webserver/webserver_start.sh
webserver:
type: tosca.nodes.WebServer
requirements:
- host: server
interfaces:
tosca.interfaces.node.lifecycle.Standard:
create: webserver/webserver_install.sh
start: webserver/webserver_start.sh
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
server:
type: tosca.nodes.Compute
properties:
# compute properties (flavor)
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
capabilities:
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18
outputs:
website_url:
description: URL for Wordpress wiki.
value: { get_attribute: [server, private_address] }
outputs:
website_url:
description: URL for Wordpress wiki.
value: { get_attribute: [server, private_address] }

View File

@ -119,7 +119,10 @@ class TopologyTemplate(object):
pass
def _tpl_description(self):
return self.tpl[DESCRIPTION].rstrip()
description = self.tpl.get(DESCRIPTION)
if description:
description = description.rstrip()
return description
def _tpl_inputs(self):
return self.tpl.get(INPUTS) or {}

View File

@ -17,28 +17,22 @@ import os
from translator.toscalib.common.exception import InvalidTemplateVersion
from translator.toscalib.common.exception import MissingRequiredFieldError
from translator.toscalib.common.exception import UnknownFieldError
from translator.toscalib import functions
from translator.toscalib.nodetemplate import NodeTemplate
from translator.toscalib.parameters import Input
from translator.toscalib.parameters import Output
from translator.toscalib.relationship_template import RelationshipTemplate
from translator.toscalib.topology_template import TopologyTemplate
from translator.toscalib.tpl_relationship_graph import ToscaGraph
import translator.toscalib.utils.yamlparser
# TOSCA template key names
SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME,
TEMPLATE_AUTHOR, TEMPLATE_VERSION, DESCRIPTION, IMPORTS,
DSL_DEFINITIONS, INPUTS, NODE_TEMPLATES, RELATIONSHIP_TEMPLATES,
NODE_TYPES, RELATIONSHIP_TYPES, CAPABILITY_TYPES, ARTIFACT_TYPES,
OUTPUTS, GROUPS, DATATYPE_DEFINITIONS) = \
TOPOLOGY_TEMPLATE, TEMPLATE_AUTHOR, TEMPLATE_VERSION,
DESCRIPTION, IMPORTS, DSL_DEFINITIONS, NODE_TYPES,
RELATIONSHIP_TYPES, CAPABILITY_TYPES, ARTIFACT_TYPES,
DATATYPE_DEFINITIONS) = \
('tosca_definitions_version', 'tosca_default_namespace',
'template_name', 'template_author', 'template_version',
'description', 'imports', 'dsl_definitions', 'inputs',
'node_templates', 'relationship_templates', 'node_types',
'relationship_types', 'capability_types', 'artifact_types',
'outputs', 'groups', 'datatype_definitions')
'template_name', 'topology_template', 'template_author',
'template_version', 'description', 'imports', 'dsl_definitions',
'node_types', 'relationship_types', 'capability_types',
'artifact_types', 'datatype_definitions')
log = logging.getLogger("tosca.model")
@ -56,58 +50,28 @@ class ToscaTemplate(object):
self._validate_field()
self.version = self._tpl_version()
self.description = self._tpl_description()
self.topology_template = self._topology_template()
self.inputs = self._inputs()
self.relationship_templates = self._relationship_templates()
self.nodetemplates = self._nodetemplates()
self.outputs = self._outputs()
self.graph = ToscaGraph(self.nodetemplates)
self._process_intrinsic_functions()
def _topology_template(self):
return TopologyTemplate(self._tpl_topology_template(),
self._get_all_custom_defs())
def _inputs(self):
inputs = []
for name, attrs in self._tpl_inputs().items():
input = Input(name, attrs)
input.validate()
inputs.append(input)
return inputs
return self.topology_template.inputs
def _nodetemplates(self):
custom_defs = {}
node_types = self._get_custom_types(NODE_TYPES)
if node_types:
custom_defs.update(node_types)
data_types = self._get_custom_types(DATATYPE_DEFINITIONS)
if data_types:
custom_defs.update(data_types)
capability_types = self._get_custom_types(CAPABILITY_TYPES)
if capability_types:
custom_defs.update(capability_types)
nodetemplates = []
tpls = self._tpl_nodetemplates()
for name in tpls:
tpl = NodeTemplate(name, tpls, custom_defs,
self.relationship_templates)
tpl.validate(self)
nodetemplates.append(tpl)
return nodetemplates
return self.topology_template.nodetemplates
def _relationship_templates(self):
custom_defs = self._get_custom_types(RELATIONSHIP_TYPES)
rel_templates = []
tpls = self._tpl_relationship_templates()
for name in tpls:
tpl = RelationshipTemplate(tpls[name], name, custom_defs)
rel_templates.append(tpl)
return rel_templates
return self.topology_template.relationship_templates
def _outputs(self):
outputs = []
for name, attrs in self._tpl_outputs().items():
output = Output(name, attrs)
output.validate()
outputs.append(output)
return outputs
return self.topology_template.outputs
def _tpl_version(self):
return self.tpl[DEFINITION_VERSION]
@ -119,11 +83,21 @@ class ToscaTemplate(object):
if IMPORTS in self.tpl:
return self.tpl[IMPORTS]
def _tpl_inputs(self):
return self.tpl.get(INPUTS) or {}
def _tpl_relationship_types(self):
return self._get_custom_types(RELATIONSHIP_TYPES)
def _tpl_nodetemplates(self):
return self.tpl[NODE_TEMPLATES]
def _tpl_topology_template(self):
return self.tpl.get(TOPOLOGY_TEMPLATE)
def _get_all_custom_defs(self):
types = [NODE_TYPES, CAPABILITY_TYPES, RELATIONSHIP_TYPES,
DATATYPE_DEFINITIONS]
custom_defs = {}
for type in types:
custom_def = self._get_custom_types(type)
if custom_def:
custom_defs.update(custom_def)
return custom_defs
def _get_custom_types(self, type_definition):
# Handle custom types defined in outer template file
@ -147,15 +121,6 @@ class ToscaTemplate(object):
custom_defs.update(inner_custom_types)
return custom_defs
def _tpl_relationship_templates(self):
return self.tpl.get(RELATIONSHIP_TEMPLATES) or {}
def _tpl_relationship_types(self):
return self._get_custom_types(RELATIONSHIP_TYPES)
def _tpl_outputs(self):
return self.tpl.get(OUTPUTS) or {}
def _validate_field(self):
try:
version = self._tpl_version()
@ -167,38 +132,6 @@ class ToscaTemplate(object):
if name not in SECTIONS:
raise UnknownFieldError(what='Template', field=name)
def _process_intrinsic_functions(self):
"""Process intrinsic functions
Current implementation processes functions within node template
properties, requirements, interfaces inputs and template outputs.
"""
for node_template in self.nodetemplates:
for prop in node_template.get_properties_objects():
prop.value = functions.get_function(self,
node_template,
prop.value)
for interface in node_template.interfaces:
if interface.inputs:
for name, value in interface.inputs.items():
interface.inputs[name] = functions.get_function(
self,
node_template,
value)
if node_template.requirements:
for req in node_template.requirements:
if 'properties' in req:
for key, value in req['properties'].items():
req['properties'][key] = functions.get_function(
self,
req,
value)
for output in self.outputs:
func = functions.get_function(self, self.outputs, output.value)
if isinstance(func, functions.GetAttribute):
output.attrs[output.VALUE] = func
def _validate_version(self, version):
if version not in self.VALID_TEMPLATE_VERSIONS:
raise InvalidTemplateVersion(