Implement tosca-parser/heat-translator integration

Change-Id: Idf902cd01bd369cfede83842e1ae295bff3da710
Implements: bp/tosca-parser-integration
changes/21/278121/22
Bob.Haddleton 7 years ago committed by Bob Haddleton
parent bab51c88b5
commit d6b102b201
  1. 72
      devstack/samples/sample-tosca-vnfd-http-monitor.yaml
  2. 73
      devstack/samples/sample-tosca-vnfd-monitor.yaml
  3. 137
      devstack/samples/sample-tosca-vnfd-multi-vdu.yaml
  4. 63
      devstack/samples/sample-tosca-vnfd.yaml
  5. 71
      devstack/samples/tosca_openwrt.yaml
  6. 1
      requirements.txt
  7. 12
      tacker/extensions/vnfm.py
  8. 72
      tacker/tests/etc/samples/sample-tosca-vnfd-http-monitor.yaml
  9. 73
      tacker/tests/etc/samples/sample-tosca-vnfd-monitor.yaml
  10. 137
      tacker/tests/etc/samples/sample-tosca-vnfd-multi-vdu.yaml
  11. 63
      tacker/tests/etc/samples/sample-tosca-vnfd.yaml
  12. 63
      tacker/tests/functional/vnfm/test_tosca_vnf.py
  13. 82
      tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py
  14. 39
      tacker/tests/functional/vnfm/test_tosca_vnfd.py
  15. 231
      tacker/tests/unit/db/utils.py
  16. 0
      tacker/tests/unit/vm/infra_drivers/__init__.py
  17. 0
      tacker/tests/unit/vm/infra_drivers/heat/__init__.py
  18. 12
      tacker/tests/unit/vm/infra_drivers/heat/data/config_data.yaml
  19. 26
      tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt.yaml
  20. 41
      tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt_ipparams.yaml
  21. 34
      tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt_params.yaml
  22. 24
      tacker/tests/unit/vm/infra_drivers/heat/data/hot_tosca_openwrt.yaml
  23. 35
      tacker/tests/unit/vm/infra_drivers/heat/data/openwrt.yaml
  24. 54
      tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_openwrt.yaml
  25. 17
      tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_param_values_ipaddr.yaml
  26. 16
      tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_param_values_user_data.yaml
  27. 42
      tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_template_ipaddr.yaml
  28. 41
      tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_template_user_data.yaml
  29. 173
      tacker/tests/unit/vm/infra_drivers/heat/test_heat.py
  30. 122
      tacker/tests/unit/vm/test_toscautils.py
  31. 249
      tacker/vm/infra_drivers/heat/heat.py
  32. 0
      tacker/vm/tosca/__init__.py
  33. 82
      tacker/vm/tosca/lib/tacker_defs.yaml
  34. 46
      tacker/vm/tosca/lib/tacker_nfv_defs.yaml
  35. 158
      tacker/vm/tosca/utils.py

@ -0,0 +1,72 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: ubuntu
flavor: m1.small
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
monitoring_policy:
properties:
name: http_ping
monitoring_params:
retry: 5
timeout: 10
port: 8000
actions:
failure: respawn
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,73 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
monitoring_policy:
properties:
name: ping
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: respawn
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,137 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP11:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP12:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP13:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VDU2:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.medium
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP21:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU2
CP22:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU2
CP23:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU2
VDU3:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP31:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU3
CP32:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU3
CP33:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU3
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,63 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,71 @@
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:
- {trigger: failure, action: respawn}
parameters:
count: "3"
interval: "10"
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: pkt_in
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: pkt_out
vendor: Tacker

@ -29,3 +29,4 @@ oslo.rootwrap>=2.0.0 # Apache-2.0
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0
tosca-parser>=0.4.0 # Apache-2.0
heat-translator>=0.4.0 # Apache-2.0

@ -37,6 +37,10 @@ class MGMTDriverNotSpecified(exceptions.InvalidInput):
message = _('mgmt driver is not specified')
class MultipleMGMTDriversSpecified(exceptions.InvalidInput):
message = _('More than one MGMT Driver per template is not supported')
class ServiceTypesNotSpecified(exceptions.InvalidInput):
message = _('service types are not specified')
@ -85,6 +89,14 @@ class ParamYAMLNotWellFormed(exceptions.InvalidInput):
message = _("Parameter YAML not well formed - %(error_msg_details)s")
class ToscaParserFailed(exceptions.InvalidInput):
message = _("tosca-parser failed: - %(error_msg_details)s")
class HeatTranslatorFailed(exceptions.InvalidInput):
message = _("heat-translator failed: - %(error_msg_details)s")
class InputValuesMissing(exceptions.InvalidInput):
message = _("Parameter input values missing for the key '%(key)s'")

