Merge "Fix user_data handling in VDU.Tacker node type"
This commit is contained in:
commit
2044d0e212
@ -0,0 +1,29 @@
|
||||
heat_template_version: 2013-05-23
|
||||
description: 'OpenWRT with services
|
||||
|
||||
'
|
||||
parameters: {}
|
||||
resources:
|
||||
VDU1:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
config_drive: false
|
||||
flavor: m1.tiny
|
||||
image: OpenWRT
|
||||
networks:
|
||||
- port:
|
||||
get_resource: CP1
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
echo "my hostname is `hostname`" > /tmp/hostname
|
||||
df -h > /home/openwrt/diskinfo
|
||||
CP1:
|
||||
type: OS::Neutron::Port
|
||||
properties:
|
||||
network: existing_network_1
|
||||
port_security_enabled: false
|
||||
outputs:
|
||||
mgmt_ip-VDU1:
|
||||
value:
|
||||
get_attr: [CP1, fixed_ips, 0, ip_address]
|
@ -0,0 +1,49 @@
|
||||
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
|
||||
|
||||
description: OpenWRT with services
|
||||
|
||||
metadata:
|
||||
template_name: OpenWRT
|
||||
|
||||
topology_template:
|
||||
node_templates:
|
||||
|
||||
VDU1:
|
||||
type: tosca.nodes.nfv.VDU.Tacker
|
||||
properties:
|
||||
image: OpenWRT
|
||||
flavor: m1.tiny
|
||||
config: |
|
||||
param0: key1
|
||||
param1: key2
|
||||
mgmt_driver: openwrt
|
||||
monitoring_policy:
|
||||
name: ping
|
||||
actions:
|
||||
failure: respawn
|
||||
parameters:
|
||||
count: 3
|
||||
interval: 10
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
echo "my hostname is `hostname`" > /tmp/hostname
|
||||
df -h > /home/openwrt/diskinfo
|
||||
|
||||
CP1:
|
||||
type: tosca.nodes.nfv.CP.Tacker
|
||||
properties:
|
||||
management: true
|
||||
anti_spoofing_protection: false
|
||||
requirements:
|
||||
- virtualLink:
|
||||
node: VL1
|
||||
- virtualBinding:
|
||||
node: VDU1
|
||||
|
||||
VL1:
|
||||
type: tosca.nodes.nfv.VL
|
||||
properties:
|
||||
network_name: existing_network_1
|
||||
vendor: ACME
|
||||
|
@ -265,6 +265,11 @@ class TestDeviceHeat(base.TestCase):
|
||||
self._test_assert_equal_for_tosca_templates('test_tosca_openwrt.yaml',
|
||||
'hot_tosca_openwrt.yaml')
|
||||
|
||||
def test_create_tosca_with_userdata(self):
|
||||
self._test_assert_equal_for_tosca_templates(
|
||||
'test_tosca_openwrt_userdata.yaml',
|
||||
'hot_tosca_openwrt_userdata.yaml')
|
||||
|
||||
def test_create_tosca_with_new_flavor(self):
|
||||
self._test_assert_equal_for_tosca_templates('test_tosca_flavor.yaml',
|
||||
'hot_flavor.yaml')
|
||||
|
@ -49,6 +49,15 @@ node_types:
|
||||
type: string
|
||||
required: false
|
||||
|
||||
user_data:
|
||||
type: string
|
||||
required: false
|
||||
|
||||
user_data_format:
|
||||
type: string
|
||||
required: false
|
||||
|
||||
|
||||
tosca.nodes.nfv.CP.Tacker:
|
||||
derived_from: tosca.nodes.nfv.CP
|
||||
properties:
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
@ -177,6 +178,18 @@ def convert_unsupported_res_prop(heat_dict, unsupported_res_prop):
|
||||
@log.log
|
||||
def post_process_heat_template(heat_tpl, mgmt_ports, res_tpl,
|
||||
unsupported_res_prop=None):
|
||||
#
|
||||
# TODO(bobh) - remove when heat-translator can support literal strings.
|
||||
#
|
||||
def fix_user_data(user_data_string):
|
||||
user_data_string = re.sub('user_data: #', 'user_data: |\n #',
|
||||
user_data_string, re.MULTILINE)
|
||||
return re.sub('\n\n', '\n', user_data_string, re.MULTILINE)
|
||||
|
||||
heat_tpl = fix_user_data(heat_tpl)
|
||||
#
|
||||
# End temporary workaround for heat-translator
|
||||
#
|
||||
heat_dict = yamlparser.simple_ordered_parse(heat_tpl)
|
||||
for outputname, portname in mgmt_ports.items():
|
||||
ipval = {'get_attr': [portname, 'fixed_ips', 0, 'ip_address']}
|
||||
|
Loading…
x
Reference in New Issue
Block a user