Remove support for legacy VNFD templates.

From Mitaka version, Tacker supports TOSCA based VNFD templates. Legacy
templates described under tacker/samples/legacy-templates are deprecated
in newton. Removing in Ocata.

Implements: blueprint deprecate-legacy-template-dsl
Closes-Bug: #1632214
Change-Id: I39f200bb536f4c5d10c920fc1c93bf8f382ca6c2
This commit is contained in:
dharmendra 2016-10-06 18:01:06 +09:00
parent 0c648397e3
commit eedd840236
32 changed files with 93 additions and 1438 deletions

View File

@ -0,0 +1,5 @@
---
upgrade:
- From Mitaka version, Tacker supports TOSCA based VNFD templates.
Legacy templates described under tacker/samples/legacy-templates
are deprecated in newton and removed in Ocata.

View File

@ -1,6 +0,0 @@
Legacy Template Deprecate Warning
=================================
From Mitaka version, Tacker supports TOSCA based VNFD templates. Legacy
templates described under tacker/samples/legacy-templates are deprecated. Use
TOSCA based templates described at tacker/samples/tosca-templates

View File

@ -1,122 +0,0 @@
vdus:
vdu1:
config:
firewall: |
package firewall
config defaults
option syn_flood '1'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
config zone
option name 'lan'
list network 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
config zone
option name 'wan'
list network 'wan'
list network 'wan6'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
config forwarding
option src 'lan'
option dest 'wan'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option src_ip 'fe80::/10'
option src_port '547'
option dest_ip 'fe80::/10'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config include
option path '/etc/firewall.user'
config include 'miniupnpd'
option type 'script'
option path '/usr/share/miniupnpd/firewall.include'
option family 'any'
option reload '1'

View File

@ -1,42 +0,0 @@
template_name: OpenWRT
description: Virtual WRT opensource router
service_properties:
Id: openwrt-vnfd
vendor: tacker
version: 1
type:
- router
- firewall
vdus:
vdu1:
id: vdu1
vm_image: OpenWRT
instance_type: m1.tiny
service_type: firewall
mgmt_driver: openwrt
network_interfaces:
management:
network: net_mgmt
management: True
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
auto-scaling: noop
monitoring_policy: ping
failure_policy: respawn
monitoring_parameter:
a:
config:
param0: key0
param1: key1

View File

@ -1,39 +0,0 @@
template_name: sample-vnfd-http-monitor
description: demo-example
service_properties:
Id: sample-vnfd
vendor: tacker
version: 1
vdus:
vdu1:
id: vdu1
vm_image: ubuntu
instance_type: m1.small
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
auto-scaling: noop
monitoring_policy:
http_ping:
monitoring_params:
retry: 5
timeout: 10
port: 8000
actions:
failure: respawn
config:
param0: key0
param1: key1

View File

@ -1,40 +0,0 @@
template_name: sample-vnfd
description: demo-example
service_properties:
Id: sample-vnfd
vendor: tacker
version: 1
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
auto-scaling: noop
monitoring_policy:
ping:
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: respawn
config:
param0: key0
param1: key1

View File

@ -1,75 +0,0 @@
template_name: sample-vnfd-multiple-vdus
description: demo-example
service_properties:
Id: sample-vnfd-multiple-vdus
vendor: tacker
version: 1
type:
- firewall
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
config:
param0: key0
param1: key1
vdu2:
id: vdu2
vm_image: cirros-0.3.4-x86_64-uec-ramdisk
instance_type: m1.medium
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
config:
param0: key0
param1: key1
vdu3:
id: vdu3
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
config:
param0: key0
param1: key1

View File

@ -1,31 +0,0 @@
template_name: sample-vnfd
description: demo-example
service_properties:
Id: sample-vnfd
vendor: tacker
version: 1
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
auto-scaling: noop
config:
param0: key0
param1: key1

View File

