Implement SoftwareComponent and WebApplication normative types
Add support for translating TOSCA normative types tosca.nodes.SoftwareComponent and tosca.nodes.WebApplication and added unit tests for them. Change-Id: I4b2bf955b5ca5181fc0021cd5633722cd449fbc6 Closes-Bug: #1479132
This commit is contained in:
parent
b1075e9992
commit
518676d738
|
@ -0,0 +1,27 @@
|
|||
#
|
||||
# Licensed 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 translator.hot.syntax.hot_resource import HotResource
|
||||
|
||||
|
||||
class ToscaSoftwareComponent(HotResource):
|
||||
'''Translate TOSCA node type tosca.nodes.SoftwareComponent.'''
|
||||
|
||||
toscatype = 'tosca.nodes.SoftwareComponent'
|
||||
|
||||
def __init__(self, nodetemplate):
|
||||
super(ToscaSoftwareComponent, self).__init__(nodetemplate)
|
||||
pass
|
||||
|
||||
def handle_properties(self):
|
||||
pass
|
|
@ -0,0 +1,27 @@
|
|||
#
|
||||
# Licensed 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 translator.hot.syntax.hot_resource import HotResource
|
||||
|
||||
|
||||
class ToscaWebApplication(HotResource):
|
||||
'''Translate TOSCA node type tosca.nodes.WebApplication.'''
|
||||
|
||||
toscatype = 'tosca.nodes.WebApplication'
|
||||
|
||||
def __init__(self, nodetemplate):
|
||||
super(ToscaWebApplication, self).__init__(nodetemplate)
|
||||
pass
|
||||
|
||||
def handle_properties(self):
|
||||
pass
|
|
@ -36,6 +36,10 @@ from translator.hot.tosca.tosca_dbms import ToscaDbms
|
|||
from translator.hot.tosca.tosca_network_network import ToscaNetwork
|
||||
from translator.hot.tosca.tosca_network_port import ToscaNetworkPort
|
||||
from translator.hot.tosca.tosca_object_storage import ToscaObjectStorage
|
||||
from translator.hot.tosca.tosca_software_component import (
|
||||
ToscaSoftwareComponent
|
||||
)
|
||||
from translator.hot.tosca.tosca_web_application import ToscaWebApplication
|
||||
from translator.hot.tosca.tosca_webserver import ToscaWebserver
|
||||
from translator.toscalib.functions import GetAttribute
|
||||
from translator.toscalib.functions import GetInput
|
||||
|
@ -65,8 +69,10 @@ TOSCA_TO_HOT_TYPE = {'tosca.nodes.Compute': ToscaCompute,
|
|||
'tosca.nodes.WebServer': ToscaWebserver,
|
||||
'tosca.nodes.DBMS': ToscaDbms,
|
||||
'tosca.nodes.Database': ToscaDatabase,
|
||||
'tosca.nodes.WebApplication': ToscaWebApplication,
|
||||
'tosca.nodes.WebApplication.WordPress': ToscaWordpress,
|
||||
'tosca.nodes.BlockStorage': ToscaBlockStorage,
|
||||
'tosca.nodes.SoftwareComponent': ToscaSoftwareComponent,
|
||||
'tosca.nodes.SoftwareComponent.Nodejs': ToscaNodejs,
|
||||
'tosca.nodes.network.Network': ToscaNetwork,
|
||||
'tosca.nodes.network.Port': ToscaNetworkPort,
|
||||
|
|
|
@ -281,3 +281,25 @@ class ToscaHotTranslationTest(TestCase):
|
|||
params)
|
||||
self.assertEqual({}, diff, '<difference> : ' +
|
||||
json.dumps(diff, indent=4, separators=(', ', ': ')))
|
||||
|
||||
def test_hot_translate_software_component(self):
|
||||
tosca_file = '../toscalib/tests/data/tosca_software_component.yaml'
|
||||
hot_file = '../toscalib/tests/data/hot_output/' \
|
||||
'hot_software_component.yaml'
|
||||
params = {'cpus': '1',
|
||||
'download_url': 'http://www.software.com/download'}
|
||||
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
|
||||
hot_file,
|
||||
params)
|
||||
self.assertEqual({}, diff, '<difference> : ' +
|
||||
json.dumps(diff, indent=4, separators=(', ', ': ')))
|
||||
|
||||
def test_hot_translate_web_application(self):
|
||||
tosca_file = '../toscalib/tests/data/tosca_web_application.yaml'
|
||||
hot_file = '../toscalib/tests/data/hot_output/hot_web_application.yaml'
|
||||
params = {'cpus': '2', 'context_root': 'my_web_app'}
|
||||
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
|
||||
hot_file,
|
||||
params)
|
||||
self.assertEqual({}, diff, '<difference> : ' +
|
||||
json.dumps(diff, indent=4, separators=(', ', ': ')))
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
heat_template_version: 2013-05-23
|
||||
|
||||
description: >
|
||||
TOSCA simple profile with a software component.
|
||||
|
||||
parameters:
|
||||
cpus:
|
||||
type: number
|
||||
description: Number of CPUs for the server.
|
||||
default: 1
|
||||
constraints:
|
||||
- allowed_values:
|
||||
- 1
|
||||
- 2
|
||||
- 4
|
||||
- 8
|
||||
|
||||
resources:
|
||||
server:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
flavor: m1.small
|
||||
image: ubuntu-software-config-os-init
|
||||
key_name: userkey
|
||||
user_data_format: SOFTWARE_CONFIG
|
||||
|
||||
my_software_create_deploy:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
properties:
|
||||
config:
|
||||
get_resource: my_software_create_config
|
||||
server:
|
||||
get_resource: server
|
||||
|
||||
my_software_create_config:
|
||||
type: OS::Heat::SoftwareConfig
|
||||
properties:
|
||||
config:
|
||||
get_file: software_install.sh
|
||||
group: script
|
||||
|
||||
my_software_start_deploy:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
properties:
|
||||
config:
|
||||
get_resource: my_software_start_config
|
||||
server:
|
||||
get_resource: server
|
||||
depends_on:
|
||||
- my_software_create_deploy
|
||||
|
||||
my_software_start_config:
|
||||
type: OS::Heat::SoftwareConfig
|
||||
properties:
|
||||
config:
|
||||
get_file: software_start.sh
|
||||
group: script
|
||||
|
||||
outputs: {}
|
|
@ -0,0 +1,100 @@
|
|||
heat_template_version: 2013-05-23
|
||||
|
||||
description: >
|
||||
TOSCA simple profile with a web application.
|
||||
|
||||
parameters:
|
||||
context_root:
|
||||
type: string
|
||||
description: Context root for installing the application.
|
||||
default: my_web_app
|
||||
|
||||
cpus:
|
||||
type: number
|
||||
description: Number of CPUs for the server.
|
||||
default: 2
|
||||
constraints:
|
||||
- allowed_values:
|
||||
- 1
|
||||
- 2
|
||||
- 4
|
||||
- 8
|
||||
|
||||
resources:
|
||||
server:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
flavor: m1.small
|
||||
image: ubuntu-software-config-os-init
|
||||
key_name: userkey
|
||||
user_data_format: SOFTWARE_CONFIG
|
||||
|
||||
web_server_create_deploy:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
properties:
|
||||
config:
|
||||
get_resource: web_server_create_config
|
||||
server:
|
||||
get_resource: server
|
||||
|
||||
web_server_create_config:
|
||||
type: OS::Heat::SoftwareConfig
|
||||
properties:
|
||||
config:
|
||||
get_file: web_server_install.sh
|
||||
group: script
|
||||
|
||||
web_server_start_deploy:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
properties:
|
||||
config:
|
||||
get_resource: web_server_start_config
|
||||
server:
|
||||
get_resource: server
|
||||
depends_on:
|
||||
- web_server_create_deploy
|
||||
|
||||
web_server_start_config:
|
||||
type: OS::Heat::SoftwareConfig
|
||||
properties:
|
||||
config:
|
||||
get_file: web_server_start.sh
|
||||
group: script
|
||||
|
||||
web_app_create_deploy:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
properties:
|
||||
config:
|
||||
get_resource: web_app_create_config
|
||||
input_values:
|
||||
context_root: app
|
||||
server:
|
||||
get_resource: server
|
||||
depends_on:
|
||||
- web_server_start_deploy
|
||||
|
||||
web_app_create_config:
|
||||
type: OS::Heat::SoftwareConfig
|
||||
properties:
|
||||
config:
|
||||
get_file: web_app_install.sh
|
||||
group: script
|
||||
|
||||
web_app_start_deploy:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
properties:
|
||||
config:
|
||||
get_resource: web_app_start_config
|
||||
server:
|
||||
get_resource: server
|
||||
depends_on:
|
||||
- web_app_create_deploy
|
||||
|
||||
web_app_start_config:
|
||||
type: OS::Heat::SoftwareConfig
|
||||
properties:
|
||||
config:
|
||||
get_file: web_app_start.sh
|
||||
group: script
|
||||
|
||||
outputs: {}
|
|
@ -0,0 +1,40 @@
|
|||
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||
|
||||
description: >
|
||||
TOSCA simple profile with a software component.
|
||||
|
||||
topology_template:
|
||||
inputs:
|
||||
cpus:
|
||||
type: integer
|
||||
description: Number of CPUs for the server.
|
||||
constraints:
|
||||
- valid_values: [ 1, 2, 4, 8 ]
|
||||
default: 1
|
||||
|
||||
node_templates:
|
||||
my_software:
|
||||
type: tosca.nodes.SoftwareComponent
|
||||
properties:
|
||||
component_version: 1.0
|
||||
requirements:
|
||||
- host: server
|
||||
interfaces:
|
||||
Standard:
|
||||
create: software_install.sh
|
||||
start: software_start.sh
|
||||
|
||||
server:
|
||||
type: tosca.nodes.Compute
|
||||
capabilities:
|
||||
host:
|
||||
properties:
|
||||
disk_size: 10 GB
|
||||
num_cpus: { get_input: cpus }
|
||||
mem_size: 1024 MB
|
||||
os:
|
||||
properties:
|
||||
architecture: x86_64
|
||||
type: Linux
|
||||
distribution: Ubuntu
|
||||
version: 14.04
|
|
@ -0,0 +1,56 @@
|
|||
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||
|
||||
description: >
|
||||
TOSCA simple profile with a web application.
|
||||
|
||||
topology_template:
|
||||
inputs:
|
||||
cpus:
|
||||
type: integer
|
||||
description: Number of CPUs for the server.
|
||||
constraints:
|
||||
- valid_values: [ 1, 2, 4, 8 ]
|
||||
default: 1
|
||||
context_root:
|
||||
type: string
|
||||
description: Context root for installing the application.
|
||||
default: app
|
||||
|
||||
node_templates:
|
||||
web_app:
|
||||
type: tosca.nodes.WebApplication
|
||||
properties:
|
||||
context_root: { get_input: context_root }
|
||||
requirements:
|
||||
- host: web_server
|
||||
interfaces:
|
||||
Standard:
|
||||
create:
|
||||
implementation: web_app_install.sh
|
||||
inputs:
|
||||
context_root: { get_input: context_root }
|
||||
start: web_app_start.sh
|
||||
|
||||
web_server:
|
||||
type: tosca.nodes.WebServer
|
||||
requirements:
|
||||
- host: server
|
||||
interfaces:
|
||||
Standard:
|
||||
create: web_server_install.sh
|
||||
start: web_server_start.sh
|
||||
|
||||
server:
|
||||
type: tosca.nodes.Compute
|
||||
capabilities:
|
||||
host:
|
||||
properties:
|
||||
disk_size: 10 GB
|
||||
num_cpus: { get_input: cpus }
|
||||
mem_size: 1024 MB
|
||||
os:
|
||||
properties:
|
||||
architecture: x86_64
|
||||
type: Linux
|
||||
distribution: Ubuntu
|
||||
version: 14.04
|
Loading…
Reference in New Issue