diff --git a/releasenotes/notes/add-key-name-support-to-tosca-nodes-nfv-VDU-Tracker-bf415eaf6eb13c0d.yaml b/releasenotes/notes/add-key-name-support-to-tosca-nodes-nfv-VDU-Tracker-bf415eaf6eb13c0d.yaml new file mode 100644 index 000000000..fd01763d6 --- /dev/null +++ b/releasenotes/notes/add-key-name-support-to-tosca-nodes-nfv-VDU-Tracker-bf415eaf6eb13c0d.yaml @@ -0,0 +1,4 @@ +--- +features: + - Added support for key_name in TOSCA template for type + tosca.nodes.nfv.VDU.Tacker. diff --git a/samples/tosca-templates/vnfd/tosca-vnfd-keyname.yaml b/samples/tosca-templates/vnfd/tosca-vnfd-keyname.yaml new file mode 100644 index 000000000..640b727c6 --- /dev/null +++ b/samples/tosca-templates/vnfd/tosca-vnfd-keyname.yaml @@ -0,0 +1,37 @@ +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 + +description: Demo example with key_name + +metadata: + template_name: sample-tosca-vnfd-keyname + +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 + key_name: userKey + 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: net1 + vendor: Tacker \ No newline at end of file diff --git a/tacker/tests/contrib/post_test_hook.sh b/tacker/tests/contrib/post_test_hook.sh index 83a76c4cb..1def6cff7 100755 --- a/tacker/tests/contrib/post_test_hook.sh +++ b/tacker/tests/contrib/post_test_hook.sh @@ -59,6 +59,14 @@ function fixup_nova_quota { nova quota-class-update --instances -1 --cores -1 default } +# Adding nova keypair to support key_name (#1578785). +function add_key { + echo "Adding nova key" + source $DEVSTACK_DIR/openrc admin admin + userId=$(openstack user list | awk '/\ nfv_user\ / {print $2}') + nova keypair-add userKey --user $userId > keypair.priv +} + if [[ "$venv" == dsvm-functional* ]] then owner=stack @@ -66,6 +74,7 @@ then log_dir="/tmp/${venv}-logs" fixup_nova_quota + add_key fi # Set owner permissions according to job's requirements. @@ -76,7 +85,7 @@ sudo chown -R $owner:stack $TACKER_DIR echo "Running tacker $venv test suite" set +e -sudo -H -u $owner $sudo_env tox -e $venv +sudo -H -u $owner $sudo_env tox -e $venv testr_exit_code=$? set -e diff --git a/tacker/tests/etc/samples/sample-tosca-vnfd.yaml b/tacker/tests/etc/samples/sample-tosca-vnfd.yaml index 18be4c5a4..57c5c32e8 100644 --- a/tacker/tests/etc/samples/sample-tosca-vnfd.yaml +++ b/tacker/tests/etc/samples/sample-tosca-vnfd.yaml @@ -12,6 +12,7 @@ topology_template: properties: image: cirros-0.3.4-x86_64-uec flavor: m1.tiny + key_name: userKey availability_zone: nova mgmt_driver: noop config: | diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt_params.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt_params.yaml index c8ff41f4a..c5ade7824 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt_params.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/hot_openwrt_params.yaml @@ -12,6 +12,7 @@ resources: config_drive: true flavor: m1.tiny image: cirros-0.3.4-x86_64-uec + key_name: keyName metadata: {param0: key0, param1: key1} networks: - port: {get_resource: vdu1-net_mgmt-port} diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_param_values_user_data.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_param_values_user_data.yaml index 3bde6bebb..e219bbf09 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_param_values_user_data.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_param_values_user_data.yaml @@ -10,6 +10,7 @@ vdus: management: True network: net_mgmt user_data_format: RAW + key_name: keyName user_data: | #!/bin/sh echo "my hostname is `hostname`" > /tmp/hostname diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_template_user_data.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_template_user_data.yaml index 139737a66..a1deba677 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_template_user_data.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/vnf_cirros_template_user_data.yaml @@ -18,6 +18,7 @@ vdus: 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: diff --git a/tacker/vm/infra_drivers/heat/heat.py b/tacker/vm/infra_drivers/heat/heat.py index 9824dc809..4fea4e440 100644 --- a/tacker/vm/infra_drivers/heat/heat.py +++ b/tacker/vm/infra_drivers/heat/heat.py @@ -359,6 +359,8 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): 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') diff --git a/tacker/vm/tosca/lib/tacker_nfv_defs.yaml b/tacker/vm/tosca/lib/tacker_nfv_defs.yaml index 734478f2f..d2d089847 100644 --- a/tacker/vm/tosca/lib/tacker_nfv_defs.yaml +++ b/tacker/vm/tosca/lib/tacker_nfv_defs.yaml @@ -57,6 +57,9 @@ node_types: type: string required: false + key_name: + type: string + required: false tosca.nodes.nfv.CP.Tacker: derived_from: tosca.nodes.nfv.CP