@ -1,17 +0,0 @@
vdus:
vdu1:
param:
vm_image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
service: firewall
pkt_in_network: net0
pkt_out_network: net1
zone: nova
management: True
network: net_mgmt
mgmt_ip:
- 192.168.120.98
pkt_in_ip:
- 10.10.0.98
pkt_out_ip:
- 10.10.1.98

View File

@ -1,16 +0,0 @@
vdus:
vdu1:
param:
vm_image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
service: firewall
pkt_in_network: net0
pkt_out_network: net1
zone: nova
management: True
network: net_mgmt
user_data_format: RAW
user_data: |
#!/bin/sh
echo "my hostname is `hostname`" > /tmp/hostname
df -h > /home/cirros/diskinfo

View File

@ -1,45 +0,0 @@
template_name: cirros_ipaddr_template
description: Parameterized VNF descriptor that supports
fixed IP addresses with IP address values passed using
the format show in vnf_cirros_param_values_ipaddr.yaml
file
service_properties:
Id: cirros
vendor: ACME
version: 1
type:
- router
- firewall
vdus:
vdu1:
id: vdu1
vm_image: { get_input: vm_image }
instance_type: {get_input: flavor }
service_type: {get_input: service}
mgmt_driver: noop
network_interfaces:
management:
network: { get_input: network }
management: { get_input: management }
addresses: { get_input: mgmt_ip}
pkt_in:
network: { get_input: pkt_in_network }
addresses: { get_input: pkt_in_ip}
pkt_out:
network: { get_input: pkt_out_network }
addresses: { get_input: pkt_out_ip}
placement_policy:
availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
failure_policy: noop
config:
param0: key0
param1: key1

View File

@ -1,44 +0,0 @@
template_name: cirros_user_data
description: Parameterized VNF descriptor that supports
passing values for 'user_data' and 'user_data_format'
during VNF deploy using the format show in
vnf_cirros_param_values_user_data.yaml file
service_properties:
Id: cirros
vendor: ACME
version: 1
type:
- router
- firewall
vdus:
vdu1:
id: vdu1
vm_image: { get_input: vm_image }
instance_type: {get_input: flavor }
service_type: {get_input: service}
mgmt_driver: noop
user_data: {get_input: user_data}
user_data_format: {get_input: user_data_format}
network_interfaces:
management:
network: { get_input: network }
management: { get_input: management }
pkt_in:
network: { get_input: pkt_in_network }
pkt_out:
network: { get_input: pkt_out_network }
placement_policy:
availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
failure_policy: noop
config:
param0: key0
param1: key1

View File

@ -1,94 +0,0 @@
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
capabilities:
properties:
image: cirros-0.3.4-x86_64-uec
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
monitoring_policy:
name: http_ping
actions:
failure: respawn
parameters:
interval: 10
monitoring_delay: 60
timeout: 10
retry: 5
port: 8000
config_drive: true
user_data_format: RAW
user_data: |
#!/bin/sh
cd /tmp
rm -f httpsrv.sh
cat > httpsrv.sh << EOL
while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome " | sudo nc -l -p 8000 ; done&
EOL
sudo chmod +x httpsrv.sh
sudo ./httpsrv.sh &
sleep 90
pid=$(ps -ef | grep httpsrv | grep -v grep | awk '{print $1}')
echo "killing $pid"
kill -9 ${pid}
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP2:
type: tosca.nodes.nfv.CP.Tacker
properties:
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
CP3:
type: tosca.nodes.nfv.CP.Tacker
properties:
anti_spoofing_protection: false
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

View File

@ -0,0 +1,35 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: VNFD With no Monitor
metadata:
template_name: sample-tosca-vnfd-no-monitor
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
config: |
param0: key1
param1: key2
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: net_mgmt
vendor: TACKER

View File

