diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install_odl.sh | 58 | ||||
-rwxr-xr-x | scripts/install_odl_from_jumphost.sh | 14 | ||||
-rw-r--r-- | scripts/lib.sh | 31 | ||||
-rwxr-xr-x | scripts/remount_vpp_into_odl.sh | 9 | ||||
-rwxr-xr-x | scripts/resource_cleanup.sh | 14 | ||||
-rwxr-xr-x | scripts/service.sh | 7 |
6 files changed, 117 insertions, 16 deletions
diff --git a/scripts/install_odl.sh b/scripts/install_odl.sh new file mode 100755 index 0000000..3067a25 --- /dev/null +++ b/scripts/install_odl.sh @@ -0,0 +1,58 @@ +#!/bin/bash +SCRIPT_DIR=$(dirname $0) +. $SCRIPT_DIR/lib.sh +service opendaylight stop +sleep 10 +INSTALL_DIR=/opt +ODL_DIR=$INSTALL_DIR/opendaylight +ODL_TGZ_NAME=$1 +cp $ODL_DIR/etc/jetty.xml $INSTALL_DIR +cp $ODL_DIR/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg $INSTALL_DIR +cp $ODL_DIR/etc/org.opendaylight.groupbasedpolicy.renderer.vpp.startup.cfg $INSTALL_DIR +rm -rf $ODL_DIR +#mv opendaylight orig_opendaylight +ODL_DEFAULT_DIR_NAME=$(tar tf $ODL_TGZ_NAME | head -n1 | cut -d "/" -f 1) +echo "$HOSTNAME: unpacking odl" +tar -C $INSTALL_DIR -xf $ODL_TGZ_NAME +mv $INSTALL_DIR/$ODL_DEFAULT_DIR_NAME $INSTALL_DIR/opendaylight + +#CHANGE PORT AND CONFIGURE: +echo "$HOSTNAME: configuring odl" +cp $INSTALL_DIR/jetty.xml $ODL_DIR/etc/ +cp $INSTALL_DIR/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg $ODL_DIR/etc/ +cp $INSTALL_DIR/org.opendaylight.groupbasedpolicy.renderer.vpp.startup.cfg $ODL_DIR/etc/ + +#CONFIGURE LOGGING: +sed -i 's/log4j.appender.out.maxFileSize=.*/log4j.appender.out.maxFileSize=100MB/' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +sed -i 's/log4j.appender.out.maxBackupIndex=.*/log4j.appender.out.maxBackupIndex=10/' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +#sed -i '$alog4j.logger.org.opendaylight.groupbasedpolicy.renderer.vpp = TRACE' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +#sed -i '$alog4j.logger.org.opendaylight.groupbasedpolicy.neutron.mapper = TRACE' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +#sed -i '$alog4j.logger.org.opendaylight.groupbasedpolicy.neutron.vpp.mapper = TRACE' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +#sed -i '$alog4j.logger.org.opendaylight.vbd = TRACE' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +#sed -i '$alog4j.logger.org.opendaylight.netconf.sal.connect.netconf = TRACE' $ODL_DIR/etc/org.ops4j.pax.logging.cfg +#sed -i '$alog4j.logger.org.opendaylight.netconf = DEBUG' $ODL_DIR/etc/org.ops4j.pax.logging.cfg + +#ACL LOGGING +#sed -i '$alog4j.logger.org.opendaylight.groupbasedpolicy.renderer.vpp.policy.acl = INFO' $ODL_DIR/etc/org.ops4j.pax.logging.cfg + +#INSTALL FEATURES +sed -i 's/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,odl-restconf,odl-netconf-all,odl-groupbasedpolicy-neutron-vpp-mapper,odl-vbd/' $ODL_DIR/etc/org.apache.karaf.features.cfg + +#CHANGE OWNER AND RESTART DAEMON +echo "$HOSTNAME: changing owner to odl" +chown -R odl:odl $ODL_DIR +systemctl daemon-reload + +#CONFIGURE CLUSTER +if [[ $2 == "-c" ]] +then + NODE_NUMBER=$(hostname | grep -o [0-9]) + ((NODE_NUMBER++)) + ODL_IPS=$(grep -A 7 "listen opendaylight" /etc/haproxy/haproxy.cfg | grep server | grep -Eo "$IPV4_REGEX") + echo "$HOSTNAME: configuring cluster with id $NODE_NUMBER and ips $ODL_IPS" + $ODL_DIR/bin/configure_cluster.sh $NODE_NUMBER $ODL_IPS +fi + +#START ODL +service opendaylight start + diff --git a/scripts/install_odl_from_jumphost.sh b/scripts/install_odl_from_jumphost.sh new file mode 100755 index 0000000..436053e --- /dev/null +++ b/scripts/install_odl_from_jumphost.sh @@ -0,0 +1,14 @@ +#!/bin/bash +SCRIPT_DIR=$(dirname $0) +. $SCRIPT_DIR/lib.sh +REMOTE_ODL_LOC=/opt/$(basename "$1") +copy_to_controllers $1 $REMOTE_ODL_LOC +if [[ $(echo $NODES | wc -w) -gt 1 ]] +then + exec_on_controllers /root/fds/scripts/install_odl.sh $REMOTE_ODL_LOC -c +else + exec_on_controllers /root/fds/scripts/install_odl.sh $REMOTE_ODL_LOC +fi + +sleep 60 +$SCRIPT_DIR/remount_vpp_into_odl.sh diff --git a/scripts/lib.sh b/scripts/lib.sh index b825b9c..b3d9db3 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -7,9 +7,40 @@ hc_username=admin hc_password=admin hc_netconf_port=2831 NODE_PATTERN=overcloud +CONTROLLER_PATTERN=controller overcloudrc_path=/root/$overcloud_file_name overcloud_fds_repo_loc=/root overcloud_script_loc=$overcloud_fds_repo_loc/fds/scripts +IPV4_REGEX='([0-9]{1,3}.){3}[0-9]{1,3}' + +get_nodes() { + if [[ $1 ]] + then + NODES=$(grep -o "$NODE_PATTERN-$1-[0-9]" /etc/hosts) + else + NODES=$(grep -Eo "$NODE_PATTERN-[^-]+-[0-9]" /etc/hosts) + fi +} + +copy_to_controllers () { + get_nodes $CONTROLLER_PATTERN + LOCAL_FILE=$1 + REMOTE_LOC=$2 + for NODE in $NODES + do + scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $LOCAL_FILE $NODE:$REMOTE_LOC & + done + wait +} + +exec_on_controllers() { + get_nodes $CONTROLLER_PATTERN + for NODE in $NODES + do + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $NODE $@ & + done + wait +} in_array() { key=$1 diff --git a/scripts/remount_vpp_into_odl.sh b/scripts/remount_vpp_into_odl.sh index e794f23..148f1cf 100755 --- a/scripts/remount_vpp_into_odl.sh +++ b/scripts/remount_vpp_into_odl.sh @@ -1,11 +1,12 @@ #!/bin/bash -script_dir=$(dirname $0) -. $script_dir/lib.sh +SCRIPT_DIR=$(dirname $0) +. $SCRIPT_DIR/lib.sh -overcloud_node_ips=$(grep -E "$NODE_PATTERN-[^-]+-[0-9]" /etc/hosts | grep -Eo '([0-9]{1,3}.){3}[0-9]{1,3}') +overcloud_node_ips=$(grep -E "$NODE_PATTERN-[^-]+-[0-9]" /etc/hosts | grep -Eo "$IPV4_REGEX") 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) + # TODO get node names from nova service list and neutron agent-list 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 + $SCRIPT_DIR/mount_vpp_into_odl.sh $NODE_PATTERN-controller-0 $overcloud_node_hostname $overcloud_node_ip done diff --git a/scripts/resource_cleanup.sh b/scripts/resource_cleanup.sh index af055cf..46ed8bb 100755 --- a/scripts/resource_cleanup.sh +++ b/scripts/resource_cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash -script_dir=$(dirname $0) -. $script_dir/lib.sh +SCRIPT_DIR=$(dirname $0) +. $SCRIPT_DIR/lib.sh NODE_TYPES="compute controller" RESOURCE_TYPES="openstack opendaylight fdio" @@ -141,7 +141,7 @@ clean_from_jumphost() { echo "Cleanup finished" if [[ $REMOUNT ]] then - $script_dir/remount_vpp_into_odl.sh + $SCRIPT_DIR/remount_vpp_into_odl.sh fi } @@ -201,11 +201,11 @@ clean_overcloud_resource() { if [[ $MANUAL_CONFIG ]] then TENANT_INTERFACE_IP=$(vppctl show int $TENANT_INTERFACE addr \ - | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+") + | grep -Eo "$IPV4_REGEX") if [[ -n $PUBLIC_INTERFACE ]] then PUBLIC_INTERFACE_IP=$(vppctl show int $PUBLIC_INTERFACE addr \ - n| grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+") + n| grep -Eo "$IPV4_REGEX") fi fi @@ -239,7 +239,7 @@ clean_overcloud_resource() { sleep 1 service honeycomb start &> /dev/null echo "$HOSTNAME: starting honeycomb" - HC_IP=$(grep restconf-binding-address /opt/honeycomb/config/honeycomb.json | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") + HC_IP=$(grep restconf-binding-address /opt/honeycomb/config/honeycomb.json | grep -Eo "$IPV4_REGEX") HC_PORT=$(grep restconf-port /opt/honeycomb/config/honeycomb.json | grep -Eo [0-9]+) for i in $(seq 1 30) do @@ -378,7 +378,7 @@ else if [[ $ODL_RESTARTED ]] then ODL_IP=$(awk '/<Call/{f=1} f{print; if (/<\/Call>/) exit}' $ODL_DIR/etc/jetty.xml | \ - grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") + grep -Eo "$IPV4_REGEX") ODL_PORT=$(awk '/<Call/{f=1} f{print; if (/<\/Call>/) exit}' $ODL_DIR/etc/jetty.xml | \ grep jetty.port | grep -Eo [0-9]+) echo "$HOSTNAME: waiting for odl to start" diff --git a/scripts/service.sh b/scripts/service.sh index ff458bc..3fb6736 100755 --- a/scripts/service.sh +++ b/scripts/service.sh @@ -1,11 +1,8 @@ #!/bin/bash +. $(dirname "$0")/lib.sh 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 +exec_on_controllers service $1 $2 |