From f27a592f03ff6ca772195ecf71f64da3fb251b48 Mon Sep 17 00:00:00 2001 From: peusterm Date: Wed, 17 May 2017 08:48:54 +0200 Subject: [PATCH] Manually added test code for openstack apis --- src/emuvim/test/api_base_openstack.py | 160 +++ src/emuvim/test/test-initial-template.yml | 276 ++++ src/emuvim/test/test-scaleout-template.yml | 479 +++++++ .../test_heatapi_keystone_get_token.json | 9 + .../test_heatapi_template_chaining.json | 425 ++++++ .../test_heatapi_template_create_stack.json | 425 ++++++ .../test_heatapi_template_update_stack.json | 726 ++++++++++ src/emuvim/test/unittests/test_openstack.py | 1264 +++++++++++++++++ 8 files changed, 3764 insertions(+) create mode 100755 src/emuvim/test/api_base_openstack.py create mode 100644 src/emuvim/test/test-initial-template.yml create mode 100644 src/emuvim/test/test-scaleout-template.yml create mode 100644 src/emuvim/test/unittests/test_heatapi_keystone_get_token.json create mode 100644 src/emuvim/test/unittests/test_heatapi_template_chaining.json create mode 100644 src/emuvim/test/unittests/test_heatapi_template_create_stack.json create mode 100644 src/emuvim/test/unittests/test_heatapi_template_update_stack.json create mode 100755 src/emuvim/test/unittests/test_openstack.py diff --git a/src/emuvim/test/api_base_openstack.py b/src/emuvim/test/api_base_openstack.py new file mode 100755 index 0000000..207d359 --- /dev/null +++ b/src/emuvim/test/api_base_openstack.py @@ -0,0 +1,160 @@ +""" +Copyright (c) 2015 SONATA-NFV +ALL RIGHTS RESERVED. + +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. + +Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] +nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written +permission. + +This work has been performed in the framework of the SONATA project, +funded by the European Commission under Grant number 671517 through +the Horizon 2020 and 5G-PPP programmes. The authors would like to +acknowledge the contributions of their colleagues of the SONATA +partner consortium (www.sonata-nfv.eu). +""" + +""" +Helper module that implements helpers for test implementations. +""" + +import unittest +import os +import subprocess +import docker +from emuvim.dcemulator.net import DCNetwork +from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint +from mininet.clean import cleanup +from mininet.node import Controller + +class ApiBaseOpenStack(unittest.TestCase): + """ + Helper class to do basic test setups. + s1 -- s2 -- s3 -- ... -- sN + """ + + def __init__(self, *args, **kwargs): + self.net = None + self.api = [] + self.s = [] # list of switches + self.h = [] # list of hosts + self.d = [] # list of docker containers + self.dc = [] # list of data centers + self.docker_cli = None + super(ApiBaseOpenStack, self).__init__(*args, **kwargs) + + def createNet( + self, + nswitches=0, ndatacenter=0, nhosts=0, ndockers=0, + autolinkswitches=False, controller=Controller, **kwargs): + """ + Creates a Mininet instance and automatically adds some + nodes to it. + + Attention, we should always use Mininet's default controller + for our tests. Only use other controllers if you want to test + specific controller functionality. + """ + self.net = DCNetwork(controller=controller, **kwargs) + for i in range(0, ndatacenter): + self.api.append(OpenstackApiEndpoint("0.0.0.0", 5000+i)) + + # add some switches + # start from s1 because ovs does not like to have dpid = 0 + # and switch name-number is being used by mininet to set the dpid + for i in range(1, nswitches+1): + self.s.append(self.net.addSwitch('s%d' % i)) + # if specified, chain all switches + if autolinkswitches: + for i in range(0, len(self.s) - 1): + self.net.addLink(self.s[i], self.s[i + 1]) + self.net.addLink(self.s[2], self.s[0]) # link switches s1, s2 and s3 + + # add some data centers + for i in range(0, ndatacenter): + self.dc.append( + self.net.addDatacenter( + 'dc%d' % i, + metadata={"unittest_dc": i})) + self.net.addLink(self.dc[0].switch, self.s[0]) # link switches dc0.s1 with s1 + # connect data centers to the endpoint + for i in range(0, ndatacenter): + self.api[i].connect_datacenter(self.dc[i]) + self.api[i].connect_dc_network(self.net) + # add some hosts + for i in range(0, nhosts): + self.h.append(self.net.addHost('h%d' % i)) + # add some dockers + for i in range(0, ndockers): + self.d.append(self.net.addDocker('d%d' % i, dimage="ubuntu:trusty")) + + def startApi(self): + for i in self.api: + i.start() + + def stopApi(self): + for i in self.api: + i.manage.stop_floating_network() + i.stop() + + def startNet(self): + self.net.start() + + def stopNet(self): + self.net.stop() + + def getDockerCli(self): + """ + Helper to interact with local docker instance. + """ + if self.docker_cli is None: + self.docker_cli = docker.Client( + base_url='unix://var/run/docker.sock') + return self.docker_cli + + def getContainernetContainers(self): + """ + List the containers managed by containernet + """ + return self.getDockerCli().containers(filters={"label": "com.containernet"}) + + @staticmethod + def setUp(): + pass + + + def tearDown(self): + print('->>>>>>> tear everything down ->>>>>>>>>>>>>>>') + self.stopApi() # stop all flask threads + self.stopNet() # stop some mininet and containernet stuff + cleanup() + # make sure that all pending docker containers are killed + with open(os.devnull, 'w') as devnull: # kill a possibly running docker process that blocks the open ports + subprocess.call("kill $(netstat -npl | grep '5000' | grep -o -e'[0-9]\+/docker' | grep -o -e '[0-9]\+')", + stdout=devnull, + stderr=devnull, + shell=True) + + with open(os.devnull, 'w') as devnull: + subprocess.call( + "sudo docker rm -f $(sudo docker ps --filter 'label=com.containernet' -a -q)", + stdout=devnull, + stderr=devnull, + shell=True) + + + + + diff --git a/src/emuvim/test/test-initial-template.yml b/src/emuvim/test/test-initial-template.yml new file mode 100644 index 0000000..be2c9c5 --- /dev/null +++ b/src/emuvim/test/test-initial-template.yml @@ -0,0 +1,276 @@ +--- +heat_template_version: '2015-04-30' +resources: + firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:firewall-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Router + properties: + name: sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Router + properties: + name: sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:mgmt:internal:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: 20790da5-2dc1-4c7e-b9c3-a8d590517563 + subnet: + get_resource: sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:firewall-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest diff --git a/src/emuvim/test/test-scaleout-template.yml b/src/emuvim/test/test-scaleout-template.yml new file mode 100644 index 0000000..0006c85 --- /dev/null +++ b/src/emuvim/test/test-scaleout-template.yml @@ -0,0 +1,479 @@ +--- +heat_template_version: '2015-04-30' +resources: + firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:firewall-2-loadbalancer:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + floating:tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: decd89e2-1681-427e-ac24-6e9f1abb1715 + port_id: + get_resource: tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: loadbalancer1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: loadbalancer1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: loadbalancer1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: loadbalancer1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: loadbalancer1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer1:firewall-2-loadbalancer:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: loadbalancer:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer1:loadbalancer-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: loadbalancer:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: loadbalancer:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + loadbalancer:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.1.0/29 + gateway_ip: 192.1.0.1 + name: loadbalancer:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Router + properties: + name: sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Router + properties: + name: sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Router + properties: + name: sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:mgmt:internal:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: 20790da5-2dc1-4c7e-b9c3-a8d590517563 + subnet: + get_resource: sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:loadbalancer-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: tcpdump2:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump2:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump2:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump2:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump2:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:loadbalancer-2-tcpdump:2:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump2:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump2:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump2:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump2:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Nova::Server + properties: + flavor: + flavorName: m1.small + vcpu: 2 + ram: 2048 + storage: 20 + image: ubuntu:trusty + name: tcpdump3:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + networks: + - port: + get_resource: tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump3:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + - port: + get_resource: tcpdump3:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump3:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Port + properties: + name: tcpdump3:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:loadbalancer-2-tcpdump:3:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::RouterInterface + properties: + router: + get_resource: sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + subnet: + get_resource: tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump3:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump3:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump3:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump3:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Net + properties: + name: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest: + type: OS::Neutron::Subnet + properties: + cidr: 192.0.2.0/29 + gateway_ip: 192.1.0.1 + name: tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + network: + get_resource: tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest diff --git a/src/emuvim/test/unittests/test_heatapi_keystone_get_token.json b/src/emuvim/test/unittests/test_heatapi_keystone_get_token.json new file mode 100644 index 0000000..9eb13c0 --- /dev/null +++ b/src/emuvim/test/unittests/test_heatapi_keystone_get_token.json @@ -0,0 +1,9 @@ +{ + "auth": { + "tenantName": "demo", + "tenantId": "fc394f2ab2df4114bde39905f800dc57", + "token": { + "id": "cbc36478b0bd8e67e89469c7749d4127" + } + } +} \ No newline at end of file diff --git a/src/emuvim/test/unittests/test_heatapi_template_chaining.json b/src/emuvim/test/unittests/test_heatapi_template_chaining.json new file mode 100644 index 0000000..39a1cb1 --- /dev/null +++ b/src/emuvim/test/unittests/test_heatapi_template_chaining.json @@ -0,0 +1,425 @@ +{ + "template": { + "heat_template_version": "2015-04-30", + "resources": { + "firewall1": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "firewall1", + "networks": [ + { + "port": { + "get_resource": "firewall1:cp01:mgmt" + } + }, + { + "port": { + "get_resource": "firewall1:cp02:input" + } + }, + { + "port": { + "get_resource": "firewall1:cp03:output" + } + } + ] + } + }, + "firewall1:cp01:mgmt": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp01:mgmt", + "network": { + "get_resource": "sonata-demo:mgmt:net" + } + } + }, + "firewall1:cp02:input": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp02:input", + "network": { + "get_resource": "firewall:input:net" + } + } + }, + "firewall1:cp03:output": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp03:output", + "network": { + "get_resource": "firewall:output:net" + } + } + }, + "firewall1:firewall-2-tcpdump:1": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:firewall-2-tcpdump" + }, + "subnet": { + "get_resource": "firewall:output:subnet" + } + } + }, + "firewall1:iperf-2-firewall:1": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:iperf-2-firewall" + }, + "subnet": { + "get_resource": "firewall:input:subnet" + } + } + }, + "firewall:input:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "firewall:input:net" + } + }, + "firewall:input:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "firewall:input:subnet", + "network": { + "get_resource": "firewall:input:net" + } + } + }, + "firewall:output:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "firewall:output:net" + } + }, + "firewall:output:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "firewall:output:subnet", + "network": { + "get_resource": "firewall:output:net" + } + } + }, + "floating:firewall1:cp01:mgmt": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "firewall1:cp01:mgmt" + } + } + }, + "floating:iperf1:cp01:mgmt": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "iperf1:cp01:mgmt" + } + } + }, + "floating:tcpdump1:cp01:mgmt": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "tcpdump1:cp01:mgmt" + } + } + }, + "iperf1": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "iperf1", + "networks": [ + { + "port": { + "get_resource": "iperf1:cp01:mgmt" + } + }, + { + "port": { + "get_resource": "iperf1:cp02:input" + } + }, + { + "port": { + "get_resource": "iperf1:cp03:output" + } + } + ] + } + }, + "iperf1:cp01:mgmt": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp01:mgmt", + "network": { + "get_resource": "sonata-demo:mgmt:net" + } + } + }, + "iperf1:cp02:input": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp02:input", + "network": { + "get_resource": "iperf:input:net" + } + } + }, + "iperf1:cp03:output": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp03:output", + "network": { + "get_resource": "iperf:output:net" + } + } + }, + "iperf1:input-2-iperf:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf1:input-2-iperf:net" + } + }, + "iperf1:input-2-iperf:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf1:input-2-iperf:subnet", + "network": { + "get_resource": "iperf1:input-2-iperf:net" + } + } + }, + "iperf1:iperf-2-firewall:1": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:iperf-2-firewall" + }, + "subnet": { + "get_resource": "iperf:output:subnet" + } + } + }, + "iperf:input:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf:input:net" + } + }, + "iperf:input:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf:input:subnet", + "network": { + "get_resource": "iperf:input:net" + } + } + }, + "iperf:output:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf:output:net" + } + }, + "iperf:output:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf:output:subnet", + "network": { + "get_resource": "iperf:output:net" + } + } + }, + "sonata-demo:firewall-2-tcpdump": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:firewall-2-tcpdump" + } + }, + "sonata-demo:iperf-2-firewall": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:iperf-2-firewall" + } + }, + "sonata-demo:mgmt:internal": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": "20790da5-2dc1-4c7e-b9c3-a8d590517563", + "subnet": { + "get_resource": "sonata-demo:mgmt:subnet" + } + } + }, + "sonata-demo:mgmt:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "sonata-demo:mgmt:net" + } + }, + "sonata-demo:mgmt:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "sonata-demo:mgmt:subnet", + "network": { + "get_resource": "sonata-demo:mgmt:net" + } + } + }, + "tcpdump1": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "tcpdump1", + "networks": [ + { + "port": { + "get_resource": "tcpdump1:cp01:mgmt" + } + }, + { + "port": { + "get_resource": "tcpdump1:cp02:input" + } + }, + { + "port": { + "get_resource": "tcpdump1:cp03:output" + } + } + ] + } + }, + "tcpdump1:cp01:mgmt": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp01:mgmt", + "network": { + "get_resource": "sonata-demo:mgmt:net" + } + } + }, + "tcpdump1:cp02:input": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp02:input", + "network": { + "get_resource": "tcpdump:input:net" + } + } + }, + "tcpdump1:cp03:output": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp03:output", + "network": { + "get_resource": "tcpdump:output:net" + } + } + }, + "tcpdump1:firewall-2-tcpdump:1": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:firewall-2-tcpdump" + }, + "subnet": { + "get_resource": "tcpdump:input:subnet" + } + } + }, + "tcpdump1:tcpdump-2-output:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump1:tcpdump-2-output:net" + } + }, + "tcpdump1:tcpdump-2-output:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump1:tcpdump-2-output:subnet", + "network": { + "get_resource": "tcpdump1:tcpdump-2-output:net" + } + } + }, + "tcpdump:input:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump:input:net" + } + }, + "tcpdump:input:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump:input:subnet", + "network": { + "get_resource": "tcpdump:input:net" + } + } + }, + "tcpdump:output:net": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump:output:net" + } + }, + "tcpdump:output:subnet": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump:output:subnet", + "network": { + "get_resource": "tcpdump:output:net" + } + } + } + } + }, + "stack_name": "s1" + +} \ No newline at end of file diff --git a/src/emuvim/test/unittests/test_heatapi_template_create_stack.json b/src/emuvim/test/unittests/test_heatapi_template_create_stack.json new file mode 100644 index 0000000..400b41c --- /dev/null +++ b/src/emuvim/test/unittests/test_heatapi_template_create_stack.json @@ -0,0 +1,425 @@ +{ + "template": { + "heat_template_version": "2015-04-30", + "resources": { + "firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:firewall-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:mgmt:internal:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": "20790da5-2dc1-4c7e-b9c3-a8d590517563", + "subnet": { + "get_resource": "sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:firewall-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:firewall-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + } + } + }, + "stack_name": "s1" + +} \ No newline at end of file diff --git a/src/emuvim/test/unittests/test_heatapi_template_update_stack.json b/src/emuvim/test/unittests/test_heatapi_template_update_stack.json new file mode 100644 index 0000000..432a348 --- /dev/null +++ b/src/emuvim/test/unittests/test_heatapi_template_update_stack.json @@ -0,0 +1,726 @@ +{ + "template": { + "heat_template_version": "2015-04-30", + "resources": { + "firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "firewall1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:firewall-2-loadbalancer:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "firewall:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "firewall:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "firewall:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "firewall1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "floating:tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::FloatingIP", + "properties": { + "floating_network_id": "decd89e2-1681-427e-ac24-6e9f1abb1715", + "port_id": { + "get_resource": "tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "iperf1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "iperf1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf1:input-2-iperf:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf1:input-2-iperf:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf1:iperf-2-firewall:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "iperf:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "iperf:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "loadbalancer1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "loadbalancer1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "loadbalancer1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "loadbalancer1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "loadbalancer1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "loadbalancer1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer1:firewall-2-loadbalancer:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "loadbalancer:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer1:loadbalancer-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "loadbalancer:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "loadbalancer:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "loadbalancer:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "loadbalancer:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "loadbalancer:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.1.0/29", + "gateway_ip": "192.1.0.1", + "name": "loadbalancer:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "loadbalancer:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:firewall-2-loadbalancer:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:iperf-2-firewall:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Router", + "properties": { + "name": "sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:mgmt:internal:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": "20790da5-2dc1-4c7e-b9c3-a8d590517563", + "subnet": { + "get_resource": "sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/28", + "gateway_ip": "192.1.0.1", + "name": "sonata-demo:mgmt:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "tcpdump1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump1:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:loadbalancer-2-tcpdump:1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump1:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump1:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump2:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "tcpdump2:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump2:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump2:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump2:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump2:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump2:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump2:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump2:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump2:loadbalancer-2-tcpdump:2:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump2:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump2:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump2:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump2:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump2:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump3:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Nova::Server", + "properties": { + "flavor": { + "flavorName": "m1.small", + "vcpu": 2, + "ram": 2048, + "storage": 20 + }, + "image": "ubuntu:trusty", + "name": "tcpdump3:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "networks": [ + { + "port": { + "get_resource": "tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump3:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + { + "port": { + "get_resource": "tcpdump3:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + ] + } + }, + "tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump3:cp01:mgmt:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "sonata-demo:mgmt:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump3:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump3:cp02:input:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump3:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Port", + "properties": { + "name": "tcpdump3:cp03:output:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump3:loadbalancer-2-tcpdump:3:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::RouterInterface", + "properties": { + "router": { + "get_resource": "sonata-demo:loadbalancer-2-tcpdump:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + }, + "subnet": { + "get_resource": "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump3:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump3:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump3:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump3:tcpdump-2-output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump3:tcpdump-2-output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump:input:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + }, + "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Net", + "properties": { + "name": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + }, + "tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest": { + "type": "OS::Neutron::Subnet", + "properties": { + "cidr": "192.0.2.0/29", + "gateway_ip": "192.1.0.1", + "name": "tcpdump:output:subnet:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest", + "network": { + "get_resource": "tcpdump:output:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + } + } + } + } + }, + "stack_name": "s1" +} \ No newline at end of file diff --git a/src/emuvim/test/unittests/test_openstack.py b/src/emuvim/test/unittests/test_openstack.py new file mode 100755 index 0000000..a103ba4 --- /dev/null +++ b/src/emuvim/test/unittests/test_openstack.py @@ -0,0 +1,1264 @@ +""" +Copyright (c) 2015 SONATA-NFV +ALL RIGHTS RESERVED. + +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. + +Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] +nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written +permission. + +This work has been performed in the framework of the SONATA project, +funded by the European Commission under Grant number 671517 through +the Horizon 2020 and 5G-PPP programmes. The authors would like to +acknowledge the contributions of their colleagues of the SONATA +partner consortium (www.sonata-nfv.eu). +""" + +""" +Test suite to automatically test emulator REST API endpoints. +""" + +import os +import unittest +import requests +import simplejson as json + +from emuvim.test.api_base_openstack import ApiBaseOpenStack + + +class testRestApi(ApiBaseOpenStack): + """ + Tests to check the REST API endpoints of the emulator. + """ + + def setUp(self): + # create network + self.createNet(nswitches=3, ndatacenter=2, nhosts=2, ndockers=0, autolinkswitches=True) + + # setup links + self.net.addLink(self.dc[0], self.h[0]) + self.net.addLink(self.h[1], self.dc[1]) + self.net.addLink(self.dc[0], self.dc[1]) + + # start api + self.startApi() + + # start Mininet network + self.startNet() + + @unittest.skip("temporarily disabled") + def testChainingDummy(self): + print('->>>>>>> test Chaining Class->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_chaining.json")).read() + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) + + + print('->>>>>>> test Chaining Versions ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/" + listapiversionstackresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversionstackresponse.status_code, 200) + self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1") + print(" ") + + print('->>>>>>> test Chaining List ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/list" + chainlistresponse = requests.get(url, headers=headers) + self.assertEqual(chainlistresponse.status_code, 200) + self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) + print(" ") + + print('->>>>>>> test Loadbalancing List ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/list" + lblistresponse = requests.get(url, headers=headers) + self.assertEqual(lblistresponse.status_code, 200) + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"], []) + print(" ") + + testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/iper-in-0" + print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" %(testchain) + chainvnfresponse = requests.put(url) + self.assertEqual(chainvnfresponse.status_code, 200) + self.assertGreaterEqual(json.loads(chainvnfresponse.content)["cookie"], 0) + print(" ") + + print('->>>>>>> test Chaining List ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/list" + chainlistresponse = requests.get(url, headers=headers) + self.assertEqual(chainlistresponse.status_code, 200) + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_vnf"], "dc0_s1_firewall1") + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_intf"], "fire-out-0") + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_vnf"], "dc0_s1_iperf1") + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_intf"], "iper-in-0") + print(" ") + + print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + deletechainvnfresponse = requests.delete(url) + self.assertEqual(deletechainvnfresponse.status_code, 200) + self.assertEqual(deletechainvnfresponse.content, "true") + print(" ") + + print('->>>>>>> test Chaining List If Empty Again ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/list" + chainlistresponse = requests.get(url, headers=headers) + self.assertEqual(chainlistresponse.status_code, 200) + self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) + print(" ") + + testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/iper-in-0" + print('->>>>>>> test Stack Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + stackchainvnfresponse = requests.post(url, data=json.dumps(json.loads('{"path":["dc1.s1", "s1","s2","s3","s1","dc1.s1"]}')), headers=headers) + self.assertEqual(stackchainvnfresponse.status_code, 200) + print (stackchainvnfresponse.content) + self.assertGreaterEqual(json.loads(stackchainvnfresponse.content)["cookie"], 0) + print(" ") + + + print('->>>>>>> test Stack Chaining List ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/list" + chainlistresponse = requests.get(url, headers=headers) + self.assertEqual(chainlistresponse.status_code, 200) + print (chainlistresponse.content) + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_vnf"], "dc0_s1_firewall1") + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_intf"], "fire-out-0") + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_vnf"], "dc0_s1_iperf1") + self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_intf"], "iper-in-0") + self.assertItemsEqual(json.loads(chainlistresponse.content)["chains"][0]["path"],['dc1.s1', 's1', 's2', 's3', 's1', 'dc1.s1']) + print(" ") + + print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + deletechainvnfresponse = requests.delete(url) + self.assertEqual(deletechainvnfresponse.status_code, 200) + self.assertEqual(deletechainvnfresponse.content, "true") + print(" ") + + print('->>>>>>> test Chaining List If Empty Again ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/list" + chainlistresponse = requests.get(url, headers=headers) + self.assertEqual(chainlistresponse.status_code, 200) + self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) + print(" ") + + + testchain = "dc0_s1_firewall1/non-existing-interface/dc0_s1_iperf1/iper-in-0" + print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + chainvnfresponse = requests.put(url) + self.assertEqual(chainvnfresponse.status_code, 501) + print(" ") + + testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/non-existing-interface" + print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + chainvnfresponse = requests.put(url) + self.assertEqual(chainvnfresponse.status_code, 501) + print(" ") + + testchain = "dc0_s1_firewall1/non-existing-interface/dc0_s1_iperf1/iper-in-0" + print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + deletechainvnfresponse = requests.delete(url) + self.assertEqual(deletechainvnfresponse.status_code, 501) + print(" ") + + testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/non-existing-interface" + print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + deletechainvnfresponse = requests.delete(url) + self.assertEqual(deletechainvnfresponse.status_code, 501) + print(" ") + + testchain = "non-existent-dc/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" + print('->>>>>>> test Chain VNF Non-Existing DC ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + chainvnfresponse = requests.put(url) + self.assertEqual(chainvnfresponse.status_code, 500) + print(" ") + + + testchain = "dc0/s1/firewall1/non-existent:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" + print('->>>>>>> test Chain VNF Non-Existing Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + chainvnfresponse = requests.put(url) + self.assertEqual(chainvnfresponse.status_code, 500) + print(" ") + + testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/non-existent:cp02:input" + print('->>>>>>> test Chain VNF Non-Existing Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + chainvnfresponse = requests.put(url) + self.assertEqual(chainvnfresponse.status_code, 500) + print(" ") + + testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" + print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + chainvnfresponse = requests.put(url) + print (chainvnfresponse.content) + self.assertEqual(chainvnfresponse.status_code, 200) + self.assertGreaterEqual(json.loads(chainvnfresponse.content)["cookie"], 0) + print(" ") + + print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + deletechainvnfresponse = requests.delete(url) + self.assertEqual(deletechainvnfresponse.status_code, 200) + self.assertEqual(deletechainvnfresponse.content, "true") + print(" ") + + print('->>>>>>> test Chaining List If Empty Again ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/list" + chainlistresponse = requests.get(url, headers=headers) + self.assertEqual(chainlistresponse.status_code, 200) + self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) + print(" ") + + testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" + print('->>>>>>> test Stack Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + stackchainvnfresponse = requests.post(url, data=json.dumps( + json.loads('{"path":["dc1.s1", "s1","s2","s3","s1","dc1.s1"]}')), headers=headers) + self.assertEqual(stackchainvnfresponse.status_code, 200) + print (stackchainvnfresponse.content) + self.assertGreaterEqual(json.loads(stackchainvnfresponse.content)["cookie"], 0) + print(" ") + + testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" + print('->>>>>>> test Stack Chain VNF Interfaces ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) + stackchainvnfresponse = requests.delete(url, headers=headers) + self.assertEqual(stackchainvnfresponse.status_code, 200) + print(" ") + + + print('->>>>>>> test Loadbalancing ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/dc0/s1/firewall1/firewall1:cp03:output" + lblistresponse = requests.post(url, data=json.dumps( + {"dst_vnf_interfaces":[{"pop":"dc0","stack":"s1","server":"iperf1","port":"iperf1:cp02:input"}]}) + , headers=headers) + print (lblistresponse.content) + self.assertEqual(lblistresponse.status_code, 200) + self.assertIn("dc0_s1_firewall1:fire-out-0", lblistresponse.content) + print(" ") + + print('->>>>>>> test Loadbalancing List ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/list" + lblistresponse = requests.get(url, headers=headers) + self.assertEqual(lblistresponse.status_code, 200) + print (lblistresponse.content ) + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_vnf"], "dc0_s1_iperf1") + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_intf"], "iper-in-0") + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_vnf"], "dc0_s1_firewall1") + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_intf"],"fire-out-0") + print(" ") + + print('->>>>>>> test delete Loadbalancing ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/dc0/s1/firewall1/firewall1:cp03:output" + lbdeleteresponse = requests.delete(url, headers=headers) + print (lbdeleteresponse.content) + self.assertEqual(lbdeleteresponse.status_code, 200) + print(" ") + + print('->>>>>>> testFloatingLoadbalancer ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/dc0/floating/bla/blubb" + lblistresponse = requests.post(url, data=json.dumps( + {"dst_vnf_interfaces":[{"pop":"dc0","stack":"s1","server":"iperf1","port":"iperf1:cp02:input"}]}) + , headers=headers) + print (lblistresponse.content) + self.assertEqual(lblistresponse.status_code, 200) + resp = json.loads(lblistresponse.content) + self.assertIsNotNone(resp.get('cookie')) + self.assertIsNotNone(resp.get('floating_ip')) + cookie = resp.get('cookie') + print(" ") + + print('->>>>>>> testDeleteFloatingLoadbalancer ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/dc0/floating/%s/blubb" % cookie + lblistresponse = requests.delete(url, headers=headers) + print (lblistresponse.content) + self.assertEqual(lblistresponse.status_code, 200) + print(" ") + + print('->>>>>>> testLoadbalancingCustomPath ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/dc0_s1_firewall1/fire-out-0" + lblistresponse = requests.post(url, data=json.dumps( + {"dst_vnf_interfaces":{"dc0_s1_iperf1":"iper-in-0"}, + "path": {"dc0_s1_iperf1": {"iper-in-0": ["dc1.s1", "s1","s2","s3","s1","dc1.s1"]}}}), headers=headers) + print (lblistresponse.content) + self.assertEqual(lblistresponse.status_code, 200) + self.assertIn("dc0_s1_firewall1:fire-out-0", lblistresponse.content) + print(" ") + + print('->>>>>>> testLoadbalancingListCustomPath ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/list" + lblistresponse = requests.get(url, headers=headers) + self.assertEqual(lblistresponse.status_code, 200) + print (lblistresponse.content ) + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_vnf"], "dc0_s1_iperf1") + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_intf"], "iper-in-0") + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["path"], + ["dc1.s1", "s1","s2","s3","s1","dc1.s1"] ) + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_vnf"], "dc0_s1_firewall1") + self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_intf"],"fire-out-0") + print(" ") + + + print('->>>>>>> test Delete Loadbalancing ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/lb/dc0_s1_firewall1/fire-out-0" + lblistresponse = requests.delete(url, headers=headers) + self.assertEqual(lblistresponse.status_code, 200) + print(" ") + + print('->>>>>>> test Query Topology ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:4000/v1/topo" + topolistresponse = requests.get(url, headers=headers) + print(topolistresponse.content) + self.assertEqual(topolistresponse.status_code, 200) + print(" ") + + + + def testMonitoringDummy(self): + print('->>>>>>> test Monitoring Dummy Class->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)),headers=headers) + + + print('->>>>>>> test Monitoring List Versions ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/" + listapiversionstackresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversionstackresponse.status_code, 200) + self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1") + print(" ") + + print('->>>>>>> test Monitor VNF ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/dc0_s1_firewall1" + listmonitoringvnfresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfresponse.status_code, 200) + self.assertGreaterEqual(json.loads(listmonitoringvnfresponse.content)["MEM_%"], 0) + print(" ") + + print('->>>>>>> test Monitor VNF Abs Without Mininet Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/abs/dc0_s1_firewall1" + listmonitoringvnfabsresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfabsresponse.status_code, 200) + self.assertGreaterEqual(json.loads(listmonitoringvnfabsresponse.content)["MEM_%"], 0) + print(" ") + + print('->>>>>>> test Monitor VNF Abs Without Mininet Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/abs/mn.dc0_s1_firewall1" + listmonitoringvnfabsmnresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfabsmnresponse.status_code, 200) + self.assertGreaterEqual(json.loads(listmonitoringvnfabsmnresponse.content)["MEM_%"], 0) + print(" ") + + print('->>>>>>> test Monitor VNF Abs With Non-Existing VNF ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/abs/mn.dc0_s1_non_existing" + listmonitoringvnfabsnonexistingresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfabsnonexistingresponse.status_code, 500) + print(" ") + + print('->>>>>>> test Monitor VNF DC Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/dc0/s1/firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + listmonitoringvnfdcstackresponse = requests.get(url, headers=headers) + print(listmonitoringvnfdcstackresponse.content) + self.assertEqual(listmonitoringvnfdcstackresponse.status_code, 200) + self.assertGreaterEqual(json.loads(listmonitoringvnfdcstackresponse.content)["MEM_%"], 0) + print(" ") + + print('->>>>>>> test Monitor VNF DC Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/dc0/s1/firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" + listmonitoringvnfdcstackresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfdcstackresponse.status_code, 200) + self.assertGreaterEqual(json.loads(listmonitoringvnfdcstackresponse.content)["MEM_%"], 0) + print(" ") + + print('->>>>>>> test Monitor VNF DC Stack With Non-Existing Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/dc0/s1/non_existing" + listmonitoringvnfdcstackwithnonexistingnameresponse = requests.get(url, headers=headers) + + self.assertEqual(listmonitoringvnfdcstackwithnonexistingnameresponse.status_code, 500) + print(" ") + + print('->>>>>>> test Monitor VNF DC Stack With Non-Existing DC ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/non_exisintg0/s1/firewall1" + listmonitoringvnfdcstackwithnonexistingdcresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfdcstackwithnonexistingdcresponse.status_code, 500) + print(" ") + + print('->>>>>>> test Monitor VNF DC Stack With Non-Existing Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:3000/v1/monitor/dc0/non_existing_stack/firewall1" + listmonitoringvnfdcstackwithnonexistingstackresponse = requests.get(url, headers=headers) + self.assertEqual(listmonitoringvnfdcstackwithnonexistingstackresponse.status_code, 500) + print(" ") + + + + + + def testNovaDummy(self): + print('->>>>>>> test Nova Dummy Class->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), + headers=headers) + + print('->>>>>>> test Nova List Versions ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/" + listapiversionnovaresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversionnovaresponse.status_code, 200) + self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["id"], "v2.1") + self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["status"], "CURRENT") + self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["version"], "2.38") + self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["min_version"], "2.1") + self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["updated"], "2013-07-23T11:33:21Z") + print(" ") + + print('->>>>>>> test Nova Version Show ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla" + listapiversion21novaresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversion21novaresponse.status_code, 200) + self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["id"], "v2.1") + self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["status"], "CURRENT") + self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["version"], "2.38") + self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["min_version"], "2.1") + self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["updated"], "2013-07-23T11:33:21Z") + print(" ") + + print('->>>>>>> test Nova Version List Server APIs ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers" + listserverapisnovaresponse = requests.get(url, headers=headers) + self.assertEqual(listserverapisnovaresponse.status_code, 200) + self.assertNotEqual(json.loads(listserverapisnovaresponse.content)["servers"][0]["name"], "") + print(" ") + + print('->>>>>>> test Nova Delete Server APIs ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s" % (json.loads(listserverapisnovaresponse.content)["servers"][0]["id"]) + deleteserverapisnovaresponse = requests.delete(url, headers=headers) + self.assertEqual(deleteserverapisnovaresponse.status_code, 204) + print(" ") + + print('->>>>>>> test Nova Delete Non-Existing Server APIs ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/non-existing-ix" + deleteserverapisnovaresponse = requests.delete(url, headers=headers) + self.assertEqual(deleteserverapisnovaresponse.status_code, 404) + print(" ") + + + print('->>>>>>> testNovaVersionListServerAPIs_withPortInformation ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/andPorts" + listserverapisnovaresponse = requests.get(url, headers=headers) + self.assertEqual(listserverapisnovaresponse.status_code, 200) + self.assertNotEqual(json.loads(listserverapisnovaresponse.content)["servers"][0]["name"], "") + print(" ") + + print('->>>>>>> test Nova List Flavors ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/flavors" + listflavorsresponse = requests.get(url, headers=headers) + self.assertEqual(listflavorsresponse.status_code, 200) + self.assertIn(json.loads(listflavorsresponse.content)["flavors"][0]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) + self.assertIn(json.loads(listflavorsresponse.content)["flavors"][1]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) + self.assertIn(json.loads(listflavorsresponse.content)["flavors"][2]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) + print(" ") + + print('->>>>>>> testNovaAddFlavors ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/flavors" + addflavorsresponse = requests.post(url, + data='{"flavor":{"name": "testFlavor", "vcpus": "test_vcpus", "ram": 1024, "disk": 10}}', + headers=headers) + self.assertEqual(addflavorsresponse.status_code, 200) + self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["id"]) + self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["links"][0]['href']) + print(" ") + + print('->>>>>>> test Nova List Flavors Detail ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/flavors/detail" + listflavorsdetailresponse = requests.get(url, headers=headers) + self.assertEqual(listflavorsdetailresponse.status_code, 200) + self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][0]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) + self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][1]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) + self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][2]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) + print(" ") + + print('->>>>>>> testNovaAddFlavors ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/flavors/detail" + addflavorsresponse = requests.post(url, + data='{"flavor":{"name": "testFlavor", "vcpus": "test_vcpus", "ram": 1024, "disk": 10}}', + headers=headers) + self.assertEqual(addflavorsresponse.status_code, 200) + self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["id"]) + self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["links"][0]['href']) + print(" ") + + print('->>>>>>> test Nova List Flavor By Id ->>>>>>>>>>>>>>>') + + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/flavors/%s" % (json.loads(listflavorsdetailresponse.content)["flavors"][0]["name"]) + listflavorsbyidresponse = requests.get(url, headers=headers) + self.assertEqual(listflavorsbyidresponse.status_code, 200) + self.assertEqual(json.loads(listflavorsbyidresponse.content)["flavor"]["id"], json.loads(listflavorsdetailresponse.content)["flavors"][0]["id"]) + print(" ") + + print('->>>>>>> test Nova List Images ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/images" + listimagesresponse = requests.get(url, headers=headers) + self.assertEqual(listimagesresponse.status_code, 200) + print(listimagesresponse.content) + # deactivated: highly depends on the environment in which the tests are executed. one cannot make such an assumption. + #self.assertIn(json.loads(listimagesresponse.content)["images"][0]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) + #self.assertIn(json.loads(listimagesresponse.content)["images"][1]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) + #self.assertIn(json.loads(listimagesresponse.content)["images"][2]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) + print(" ") + + print('->>>>>>> test Nova List Images Details ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/images/detail" + listimagesdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(listimagesdetailsresponse.status_code, 200) + # deactivated: highly depends on the environment in which the tests are executed. one cannot make such an assumption. + #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][0]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) + #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][1]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) + #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][2]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) + self.assertEqual(json.loads(listimagesdetailsresponse.content)["images"][0]["metadata"]["architecture"],"x86_64") + print(" ") + + print('->>>>>>> test Nova List Image By Id ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/images/%s" % (json.loads(listimagesdetailsresponse.content)["images"][0]["id"]) + listimagebyidresponse = requests.get(url, headers=headers) + self.assertEqual(listimagebyidresponse.status_code, 200) + self.assertEqual(json.loads(listimagebyidresponse.content)["image"]["id"],json.loads(listimagesdetailsresponse.content)["images"][0]["id"]) + print(" ") + + print('->>>>>>> test Nova List Image By Non-Existend Id ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/images/non_existing_id" + listimagebynonexistingidresponse = requests.get(url, headers=headers) + self.assertEqual(listimagebynonexistingidresponse.status_code, 404) + print(" ") + + #find ubuntu id + for image in json.loads(listimagesresponse.content)["images"]: + if image["name"] == "ubuntu:trusty": + ubuntu_image_id = image["id"] + + + + print('->>>>>>> test Nova Create Server Instance ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers" + data = '{"server": {"name": "X", "flavorRef": "%s", "imageRef":"%s"}}' % (json.loads(listflavorsresponse.content)["flavors"][0]["id"], ubuntu_image_id) + createserverinstance = requests.post(url, data=data, headers=headers) + self.assertEqual(createserverinstance.status_code, 200) + self.assertEqual(json.loads(createserverinstance.content)["server"]["image"]["id"], ubuntu_image_id) + print(" ") + + print('->>>>>>> test Nova Create Server Instance With Already Existing Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers" + data = '{"server": {"name": "X", "flavorRef": "%s", "imageRef":"%s"}}' % (json.loads(listflavorsresponse.content)["flavors"][0]["id"], ubuntu_image_id) + createserverinstance = requests.post(url, data=data, headers=headers) + self.assertEqual(createserverinstance.status_code, 409) + print(" ") + + print('->>>>>>> test Nova Version List Server APIs Detailed ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/detail" + listserverapisdetailedresponse = requests.get(url, headers=headers) + self.assertEqual(listserverapisdetailedresponse.status_code, 200) + self.assertEqual(json.loads(listserverapisdetailedresponse.content)["servers"][0]["status"], "ACTIVE") + print(" ") + + print('->>>>>>> test Nova Show Server Details ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s" % (json.loads(listserverapisdetailedresponse.content)["servers"][0]["id"]) + listserverdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(listserverdetailsresponse.status_code, 200) + self.assertEqual(json.loads(listserverdetailsresponse.content)["server"]["flavor"]["links"][0]["rel"], "bookmark") + print(" ") + + print('->>>>>>> test Nova Show Non-Existing Server Details ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/non_existing_server_id" + listnonexistingserverdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(listnonexistingserverdetailsresponse.status_code, 404) + print(" ") + + + + def testNeutronDummy(self): + print('->>>>>>> test Neutron Dummy Class->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) + # test_heatapi_keystone_get_token = open("test_heatapi_keystone_get_token.json").read() + + print('->>>>>>> test Neutron List Versions ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/" + listapiversionstackresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversionstackresponse.status_code, 200) + self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v2.0") + print(" ") + + print('->>>>>>> test Neutron Show API v2.0 ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0" + listapiversionv20response = requests.get(url, headers=headers) + self.assertEqual(listapiversionv20response.status_code, 200) + self.assertEqual(json.loads(listapiversionv20response.content)["resources"][0]["name"], "subnet") + self.assertEqual(json.loads(listapiversionv20response.content)["resources"][1]["name"], "network") + self.assertEqual(json.loads(listapiversionv20response.content)["resources"][2]["name"], "ports") + print(" ") + + print('->>>>>>> test Neutron List Networks ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks" + listnetworksesponse1 = requests.get(url, headers=headers) + self.assertEqual(listnetworksesponse1.status_code, 200) + self.assertEqual(json.loads(listnetworksesponse1.content)["networks"][0]["status"], "ACTIVE") + listNetworksId = json.loads(listnetworksesponse1.content)["networks"][0]["id"] + listNetworksName = json.loads(listnetworksesponse1.content)["networks"][0]["name"] + listNetworksId2 = json.loads(listnetworksesponse1.content)["networks"][1]["id"] + print(" ") + + print('->>>>>>> test Neutron List Non-Existing Networks ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks?name=non_existent_network_name" + listnetworksesponse2 = requests.get(url,headers=headers) + self.assertEqual(listnetworksesponse2.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron List Networks By Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks?name=" + listNetworksName #tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + listnetworksesponse3 = requests.get(url, headers=headers) + self.assertEqual(listnetworksesponse3.status_code, 200) + self.assertEqual(json.loads(listnetworksesponse3.content)["networks"][0]["name"], listNetworksName) + print(" ") + + print('->>>>>>> test Neutron List Networks By Id ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks?id=" + listNetworksId # tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + listnetworksesponse4 = requests.get(url, headers=headers) + self.assertEqual(listnetworksesponse4.status_code, 200) + self.assertEqual(json.loads(listnetworksesponse4.content)["networks"][0]["id"], listNetworksId) + print(" ") + + print('->>>>>>> test Neutron List Networks By Multiple Ids ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks?id=" + listNetworksId + "&id="+ listNetworksId2 # tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest + listnetworksesponse5 = requests.get(url, headers=headers) + self.assertEqual(listnetworksesponse5.status_code, 200) + self.assertEqual(json.loads(listnetworksesponse5.content)["networks"][0]["id"], listNetworksId) + self.assertEqual(json.loads(listnetworksesponse5.content)["networks"][1]["id"], listNetworksId2) + print(" ") + + print('->>>>>>> test Neutron Show Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks/"+listNetworksId + shownetworksesponse = requests.get(url, headers=headers) + self.assertEqual(shownetworksesponse.status_code, 200) + self.assertEqual(json.loads(shownetworksesponse.content)["network"]["status"], "ACTIVE") + print(" ") + + print('->>>>>>> test Neutron Show Network Non-ExistendNetwork ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks/non_existent_network_id" + shownetworksesponse2 = requests.get(url, headers=headers) + self.assertEqual(shownetworksesponse2.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron Create Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks" + createnetworkresponse = requests.post(url, data='{"network": {"name": "sample_network","admin_state_up": true}}', headers=headers) + self.assertEqual(createnetworkresponse.status_code, 201) + self.assertEqual(json.loads(createnetworkresponse.content)["network"]["status"], "ACTIVE") + print(" ") + + print('->>>>>>> test Neutron Create Network With Existing Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks" + createnetworkresponsefailure = requests.post(url,data='{"network": {"name": "sample_network","admin_state_up": true}}',headers=headers) + self.assertEqual(createnetworkresponsefailure.status_code, 400) + print(" ") + + print('->>>>>>> test Neutron Update Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks/%s" % (json.loads(createnetworkresponse.content)["network"]["id"]) + updatenetworkresponse = requests.put(url, data='{"network": {"status": "ACTIVE", "admin_state_up":true, "tenant_id":"abcd123", "name": "sample_network_new_name", "shared":false}}' , headers=headers) + self.assertEqual(updatenetworkresponse.status_code, 200) + self.assertEqual(json.loads(updatenetworkresponse.content)["network"]["name"], "sample_network_new_name") + self.assertEqual(json.loads(updatenetworkresponse.content)["network"]["tenant_id"], "abcd123") + print(" ") + + print('->>>>>>> test Neutron Update Non-Existing Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks/non-existing-name123" + updatenetworkresponse = requests.put(url, data='{"network": {"name": "sample_network_new_name"}}', headers=headers) + self.assertEqual(updatenetworkresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron List Subnets ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets" + listsubnetsresponse = requests.get(url, headers=headers) + listSubnetName = json.loads(listsubnetsresponse.content)["subnets"][0]["name"] + listSubnetId = json.loads(listsubnetsresponse.content)["subnets"][0]["id"] + listSubnetId2 = json.loads(listsubnetsresponse.content)["subnets"][1]["id"] + self.assertEqual(listsubnetsresponse.status_code, 200) + self.assertNotIn('None', listSubnetName) + print(" ") + + print('->>>>>>> test Neutron List Subnets By Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets?name="+listSubnetName + listsubnetByNameresponse = requests.get(url, headers=headers) + self.assertEqual(listsubnetByNameresponse.status_code, 200) + self.assertNotIn('None', json.loads(listsubnetByNameresponse.content)["subnets"][0]["name"]) + print(" ") + + print('->>>>>>> test Neutron List Subnets By Id ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets?id=" + listSubnetId + listsubnetsbyidresponse = requests.get(url, headers=headers) + self.assertEqual(listsubnetsbyidresponse.status_code, 200) + self.assertNotIn("None", json.loads(listsubnetsbyidresponse.content)["subnets"][0]["name"]) + print(" ") + + print('->>>>>>> test Neutron List Subnets By Multiple Id ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets?id=" + listSubnetId +"&id="+listSubnetId2 + listsubnetsbymultipleidsresponse = requests.get(url, headers=headers) + self.assertEqual(listsubnetsbymultipleidsresponse.status_code, 200) + self.assertNotIn("None", json.loads(listsubnetsbymultipleidsresponse.content)["subnets"][0]["name"]) + print(" ") + + + + print('->>>>>>> test Neutron Show Subnet->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets/%s" % (json.loads(listsubnetsresponse.content)["subnets"][0]["id"]) + showsubnetsresponse = requests.get(url, headers=headers) + self.assertEqual(showsubnetsresponse.status_code, 200) + self.assertNotIn("None", json.loads(showsubnetsresponse.content)["subnet"]["name"]) + print(" ") + + print('->>>>>>> test Neutron Show Non-Existing Subnet->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets/non-existing-id123" + showsubnetsresponse = requests.get(url, headers=headers) + self.assertEqual(showsubnetsresponse.status_code, 404) + print(" ") + + + print('->>>>>>> test Neutron Create Subnet ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets" + createsubnetdata = '{"subnet": {"name": "new_subnet", "network_id": "%s","ip_version": 4,"cidr": "10.0.0.1/24"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) + createsubnetresponse = requests.post(url, data=createsubnetdata, headers=headers) + self.assertEqual(createsubnetresponse.status_code, 201) + self.assertEqual(json.loads(createsubnetresponse.content)["subnet"]["name"], "new_subnet") + print(" ") + + print('->>>>>>> test Neutron Create Second Subnet ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets" + createsubnetdata = '{"subnet": {"name": "new_subnet", "network_id": "%s","ip_version": 4,"cidr": "10.0.0.1/24"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) + createsubnetfailureresponse = requests.post(url, data=createsubnetdata, headers=headers) + self.assertEqual(createsubnetfailureresponse.status_code, 409) + print(" ") + + print('->>>>>>> test Neutron Update Subnet ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets/%s" % (json.loads(createsubnetresponse.content)["subnet"]["id"]) + updatesubnetdata = '{"subnet": {"name": "new_subnet_new_name", "network_id":"some_id", "tenant_id":"new_tenant_id", "allocation_pools":"change_me", "gateway_ip":"192.168.1.120", "ip_version":4, "cidr":"10.0.0.1/24", "id":"some_new_id", "enable_dhcp":true} }' + updatesubnetresponse = requests.put(url, data=updatesubnetdata, headers=headers) + self.assertEqual(updatesubnetresponse.status_code, 200) + self.assertEqual(json.loads(updatesubnetresponse.content)["subnet"]["name"], "new_subnet_new_name") + print(" ") + + print('->>>>>>> test Neutron Update Non-Existing Subnet ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/subnets/non-existing-subnet-12345" + updatenonexistingsubnetdata = '{"subnet": {"name": "new_subnet_new_name"} }' + updatenonexistingsubnetresponse = requests.put(url, data=updatenonexistingsubnetdata, headers=headers) + self.assertEqual(updatenonexistingsubnetresponse.status_code, 404) + print(" ") + + + + print('->>>>>>> test Neutron List Ports ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + listportsesponse = requests.get(url, headers=headers) + self.assertEqual(listportsesponse.status_code, 200) + self.assertEqual(json.loads(listportsesponse.content)["ports"][0]["status"], "ACTIVE") + listPortsName = json.loads(listportsesponse.content)["ports"][0]["name"] + listPortsId1 = json.loads(listportsesponse.content)["ports"][0]["id"] + listPortsId2 = json.loads(listportsesponse.content)["ports"][1]["id"] + print(" ") + + print('->>>>>>> test Neutron List Ports By Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports?name=" + listPortsName + listportsbynameesponse = requests.get(url, headers=headers) + self.assertEqual(listportsbynameesponse.status_code, 200) + self.assertEqual(json.loads(listportsbynameesponse.content)["ports"][0]["name"], listPortsName) + print(" ") + + print('->>>>>>> test Neutron List Ports By Id ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports?id=" + listPortsId1 + listportsbyidesponse = requests.get(url, headers=headers) + self.assertEqual(listportsbyidesponse.status_code, 200) + self.assertEqual(json.loads(listportsbyidesponse.content)["ports"][0]["id"], listPortsId1) + print(" ") + + print('->>>>>>> test Neutron List Ports By Multiple Ids ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports?id=" + listPortsId1 +"&id="+listPortsId2 + listportsbymultipleidsesponse = requests.get(url, headers=headers) + self.assertEqual(listportsbymultipleidsesponse.status_code, 200) + self.assertEqual(json.loads(listportsbymultipleidsesponse.content)["ports"][0]["id"], listPortsId1) + print(" ") + + print('->>>>>>> test Neutron List Non-Existing Ports ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports?id=non-existing-port-id" + listportsbynonexistingidsesponse = requests.get(url, headers=headers) + self.assertEqual(listportsbynonexistingidsesponse.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron Show Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports/%s" % (json.loads(listportsesponse.content)["ports"][0]["id"]) + showportresponse = requests.get(url, headers=headers) + self.assertEqual(showportresponse.status_code, 200) + self.assertEqual(json.loads(showportresponse.content)["port"]["status"], "ACTIVE") + print(" ") + + print('->>>>>>> test Neutron Show Non-Existing Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports/non-existing-portid123" + shownonexistingportresponse = requests.get(url, headers=headers) + self.assertEqual(shownonexistingportresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron Create Port In Non-Existing Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + createnonexistingportdata = '{"port": {"name": "new_port", "network_id": "non-existing-id"} }' + createnonexistingnetworkportresponse = requests.post(url, data=createnonexistingportdata, headers=headers) + self.assertEqual(createnonexistingnetworkportresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron Create Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + createportdata = '{"port": {"name": "new_port", "network_id": "%s", "admin_state_up":true, "device_id":"device_id123", "device_owner":"device_owner123", "fixed_ips":"change_me","id":"new_id1234", "mac_address":"12:34:56:78:90", "status":"change_me", "tenant_id":"tenant_id123"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) + createportresponse = requests.post(url, data=createportdata, headers=headers) + self.assertEqual(createportresponse.status_code, 201) + print (createportresponse.content) + self.assertEqual(json.loads(createportresponse.content)["port"]["name"], "new_port") + print(" ") + + print('->>>>>>> test Neutron Create Port With Existing Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + createportwithexistingnamedata = '{"port": {"name": "new_port", "network_id": "%s"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) + createportwithexistingnameresponse = requests.post(url, data=createportwithexistingnamedata, headers=headers) + self.assertEqual(createportwithexistingnameresponse.status_code, 500) + print(" ") + + print('->>>>>>> test Neutron Create Port Without Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + createportdatawithoutname = '{"port": {"network_id": "%s"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) + createportwithoutnameresponse = requests.post(url, data=createportdatawithoutname, headers=headers) + self.assertEqual(createportwithoutnameresponse.status_code, 201) + self.assertIn("port:cp", json.loads(createportwithoutnameresponse.content)["port"]["name"]) + print(" ") + + print('->>>>>>> test Neutron Update Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(json.loads(createportresponse.content)["port"]["name"]) + url = "http://0.0.0.0:9696/v2.0/ports/%s" % (json.loads(createportresponse.content)["port"]["name"]) + updateportdata = '{"port": {"name": "new_port_new_name", "admin_state_up":true, "device_id":"device_id123", "device_owner":"device_owner123", "fixed_ips":"change_me","mac_address":"12:34:56:78:90", "status":"change_me", "tenant_id":"tenant_id123", "network_id":"network_id123"} }' + updateportresponse = requests.put(url, data=updateportdata, headers=headers) + self.assertEqual(updateportresponse.status_code, 200) + self.assertEqual(json.loads(updateportresponse.content)["port"]["name"], "new_port_new_name") + print(" ") + + print('->>>>>>> test Neutron Update Non-Existing Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports/non-existing-port-ip" + updatenonexistingportdata = '{"port": {"name": "new_port_new_name"} }' + updatenonexistingportresponse = requests.put(url, data=updatenonexistingportdata, headers=headers) + self.assertEqual(updatenonexistingportresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron Delete Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + righturl = "http://0.0.0.0:9696/v2.0/ports/%s" % (json.loads(createportresponse.content)["port"]["id"]) + deleterightportresponse = requests.delete(righturl, headers=headers) + self.assertEqual(deleterightportresponse.status_code, 204) + print(" ") + + + print('->>>>>>> test Neutron Delete Non-Existing Port ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + wrongurl = "http://0.0.0.0:9696/v2.0/ports/unknownid" + deletewrongportresponse = requests.delete(wrongurl, headers=headers) + self.assertEqual(deletewrongportresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Neutron Delete Subnet ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + wrongurl = "http://0.0.0.0:9696/v2.0/subnets/unknownid" + righturl = "http://0.0.0.0:9696/v2.0/subnets/%s" % (json.loads(updatesubnetresponse.content)["subnet"]["id"]) + deletewrongsubnetresponse = requests.delete(wrongurl, headers=headers) + deleterightsubnetresponse = requests.delete(righturl, headers=headers) + self.assertEqual(deletewrongsubnetresponse.status_code, 404) + self.assertEqual(deleterightsubnetresponse.status_code, 204) + print(" ") + + print('->>>>>>> test Neutron Delete Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + righturl = "http://0.0.0.0:9696/v2.0/networks/%s" % (json.loads(createnetworkresponse.content)["network"]["id"]) + deleterightnetworkresponse = requests.delete(righturl, headers=headers) + self.assertEqual(deleterightnetworkresponse.status_code, 204) + print(" ") + + print('->>>>>>> test Neutron Delete Non-Existing Network ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + wrongurl = "http://0.0.0.0:9696/v2.0/networks/unknownid" + deletewrongnetworkresponse = requests.delete(wrongurl, headers=headers) + self.assertEqual(deletewrongnetworkresponse.status_code, 404) + print(" ") + + def testKeystomeDummy(self): + print('->>>>>>> test Keystone Dummy Class->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_keystone_get_token = open(os.path.join(os.path.dirname(__file__), "test_heatapi_keystone_get_token.json")).read() + + print('->>>>>>> test Keystone List Versions ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:5000/" + listapiversionstackresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversionstackresponse.status_code, 200) + self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"]["values"][0]["id"], "v2.0") + print(" ") + + print('->>>>>>> test Keystone Show ApiV2 ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:5000/v2.0" + showapiversionstackresponse = requests.get(url, headers=headers) + self.assertEqual(showapiversionstackresponse.status_code, 200) + self.assertEqual(json.loads(showapiversionstackresponse.content)["version"]["id"], "v2.0") + print(" ") + + print('->>>>>>> test Keystone Get Token ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:5000/v2.0/tokens" + gettokenstackresponse = requests.post(url, data=json.dumps(json.loads(test_heatapi_keystone_get_token)), headers=headers) + self.assertEqual(gettokenstackresponse.status_code, 200) + self.assertEqual(json.loads(gettokenstackresponse.content)["access"]["user"]["name"], "tenantName") + print(" ") + + + def testHeatDummy(self): + print('->>>>>>> test Heat Dummy Class->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() + test_heatapi_template_update_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_update_stack.json")).read() + + print('->>>>>>> test Heat List API Versions Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/" + listapiversionstackresponse = requests.get(url, headers=headers) + self.assertEqual(listapiversionstackresponse.status_code, 200) + self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1.0") + print(" ") + + print('->>>>>>> test Create Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + createstackresponse = requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) + self.assertEqual(createstackresponse.status_code, 201) + self.assertNotEqual(json.loads(createstackresponse.content)["stack"]["id"], "") + print(" ") + + print('->>>>>>> test Create Stack With Existing Name ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + createstackwithexistingnameresponse = requests.post(url, data='{"stack_name" : "s1"}', headers=headers) + self.assertEqual(createstackwithexistingnameresponse.status_code, 409) + print(" ") + + print('->>>>>>> test Create Stack With Unsupported Version ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + createstackwitheunsupportedversionresponse = requests.post(url, data='{"stack_name" : "stackname123", "template" : {"heat_template_version": "2015-04-29"}}', headers=headers) + self.assertEqual(createstackwitheunsupportedversionresponse.status_code, 400) + print(" ") + + + print('->>>>>>> test List Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + liststackresponse = requests.get(url, headers=headers) + self.assertEqual(liststackresponse.status_code, 200) + self.assertEqual(json.loads(liststackresponse.content)["stacks"][0]["stack_status"], "CREATE_COMPLETE") + print(" ") + + + print('->>>>>>> test Show Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123showStack/stacks/%s"% json.loads(createstackresponse.content)['stack']['id'] + liststackdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(liststackdetailsresponse.status_code, 200) + self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "CREATE_COMPLETE") + print(" ") + + print('->>>>>>> test Show Non-Exisitng Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123showStack/stacks/non_exisitng_id123" + listnonexistingstackdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(listnonexistingstackdetailsresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Update Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123updateStack/stacks/%s"% json.loads(createstackresponse.content)['stack']['id'] + updatestackresponse = requests.put(url, data=json.dumps(json.loads(test_heatapi_template_update_stack)), + headers=headers) + self.assertEqual(updatestackresponse.status_code, 202) + liststackdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "UPDATE_COMPLETE") + print(" ") + + print('->>>>>>> test Update Non-Existing Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123updateStack/stacks/non_existing_id_1234" + updatenonexistingstackresponse = requests.put(url, data={"non": "sense"}, headers=headers) + self.assertEqual(updatenonexistingstackresponse.status_code, 404) + print(" ") + + print('->>>>>>> test Delete Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123showStack/stacks/%s" % \ + json.loads(createstackresponse.content)['stack']['id'] + deletestackdetailsresponse = requests.delete(url, headers=headers) + self.assertEqual(deletestackdetailsresponse.status_code, 204) + print(" ") + + + def test_CombinedTesting(self): + print('->>>>>>> test Combinded tests->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + print(" ") + + headers = {'Content-type': 'application/json'} + test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), + "test_heatapi_template_create_stack.json")).read() + test_heatapi_template_update_stack = open(os.path.join(os.path.dirname(__file__), + "test_heatapi_template_update_stack.json")).read() + + print('->>>>>>> test Combined Create Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" + createstackresponse = requests.post(url, + data=json.dumps(json.loads(test_heatapi_template_create_stack)), + headers=headers) + self.assertEqual(createstackresponse.status_code, 201) + self.assertNotEqual(json.loads(createstackresponse.content)["stack"]["id"], "") + print(" ") + + print('->>>>>>> test Combined Neutron List Ports ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + listportsesponse = requests.get(url, headers=headers) + self.assertEqual(listportsesponse.status_code, 200) + self.assertEqual(len(json.loads(listportsesponse.content)["ports"]), 9) + for port in json.loads(listportsesponse.content)["ports"]: + self.assertEqual(len(str(port['fixed_ips'][0]['subnet_id'])), 36) + print(" ") + + print('->>>>>>> test Combined Neutron List Networks ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks" + listnetworksesponse = requests.get(url, headers=headers) + self.assertEqual(listnetworksesponse.status_code, 200) + self.assertEqual(len(json.loads(listnetworksesponse.content)["networks"]), 10) + for net in json.loads(listnetworksesponse.content)["networks"]: + self.assertEqual(len(str(net['subnets'][0])), 36) + print(" ") + + print('->>>>>>> test Combined Update Stack ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8004/v1/tenantabc123updateStack/stacks/%s"% \ + json.loads(createstackresponse.content)['stack']['id'] + updatestackresponse = requests.put(url, + data=json.dumps(json.loads(test_heatapi_template_update_stack)), + headers=headers) + self.assertEqual(updatestackresponse.status_code, 202) + liststackdetailsresponse = requests.get(url, headers=headers) + self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "UPDATE_COMPLETE") + print(" ") + + print('->>>>>>> test Combined Neutron List Ports ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/ports" + listportsesponse = requests.get(url, headers=headers) + self.assertEqual(listportsesponse.status_code, 200) + self.assertEqual(len(json.loads(listportsesponse.content)["ports"]), 18) + for port in json.loads(listportsesponse.content)["ports"]: + self.assertEqual(len(str(port['fixed_ips'][0]['subnet_id'])), 36) + print(" ") + + print('->>>>>>> test Combined Neutron List Networks ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/networks" + listnetworksesponse = requests.get(url, headers=headers) + self.assertEqual(listnetworksesponse.status_code, 200) + self.assertEqual(len(json.loads(listnetworksesponse.content)["networks"]), 14) + for net in json.loads(listnetworksesponse.content)["networks"]: + self.assertEqual(len(str(net['subnets'][0])), 36) + print(" ") + + + # workflow create floating ip and assign it to a server + + print('->>>>>>> CombinedNeutronCreateFloatingIP ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:9696/v2.0/floatingips" + createflip = requests.post(url, headers=headers, + data='{"floatingip":{"floating_network_id":"default"}}') + self.assertEqual(createflip.status_code, 200) + self.assertIsNotNone(json.loads(createflip.content)["floatingip"].get("port_id")) + port_id = json.loads(createflip.content)["floatingip"].get("port_id") + print(" ") + + print('->>>>>>> CombinedNovaGetServer ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/detail" + listserverapisdetailedresponse = requests.get(url, headers=headers) + self.assertEqual(listserverapisdetailedresponse.status_code, 200) + self.assertEqual(json.loads(listserverapisdetailedresponse.content)["servers"][0]["status"], "ACTIVE") + server_id = json.loads(listserverapisdetailedresponse.content)["servers"][0]["id"] + print(" ") + + print('->>>>>>> CombinedNovaAssignInterface ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s/os-interface" % server_id + assign = requests.post(url, headers=headers, + data='{"interfaceAttachment":{"net_id": "default"}}') + self.assertEqual(assign.status_code, 202) + self.assertIsNotNone(json.loads(assign.content)["interfaceAttachment"].get("port_id")) + port_id = json.loads(assign.content)["interfaceAttachment"].get("port_id") + print(" ") + + print('->>>>>>> CombinedNovaDeleteInterface ->>>>>>>>>>>>>>>') + print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') + url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s/os-interface/%s" % (server_id, port_id) + getintfs = requests.delete(url, headers=headers) + self.assertEqual(getintfs.status_code, 202) + print(" ") + + +if __name__ == '__main__': + unittest.main() -- 2.25.1