3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
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 ##############################################################################
13 # download and create image
17 echo "external_network=$external_network"
19 wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2
20 glance image-create --name 'Fedora22' --disk-format qcow2 \
21 --container-format bare --file ./Fedora-Cloud-Base-22-20150521.x86_64.qcow2
24 neutron router-create ipv4-router
25 neutron router-create ipv6-router
27 # Associate the net04_ext to the Neutron routers
28 neutron router-gateway-set ipv6-router $external_network
29 neutron router-gateway-set ipv4-router $external_network
31 # create two ipv4 networks with associated subnets
32 neutron net-create ipv4-int-network1
33 neutron net-create ipv4-int-network2
35 # Create IPv4 subnet and associate it to ipv4-router
36 neutron subnet-create --name ipv4-int-subnet1 \
37 --dns-nameserver 8.8.8.8 ipv4-int-network1 20.0.0.0/24
39 # Associate the ipv4-int-subnet1 with ipv4-router
40 neutron router-interface-add ipv4-router ipv4-int-subnet1
42 # BIN-HU: Here, for scenario 2, ipv6-int-subnet2 cannot be created automatically because of a bug in ODL
43 # BIN-HU: we need to manually spawn a RADVD daemon in ipv6-router namespace
45 # Create an IPv4 subnet ipv4-int-subnet2 and associate it with ipv6-router
46 neutron subnet-create --name ipv4-int-subnet2 --dns-nameserver 8.8.8.8 ipv4-int-network2 10.0.0.0/24
48 neutron router-interface-add ipv6-router ipv4-int-subnet2
50 # BIN-HU: for the reason above in scenario 2, we need to remove the following command
53 nova keypair-add vRouterKey > ~/vRouterKey
55 # Create ports for vRouter
56 neutron port-create --name eth0-vRouter --mac-address fa:16:3e:11:11:11 ipv4-int-network2
57 neutron port-create --name eth1-vRouter --mac-address fa:16:3e:22:22:22 ipv4-int-network1
59 # Create ports for VM1 and VM2.
60 neutron port-create --name eth0-VM1 --mac-address fa:16:3e:33:33:33 ipv4-int-network1
61 neutron port-create --name eth0-VM2 --mac-address fa:16:3e:44:44:44 ipv4-int-network1
64 # Hope you are cloning the following repo for some files like radvd.conf and metadata.txt
65 # JFYI, metadata.txt is available at the following git repo. https://github.com/sridhargaddam/opnfv_os_ipv6_poc/blob/master/metadata.txt
67 nova boot --image Fedora22 --flavor m1.small \
68 --user-data ./metadata.txt \
69 --nic port-id=$(neutron port-list | grep -w eth0-vRouter | awk '{print $2}') \
70 --nic port-id=$(neutron port-list | grep -w eth1-vRouter | awk '{print $2}') \
71 --key-name vRouterKey vRouter
73 # BIN-HU: Note that some other parameters might be needed in Scenario 2, if it does not work
74 # BIN-HU: Refer to http://artifacts.opnfv.org/ipv6/docs/setupservicevm/4-ipv6-configguide-servicevm.html#boot-two-other-vms-in-ipv4-int-network1
75 # BIN-HU: Section 3.5.7
77 nova boot --image Fedora22 --flavor m1.small \
78 --nic port-id=$(neutron port-list | grep -w eth0-VM1 | awk '{print $2}') \
79 --key-name vRouterKey VM1
81 nova boot --image Fedora22 --flavor m1.small \
82 --nic port-id=$(neutron port-list | grep -w eth0-VM2 | awk '{print $2}') \
83 --key-name vRouterKey VM2
87 # BIN-HU: Now we need to spawn a RADVD daemon inside ipv6-router namespace
88 # BIN-HU: The following is specific for Scenario 2 to spawn a RADVD daemon in ipv6-router namespace
89 # BIN-HU: Refer to http://artifacts.opnfv.org/ipv6/docs/setupservicevm/4-ipv6-configguide-servicevm.html#spawn-radvd-in-ipv6-router
90 # BIN-HU: Section 3.5.8, Steps SETUP-SVM-24 through SETUP-SVM-30
91 # BIN-HU: Also note that in case of HA deployment, ipv6-router created in previous step
92 # BIN-HU: could be in any of the controller node. Thus you need to identify in which controller node
93 # BIN-HU: ipv6-router is created in order to manually spawn RADVD daemon inside the ipv6-router
94 # BIN-HU: namespace in the following steps.
95 # BIN-HU: Just FYI: the following command in Neutron will display the controller on which the
96 # BIN-HU: ipv6-router is spawned.
97 neutron l3-agent-list-hosting-router ipv6-router
99 # find host which is located by ipv6-router, but need to debug
100 host_num=$(neutron l3-agent-list-hosting-router ipv6-router | grep True | awk -F [=\ ] '{printf $4}')
103 # BIN-HU: identify the ipv6-router namespace and move to the namespace
104 sudo ip netns exec qrouter-$(neutron router-list | grep -w ipv6-router | awk '{print $2}') bash
106 # BIN-HU: Inside ipv6-router namespace, configure the IPv6 address on the <qr-xxx> interface.
107 export router_interface=$(ip a s | grep -w "global qr-*" | awk '{print $7}')
108 ip -6 addr add 2001:db8:0:1::1 dev $router_interface
110 # BIN-HU: Update the sample file radvd.conf with $router_interface
111 sed -i 's/$router_interface/'$router_interface'/g' ~/br-ex.radvd.conf
113 # BIN-HU: Spawn a RADVD daemon to simulate an external router
114 radvd -C ~/br-ex.radvd.conf -p ~/br-ex.pid.radvd
116 # BIN-HU: Add an IPv6 downstream route pointing to the eth0 interface of vRouter.
117 ip -6 route add 2001:db8:0:2::/64 via 2001:db8:0:1:f816:3eff:fe11:1111
119 # BIN-HU: you can double check the routing table
123 # BIN-HU: End of Scenario 2, and you can continue to SSH etc., the same as Scenario 1