@ -0,0 +1,72 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: ubuntu
flavor: m1.small
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
monitoring_policy:
properties:
name: http_ping
monitoring_params:
retry: 5
timeout: 10
port: 8000
actions:
failure: respawn
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,73 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
monitoring_policy:
properties:
name: ping
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: respawn
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,137 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP11:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP12:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP13:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VDU2:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.medium
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP21:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU2
CP22:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU2
CP23:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU2
VDU3:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP31:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU3
CP32:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU3
CP33:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU3
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,63 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL3
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker
VL3:
type: tosca.nodes.nfv.VL
properties:
network_name: net1
vendor: Tacker

@ -0,0 +1,63 @@
# Copyright 2016 Brocade Communications System, Inc.
#
# 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 oslo_config import cfg
from tacker.tests import constants
from tacker.tests.functional.vnfm import base
from tacker.tests.utils import read_file
CONF = cfg.CONF
VNF_CIRROS_CREATE_TIMEOUT = 120
class VnfTestToscaCreate(base.BaseTackerTest):
def test_create_delete_vnf_tosca_no_monitoring(self):
data = dict()
data['tosca'] = read_file('sample-tosca-vnfd.yaml')
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_name = 'test_tosca_vnf_with_cirros_no_monitoring'
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE')
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete failed"
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"

@ -0,0 +1,82 @@
# Copyright 2016 Brocade Communications System, Inc.
# 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 oslo_config import cfg
from tacker.common import utils
from tacker.tests import constants
from tacker.tests.functional.vnfm import base
from tacker.tests.utils import read_file
from tacker.vm.tosca import utils as toscautils
from toscaparser.tosca_template import ToscaTemplate
import yaml
CONF = cfg.CONF
class VnfTestToscaMultipleVDU(base.BaseTackerTest):
def test_create_delete_tosca_vnf_with_multiple_vdus(self):
data = dict()
input_yaml = read_file('sample-tosca-vnfd-multi-vdu.yaml')
data['tosca'] = input_yaml
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name':
"test_tosca_vnf_with_multiple_vdus"}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(self.client.show_vnf(vnf_id)['vnf']['status'],
'ACTIVE')
self.validate_vnf_instance(vnfd_instance, vnf_instance)
# Validate mgmt_url with input yaml file
mgmt_url = self.client.show_vnf(vnf_id)['vnf']['mgmt_url']
self.assertIsNotNone(mgmt_url)
mgmt_dict = yaml.load(str(mgmt_url))
input_dict = yaml.load(input_yaml)
toscautils.updateimports(input_dict)
tosca = ToscaTemplate(parsed_params={}, a_file=False,
yaml_dict_tpl=input_dict)
vdus = toscautils.findvdus(tosca)
self.assertEqual(len(mgmt_dict.keys()), len(vdus))
for vdu in vdus:
self.assertIsNotNone(mgmt_dict[vdu.name])
self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu.name]))
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete of sample-vnfd-multiple-vdus failed"

@ -0,0 +1,39 @@
# Copyright 2016 Brocade Communications System, Inc.
#
# 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 oslo_config import cfg
from tacker.tests.functional.vnfm import base
from tacker.tests.utils import read_file
CONF = cfg.CONF
class VnfdTestCreate(base.BaseTackerTest):
def test_create_list_delete_tosca_vnfd(self):
data = dict()
data['tosca'] = read_file('sample-tosca-vnfd.yaml')
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
vnfds = self.client.list_vnfds().get('vnfds')
self.assertIsNotNone(vnfds, "List of vnfds are Empty after Creation")
vnfd_id = vnfd_instance['vnfd']['id']
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"

