From 6aa63bdc7bdcd5b5f9786047951491e99a5cc591 Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Tue, 15 Aug 2017 14:25:40 +0200 Subject: [PATCH] Add tacker sfc contrib demo Create demo SFC environment. Usage docs will be added in a global tacker documentation PS. Change-Id: Ia8fe54a1657e76c090b3f6f03bb13d53cf8ac2f2 --- contrib/demos/tacker/cleanup-tacker | 11 ++- contrib/demos/tacker/deploy-tacker-demo | 6 +- contrib/demos/tacker/deploy-tacker-demo-sfc | 81 +++++++++++++++++++++ 3 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 contrib/demos/tacker/deploy-tacker-demo-sfc diff --git a/contrib/demos/tacker/cleanup-tacker b/contrib/demos/tacker/cleanup-tacker index 781b8396f6..63a65e6468 100644 --- a/contrib/demos/tacker/cleanup-tacker +++ b/contrib/demos/tacker/cleanup-tacker @@ -1,5 +1,12 @@ #!/bin/bash - +if [[ -f kolla-sample-vnffgd.yaml ]]; then + echo "Deleting VNFFG" + tacker vnffg-delete kolla-sample-vnffg + echo "Deleting VNFFGD" + tacker vnffgd-delete kolla-sample-vnffgd + echo "Deleting sample sfc instances" + openstack server delete kolla_sfc_server kolla_sfc_client +fi echo "Deleting sample VNF" tacker vnf-delete kolla-sample-vnf while tacker vnf-list | grep -q kolla-sample-vnf; do @@ -10,4 +17,4 @@ tacker vnfd-delete kolla-sample-vnfd echo "Deleting sample VIM" tacker vim-delete kolla-sample-vim echo "Removing sample config" -rm -rf ./kolla-sample-*.yaml +rm -rf ./kolla-sample-* diff --git a/contrib/demos/tacker/deploy-tacker-demo b/contrib/demos/tacker/deploy-tacker-demo index eb3f139957..d3f6c84e7e 100644 --- a/contrib/demos/tacker/deploy-tacker-demo +++ b/contrib/demos/tacker/deploy-tacker-demo @@ -34,8 +34,12 @@ topology_template: image: ${IMAGE_ID} availability_zone: nova mgmt_driver: noop + user_data_format: RAW + user_data: | + #!/bin/sh + echo 1 > /proc/sys/net/ipv4/ip_forward - CP1: + CP11: type: tosca.nodes.nfv.CP.Tacker properties: management: true diff --git a/contrib/demos/tacker/deploy-tacker-demo-sfc b/contrib/demos/tacker/deploy-tacker-demo-sfc new file mode 100644 index 0000000000..fe755556b7 --- /dev/null +++ b/contrib/demos/tacker/deploy-tacker-demo-sfc @@ -0,0 +1,81 @@ +#!/bin/bash + +function create_servers { + echo "Creating SFC demo instances" + DEMO_NET=$(openstack network list | awk '/demo-net/ { print $2 }') + IMAGE_ID=$(openstack image list | awk '/cirros/ { print $2 }') + FLOATING_IP_CLIENT=$(openstack floating ip create public1 -c floating_ip_address -f value) + FLOATING_IP_SERVER=$(openstack floating ip create public1 -c floating_ip_address -f value) + openstack server create --wait --flavor m1.tiny --image $IMAGE_ID --nic net-id=$DEMO_NET kolla_sfc_server + openstack server create --wait --flavor m1.tiny --image $IMAGE_ID --nic net-id=$DEMO_NET kolla_sfc_client + openstack server add floating ip kolla_sfc_client $FLOATING_IP_CLIENT + openstack server add floating ip kolla_sfc_server $FLOATING_IP_SERVER + KOLLA_SFC_CLIENT_PORT=$(openstack port list --server kolla_sfc_client | awk '/ACTIVE/ {print $2}') +} + +function sfc_gen_config { + echo "Tacker SFC config files" + cat > ./kolla-sample-vnffgd.yaml <CP12) + properties: + id: 51 + policy: + type: ACL + criteria: + - network_src_port_id: ${KOLLA_SFC_CLIENT_PORT} + - network_id: ${DEMO_NET} + - ip_proto: 6 + - destination_port_range: 80-80 + path: + - forwarder: kolla-sample-vnfd + capability: CP11 + + groups: + VNFFG1: + type: tosca.groups.nfv.VNFFG + description: HTTP to Corporate Net + properties: + vendor: tacker + version: 1.0 + number_of_endpoints: 1 + dependent_virtual_link: [VL1] + connection_point: [CP11] + constituent_vnfs: [kolla-sample-vnfd] + members: [Forwarding_path1] +EOF +} + +function deploy_sfc { + sh ./deploy-tacker-demo + create_servers + sfc_gen_config + echo "Creating VNFFGD" + tacker vnffgd-create --vnffgd-file kolla-sample-vnffgd.yaml kolla-sample-vnffgd + echo "Creating VNFFG" + tacker vnffg-create --vnffgd-name kolla-sample-vnffgd kolla-sample-vnffg + echo "Tacker sfc client floating ip address: $FLOATING_IP_CLIENT" + echo "Tacker sfc server floating ip address: $FLOATING_IP_SERVER" + cat << EOF + +Done. + +To create simple HTTP server in tacker_sfc_server instance run: + +ssh cirros@$FLOATING_IP_SERVER 'while true; \\ + do echo -e "HTTP/1.0 200 OK\r\n\r\nW00t from Kolla HTTP server!" | sudo nc -l -p 80 ; done &' + +EOF +} + +deploy_sfc