@ -1,109 +0,0 @@
template_name: sample-vnfd-multiple-vdus-monitoring
description: demo-example
service_properties:
Id: sample-vnfd-multiple-vdus-monitoring
vendor: tacker
version: 1
type:
- firewall
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
monitoring_policy:
ping:
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: respawn
config:
param0: key0
param1: key1
vdu2:
id: vdu2
vm_image: cirros-0.3.4-x86_64-uec-ramdisk
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
monitoring_policy:
ping:
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: noop
config:
param0: key0
param1: key1
vdu3:
id: vdu3
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
config_drive: true
user_data_format: RAW
user_data: |
#!/bin/sh
df -h > /home/cirros/diskinfo
sleep 90
sudo ifdown eth0
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
monitoring_policy:
ping:
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: respawn
config:
param0: key0
param1: key1

View File

@ -1,75 +0,0 @@
template_name: sample-vnfd-multiple-vdus
description: demo-example
service_properties:
Id: sample-vnfd-multiple-vdus
vendor: tacker
version: 1
type:
- firewall
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
config:
param0: key0
param1: key1
vdu2:
id: vdu2
vm_image: cirros-0.3.4-x86_64-uec-ramdisk
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
config:
param0: key0
param1: key1
vdu3:
id: vdu3
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
config:
param0: key0
param1: key1

View File

@ -1,47 +0,0 @@
template_name: sample-vnfd-monitoring-new-template
description: demo-example
service_properties:
Id: sample-vnfd
vendor: tacker
version: 1
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
config_drive: true
user_data_format: RAW
user_data: |
#!/bin/sh
df -h > /home/cirros/diskinfo
sleep 90
sudo ifdown eth0
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
auto-scaling: noop
monitoring_policy:
ping:
monitoring_params:
monitoring_delay: 45
count: 3
interval: .5
timeout: 2
actions:
failure: respawn
config:
param0: key0
param1: key1

View File

@ -1,55 +0,0 @@
template_name: http-ping
description: http-ping-cirros-example
service_properties:
Id: cirros-vnfd-http-moniotring
vendor: canonical
version: 1
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
user_data_format: RAW
config_drive: true
user_data: |
#!/bin/sh
cd /tmp
rm -f httpsrv.sh
cat > httpsrv.sh << EOL
eth0_ip=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}')
while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $eth0_ip" | sudo nc -l -p 80 ; done&
EOL
sudo chmod +x httpsrv.sh
sudo ./httpsrv.sh &
sleep 150
cat > kill.sh << EOL
cat <<'EOF' > kill.sh
pid = `ps -ef | grep httpsrv | grep exe | grep -v grep | awk '{print $1}'`
echo "killing $pid"
kill -9 $pid
EOF
sudo chmod +x kill.sh
network_interfaces:
management:
network: net_mgmt
management: true
placement_policy:
availability_zone: nova
monitoring_policy:
http_ping:
monitoring_params:
monitoring_delay: 60
retry: 5
timeout: 10
port: 80
actions:
failure: respawn
config:
param0: key0
param1: key1

View File

@ -1,35 +0,0 @@
template_name: sample-vnfd
description: demo-example
service_properties:
Id: sample-vnfd
vendor: tacker
version: 1
type:
- dpi
vdus:
vdu1:
id: vdu1
vm_image: cirros-0.3.4-x86_64-uec
instance_type: m1.tiny
network_interfaces:
management:
network: net_mgmt
management: true
pkt_in:
network: net0
pkt_out:
network: net1
placement_policy:
availability_zone: nova
auto-scaling: noop
monitoring_policy: ping
failure_policy: respawn
config:
param0: key0
param1: key1

View File

@ -1,38 +0,0 @@
template_name: tacker-test
description: tacker-test
service_properties:
Id: tacker-test
vendor: {get_input: vendor }
version: 1
type:
- router
- firewall
vdus:
vdu1:
id: vdu1
vm_image: { get_input: vm_image }
instance_type: {get_input: flavor }
service_type: {get_input: service}
mgmt_driver: noop
network_interfaces:
management:
network: { get_input: network }
management: { get_input: management }
pkt_in:
network: { get_input: pkt_in_network }
pkt_out:
network: { get_input: pkt_out_network }
placement_policy:
availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
config:
param0: key0
param1: key1

View File

