Removed opendaylight build capabilities as a preparation toward Arno SR1
[genesis.git] / fuel / build / f_odl_docker / puppet / modules / opnfv / scripts / start_odl_container.sh
1 #!/bin/bash
2 #  Ericsson Canada Inc.
3 #  Authoer: Daniel Smith
4 #
5 #   A helper script to install and setup the ODL docker container on the controller
6 #
7 #
8 #   Inputs:  odl_docker_image.tar
9 #
10 #   Usage:  ./start_odl_docker.sh
11 echo "DEPRECATED - USE stage_odl.sh instead  - this will be removed shortly once automated deployment is working - SR1"
12
13
14 # ENVS
15 source ~/.bashrc
16 source ~/openrc
17
18 # VARS
19
20 # Switch for Dev mode - uses apt-get on control to cheat and get docker installed locally rather than from puppet source
21
22 DEV=1
23
24 # 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,
25 # especially for SSL/HTTPS cases. Be aware.
26
27 MATCH_PORT=1
28
29 LOCALPATH=/opt/opnfv/odl
30 DOCKERBINNAME=docker-latest
31 DOCKERIMAGENAME=odl_docker_image.tar
32 DNS=8.8.8.8
33 HOST_IP=`ifconfig br-fw-admin  | grep -i "inet addr" | awk -F":" '{print $2}' | awk -F" " '{print $1}'`
34
35
36 # Set this to "1" if you want to have your docker container startup into a shell
37
38
39 ENABLE_SHELL=1
40
41
42 echo " Fetching Docker "
43 if [ "$DEV" -eq "1" ];
44 # 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).
45 then
46         echo "Dev Mode - Fetching from Internet";
47         echo " this wont work in production builds";
48         apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
49         mkdir -p $LOCALPATH
50         wget https://get.docker.com/builds/Linux/x86_64/docker-latest -O $LOCALPATH/$DOCKERBINNAME
51         wget http://ftp.us.debian.org/debian/pool/main/d/docker.io/docker.io_1.3.3~dfsg1-2_amd64.deb
52         chmod 777 $LOCALPATH/$DOCKERBINNAME
53         echo "done ";
54 else
55         echo "Using Binaries delivered from Puppet"
56         echo "Starting Docker in Daemon mode"
57         chmod +x $LOCALPATH/$DOCKERBINNAME
58         $LOCALPATH/$DOCKERBINNAME -d &
59
60   # wait until docker will be fully initialized
61   # before any further action against just started docker
62   sleep 5
63 fi
64
65
66 # We need to perform some cleanup of the Openstack Environment
67 echo "TODO -- This should be automated in the Fuel deployment at some point"
68 echo "However, the timing should come after basic tests are running, since this "
69 echo " part will remove the subnet router association that is deployed automativally"
70 echo " via fuel. Refer to the ODL + Openstack Integration Page "
71
72 # Import the ODL container into docker
73
74 echo "Importing ODL container into docker"
75 $LOCALPATH/$DOCKERBINNAME load -i $LOCALPATH/$DOCKERIMAGENAME
76
77 echo " starting up ODL - DLUX and Mapping Ports"
78 if [ "$MATCH_PORT" -eq "1" ]
79 then
80         echo "Starting up Docker..."
81         $LOCALPATH/$DOCKERBINNAME rm odl_docker
82 fi
83
84 if [ "$ENABLE_SHELL" -eq "1" ];
85 then
86         echo "Starting Container in Interactive Mode (/bin/bash will be provided, you will need to run ./start_odl_docker.sh inside the container yourself)"
87         $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
88 else
89         echo "Starting Container in Daemon mode - no shell will be provided and docker attach will not provide shell)"
90         $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
91         echo "should see the process listed here in docker ps -a"
92         $LOCALPATH/$DOCKERBINNAME ps -a;
93         echo "Match Port  enabled, you can reach the DLUX login at: "
94         echo "http://$HOST_IP:8181/dlux.index.html"
95 fi