@ -13,37 +13,32 @@
# License for the specific language governing permissions and limitations
# under the License.
import codecs
import os
def _get_template(name):
filename = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"../vm/infra_drivers/heat/data/", name)
f = codecs.open(filename, encoding='utf-8', errors='strict')
return f.read()
vnfd_openwrt = _get_template('openwrt.yaml')
vnfd_ipparams_template = _get_template('vnf_cirros_template_ipaddr.yaml')
ipparams = _get_template('vnf_cirros_param_values_ipaddr.yaml')
vnfd_userdata_template = _get_template('vnf_cirros_template_user_data.yaml')
userdata_params = _get_template('vnf_cirros_param_values_user_data.yaml')
config_data = _get_template('config_data.yaml')
def get_dummy_vnfd_obj():
return {u'vnfd': {u'service_types': [{u'service_type': u'vnfd'}],
'name': 'dummy_vnfd', 'tenant_id':
u'ad7ebc56538745a08ef7c5e97f8bd437', u'mgmt_driver': u'noop',
u'infra_driver': u'fake_driver', u'attributes': {u'vnfd':
u'template_name: OpenWRT'
u' \r\ndescription: OpenWRT router'
u'\r\n\r\nservice_properties:\r\n'
u' Id: sample-vnfd\r\n vendor:'
u' tacker\r\n version: '
u'1\r\n\r\nvdus:'
u'\r\n vdu1:\r\n id: vdu1\r\n'
u' vm_image:'
u' cirros-0.3.2-x86_64-uec\r\n'
u' instance_type: m1.tiny\r\n\r\n'
u' network_interfaces:\r\n'
u' management:\r\n'
u' network: net_mgmt\r\n'
u' management: true\r\n'
u' pkt_in:\r\n network:'
u' net0\r\n pkt_out:\r\n'
u' network: net1\r\n\r\n'
u' placement_policy:\r\n'
u' availability_zone: nova\r\n'
u'\r'
u'\n auto-scaling: noop\r\n'
u' monitoring_policy: noop\r\n'
u' failure_policy: noop\r\n\r\n'
u' config:\r\n param0: key0'
u'\r\n param1: key1'},
'name': 'dummy_vnfd',
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
u'mgmt_driver': u'noop',
u'infra_driver': u'fake_driver',
u'attributes': {u'vnfd': vnfd_openwrt},
'description': 'dummy_vnfd_description'},
u'auth': {u'tenantName': u'admin', u'passwordCredentials': {
u'username': u'admin', u'password': u'devstack'}}}
@ -65,61 +60,37 @@ def get_dummy_vnf_config_obj():
def get_dummy_device_obj():
return {'status': 'PENDING_CREATE', 'instance_id': None, 'name':
u'test_openwrt', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'template_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
'device_template': {'service_types': [{'service_type': u'vnfd',
'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], 'description':
u'OpenWRT with services', 'tenant_id':
u'ad7ebc56538745a08ef7c5e97f8bd437', 'mgmt_driver': u'openwrt',
'infra_driver': u'heat', 'attributes': {u'vnfd': u'template_name: '
u'OpenWRT\r\ndescription: OpenWRT with services\r\n\r\nvdus:\r\n '
u'vdu1:\r\n id: vdu1\r\n vm_image: cirros-0.3.2-x86_64-uec\r\n '
u' instance_type: m1.tiny\r\n service_type: firewall\r\n '
u'mgmt_driver: openwrt\r\n\r\n network_interfaces:\r\n '
u'management:\r\n network: net_mgmt\r\n management: True'
u'\r\n pkt_in:\r\n network: net0\r\n pkt_out:\r\n '
u' network: net1\r\n\r\n placement_policy:\r\n '
u'availability_zone: nova\r\n\r\n auto-scaling: noop\r\n\r\n '
u'monitoring_policy: noop\r\n failure_policy: noop\r\n\r\n '
u'monitoring_parameter:\r\n a:\r\n\r\n config:\r\n '
u'param0: key0\r\n param1: key1\r\n\r\n'}, 'id':
u'fb048660-dc1b-4f0f-bd89-b023666650ec', 'name':
u'openwrt_services'}, 'mgmt_url': None, 'service_context': [],
'attributes': {u'param_values': u''}, 'id':
'eb84260e-5ff7-4332-b032-50a14d6c1123', 'description':
u'OpenWRT with services'}
'template_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
'device_template': {'service_types': [{'service_type': u'vnfd',
'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}],
'description': u'OpenWRT with services',
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'mgmt_driver': u'openwrt',
'infra_driver': u'heat',
'attributes': {u'vnfd': vnfd_openwrt},
'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec',
'name': u'openwrt_services'},
'mgmt_url': None, 'service_context': [],
'attributes': {u'param_values': u''},
'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': u'OpenWRT with services'}
def get_dummy_device_obj_config_attr():
return {'status': 'PENDING_CREATE', 'instance_id': None, 'name':
u'test_openwrt', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'template_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
'device_template': {'service_types': [{'service_type': u'vnfd',
'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], 'description':
u'OpenWRT with services', 'tenant_id':
u'ad7ebc56538745a08ef7c5e97f8bd437', 'mgmt_driver': u'openwrt',
'infra_driver': u'heat', 'attributes': {u'vnfd': u'template_name: '
u'OpenWRT\r\ndescription: OpenWRT with services\r\n\r\nvdus:\r\n '
u'vdu1:\r\n id: vdu1\r\n vm_image: cirros-0.3.2-x86_64-uec\r\n '
u' instance_type: m1.tiny\r\n service_type: firewall\r\n '
u'mgmt_driver: openwrt\r\n\r\n network_interfaces:\r\n '
u'management:\r\n network: net_mgmt\r\n management: True'
u'\r\n pkt_in:\r\n network: net0\r\n pkt_out:\r\n '
u' network: net1\r\n\r\n placement_policy:\r\n '
u'availability_zone: nova\r\n\r\n auto-scaling: noop\r\n\r\n '
u'monitoring_policy: noop\r\n failure_policy: noop\r\n\r\n '
u'monitoring_parameter:\r\n a:\r\n\r\n config:\r\n '
u'param0: key0\r\n param1: key1\r\n\r\n'}, 'id':
u'fb048660-dc1b-4f0f-bd89-b023666650ec', 'name':
'template_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
'device_template': {'service_types': [{'service_type': u'vnfd',
'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}],
'description': u'OpenWRT with services',
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'mgmt_driver': u'openwrt',
'infra_driver': u'heat',
'attributes': {u'vnfd': vnfd_openwrt},
'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec', 'name':
u'openwrt_services'}, 'mgmt_url': None, 'service_context': [],
'attributes': {u'config': u"vdus:\n vdu1:\n config:\n "
u"firewall: |\n package firewall"
u"\n\n config defaults\n "
u" option syn_flood '1'\n "
u" option input 'ACCEPT'\n "
u" option output 'ACCEPT'\n "
u" option forward "
u"'REJECT'\n"}, 'id':
'eb84260e-5ff7-4332-b032-50a14d6c1123',
'attributes': {u'config': config_data},
'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': u'OpenWRT with services'}
@ -138,86 +109,46 @@ def get_dummy_device_update_config_attr():
def get_dummy_device_obj_ipaddr_attr():
return {'status': 'PENDING_CREATE', 'device_template': {'service_types':
return {'status': 'PENDING_CREATE',
'device_template': {'service_types':
[{'service_type': u'vnfd', 'id':
u'16f8b3f7-a9ff-4338-bbe5-eee48692c468'}, {'service_type':
u'router', 'id': u'58878cb7-689f-47a5-9c2d-654e49e2357f'},
{'service_type': u'firewall', 'id':
u'd016144f-42a6-44f4-93f6-52d201998916'}], 'description':
u'Parameterized VNF descriptor for IP addresses', 'tenant_id':
u'4dd6c1d7b6c94af980ca886495bcfed0', 'mgmt_driver': u'noop',
'infra_driver': u'heat', 'attributes': {u'vnfd': u'template_name: '
u'cirros_ipaddr_template\ndescription: Parameterized VNF descriptor '
u'for IP addresses\nservice_properties:\n Id: cirros\n vendor: '
u'ACME\n version: 1\n type:\n - router\n - firewall\n\nvdus:\n'
u' vdu1:\n id: vdu1\n vm_image: { get_input: vm_image }\n '
u'instance_type: {get_input: flavor }\n service_type: {get_input: '
u'service}\n mgmt_driver: noop\n\n network_interfaces:\n '
u'management:\n network: { get_input: network }\n '
u'management: { get_input: management }\n addresses: '
u'{ get_input: mgmt_ip}\n pkt_in:\n network: { get_input: '
u'pkt_in_network }\n addresses: { get_input: pkt_in_ip}\n '
u'pkt_out:\n network: { get_input: pkt_out_network }\n '
u'addresses: { get_input: pkt_out_ip}\n\n placement_policy:\n '
u'availability_zone: { get_input: zone }\n\n auto-scaling: noop\n\n'
u' monitoring_policy: noop\n failure_policy: noop\n\n config:'
u'\n param0: key0\n param1: key1\n'}, 'id':
u'24c31ea1-2e28-4de2-a6cb-8d389a502c75', 'name': u'ip_vnfd'}, 'name':
u'test_ip', 'tenant_id': u'8273659b56fc46b68bd05856d1f08d14', 'id':
'd1337add-d5a1-4fd4-9447-bb9243c8460b', 'instance_id': None,
'mgmt_url': None, 'service_context': [], 'services': [],
'attributes': {u'param_values': u'vdus:\n vdu1:\n param:\n '
u' vm_image: cirros-0.3.4-x86_64-uec\n flavor: m1.tiny\n '
u' service: firewall\n pkt_in_network: net0\n '
u'pkt_out_network: net1\n zone: nova\n management: True'
u'\n network: net_mgmt\n mgmt_ip:\n - '
u'192.168.120.98\n pkt_in_ip:\n - 10.10.0.98\n '
u'pkt_out_ip:\n - 10.10.1.98\n'}, 'template_id':
u'24c31ea1-2e28-4de2-a6cb-8d389a502c75', 'description':
u'Parameterized VNF descriptor for IP addresses'}
u'd016144f-42a6-44f4-93f6-52d201998916'}],
'description': u'Parameterized VNF descriptor for IP addresses',
'tenant_id': u'4dd6c1d7b6c94af980ca886495bcfed0',
'mgmt_driver': u'noop',
'infra_driver': u'heat',
'attributes': {u'vnfd': vnfd_ipparams_template},
'id': u'24c31ea1-2e28-4de2-a6cb-8d389a502c75', 'name': u'ip_vnfd'},
'name': u'test_ip',
'tenant_id': u'8273659b56fc46b68bd05856d1f08d14',
'id': 'd1337add-d5a1-4fd4-9447-bb9243c8460b',
'instance_id': None, 'mgmt_url': None, 'service_context': [],
'services': [],
'attributes': {u'param_values': ipparams},
'template_id': u'24c31ea1-2e28-4de2-a6cb-8d389a502c75',
'description': u'Parameterized VNF descriptor for IP addresses'}
def get_dummy_device_obj_userdata_attr():
return {'status': 'PENDING_CREATE', 'instance_id': None, 'name':
u'test_userdata', 'tenant_id': u'8273659b56fc46b68bd05856d1f08d14',
'template_id': u'206e343f-c580-4494-a739-525849edab7f',
'device_template': {'service_types': [{'service_type': u'firewall',
return {'status': 'PENDING_CREATE', 'instance_id': None,
'name': u'test_userdata',
'tenant_id': u'8273659b56fc46b68bd05856d1f08d14',
'template_id': u'206e343f-c580-4494-a739-525849edab7f',
'device_template': {'service_types': [{'service_type': u'firewall',
'id': u'1fcc2d7c-a6b6-4263-8cac-9590f059a555'}, {'service_type':
u'router', 'id': u'8c99106d-826f-46eb-91a1-08dfdc78c04b'},
{'service_type': u'vnfd', 'id':
u'9bf289ec-c0e1-41fc-91d7-110735a70221'}], 'description':
u"Parameterized VNF descriptor", 'tenant_id':
u'8273659b56fc46b68bd05856d1f08d14', 'mgmt_driver': u'noop',
'infra_driver': u'heat', 'attributes': {u'vnfd':
u"template_name: cirros_user_data\ndescription: "
u"Parameterized VNF descriptor\nservice_properties:"
u"\n Id: cirros\n vendor: ACME\n version: 1\n "
u"type:\n - router\n - firewall\n\nvdus:\n "
u"vdu1:\n id: vdu1\n vm_image: { get_input: "
u"vm_image }\n instance_type: {get_input: flavor "
u"}\n service_type: {get_input: service}\n "
u"mgmt_driver: noop\n user_data: {get_input: "
u"user_data}\n user_data_format: {get_input: "
u"user_data_format}\n\n network_interfaces:\n "
u" management:\n network: { get_input: "
u"network }\n management: { get_input: "
u"management }\n pkt_in:\n network: "
u"{ get_input: pkt_in_network }\n pkt_out:\n "
u" network: { get_input: pkt_out_network }\n\n "
u" placement_policy:\n availability_zone: { "
u"get_input: zone }\n\n auto-scaling: noop\n\n "
u" monitoring_policy: noop\n failure_policy: noop"
u"\n\n config:\n param0: key0\n param1:"
u" key1\n"}, 'id':
u'206e343f-c580-4494-a739-525849edab7f', 'name':
u'cirros_user_data'}, 'mgmt_url': None, 'service_context': [],
'services': [], 'attributes': {u'param_values': u'vdus:\n vdu1:\n'
u' param:\n vm_image: cirros-0.3.4-x86_64-uec\n '
u'flavor: m1.tiny\n service: firewall\n pkt_in_network: '
u'net0\n pkt_out_network: net1\n zone: nova\n '
u'management: True\n network: net_mgmt\n '
u'user_data_format: RAW\n user_data: |\n #!/bin/sh\n '
u' echo "my hostname is `hostname`" > /tmp/hostname\n '
u'df -h > /home/cirros/diskinfo\n'}, 'id':
'18685f68-2b2a-4185-8566-74f54e548811', 'description':
u"Parameterized VNF descriptor"}
u'9bf289ec-c0e1-41fc-91d7-110735a70221'}],
'description': u"Parameterized VNF descriptor",
'tenant_id': u'8273659b56fc46b68bd05856d1f08d14',
'mgmt_driver': u'noop',
'infra_driver': u'heat',
'attributes': {u'vnfd': vnfd_userdata_template},
'id': u'206e343f-c580-4494-a739-525849edab7f', 'name':
u'cirros_user_data'}, 'mgmt_url': None, 'service_context': [],
'services': [], 'attributes': {u'param_values': userdata_params},
'id': '18685f68-2b2a-4185-8566-74f54e548811',
'description': u"Parameterized VNF descriptor"}

@ -0,0 +1,12 @@
vdus:
vdu1:
config:
firewall: |
package firewall
config defaults
option syn_flood '1'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'

@ -0,0 +1,26 @@
description: OpenWRT with services
heat_template_version: 2013-05-23
outputs:
mgmt_ip-vdu1:
description: management ip address
value:
get_attr: [vdu1-net_mgmt-port, fixed_ips, 0, ip_address]
resources:
vdu1:
properties:
availability_zone: nova
config_drive: true
flavor: m1.tiny
image: cirros-0.3.2-x86_64-uec
metadata: {param0: key0, param1: key1}
networks:
- port: {get_resource: vdu1-net_mgmt-port}
- {network: net0}
- {network: net1}
type: OS::Nova::Server
vdu1-net_mgmt-port:
properties:
fixed_ips: []
network: net_mgmt
port_security_enabled: false
type: OS::Neutron::Port

@ -0,0 +1,41 @@
description: Parameterized VNF descriptor for IP addresses
heat_template_version: 2013-05-23
outputs:
mgmt_ip-vdu1:
description: management ip address
value:
get_attr: [vdu1-net_mgmt-port, fixed_ips, 0, ip_address]
resources:
vdu1:
properties:
availability_zone: nova
config_drive: true
flavor: m1.tiny
image: cirros-0.3.4-x86_64-uec
metadata: {param0: key0, param1: key1}
networks:
- port: {get_resource: vdu1-net_mgmt-port}
- port: {get_resource: vdu1-net0-port}
- port: {get_resource: vdu1-net1-port}
type: OS::Nova::Server
vdu1-net0-port:
properties:
fixed_ips:
- {ip_address: 10.10.0.98}
network: net0
port_security_enabled: false
type: OS::Neutron::Port
vdu1-net1-port:
properties:
fixed_ips:
- {ip_address: 10.10.1.98}
network: net1
port_security_enabled: false
type: OS::Neutron::Port
vdu1-net_mgmt-port:
properties:
fixed_ips:
- {ip_address: 192.168.120.98}
network: net_mgmt
port_security_enabled: false
type: OS::Neutron::Port

@ -0,0 +1,34 @@
description: Parameterized VNF descriptor
heat_template_version: 2013-05-23
outputs:
mgmt_ip-vdu1:
description: management ip address
value:
get_attr: [vdu1-net_mgmt-port, fixed_ips, 0, ip_address]
resources:
vdu1:
properties:
availability_zone: nova
config_drive: true