From e385c470ca3c58d5038d50a86380847bb6a5a56b Mon Sep 17 00:00:00 2001 From: "juraj.linkes" Date: Tue, 4 Apr 2017 15:04:47 +0200 Subject: Reworked helper scripts and fixed typos Added scripts for odl handling Change-Id: Idf715e1c8357a52ef1cd93f58b87c0b92211f85b Signed-off-by: juraj.linkes --- scripts/create_two_vms.sh | 2 +- scripts/flush_odl.sh | 44 +++++++++++++++++++++++++++++++++++++++++ scripts/mount_vpp_into_odl.sh | 12 +++++------ scripts/post_apex.sh | 4 +--- scripts/remount_vpp_into_odl.sh | 11 +++++++++++ scripts/service.sh | 11 +++++++++++ scripts/variables.sh | 10 ++++++++++ 7 files changed, 83 insertions(+), 11 deletions(-) create mode 100755 scripts/flush_odl.sh create mode 100755 scripts/remount_vpp_into_odl.sh create mode 100755 scripts/service.sh create mode 100644 scripts/variables.sh diff --git a/scripts/create_two_vms.sh b/scripts/create_two_vms.sh index 10cc094..452e224 100755 --- a/scripts/create_two_vms.sh +++ b/scripts/create_two_vms.sh @@ -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 index 0000000..11d8f80 --- /dev/null +++ b/scripts/flush_odl.sh @@ -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 diff --git a/scripts/mount_vpp_into_odl.sh b/scripts/mount_vpp_into_odl.sh index a5cf148..a0a6ccb 100755 --- a/scripts/mount_vpp_into_odl.sh +++ b/scripts/mount_vpp_into_odl.sh @@ -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/ diff --git a/scripts/post_apex.sh b/scripts/post_apex.sh index 56caccd..fc4276f 100755 --- a/scripts/post_apex.sh +++ b/scripts/post_apex.sh @@ -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 index 0000000..9a67b6a --- /dev/null +++ b/scripts/remount_vpp_into_odl.sh @@ -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 index 0000000..ff458bc --- /dev/null +++ b/scripts/service.sh @@ -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 index 0000000..5cfdc64 --- /dev/null +++ b/scripts/variables.sh @@ -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 -- cgit 1.2.3-korg