@ -67,18 +67,17 @@ class VnfTestAlarmMonitor(base.BaseTackerTest):
self.client.post(vnf_trigger_path % vnf, body)
def _inject_monitoring_policy(vnfd_dict):
if vnfd_dict.get('tosca_definitions_version'):
polices = vnfd_dict['topology_template'].get('policies', [])
mon_policy = dict()
for policy_dict in polices:
for name, policy in policy_dict.items():
if policy['type'] == constants.POLICY_ALARMING:
triggers = policy['triggers']
for trigger_name, trigger_dict in triggers.items():
policy_action_list = trigger_dict['actions']
for policy_action in policy_action_list:
mon_policy[trigger_name] = policy_action
return mon_policy
polices = vnfd_dict['topology_template'].get('policies', [])
mon_policy = dict()
for policy_dict in polices:
for name, policy in policy_dict.items():
if policy['type'] == constants.POLICY_ALARMING:
triggers = policy['triggers']
for trigger_name, trigger_dict in triggers.items():
policy_action_list = trigger_dict['actions']
for policy_action in policy_action_list:
mon_policy[trigger_name] = policy_action
return mon_policy
def verify_policy(policy_dict, kw_policy):
for name, action in policy_dict.items():

View File

@ -26,7 +26,7 @@ VNF_CIRROS_CREATE_TIMEOUT = 120
class VnfTestCreate(base.BaseTackerTest):
def _test_create_delete_vnf(self, vnf_name, vnfd_name, vim_id=None):
data = dict()
data['tosca'] = read_file('sample_cirros_vnf_no_monitoring.yaml')
data['tosca'] = read_file('sample-tosca-vnfd-no-monitor.yaml')
toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}

View File

@ -56,26 +56,6 @@ class VnfTestPingMonitor(base.BaseTackerTest):
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
def test_create_delete_vnf_monitoring(self):
self._test_vnf_with_monitoring(
'sample-vnfd-single-vdu-monitoring.yaml',
'ping monitor vnf')
def test_create_delete_vnf_http_monitoring(self):
self._test_vnf_with_monitoring(
'sample_cirros_http_monitoring.yaml',
'http monitor vnf')
def test_create_delete_vnf_multi_vdu_ping_monitoring(self):
self._test_vnf_with_monitoring(
'sample-vnfd-multi-vdu-monitoring.yaml',
'multi vdu ping monitor vnf')
def test_create_delete_vnf_monitoring_new_template(self):
self._test_vnf_with_monitoring(
'sample-vnfd-single-vdu-monitoring-new-template.yaml',
'ping monitor vnf new template')
def test_create_delete_vnf_monitoring_tosca_template(self):
self._test_vnf_with_monitoring(
'sample-tosca-vnfd-monitor.yaml',
@ -85,8 +65,3 @@ class VnfTestPingMonitor(base.BaseTackerTest):
self._test_vnf_with_monitoring(
'sample-tosca-vnfd-multi-vdu-monitoring.yaml',
'ping monitor multi vdu vnf with tosca template')
def test_create_delete_vnf_http_monitoring_tosca_template(self):
self._test_vnf_with_monitoring(
'sample-tosca-vnfd-http-monitor.yaml',
'http monitor vnf with tosca template')

View File

@ -1,83 +0,0 @@
# Copyright 2015 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
import yaml
from tacker.common import utils
from tacker.plugins.common import constants as evt_constants
from tacker.tests import constants
from tacker.tests.functional import base
from tacker.tests.utils import read_file
CONF = cfg.CONF
class VnfTestMultipleVDU(base.BaseTackerTest):
def test_create_delete_vnf_with_multiple_vdus(self):
data = dict()
input_yaml = read_file('sample-vnfd-multi-vdu.yaml')
data['tosca'] = input_yaml
toscal = data['tosca']
vnfd_name = 'sample-vnfd-multi-vdu'
tosca_arg = {'vnfd': {'name': vnfd_name,
'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_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('ACTIVE',
self.client.show_vnf(vnf_id)['vnf']['status'])
self.validate_vnf_instance(vnfd_instance, vnf_instance)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
# 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)
self.assertEqual(len(input_dict['vdus'].keys()), len(mgmt_dict.keys()))
for vdu in input_dict['vdus'].keys():
self.assertIsNotNone(mgmt_dict[vdu])
self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu]))
# 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"
self.wait_until_vnf_delete(vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_DELETE,
evt_constants.PENDING_DELETE, cnt=2)
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)

