Skip to content
Snippets Groups Projects
Commit 0b6e5398 authored by mordkoff's avatar mordkoff Committed by Gerrit Code Review
Browse files

Merge "New folder installers and new installer to install OSM release 1 from source"

parents a80332f8 93c61317
No related branches found
No related tags found
No related merge requests found
# Copyright 2016 RIFT.IO Inc # Copyright 2016 RIFT.IO Inc
# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
...@@ -18,6 +19,6 @@ README for https://osm.etsi.org/gerrit/osm/devops.git ...@@ -18,6 +19,6 @@ README for https://osm.etsi.org/gerrit/osm/devops.git
subdirectories: subdirectories:
jenkins -- scripts executed by jenkins on the container host and some initial scripts executed inside the container to start a build jenkins -- scripts executed by jenkins on the container host and some initial scripts executed inside the container to start a build
see jenkins/README for more see jenkins/README for more
installers -- scripts to be executed to install OSM from source, builds or packages
see installers/README for more
# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
This directory holds the scripts and tools needed to install OSM
# This file is meant to be SOURCED
#
# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# 23 Sept 2016 -- Gerardo Garcia -- Genesis
#Get IP addresses
DEFAULT_IF=`route -n |awk '$1~/0.0.0.0/ {print $8}'`
export DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
export VCA_CONTAINER_IP=`lxc list VCA -c 4|grep eth0 |awk '{print $2}'`
export SO_CONTAINER_IP=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
export RO_CONTAINER_IP=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
#!/bin/bash
# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function usage(){
echo -e "usage: $0 [OPTIONS]"
echo -e "Install OSM from source code"
echo -e " OPTIONS"
echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
echo -e " --develop: install OSM from source code using the master branch"
echo -e " --nat: install only NAT rules"
echo -e " -h / --help: print this help"
}
UNINSTALL=""
DEVELOP=""
NAT=""
while getopts ":h-:" o; do
case "${o}" in
h)
usage && exit 0
;;
-)
[ "${OPTARG}" == "help" ] && usage && exit 0
[ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
[ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
[ "${OPTARG}" == "nat" ] && NAT="y" && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
usage && exit 1
;;
\?)
echo -e "Invalid option: '-$OPTARG'\n" >&2
usage && exit 1
;;
*)
usage && exit 1
;;
esac
done
echo -e "\nCreating temporary dir for OSM installation"
TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
trap 'rm -rf "$TEMPDIR"' EXIT
echo -e "\nCloning devops repo temporarily"
git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR
RC_CLONE=$?
OSM_DEVOPS=$TEMPDIR
if [ -n "$UNINSTALL" ]; then
if $RC_CLONE; then
$OSM_DEVOPS/jenkins/host/clean_container RO
$OSM_DEVOPS/jenkins/host/clean_container VCA
$OSM_DEVOPS/jenkins/host/clean_container SO
#$OSM_DEVOPS/jenkins/host/clean_container UI
else
lxc stop RO && lxc delete RO
lxc stop VCA && lxc delete VCA
lxc stop SO-ub && lxc delete SO-ub
fi
exit 0
fi
if [ -n "$NAT" ]; then
$OSM_DEVOPS/installers/nat-osm || FATAL "Failed to run nat-osm"
fi
#Installation starts here
echo -e "\nInstalling required packages: git, wget, curl, tar"
echo -e "\n Required root privileges"
sudo apt install -y git wget curl tar
echo -e "\nCreating the containers and building ..."
. $OSM_DEVOPS/jenkins/common/all_funcs
$OSM_DEVOPS/jenkins/host/start_build RO
$OSM_DEVOPS/jenkins/host/start_build VCA
$OSM_DEVOPS/jenkins/host/start_build SO
$OSM_DEVOPS/jenkins/host/start_build UI
#Configure NAT rules
echo -e "\nConfiguring NAT rules"
echo -e "\n Required root privileges"
sudo $OSM_DEVOPS/installers/nat-osm
#Configure components
# TO BE DONE
echo -e "\nConfiguring components"
. $OSM_DEVOPS/installers/export_ips
echo -e "\n Configuring RO"
#RO_TENANT_ID=`lxc exec RO -- openmano tenant-create osm |awk '{print $1}'`
echo -e "\n Configuring VCA"
#JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
#lxc exec VCA -- juju change-user-password $JUJUPASSWD
#JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
echo -e "\n Configuring SO"
#sudo route add -net $JUJU_CONTROLLER_IP/32 gw $VCA_CONTAINER_IP
#lxc exec SO-ub -- sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode --test-name "launchpad"
#sleep 2
#lxc exec SO-ub -- resource-orchestrator name openmano account-type openmano openmano host $RO_CONTAINER_IP tenant-id $RO_TENANT_ID port 9090
#lxc exec SO-ub -- config-agent account juju account-type juju juju ip-address $JUJU_CONTROLLER_IP port 17070 user admin secret $JUJU_PASSWD
echo "\nDONE"
#!/bin/bash
# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
############
# Functions
############
usage(){
echo -e "usage: $0 [OPTIONS]"
echo -e "Install NAT rules for OSM"
echo -e " OPTIONS"
echo -e " -u: UI/SO (rift) IP address"
echo -e " -r: RO (openmano) IP address"
echo -e " -v: VCA (juju) IP address"
echo -e " -h: show this help"
}
###################
# End of functions
###################
#Check root privileges
[ "$USER" != "root" ] && echo "Needed root privileges (run with sudo)" >&2 && exit 1
HERE=$(realpath $(dirname $0))
OSM_DEVOPS=$(dirname $HERE)
. $OSM_DEVOPS/jenkins/common/all_funcs
#Get default IP address
. $OSM_DEVOPS/installers/export_ips
UI_IP=$DEFAULT_IP
RO_IP=$DEFAULT_IP
VCA_IP=$DEFAULT_IP
#read input options
while getopts ":u:r:v:h-:" o; do
case "${o}" in
u)
export UI_IP="$OPTARG"
;;
r)
export RO_IP="$OPTARG"
;;
v)
export VCA_IP="$OPTARG"
;;
h)
usage && exit 0
;;
-)
[ "${OPTARG}" == "help" ] && usage && exit 0
echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
exit 1
;;
\?)
echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2
exit 1
;;
:)
echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2
exit 1
;;
*)
usage >&2
exit -1
;;
esac
done
#############
# NAT port forwarding configuration
#############
echo
echo "*** Configuring iptables rules ***"
awk -v RO_IP="$RO_IP" -v VCA_IP="$VCA_IP" -v UI_IP="$UI_IP" -v openmano_ip="$RO_CONTAINER_IP" -v rift_ip="$SO_CONTAINER_IP" -v juju_ip="$VCA_CONTAINER_IP" '
BEGIN {innat=0; innatpre=0; osmpre=0; donepre=0; innatpost=0; osmpost=0; donepost=0}
/^\*nat/ {
innat=1;
print;
next
}
innat==1 && /\:PREROUTING/ {
innatpre=1;
print;
next;
}
innatpre==1 && /\#Autogenerated by nat_osm/ {
osmpre=1;
next;
}
osmpre==1 && /#End autogeneration by nat_osm/ {
print "#Autogenerated by nat_osm"
print "-A PREROUTING -d "RO_IP" -p tcp -m tcp --dport 9090 -j DNAT --to-destination "openmano_ip
print "-A PREROUTING -d "UI_IP" -p tcp -m tcp --dport 8000 -j DNAT --to-destination "rift_ip
print "-A PREROUTING -d "UI_IP" -p tcp -m tcp --dport 4567 -j DNAT --to-destination "rift_ip
print "-A PREROUTING -d "UI_IP" -p tcp -m tcp --dport 8443 -j DNAT --to-destination "rift_ip
#print "-A PREROUTING -d "VCA_IP" -p tcp -m tcp --dport 443 -j DNAT --to-destination "juju_ip
#print "-A PREROUTING -d "VCA_IP" -p tcp -m tcp --dport 17070 -j DNAT --to-destination "juju_ip
print "#End autogeneration by nat_osm"
osmpre=0;
donepre=1;
next;
}
osmpre==1 {next;}
innatpre==1 && /\:INPUT/ {
innatpre=0;
if (donepre==0) {
print "#Autogenerated by nat_osm"
print "-A PREROUTING -d "RO_IP" -p tcp -m tcp --dport 9090 -j DNAT --to-destination "openmano_ip
print "-A PREROUTING -d "UI_IP" -p tcp -m tcp --dport 8000 -j DNAT --to-destination "rift_ip
print "-A PREROUTING -d "UI_IP" -p tcp -m tcp --dport 4567 -j DNAT --to-destination "rift_ip
print "-A PREROUTING -d "UI_IP" -p tcp -m tcp --dport 8443 -j DNAT --to-destination "rift_ip
#print "-A PREROUTING -d "VCA_IP" -p tcp -m tcp --dport 443 -j DNAT --to-destination "juju_ip
#print "-A PREROUTING -d "VCA_IP" -p tcp -m tcp --dport 17070 -j DNAT --to-destination "juju_ip
print "#End autogeneration by nat_osm"
donepre=1;
}
print;
next;
}
innat==1 && /\:POSTROUTING/ {
innatpost=1;
print;
next;
}
innatpost==1 && /\#Autogenerated by nat_osm/ {
osmpost=1;
next;
}
osmpost==1 && /#End autogeneration by nat_osm/ {
#print "#Autogenerated by nat_osm"
#print "-A POSTROUTING -s "rift_ip" -p tcp -m tcp --dport 9090 -d "openmano_ip" -j SNAT --to "UI_IP
#print "-A POSTROUTING -s "rift_ip" -p tcp -m tcp --dport 17070 -d "juju_ip" -j SNAT --to "UI_IP
#print "#End autogeneration by nat_osm"
osmpost=0;
donepost=1;
next;
}
osmpost==1 {next;}
innatpost==1 && /COMMIT/ {
innatpost=0;
innat=0;
if (donepost==0) {
#print "#Autogenerated by nat_osm"
#print "-A POSTROUTING -s "rift_ip" -p tcp -m tcp --dport 9090 -d "openmano_ip" -j SNAT --to "UI_IP
#print "-A POSTROUTING -s "rift_ip" -p tcp -m tcp --dport 17070 -d "juju_ip" -j SNAT --to "UI_IP
#print "#End autogeneration by nat_osm"
donepost=1;
}
print;
next;
}
{
print
}
' /etc/iptables/rules.v4 > testfile.tmp && mv testfile.tmp /etc/iptables/rules.v4
service netfilter-persistent restart
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment