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) self.client.post(vnf_trigger_path % vnf, body)
def _inject_monitoring_policy(vnfd_dict): def _inject_monitoring_policy(vnfd_dict):
if vnfd_dict.get('tosca_definitions_version'): polices = vnfd_dict['topology_template'].get('policies', [])
polices = vnfd_dict['topology_template'].get('policies', []) mon_policy = dict()
mon_policy = dict() for policy_dict in polices:
for policy_dict in polices: for name, policy in policy_dict.items():
for name, policy in policy_dict.items(): if policy['type'] == constants.POLICY_ALARMING:
if policy['type'] == constants.POLICY_ALARMING: triggers = policy['triggers']
triggers = policy['triggers'] for trigger_name, trigger_dict in triggers.items():
for trigger_name, trigger_dict in triggers.items(): policy_action_list = trigger_dict['actions']
policy_action_list = trigger_dict['actions'] for policy_action in policy_action_list:
for policy_action in policy_action_list: mon_policy[trigger_name] = policy_action
mon_policy[trigger_name] = policy_action return mon_policy
return mon_policy
def verify_policy(policy_dict, kw_policy): def verify_policy(policy_dict, kw_policy):
for name, action in policy_dict.items(): for name, action in policy_dict.items():

View File

@ -26,7 +26,7 @@ VNF_CIRROS_CREATE_TIMEOUT = 120
class VnfTestCreate(base.BaseTackerTest): class VnfTestCreate(base.BaseTackerTest):
def _test_create_delete_vnf(self, vnf_name, vnfd_name, vim_id=None): def _test_create_delete_vnf(self, vnf_name, vnfd_name, vim_id=None):
data = dict() 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'] toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnfd_name, tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}} 'attributes': {'vnfd': toscal}}}

View File

@ -56,26 +56,6 @@ class VnfTestPingMonitor(base.BaseTackerTest):
self.addCleanup(self.wait_until_vnf_delete, vnf_id, self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT) 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): def test_create_delete_vnf_monitoring_tosca_template(self):
self._test_vnf_with_monitoring( self._test_vnf_with_monitoring(
'sample-tosca-vnfd-monitor.yaml', 'sample-tosca-vnfd-monitor.yaml',
@ -85,8 +65,3 @@ class VnfTestPingMonitor(base.BaseTackerTest):
self._test_vnf_with_monitoring( self._test_vnf_with_monitoring(
'sample-tosca-vnfd-multi-vdu-monitoring.yaml', 'sample-tosca-vnfd-multi-vdu-monitoring.yaml',
'ping monitor multi vdu vnf with tosca template') '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): class VnfmTestParam(base.BaseTackerTest):
def _test_vnfd_create(self, vnfd_file, vnfd_name): def _test_vnfd_create(self, vnfd_file, vnfd_name):
yaml_input = read_file(vnfd_file) 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, req_dict = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': yaml_input}}} 'attributes': {'vnfd': yaml_input}}}
@ -103,30 +99,6 @@ class VnfmTestParam(base.BaseTackerTest):
except Exception: except Exception:
assert True, "Vnf Delete success" + str(vnf_d) + str(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): def test_vnfd_param_tosca_template(self):
vnfd_name = 'sample_cirros_vnfd_tosca' vnfd_name = 'sample_cirros_vnfd_tosca'
vnfd_instance = self._test_vnfd_create( 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') tosca_vnfd_openwrt = _get_template('test_tosca_openwrt.yaml')
vnfd_ipparams_template = _get_template('vnf_cirros_template_ipaddr.yaml') vnfd_ipparams_template = _get_template('vnf_cirros_template_ipaddr.yaml')
ipparams = _get_template('vnf_cirros_param_values_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') userdata_params = _get_template('vnf_cirros_param_values_user_data.yaml')
config_data = _get_template('config_data.yaml') config_data = _get_template('config_data.yaml')
update_config_data = _get_template('update_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'} '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(): def get_vim_obj():
return {'vim': {'type': 'openstack', 'auth_url': return {'vim': {'type': 'openstack', 'auth_url':
'http://localhost:5000', 'vim_project': {'name': 'http://localhost:5000', 'vim_project': {'name':

View File

@ -163,49 +163,6 @@ class TestDeviceHeat(base.TestCase):
'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': u'OpenWRT with services'} '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): def test_create_wait(self):
vnf_obj = self._get_dummy_tosca_vnf('test_tosca_openwrt.yaml') vnf_obj = self._get_dummy_tosca_vnf('test_tosca_openwrt.yaml')
expected_result = self._get_expected_vnf_wait_obj() 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', 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': u'OpenWRT with services'} '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'
expected_fields = self._get_expected_fields_ipaddr_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_wait(self):
vnf_obj = self._get_dummy_tosca_vnf('test_tosca_openwrt.yaml')
expected_result = self._get_expected_vnf_wait_obj()
vnf_id = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
self.infra_driver.create_wait(plugin=None,
context=self.context,
vnf_dict=vnf_obj,
vnf_id=vnf_id,
auth_attr=utils.get_vim_auth_obj())
self.assertEqual(expected_result, vnf_obj)
def test_delete(self): def test_delete(self):
vnf_id = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738' vnf_id = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'
self.infra_driver.delete(plugin=None, context=self.context, self.infra_driver.delete(plugin=None, context=self.context,

View File

@ -76,11 +76,8 @@ class TOSCAToHOT(object):
self._get_unsupported_resource_props(self.heatclient) self._get_unsupported_resource_props(self.heatclient)
is_tosca_format = False is_tosca_format = False
if 'tosca_definitions_version' in vnfd_dict: self._generate_hot_from_tosca(vnfd_dict, dev_attrs)
self._generate_hot_from_tosca(vnfd_dict, dev_attrs) is_tosca_format = True
is_tosca_format = True
else:
self._generate_hot_from_legacy(vnfd_dict, dev_attrs)
self.fields['template'] = self.heat_template_yaml self.fields['template'] = self.heat_template_yaml
if is_tosca_format: if is_tosca_format:
@ -323,83 +320,6 @@ class TOSCAToHOT(object):
self.monitoring_dict = monitoring_dict self.monitoring_dict = monitoring_dict
self.metadata = metadata self.metadata = metadata
@log.log
def _generate_hot_from_legacy(self, vnfd_dict, dev_attrs):
assert 'template' not in self.fields
assert 'template_url' not in self.fields
monitoring_dict = {}
template_dict = yaml.load(HEAT_TEMPLATE_BASE)
outputs_dict = {}
template_dict['outputs'] = outputs_dict
if 'get_input' in self.vnfd_yaml:
self._process_parameterized_input(dev_attrs, vnfd_dict)
KEY_LIST = (('description', 'description'), )
for (key, vnfd_key) in KEY_LIST:
if vnfd_key in vnfd_dict:
template_dict[key] = vnfd_dict[vnfd_key]
for vdu_id, vdu_dict in vnfd_dict.get('vdus', {}).items():
template_dict.setdefault('resources', {})[vdu_id] = {
"type": "OS::Nova::Server"
}
resource_dict = template_dict['resources'][vdu_id]
KEY_LIST = (('image', 'vm_image'),
('flavor', 'instance_type'))
resource_dict['properties'] = {}
properties = resource_dict['properties']
for (key, vdu_key) in KEY_LIST:
properties[key] = vdu_dict[vdu_key]
if 'network_interfaces' in vdu_dict:
vdu_dict, template_dict =\
self._process_vdu_network_interfaces(vdu_id, vdu_dict,
properties, template_dict)
if 'user_data' in vdu_dict and 'user_data_format' in vdu_dict:
properties['user_data_format'] = vdu_dict['user_data_format']
properties['user_data'] = vdu_dict['user_data']
elif 'user_data' in vdu_dict or 'user_data_format' in vdu_dict:
raise vnfm.UserDataFormatNotFound()
if 'placement_policy' in vdu_dict:
if 'availability_zone' in vdu_dict['placement_policy']:
properties['availability_zone'] = vdu_dict[
'placement_policy']['availability_zone']
if 'config' in vdu_dict:
properties['config_drive'] = True
metadata = properties.setdefault('metadata', {})
metadata.update(vdu_dict['config'])
for key, value in metadata.items():
metadata[key] = value[:255]
if 'key_name' in vdu_dict:
properties['key_name'] = vdu_dict['key_name']
monitoring_policy = vdu_dict.get('monitoring_policy', 'noop')
failure_policy = vdu_dict.get('failure_policy', 'noop')
# Convert the old monitoring specification to the new
# network. This should be removed after Mitaka
if monitoring_policy == 'ping' and failure_policy == 'respawn':
vdu_dict['monitoring_policy'] = {
'ping': {'actions': {'failure': 'respawn'}}}
vdu_dict.pop('failure_policy')
if monitoring_policy != 'noop':
monitoring_dict['vdus'] = {}
monitoring_dict['vdus'][vdu_id] = vdu_dict['monitoring_policy']
# to pass necessary parameters to plugin upwards.
for key in ('service_type',):
if key in vdu_dict:
self.vnf.setdefault('attributes', {})[vdu_id] =\
jsonutils.dumps({key: vdu_dict[key]})
heat_template_yaml = yaml.dump(template_dict)
self.heat_template_yaml = heat_template_yaml
self.monitoring_dict = monitoring_dict
@log.log @log.log
def _generate_hot_scaling(self, vnfd_dict, def _generate_hot_scaling(self, vnfd_dict,
scale_resource_type="OS::Nova::Server"): scale_resource_type="OS::Nova::Server"):

View File

@ -146,9 +146,8 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
elif isinstance(template, str): elif isinstance(template, str):
self._report_deprecated_yaml_str() self._report_deprecated_yaml_str()
if "tosca_definitions_version" not in template: if "tosca_definitions_version" not in template:
versionutils.report_deprecated_feature(LOG, 'VNFD legacy vnfds' raise exceptions.Invalid('Not a valid template: '
' are deprecated since Mitaka release and will be removed in' 'tosca_definitions_version is missing.')
' Ocata release. Please use NFV TOSCA vnfds.')
LOG.debug(_('vnfd %s'), vnfd_data) LOG.debug(_('vnfd %s'), vnfd_data)
@ -185,53 +184,29 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
inner_vnfd_dict = yaml.load(vnfd_yaml) inner_vnfd_dict = yaml.load(vnfd_yaml)
LOG.debug(_('vnfd_dict: %s'), inner_vnfd_dict) LOG.debug(_('vnfd_dict: %s'), inner_vnfd_dict)
if 'tosca_definitions_version' in inner_vnfd_dict: # Prepend the tacker_defs.yaml import file with the full
# Prepend the tacker_defs.yaml import file with the full # path to the file
# path to the file toscautils.updateimports(inner_vnfd_dict)
toscautils.updateimports(inner_vnfd_dict)
try: try:
tosca = ToscaTemplate(a_file=False, tosca = ToscaTemplate(a_file=False,
yaml_dict_tpl=inner_vnfd_dict) yaml_dict_tpl=inner_vnfd_dict)
except Exception as e: except Exception as e:
LOG.exception(_("tosca-parser error: %s"), str(e)) LOG.exception(_("tosca-parser error: %s"), str(e))
raise vnfm.ToscaParserFailed(error_msg_details=str(e)) raise vnfm.ToscaParserFailed(error_msg_details=str(e))
if ('description' not in vnfd_dict or if ('description' not in vnfd_dict or
vnfd_dict['description'] == ''): vnfd_dict['description'] == ''):
vnfd_dict['description'] = inner_vnfd_dict.get( vnfd_dict['description'] = inner_vnfd_dict.get(
'description', '') 'description', '')
if (('name' not in vnfd_dict or if (('name' not in vnfd_dict or
not len(vnfd_dict['name'])) and not len(vnfd_dict['name'])) and
'metadata' in inner_vnfd_dict): 'metadata' in inner_vnfd_dict):
vnfd_dict['name'] = inner_vnfd_dict['metadata'].get( vnfd_dict['name'] = inner_vnfd_dict['metadata'].get(
'template_name', '') 'template_name', '')
vnfd_dict['mgmt_driver'] = toscautils.get_mgmt_driver( vnfd_dict['mgmt_driver'] = toscautils.get_mgmt_driver(
tosca) tosca)
else:
KEY_LIST = (('name', 'template_name'),
('description', 'description'))
vnfd_dict.update(
dict((key, inner_vnfd_dict[vnfd_key]) for (key, vnfd_key)
in KEY_LIST
if ((key not in vnfd_dict or
vnfd_dict[key] == '') and
vnfd_key in inner_vnfd_dict and
inner_vnfd_dict[vnfd_key] != '')))
service_types = inner_vnfd_dict.get(
'service_properties', {}).get('type', [])
if service_types:
vnfd_dict.setdefault('service_types', []).extend(
[{'service_type': service_type}
for service_type in service_types])
# TODO(anyone) - this code assumes one mgmt_driver per VNFD???
for vdu in inner_vnfd_dict.get('vdus', {}).values():
mgmt_driver = vdu.get('mgmt_driver')
if mgmt_driver:
vnfd_dict['mgmt_driver'] = mgmt_driver
LOG.debug(_('vnfd %s'), vnfd) LOG.debug(_('vnfd %s'), vnfd)
def add_vnf_to_monitor(self, vnf_dict, infra_driver): def add_vnf_to_monitor(self, vnf_dict, infra_driver):
@ -675,26 +650,25 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
vnfd_tmpl = yaml.load(vnf['vnfd']['attributes']['vnfd']) vnfd_tmpl = yaml.load(vnf['vnfd']['attributes']['vnfd'])
policy_list = [] policy_list = []
if vnfd_tmpl.get('tosca_definitions_version'): polices = vnfd_tmpl['topology_template'].get('policies', [])
polices = vnfd_tmpl['topology_template'].get('policies', []) for policy_dict in polices:
for policy_dict in polices: for name, policy in policy_dict.items():
for name, policy in policy_dict.items(): def _add(policy):
def _add(policy): p = self._make_policy_dict(vnf, name, policy)
p = self._make_policy_dict(vnf, name, policy) p['name'] = name
p['name'] = name policy_list.append(p)
policy_list.append(p)
# Check for filters # Check for filters
if filters.get('name') or filters.get('type'): if filters.get('name') or filters.get('type'):
if name == filters.get('name'): if name == filters.get('name'):
_add(policy) _add(policy)
if policy['type'] == filters.get('type'): if policy['type'] == filters.get('type'):
_add(policy) _add(policy)
break break
else: else:
continue continue
_add(policy) _add(policy)
return policy_list return policy_list