diff options
Diffstat (limited to 'fuel/build/f_lith_odl_docker/puppet/modules')
8 files changed, 727 insertions, 0 deletions
diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/manifests/odl_lith_docker.pp b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/manifests/odl_lith_docker.pp new file mode 100644 index 0000000..cd243ef --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/manifests/odl_lith_docker.pp @@ -0,0 +1,81 @@ +class opnfv::odl_lith_docker +{ + case $::fuel_settings['role'] { + /controller/: { + + file { '/opt': + ensure => 'directory', + } + + file { '/opt/opnfv': + ensure => 'directory', + owner => 'root', + group => 'root', + mode => 777, + } + + file { '/opt/opnfv/odl': + ensure => 'directory', + } + + file { '/opt/opnfv/odl/lithium': + ensure => 'directory', + } + + file { '/opt/opnfv/odl/lithium/odl_docker_image.tar': + ensure => present, + source => '/etc/puppet/modules/opnfv/odl_docker/Lithium_rc0/odl_docker_image.tar', + mode => 750, + } + + file { '/opt/opnfv/odl/lithium/docker-latest': + ensure => present, + source => '/etc/puppet/modules/opnfv/odl_docker/Lithium_rc0/docker-latest', + mode => 750, + } + + file { '/opt/opnfv/odl/start_odl_conatiner.sh': + ensure => present, + source => '/etc/puppet/modules/opnfv/scripts/start_odl_container.sh', + mode => 750, + } + file { '/opt/opnfv/odl/stage_odl.sh': + ensure => present, + source => '/etc/puppet/modules/opnfv/scripts/stage_odl.sh', + mode => 750, + } + file { '/opt/opnfv/odl/config_net_odl.sh': + ensure => present, + source => '/etc/puppet/modules/opnfv/scripts/config_net_odl.sh', + mode => 750, + } + file { '/opt/opnfv/odl/change.sh': + ensure => present, + source => '/etc/puppet/modules/opnfv/scripts/change.sh', + mode => 750, + } + + + # fix failed to find the cgroup root issue + # https://github.com/docker/docker/issues/8791 + case $::operatingsystem { + 'ubuntu': { + package {'cgroup-lite': + ensure => present, + } + + service {'cgroup-lite': + ensure => running, + enable => true, + require => Package['cgroup-lite'], + } + } + 'centos': { + package {'docker-io': + ensure => latest, + } + } + } + } + } +} diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/check_feature.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/check_feature.sh new file mode 100644 index 0000000..04d7b53 --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/check_feature.sh @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# daniel.smith@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +#!/usr/bin/expect +spawn /opt/odl/distribution-karaf-0.3.0-Lithium-RC0/bin/client +expect "root>" +send "feature:list | grep -i odl-restconf\r" +send "\r\r\r" +expect "root>" +send "logout\r" + + diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/speak.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/speak.sh new file mode 100644 index 0000000..a7d0e6c --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/speak.sh @@ -0,0 +1,20 @@ +#!/usr/bin/expect +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# daniel.smith@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +# +# Simple expect script to start up ODL client and load feature set for DLUX and OVSDB +# NOTE: THIS WILL BE REPLACED WITH A PROGRAMATIC METHOD SHORTLY +################################################################################# + +spawn /opt/odl/distribution-karaf-0.3.0-Lithium-RC0/bin/client +expect "root>" +send "feature:install odl-base-all odl-aaa-authn odl-restconf odl-nsf-all odl-adsal-northbound odl-mdsal-apidocs odl-ovsdb-openstack odl-ovsdb-northbound odl-dlux-core" +send "\r\r\r" +expect "root>" +send "logout\r" diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/start_odl_docker_container.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/start_odl_docker_container.sh new file mode 100644 index 0000000..96a40ec --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/odl_docker/Lithium_rc0/container_scripts/start_odl_docker_container.sh @@ -0,0 +1,48 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# daniel.smith@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +# +# Simple expect script to start up ODL client and load feature set for DLUX and OVSDB +# NOTE: THIS WILL BE REPLACED WITH A PROGRAMATIC METHOD SHORTLY +################################################################################# +# Start up script for calling karaf / ODL inside a docker container. +# +# This script will also call a couple expect scripts to load the feature set that we want + + +#ENV +export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 + +#MAIN +echo "Starting up the da Sheilds..." +/opt/odl/distribution-karaf-0.3.0-Lithium-RC0/bin/karaf server & +echo "Sleeping 5 bad hack" +sleep 10 +echo "should see stuff listening now" +netstat -na +echo " should see proess running for karaf" +ps -efa +echo " Starting the packages we want" +/etc/init.d/speak.sh +echo "Printout the status - if its right, you should see 8181 appear now" +netstat -na +ps -efa + + + +## This is a loop that keeps our container going currently, prinout the "status of karaf" to the docker logs every minute +## Cheap - but effective +while true; +do + echo "Checking status of ODL:" + /opt/odl/distribution-karaf-0.3.0-Lithium-RC0/bin/status + sleep 60 +done + + diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/change.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/change.sh new file mode 100644 index 0000000..f7f3d6e --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/change.sh @@ -0,0 +1,219 @@ +#!/bin/bash +# script to remove bridges and reset networking for ODL + + +#VARS +MODE=0 +DNS=8.8.8.8 + +#ENV +source ~/openrc + +# GET IPS for that node +function get_ips { + BR_MGMT=`grep address /etc/network/ifcfg_backup/ifcfg-br-mgmt | awk -F" " '{print $2}'` + BR_STORAGE=`grep address /etc/network/ifcfg_backup/ifcfg-br-storage | awk -F" " '{print $2}'` + BR_FW_ADMIN=`grep address /etc/network/ifcfg_backup/ifcfg-br-fw-admin | awk -F" " '{print $2}'` + BR_EX=`grep address /etc/network/ifcfg_backup/ifcfg-br-ex | awk -F" " '{print $2}'` + DEF_NETMASK=255.255.255.0 + DEF_GW=172.30.9.1 +} + +function backup_ifcfg { + echo " backing up " + mkdir -p /etc/network/ifcfg_backup + mv /etc/network/interfaces.d/ifcfg-br-ex /etc/network/ifcfg_backup/. + mv /etc/network/interfaces.d/ifcfg-br-fw-admin /etc/network/ifcfg_backup/. + mv /etc/network/interfaces.d/ifcfg-br-mgmt /etc/network/ifcfg_backup/. + mv /etc/network/interfaces.d/ifcfg-br-storage /etc/network/ifcfg_backup/. + mv /etc/network/interfaces.d/ifcfg-br-prv /etc/network/ifcfg_backup/. + mv /etc/network/interfaces.d/ifcfg-eth0 /etc/network/ifcfg_backup/. + mv /etc/network/interfaces.d/ifcfg-eth1 /etc/network/ifcfg_backup/. + rm -rf /etc/network/interfaces.d/ifcfg-eth1.300 + rm -rf /etc/network/interfaces.d/ifcfg-eth1.301 + rm -rf /etc/network/interfaces.d/ifcfg-eth1 + rm -rf /etc/network/interfaces.d/ifcfg-eth0 + +} + + +function create_ifcfg_br_mgmt { + echo "migrating br_mgmt" + echo "auto eth1.300" >> /etc/network/interfaces.d/ifcfg-eth1.300 + echo "iface eth1.300 inet static" >> /etc/network/interfaces.d/ifcfg-eth1.300 + echo " address $BR_MGMT" >> /etc/network/interfaces.d/ifcfg-eth1.300 + echo " netmask $DEF_NETMASK" >> /etc/network/interfaces.d/ifcfg-eth1.300 +} + +function create_ifcfg_br_storage { + echo "migration br_storage" + echo "auto eth1.301" >> /etc/network/interfaces.d/ifcfg-eth1.301 + echo "iface eth1.301 inet static" >> /etc/network/interfaces.d/ifcfg-eth1.301 + echo " address $BR_STORAGE" >> /etc/network/interfaces.d/ifcfg-eth1.301 + echo " netmask $DEF_NETMASK" >> /etc/network/interfaces.d/ifcfg-eth1.301 +} + +function create_ifcfg_br_fw_admin { + echo " migratinng br_fw_admin" + echo "auto eth1" >> /etc/network/interfaces.d/ifcfg-eth1 + echo "iface eth1 inet static" >> /etc/network/interfaces.d/ifcfg-eth1 + echo " address $BR_FW_ADMIN" >> /etc/network/interfaces.d/ifcfg-eth1 + echo " netmask $DEF_NETMASK" >> /etc/network/interfaces.d/ifcfg-eth1 +} + +function create_ifcfg_eth0 { + echo "migratinng br-ex to eth0 - temporarily" + echo "auto eth0" >> /etc/network/interfaces.d/ifcfg-eth0 + echo "iface eth0 inet static" >> /etc/network/interfaces.d/ifcfg-eth0 + echo " address $BR_EX" >> /etc/network/interfaces.d/ifcfg-eth0 + echo " netmask $DEF_NETMASK" >> /etc/network/interfaces.d/ifcfg-eth0 + echo " gateway $DEF_GW" >> /etc/network/interfaces.d/ifcfg-eth0 +} + +function set_mode { + if [ -d "/var/lib/glance/images" ] + then + echo " controller " + MODE=0 + else + echo " compute " + MODE=1 + fi +} + + +function stop_ovs { + echo "Stopping OpenVSwitch" + service openvswitch-switch stop + +} + +function start_ovs { + echo "Starting OVS" + service openvswitch-switch start + ovs-vsctl show +} + + +function clean_ovs { + echo "cleaning OVS DB" + stop_ovs + rm -rf /var/log/openvswitch/* + mkdir -p /opt/opnfv/odl/ovs_back + cp -pr /etc/openvswitch/* /opt/opnfv/odl/ovs_back/. + rm -rf /etc/openvswitch/conf.db + echo "restarting OVS - you should see Nothing there" + start_ovs +} + + + +function reboot_me { + reboot +} + +function allow_challenge { + sed -i -e 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config + service ssh restart +} + +function clean_neutron { + subnets=( `neutron subnet-list | awk -F" " '{print $2}' | grep -v id | sed '/^$/d'` ) + networks=( `neutron net-list | awk -F" " '{print $2}' | grep -v id | sed '/^$/d'` ) + ports=( `neutron port-list | awk -F" " '{print $2}' | grep -v id | sed '/^$/d'` ) + routers=( `neutron router-list | awk -F" " '{print $2}' | grep -v id | sed '/^$/d'` ) + + #display all elements + echo "SUBNETS: ${subnets[@]} " + echo "NETWORKS: ${networks[@]} " + echo "PORTS: ${ports[@]} " + echo "ROUTERS: ${routers[@]} " + + + # get port and subnet for each router + for i in "${routers[@]}" + do + routerport=( `neutron router-port-list $i | awk -F" " '{print $2}' | grep -v id | sed '/^$/d' `) + routersnet=( `neutron router-port-list $i | awk -F" " '{print $8}' | grep -v fixed | sed '/^$/d' | sed 's/,$//' | sed -e 's/^"//' -e 's/"$//' `) + done + + echo "ROUTER PORTS: ${routerport[@]} " + echo "ROUTER SUBNET: ${routersnet[@]} " + + #remove router subnets + echo "router-interface-delete" + for i in "${routersnet[@]}" + do + neutron router-interface-delete ${routers[0]} $i + done + + #remove subnets + echo "subnet-delete" + for i in "${subnets[@]}" + do + neutron subnet-delete $i + done + + #remove nets + echo "net-delete" + for i in "${networks[@]}" + do + neutron net-delete $i + done + + #remove routers + echo "router-delete" + for i in "${routers[@]}" + do + neutron router-delete $i + done + + #remove ports + echo "port-delete" + for i in "${ports[@]}" + do + neutron port-delete $i + done + + #remove subnets + echo "subnet-delete second pass" + for i in "${subnets[@]}" + do + neutron subnet-delete $i + done + +} + +function set_dns { + sed -i -e 's/nameserver 10.20.0.2/nameserver $DNS/g' /etc/resolv.conf +} + + +#OUTPUT + +function check { + echo $BR_MGMT + echo $BR_STORAGE + echo $BR_FW_ADMIN + echo $BR_EX +} + +### MAIN + + +set_mode +backup_ifcfg +get_ips +create_ifcfg_br_mgmt +create_ifcfg_br_storage +create_ifcfg_br_fw_admin +if [ $MODE == "0" ] +then + create_ifcfg_eth0 +fi +allow_challenge +clean_ovs +check +reboot_me + + diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/config_net_odl.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/config_net_odl.sh new file mode 100755 index 0000000..145da80 --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/config_net_odl.sh @@ -0,0 +1,192 @@ +#!/bin/bash +# +# Author: Daniel Smith (Ericsson) +# +# Script to update neutron configuration for OVSDB/ODL integratino +# +# Usage - Set / pass CONTROL_HOST to your needs +# +### SET THIS VALUE TO MATCH YOUR SYSTEM +CONTROL_HOST=192.168.0.2 +BR_EX_IP=172.30.9.70 + +# ENV +source ~/openrc +# VARS +ML2_CONF=/etc/neutron/plugins/ml2/ml2_conf.ini +MODE=0 + + +# FUNCTIONS +# Update ml2_conf.ini +function update_ml2conf { + echo "Backing up and modifying ml2_conf.ini" + cp $ML2_CONF $ML2_CONF.bak + sed -i -e 's/mechanism_drivers =openvswitch/mechanism_drivers = opendaylight/g' $ML2_CONF + sed -i -e 's/tenant_network_types = flat,vlan,gre,vxlan/tenant_network_types = vxlan/g' $ML2_CONF + sed -i -e 's/bridge_mappings=physnet2:br-prv/bridge_mappings=physnet1:br-ex/g' $ML2_CONF + echo "[ml2_odl]" >> $ML2_CONF + echo "password = admin" >> $ML2_CONF + echo "username = admin" >> $ML2_CONF + echo "url = http://${CONTROL_HOST}:8080/controller/nb/v2/neutron" >> $ML2_CONF +} + +function reset_neutrondb { + echo "Reseting DB" + mysql -e "drop database if exists neutron_ml2;" + mysql -e "create database neutron_ml2 character set utf8;" + mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';" + neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head +} + +function restart_neutron { + echo "Restarting Neutron Server" + service neutron-server restart + echo "Should see Neutron runing now" + service neutron-server status + echo "Shouldnt be any nets, but should work (return empty)" + neutron net-list +} + +function stop_neutron { + echo "Stopping Neutron / OVS components" + service neutron-plugin-openvswitch-agent stop + if [ $MODE == "0" ] + then + service neutron-server stop + fi +} + +function disable_agent { + echo "Disabling Neutron Plugin Agents from running" + service neutron-plugin-openvswitch-agent stop + echo 'manual' > /etc/init/neutron-plugin-openvswitch-agent.override +} + + + +function verify_ML2_working { + echo "checking that we can talk via ML2 properly" + curl -u admin:admin http://${CONTROL_HOST}:8080/controller/nb/v2/neutron/networks > /tmp/check_ml2 + if grep "network" /tmp/check_ml2 + then + echo "Success - ML2 to ODL is working" + else + echo "im sorry Jim, but its dead" + fi + +} + + +function set_mode { + if [ -d "/var/lib/glance/images" ] + then + echo "Controller Mode" + MODE=0 + else + echo "Compute Mode" + MODE=1 + fi +} + +function stop_ovs { + echo "Stopping OpenVSwitch" + service openvswitch-switch stop + +} + +function start_ovs { + echo "Starting OVS" + service openvswitch-vswitch start + ovs-vsctl show +} + + +function control_setup { + echo "Modifying Controller" + stop_neutron + stop_ovs + disable_agent + rm -rf /var/log/openvswitch/* + mkdir -p /opt/opnfv/odl/ovs_back + mv /etc/openvswitch/conf.db /opt/opnfv/odl/ovs_back/. + mv /etc/openvswitch/.conf*lock* /opt/opnfv/odl/ovs_back/. + rm -rf /etc/openvswitch/conf.db + rm -rf /etc/openvswitch/.conf* + service openvswitch-switch start + ovs-vsctl add-br br-ex + ovs-vsctl add-port br-ex eth0 + ovs-vsctl set interface br-ex type=external + ifconfig br-ex 172.30.9.70/24 up + service neutron-server restart + + echo "setting up networks" + ip link add link eth1 name br-mgmt type vlan id 300 + ifconfig br-mgmt `grep address /etc/network/interfaces.d/ifcfg-br-mgmt | awk -F" " '{print $2}'`/24 up arp + ip link add link eth1 name br-storage type vlan id 301 + ip link add link eth1 name br-prv type vlan id 1000 + ifconfig br-storage `grep address /etc/network/interfaces.d/ifcfg-br-storage | awk -F" " '{print $2}'`/24 up arp + ifconfig eth1 `grep address /etc/network/interfaces.d/ifcfg-br-fw-admin | awk -F" " '{print $2}'`/24 up arp + + echo "Setting ODL Manager IP" + ovs-vsctl set-manager tcp:192.168.0.2:6640 + + echo "Verifying ODL ML2 plugin is working" + verify_ML2_working + + # BAD HACK - Should be parameterized - this is to catch up + route add default gw 172.30.9.1 + +} + +function clean_ovs { + echo "cleaning OVS DB" + stop_ovs + rm -rf /var/log/openvswitch/* + mkdir -p /opt/opnfv/odl/ovs_back + cp -pr /etc/openvswitch/* /opt/opnfv/odl/ovs_back/. + rm -rf /etc/openvswitch/conf.db + echo "restarting OVS - you should see Nothing there" + start_ovs +} + +function compute_setup { + echo "Modifying Compute" + echo "Disabling neutron openvswitch plugin" + stop_neutron + disable_agent + ip link add link eth1 name br-mgmt type vlan id 300 + ifconfig br-mgmt `grep address /etc/network/interfaces.d/ifcfg-br-mgmt | awk -F" " '{print $2}'`/24 up arp + ip link add link eth1 name br-storage type vlan id 301 + ip link add link eth1 name br-prv type vlan id 1000 + ifconfig br-storage `grep address /etc/network/interfaces.d/ifcfg-br-storage | awk -F" " '{print $2}'`/24 up arp + ifconfig eth1 `grep address /etc/network/interfaces.d/ifcfg-br-fw-admin | awk -F" " '{print $2}'`/24 up arp + + echo "set manager, and route for ODL controller" + ovs-vsctl set-manager tcp:192.168.0.2:6640 + route add 172.17.0.1 gw 192.168.0.2 + verify_ML2_working +} + + +# MAIN +echo "Starting to make call" +update_ml2conf +echo "Check Mode" +set_mode + +if [ $MODE == "0" ]; +then + echo "Calling control setup" + control_setup +elif [ $MODE == "1" ]; +then + echo "Calling compute setup" + compute_setup + +else + echo "Something is bad - call for help" + exit +fi + + diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/stage_odl.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/stage_odl.sh new file mode 100755 index 0000000..fa14b47 --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/stage_odl.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# Author: Daniel Smith (Ericsson) +# Stages ODL Controlleer +# Inputs: odl_docker_image.tar +# Usage: ./stage_odl.sh + +# ENVS +source ~/.bashrc +source ~/openrc + +LOCALPATH=/opt/opnfv/odl +DOCKERBIN=docker-latest +ODLIMGNAME=odl_docker_image.tar +DNS=8.8.8.8 +HOST_IP=`ifconfig br-ex | grep -i "inet addr" | awk -F":" '{print $2}' | awk -F" " '{print $1}'` + + + +# DEBUG ECHOS +echo $LOCALPATH +echo $DOCKERBIN +echo $ODLIMGNAME +echo $DNS +echo $HOST_IP + + +# Set DNS to someting external and default GW - ODL requires a connection to the internet +sed -i -e 's/nameserver 10.20.0.2/nameserver 8.8.8.8/g' /etc/resolv.conf +route delete default gw 10.20.0.2 +route add default gw 172.30.9.1 + +# Start Docker daemon and in background +echo "Starting Docker" +chmod +x $LOCALPATH/$DOCKERBIN +$LOCALPATH/$DOCKERBIN -d & +#courtesy sleep for virtual env +sleep 2 + +# Import the ODL Container +echo "Importing ODL Container" +$LOCALPATH/$DOCKERBIN load -i $LOCALPATH/$ODLIMGNAME + +# Start ODL, load DLUX and OVSDB modules +echo "Removing any old install found - file not found is ok here" +$LOCALPATH/$DOCKERBIN rm odl_docker +echo "Starting up ODL controller in Daemon mode - no shell possible" +$LOCALPATH/$DOCKERBIN run --name odl_docker -p 8181:8181 -p 8185:8185 -p 9000:9000 -p 1099:1099 -p 8101:8101 -p 6633:6633 -p 43506:43506 -p 44444:44444 -p 6653:6653 -p 12001:12001 -p 6400:6400 -p 6640:6640 -p 8080:8080 -p 7800:7800 -p 55130:55130 -p 52150:52150 -p 36826:26826 -i -d -t loving_daniel + +# Following, you should see the docker ps listed and a port opened +echo " you should reach ODL controller at http://HOST_IP:8181/dlux/index.html" +$LOCALPATH/$DOCKERBINNAME ps -a +netstat -lnt + + diff --git a/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/start_odl_container.sh b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/start_odl_container.sh new file mode 100755 index 0000000..347ac74 --- /dev/null +++ b/fuel/build/f_lith_odl_docker/puppet/modules/opnfv/scripts/start_odl_container.sh @@ -0,0 +1,95 @@ +#!/bin/bash +# Ericsson Canada Inc. +# Authoer: Daniel Smith +# +# A helper script to install and setup the ODL docker conatiner on the controller +# +# +# Inputs: odl_docker_image.tar +# +# Usage: ./start_odl_docker.sh +echo "DEPRECATED - USE stage_odl.sh instead - this will be removed shortly once automated deployment is working - SR1" + + +# ENVS +source ~/.bashrc +source ~/openrc + +# VARS + +# Switch for Dev mode - uses apt-get on control to cheat and get docker installed locally rather than from puppet source + +DEV=1 + +# Switch for 1:1 port mapping of EXPOSED ports in Docker to the host, if set to 0, then random ports will be used - NOTE: this doesnt work for all web services X port on Host --> Y port in Container, +# especially for SSL/HTTPS cases. Be aware. + +MATCH_PORT=1 + +LOCALPATH=/opt/opnfv/odl +DOCKERBINNAME=docker-latest +DOCKERIMAGENAME=odl_docker_image.tar +DNS=8.8.8.8 +HOST_IP=`ifconfig br-fw-admin | grep -i "inet addr" | awk -F":" '{print $2}' | awk -F" " '{print $1}'` + + +# Set this to "1" if you want to have your docker container startup into a shell + + +ENABLE_SHELL=1 + + +echo " Fetching Docker " +if [ "$DEV" -eq "1" ]; +# If testing Locally (on a control node) you can set DEV=1 to enable apt-get based install on the control node (not desired target, but good for testing). +then + echo "Dev Mode - Fetching from Internet"; + echo " this wont work in production builds"; + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 + mkdir -p $LOCALPATH + wget https://get.docker.com/builds/Linux/x86_64/docker-latest -O $LOCALPATH/$DOCKERBINNAME + wget http://ftp.us.debian.org/debian/pool/main/d/docker.io/docker.io_1.3.3~dfsg1-2_amd64.deb + chmod 777 $LOCALPATH/$DOCKERBINNAME + echo "done "; +else + echo "Using Binaries delivered from Puppet" + echo "Starting Docker in Daemon mode" + chmod +x $LOCALPATH/$DOCKERBINNAME + $LOCALPATH/$DOCKERBINNAME -d & + + # wait until docker will be fully initialized + # before any further action against just started docker + sleep 5 +fi + + +# We need to perform some cleanup of the Openstack Environment +echo "TODO -- This should be automated in the Fuel deployment at some point" +echo "However, the timing should come after basic tests are running, since this " +echo " part will remove the subnet router association that is deployed automativally" +echo " via fuel. Refer to the ODL + Openstack Integration Page " + +# Import the ODL container into docker + +echo "Importing ODL container into docker" +$LOCALPATH/$DOCKERBINNAME load -i $LOCALPATH/$DOCKERIMAGENAME + +echo " starting up ODL - DLUX and Mapping Ports" +if [ "$MATCH_PORT" -eq "1" ] +then + echo "Starting up Docker..." + $LOCALPATH/$DOCKERBINNAME rm odl_docker +fi + +if [ "$ENABLE_SHELL" -eq "1" ]; +then + echo "Starting Container in Interactive Mode (/bin/bash will be provided, you will need to run ./start_odl_docker.sh inside the container yourself)" + $LOCALPATH/$DOCKERBINNAME run --name odl_docker -p 8181:8181 -p 8185:8185 -p 9000:9000 -p 1099:1099 -p 8101:8101 -p 6633:6633 -p 43506:43506 -p 44444:44444 -p 6653:6653 -p 12001:12001 -p 6400:6400 -p 6640:6640 -p 8080:8080 -p 7800:7800 -p 55130:55130 -p 52150:52150 -p 36826:26826 -i -t loving_daniel /bin/bash +else + echo "Starting Conatiner in Daemon mode - no shell will be provided and docker attach will not provide shell)" + $LOCALPATH/$DOCKERBINNAME run --name odl_docker -p 8181:8181 -p 8185:8185 -p 9000:9000 -p 1099:1099 -p 8101:8101 -p 6633:6633 -p 43506:43506 -p 44444:44444 -p 6653:6653 -p 12001:12001 -p 6400:6400 -p 6640:6640 -p 8080:8080 -p 7800:7800 -p 55130:55130 -p 52150:52150 -p 36826:26826 -i -d -t loving_daniel + echo "should see the process listed here in docker ps -a" + $LOCALPATH/$DOCKERBINNAME ps -a; + echo "Match Port enabled, you can reach the DLUX login at: " + echo "http://$HOST_IP:8181/dlux.index.html" +fi |