View File

@ -1,51 +0,0 @@
# Copyright 2015 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.plugins.common import constants as evt_constants
from tacker.tests.functional import base
from tacker.tests.utils import read_file
CONF = cfg.CONF
class VnfdTestCreate(base.BaseTackerTest):
def _test_create_list_delete_vnfd(self, vnfd_file):
data = dict()
data['tosca'] = read_file(vnfd_file)
toscal = data['tosca']
vnfd_name = 'sample_cirros_vnf'
tosca_arg = {'vnfd': {'name': vnfd_name,
'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']
self.verify_vnfd_events(
vnfd_id, evt_constants.RES_EVT_CREATE,
evt_constants.RES_EVT_VNFD_ONBOARDED)
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE,
evt_constants.RES_EVT_VNFD_NA_STATE)
def test_vnfd(self):
self._test_create_list_delete_vnfd('sample_cirros_vnf.yaml')

View File

@ -23,10 +23,6 @@ from tacker.tests.utils import read_file
class VnfmTestParam(base.BaseTackerTest):
def _test_vnfd_create(self, vnfd_file, vnfd_name):
yaml_input = read_file(vnfd_file)
# TODO(anyone) remove this condition check once old templates
# are deprecated
if "tosca_definitions_version" in yaml_input:
yaml_input = yaml.safe_load(yaml_input)
req_dict = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': yaml_input}}}
@ -103,30 +99,6 @@ class VnfmTestParam(base.BaseTackerTest):
except Exception:
assert True, "Vnf Delete success" + str(vnf_d) + str(Exception)
def test_vnf_param(self):
vnfd_name = 'sample_cirros_vnfd_old_template'
vnfd_instance = self._test_vnfd_create(
'sample_cirros_vnf_param.yaml', vnfd_name)
values_str = read_file('sample_cirros_vnf_values.yaml')
vnf_instance, param_values_dict = self._test_vnf_create(vnfd_instance,
'test_vnf_with_parameters',
values_str)
# Verify values dictionary is same as param values from vnf_show
input_dict = yaml.safe_load(values_str)
self.assertEqual(input_dict, param_values_dict)
self._test_vnf_delete(vnf_instance)
vnf_id = vnf_instance['vnf']['id']
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
self.wait_until_vnf_delete(vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_DELETE,
evt_constants.PENDING_DELETE, cnt=2)
self.addCleanup(self.client.delete_vnfd, vnfd_instance['vnfd']['id'])
def test_vnfd_param_tosca_template(self):
vnfd_name = 'sample_cirros_vnfd_tosca'
vnfd_instance = self._test_vnfd_create(

View File

@ -29,7 +29,6 @@ vnfd_openwrt = _get_template('openwrt.yaml')
tosca_vnfd_openwrt = _get_template('test_tosca_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')
update_config_data = _get_template('update_config_data.yaml')
@ -133,27 +132,6 @@ def get_dummy_device_obj_ipaddr_attr():
'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',
'vnfd_id': u'206e343f-c580-4494-a739-525849edab7f',
'vnfd': {'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',
'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"}
def get_vim_obj():
return {'vim': {'type': 'openstack', 'auth_url':
'http://localhost:5000', 'vim_project': {'name':

View File

@ -163,49 +163,6 @@ class TestDeviceHeat(base.TestCase):
'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': u'OpenWRT with services'}
def _assert_create_result_old_template(self, expected_fields,
actual_fields, expected_result,
result):
actual_fields["template"] = yaml.safe_load(actual_fields["template"])
expected_fields["template"] = \
yaml.safe_load(expected_fields["template"])
self.assertEqual(expected_fields, actual_fields)
self.heat_client.create.assert_called_once_with(expected_fields)
self.assertEqual(expected_result, result)
def test_create(self):
vnf_obj = utils.get_dummy_device_obj()
expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
expected_fields = self._get_expected_fields()
result = self.heat_driver.create(plugin=None, context=self.context,
vnf=vnf_obj,
auth_attr=utils.get_vim_auth_obj())
actual_fields = self.heat_client.create.call_args[0][0]
self._assert_create_result_old_template(expected_fields, actual_fields,
expected_result, result)
def test_create_user_data_param_attr(self):
vnf_obj = utils.get_dummy_device_obj_userdata_attr()
expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
expected_fields = self._get_expected_fields_user_data()
result = self.heat_driver.create(plugin=None, context=self.context,
vnf=vnf_obj,
auth_attr=utils.get_vim_auth_obj())
actual_fields = self.heat_client.create.call_args[0][0]
self._assert_create_result_old_template(expected_fields, actual_fields,
expected_result, result)
def test_create_ip_addr_param_attr(self):
vnf_obj = utils.get_dummy_device_obj_ipaddr_attr()
expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
expected_fields = self._get_expected_fields_ipaddr_data()
result = self.heat_driver.create(plugin=None, context=self.context,
vnf=vnf_obj,
auth_attr=utils.get_vim_auth_obj())
actual_fields = self.heat_client.create.call_args[0][0]
self._assert_create_result_old_template(expected_fields, actual_fields,
expected_result, result)
def test_create_wait(self):
vnf_obj = self._get_dummy_tosca_vnf('test_tosca_openwrt.yaml')
expected_result = self._get_expected_vnf_wait_obj()

View File

@ -1,42 +0,0 @@
template_name: cirros_user_data
description: Parameterized VNF descriptor
service_properties:
Id: cirros
vendor: ACME
version: 1
type:
- router
- firewall
vdus:
vdu1:
id: vdu1
vm_image: { get_input: vm_image }
instance_type: {get_input: flavor }
service_type: {get_input: service}
mgmt_driver: noop
user_data: {get_input: user_data}
user_data_format: {get_input: user_data_format}
key_name: {get_input: key_name}
network_interfaces:
management:
network: { get_input: network }
management: { get_input: management }
pkt_in:
network: { get_input: pkt_in_network }
pkt_out:
network: { get_input: pkt_out_network }
placement_policy:
availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
failure_policy: noop
config:
param0: key0
param1: key1

View File

@ -163,60 +163,6 @@ class TestOpenStack(base.TestCase):
'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': u'OpenWRT with services'}
def _assert_create_result_old_template(self, expected_fields,
actual_fields, expected_result,
result):
actual_fields["template"] = yaml.safe_load(actual_fields["template"])
expected_fields["template"] = \
yaml.safe_load(expected_fields["template"])
self.assertEqual(expected_fields, actual_fields)
self.heat_client.create.assert_called_once_with(expected_fields)
self.assertEqual(expected_result, result)
def test_create(self):
vnf_obj = utils.get_dummy_device_obj()
expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
expected_fields = self._get_expected_fields()
result = self.infra_driver.create(plugin=None, context=self.context,
vnf=vnf_obj,
auth_attr=utils.get_vim_auth_obj())
actual_fields = self.heat_client.create.call_args[0][0]
self._assert_create_result_old_template(expected_fields, actual_fields,
expected_result, result)
def test_create_user_data_param_attr(self):
vnf_obj = utils.get_dummy_device_obj_userdata_attr()
expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
expected_fields = self._get_expected_fields_user_data()
result = self.infra_driver.create(plugin=None, context=self.context,
vnf=vnf_obj,
auth_attr=utils.get_vim_auth_obj())
actual_fields = self.heat_client.create.call_args[0][0]
self._assert_create_result_old_template(expected_fields, actual_fields,
expected_result, result)
def test_create_ip_addr_param_attr(self):
vnf_obj = utils.get_dummy_device_obj_ipaddr_attr()
expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'