Reworked helper scripts and fixed typos 43/32943/5
authorjuraj.linkes <jlinkes@cisco.com>
Tue, 4 Apr 2017 13:04:47 +0000 (15:04 +0200)
committerjuraj.linkes <jlinkes@cisco.com>
Wed, 3 May 2017 13:23:35 +0000 (15:23 +0200)
Added scripts for odl handling

Change-Id: Idf715e1c8357a52ef1cd93f58b87c0b92211f85b
Signed-off-by: juraj.linkes <jlinkes@cisco.com>
scripts/create_two_vms.sh
scripts/flush_odl.sh [new file with mode: 0755]
scripts/mount_vpp_into_odl.sh
scripts/post_apex.sh
scripts/remount_vpp_into_odl.sh [new file with mode: 0755]
scripts/service.sh [new file with mode: 0755]
scripts/variables.sh [new file with mode: 0644]

index 10cc094..452e224 100755 (executable)
@@ -5,7 +5,7 @@ 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"
+echo "Attaching external and tenant networks to router"
 neutron router-create test-router
 neutron router-interface-add test-router test-subnet
 neutron router-gateway-set test-router external
diff --git a/scripts/flush_odl.sh b/scripts/flush_odl.sh
new file mode 100755 (executable)
index 0000000..11d8f80
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+script_dir=$(dirname $0)
+. $script_dir/variables.sh
+
+echo "WARNING: this script doesn't install odl features; It assumes features are already configured in $ODL_ROOT/etc/org.apache.karaf.features.cfg"
+echo "WARNING: this script also doesn't configure logging; You can configure logging in $ODL_ROOT/etc/org.ops4j.pax.logging.cfg"
+echo
+
+echo "Stopping odl on all nodes"
+$script_dir/service.sh opendaylight stop
+
+echo "Waiting 10 seconds for odl to stop"
+for i in {1..10}
+do
+    echo -n "."
+    sleep 1
+done
+
+echo
+
+odl_hostnames=$(grep -Eo 'overcloud-controller-[0-9]' /etc/hosts)
+
+echo
+for odl_hostname in $odl_hostnames
+do
+    echo "Removing data, journal, snapshots and instances on $odl_hostname"
+    ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $odl_hostname rm -rf $odl_dir/data $odl_dir/journal $odl_dir/snapshots $odl_dir/instances 2> /dev/null
+done
+
+echo
+
+echo "Starting odl on all nodes"
+$script_dir/service.sh opendaylight start
+
+echo "Waiting 20 seconds for odl to start"
+for i in {1..20}
+do
+    echo -n "."
+    sleep 1
+done
+
+echo
+echo
+$script_dir/remount_vpp_into_odl.sh
index a5cf148..a0a6ccb 100755 (executable)
@@ -5,6 +5,8 @@ display_usage() {
   exit 85
 }
 
+. $(dirname $0)/variables.sh
+
 if [  $# -lt 3 ]
 then
   display_usage
@@ -15,13 +17,10 @@ odl_ip=$1
 vpp_host=$2
 vpp_ip=$3
 
-vpp_username=admin
-vpp_password=admin
-
 post_data='{"node" : [
 {"node-id":"'$vpp_host'",
 "netconf-node-topology:host":"'$vpp_ip'",
-"netconf-node-topology:port":"2831",
+"netconf-node-topology:port":"'$vpp_port'",
 "netconf-node-topology:tcp-only":false,
 "netconf-node-topology:keepalive-delay":0,
 "netconf-node-topology:username":"'$vpp_username'",
@@ -29,10 +28,9 @@ post_data='{"node" : [
 "netconf-node-topology:connection-timeout-millis":10000,
 "netconf-node-topology:default-request-timeout-millis":10000,
 "netconf-node-topology:max-connection-attempts":10,
-"netconf-node-topology:between-attempts-timeout-millis":10000,
-"netconf-node-topology:schema-cache-directory":"hcmount"}
+"netconf-node-topology:between-attempts-timeout-millis":10000}
 ]
 }
 '
 
-curl -u admin:admin -X POST -d "$post_data" -H 'Content-Type: application/json' http://$odl_ip:8081/restconf/config/network-topology:network-topology/network-topology:topology/topology-netconf/
+curl -u $odl_username:$odl_password -X POST -d "$post_data" -H 'Content-Type: application/json' http://$odl_ip:$odl_port/restconf/config/network-topology:network-topology/network-topology:topology/topology-netconf/
index 56caccd..fc4276f 100755 (executable)
@@ -1,7 +1,5 @@
 #!/bin/bash
-overcloud_file_name=overcloudrc # change this if needed
-NODE_PATTERN=overcloud
-overcloudrc_path=/root/$overcloud_file_name
+. $(dirname "$0")/variables.sh
 undercloud_ip=`arp -a | grep $(virsh domiflist undercloud | grep default | awk '{print $5}') | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"`
 #echo $undercloud_ip
 
diff --git a/scripts/remount_vpp_into_odl.sh b/scripts/remount_vpp_into_odl.sh
new file mode 100755 (executable)
index 0000000..9a67b6a
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+script_dir=$(dirname $0)
+. $script_dir/variables.sh
+
+overcloud_node_ips=$(grep -E "$NODE_PATTERN-[^-]+-[0-9]" /etc/hosts | grep -Eo '([0-9]{1,3}.){3}[0-9]{1,3}')
+for overcloud_node_ip in $overcloud_node_ips
+do
+    overcloud_node_hostname=$(ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $overcloud_node_ip hostname 2> /dev/null)
+    echo "Mounting $overcloud_node_hostname:$overcloud_node_ip on $NODE_PATTERN-controller-0"
+    $script_dir/mount_vpp_into_odl.sh $NODE_PATTERN-controller-0 $overcloud_node_hostname $overcloud_node_ip
+done
diff --git a/scripts/service.sh b/scripts/service.sh
new file mode 100755 (executable)
index 0000000..ff458bc
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+if [[ $# -ne 2 ]]
+then
+    echo "Must have at least two arguments. The first is name of the service and the second is the action to be done with the service."
+    exit 1
+fi
+for odl_hostname in `grep -Eo 'overcloud-controller-[0-9]' /etc/hosts`
+do
+    echo "Executing service $1 $2 on $odl_hostname"
+    ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $odl_hostname service $1 $2 2> /dev/null
+done
diff --git a/scripts/variables.sh b/scripts/variables.sh
new file mode 100644 (file)
index 0000000..5cfdc64
--- /dev/null
@@ -0,0 +1,10 @@
+overcloud_file_name=overcloudrc # change this if needed
+odl_username=admin
+odl_password=admin
+odl_port=8081
+odl_dir=/opt/opendaylight
+vpp_username=admin
+vpp_password=admin
+vpp_port=2831
+NODE_PATTERN=overcloud
+overcloudrc_path=/root/$overcloud_file_name