summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorjuraj.linkes <jlinkes@cisco.com>2016-12-06 10:30:35 +0100
committerjuraj.linkes <jlinkes@cisco.com>2016-12-06 10:30:35 +0100
commitccccedae0b0a77c98a0bccffb18cc0f0da7b94d7 (patch)
tree07bc97445dea178c44c87ecc0eccf08f7dadaac7 /scripts
parent439106f86a5c9f3a06ca1bbbd1068006658c156a (diff)
Added basic script for creating two vms using openstack client and a script that mimics functests' vping_ssh using openstack client
Change-Id: I90cfacd8d4f042f707a197deb6a3dc680ff692e5 Signed-off-by: juraj.linkes <jlinkes@cisco.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create_two_vms.sh25
-rwxr-xr-xscripts/functest_sim.sh37
2 files changed, 62 insertions, 0 deletions
diff --git a/scripts/create_two_vms.sh b/scripts/create_two_vms.sh
new file mode 100755
index 0000000..10cc094
--- /dev/null
+++ b/scripts/create_two_vms.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# NETWORK AND SUBNET
+echo "Creating network with subnet"
+neutron net-create test-net
+neutron subnet-create --name test-subnet test-net 192.168.20.0/24
+
+# ATTACH NETWORK TO ROUTER
+echo "Attaching external and tenant networks to reouter"
+neutron router-create test-router
+neutron router-interface-add test-router test-subnet
+neutron router-gateway-set test-router external
+
+# FIRST VM
+echo "Creating port and first VM"
+neutron port-create --name test-port1 test-net
+nova boot --image cirros-0.3.4 --flavor nfv --nic port-id=`neutron port-list | grep test-port1 | cut -f 2 -d " "` test-vm1
+
+# SECOND VM
+echo "Creating port and second VM"
+neutron port-create --name test-port2 test-net
+nova boot --image cirros-0.3.4 --flavor nfv --nic port-id=`neutron port-list | grep test-port2 | cut -f 2 -d " "` test-vm2
+
+# FLOATING IP
+echo "Creating floating IP for the first VM"
+neutron floatingip-create external --port-id `neutron port-list | grep test-port1 | cut -f 2 -d " "`
diff --git a/scripts/functest_sim.sh b/scripts/functest_sim.sh
new file mode 100755
index 0000000..abc6ec9
--- /dev/null
+++ b/scripts/functest_sim.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# NETWORK AND SUBNET
+echo "Creating network with subnet"
+neutron net-create test-net
+neutron subnet-create --name test-subnet test-net 192.168.20.0/24
+net_id=`neutron net-list | grep test-net | cut -f 2 -d " "`
+
+# ATTACH NETWORK TO ROUTER
+echo "Attaching external and tenant networks to reouter"
+neutron router-create test-router
+neutron router-interface-add test-router test-subnet
+neutron router-gateway-set test-router external
+
+# CREATE SECURITY GROUP
+echo "Creating security groups with ICMP and SSH allow rules"
+nova secgroup-create test-secgroup test
+nova secgroup-add-rule test-secgroup icmp -1 -1 0.0.0.0/0
+nova secgroup-add-rule test-secgroup tcp 22 22 0.0.0.0/0
+
+# FIRST VM
+echo "Creating first VM in the network and adding the security group to it"
+nova boot --image cirros-0.3.4 --flavor 1 --nic net-id=$net_id test-vm1
+nova add-secgroup test-vm1 test-secgroup
+
+echo "Waiting 7 seconds for the VM to come up"
+sleep 7
+
+# SECOND VM
+echo "Creating second VM in the network and adding the security group to it"
+nova boot --image cirros-0.3.4 --flavor 1 --nic net-id=$net_id test-vm1
+nova boot --image cirros-0.3.4 --flavor 1 --nic net-id=$net_id test-vm2
+nova add-secgroup test-vm2 test-secgroup
+
+# FLOATING IP
+echo "Creating and associating floating IP for the first VM"
+floatingip_id=`neutron floatingip-create external | grep " id " | tr -s " " | cut -f 4 -d " "`
+neutron floatingip-associate $floatingip_id `neutron port-list | grep 192.168.20.3 | cut -d " " -f 2