Merge "Fixed few gaps when running on a minimal version of system"
[yardstick.git] / yardstick / benchmark / scenarios / networking / ping6_setup.bash
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12
13 # download and create image
14 openrc=$1
15 external_network=$2
16 echo "openrc=$openrc"
17 echo "external_network=$external_network"
18 echo "nameserver 8.8.4.4" >> /etc/resolv.conf
19 source $openrc
20
21 fedora_img="Fedora-Cloud-Base-22-20150521.x86_64.qcow2"
22 if [ ! -f "$fedora_img" ]; then
23     wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/${fedora_img} >/dev/null 2>&1
24 fi
25
26 glance image-create --name 'Fedora22' --disk-format qcow2 \
27 --container-format bare --file ./Fedora-Cloud-Base-22-20150521.x86_64.qcow2
28
29
30 # create router
31 neutron router-create ipv4-router
32 neutron router-create ipv6-router
33
34
35 # create (ipv4,ipv6)router and net and subnet
36 neutron net-create ipv4-int-network1
37 neutron net-create ipv6-int-network2
38
39 # Create IPv4 subnet and associate it to ipv4-router
40 neutron subnet-create --name ipv4-int-subnet1 \
41 --dns-nameserver 8.8.8.8 ipv4-int-network1 20.0.0.0/24
42 neutron router-interface-add ipv4-router ipv4-int-subnet1
43
44 #  Associate the net04_ext to the Neutron routers
45 neutron router-gateway-set ipv6-router $external_network
46 neutron router-gateway-set ipv4-router $external_network
47
48 # Create two subnets, one IPv4 subnet ipv4-int-subnet2 and
49 # one IPv6 subnet ipv6-int-subnet2 in ipv6-int-network2, and associate both subnets to ipv6-router
50 neutron subnet-create --name ipv4-int-subnet2 --dns-nameserver 8.8.8.8 ipv6-int-network2 10.0.0.0/24
51 neutron subnet-create --name ipv6-int-subnet2 \
52  --ip-version 6 --ipv6-ra-mode slaac --ipv6-address-mode slaac ipv6-int-network2 2001:db8:0:1::/64
53
54
55 neutron router-interface-add ipv6-router ipv4-int-subnet2
56 neutron router-interface-add ipv6-router ipv6-int-subnet2
57
58
59 # create key
60 nova keypair-add vRouterKey > ~/vRouterKey
61
62 # Create ports for vRouter
63 neutron port-create --name eth0-vRouter --mac-address fa:16:3e:11:11:11 ipv6-int-network2
64 neutron port-create --name eth1-vRouter --mac-address fa:16:3e:22:22:22 ipv4-int-network1
65
66 # Create ports for VM1 and VM2.
67 neutron port-create --name eth0-VM1 --mac-address fa:16:3e:33:33:33 ipv4-int-network1
68 neutron port-create --name eth0-VM2 --mac-address fa:16:3e:44:44:44 ipv4-int-network1
69
70 # Update ipv6-router with routing information to subnet 2001:db8:0:2::/64
71 neutron router-update ipv6-router \
72  --routes type=dict list=true destination=2001:db8:0:2::/64,nexthop=2001:db8:0:1:f816:3eff:fe11:1111
73
74 # vRouter boot
75 nova boot --image Fedora22 --flavor m1.small \
76 --user-data ./metadata.txt \
77 --nic port-id=$(neutron port-list | grep -w eth0-vRouter | awk '{print $2}') \
78 --nic port-id=$(neutron port-list | grep -w eth1-vRouter | awk '{print $2}') \
79 --key-name vRouterKey vRouter
80
81 # VM create
82 nova boot --image Fedora22  --flavor m1.small \
83 --nic port-id=$(neutron port-list | grep -w eth0-VM1 | awk '{print $2}') \
84 --key-name vRouterKey VM1
85
86 nova boot --image Fedora22  --flavor m1.small \
87 --nic port-id=$(neutron port-list | grep -w eth0-VM2 | awk '{print $2}') \
88 --key-name vRouterKey VM2
89
90 sleep 60
91
92 nova list
93 # disable eth0-VM1, eth0-VM2, eth0-vRouter, eth1-vRouter port-security
94 for port in eth0-VM1 eth0-VM2 eth0-vRouter eth1-vRouter
95 do
96     neutron port-update --no-security-groups $port
97     neutron port-update $port --port-security-enabled=False
98     neutron port-show $port | grep port_security_enabled
99 done