Newer
Older
track prereqok
[ -z "$INSTALL_NOJUJU" ] && install_juju
track juju_install
if [ -z "$OSM_VCA_HOST" ]; then
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
if [ -z "$CONTROLLER_NAME" ]; then
if [ -n "$LXD_CLOUD_FILE" ]; then
[ -z "$LXD_CRED_FILE" ] && FATAL "The installer needs the LXD credential yaml if the LXD is external"
OSM_VCA_CLOUDNAME="lxd-cloud"
juju add-cloud $OSM_VCA_CLOUDNAME $LXD_CLOUD_FILE --force || juju update-cloud $OSM_VCA_CLOUDNAME --client -f $LXD_CLOUD_FILE
juju add-credential $OSM_VCA_CLOUDNAME -f $LXD_CRED_FILE || juju update-credential $OSM_VCA_CLOUDNAME lxd-cloud-creds -f $LXD_CRED_FILE
fi
juju_createcontroller
else
OSM_VCA_CLOUDNAME="lxd-cloud"
if [ -n "$LXD_CLOUD_FILE" ]; then
[ -z "$LXD_CRED_FILE" ] && FATAL "The installer needs the LXD credential yaml if the LXD is external"
juju add-cloud -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME $LXD_CLOUD_FILE --force || juju update-cloud lxd-cloud -c $CONTROLLER_NAME -f $LXD_CLOUD_FILE
juju add-credential -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME -f $LXD_CRED_FILE || juju update-credential lxd-cloud -c $CONTROLLER_NAME -f $LXD_CRED_FILE
else
mkdir -p ~/.osm
cat << EOF > ~/.osm/lxd-cloud.yaml
clouds:
lxd-cloud:
type: lxd
auth-types: [certificate]
endpoint: "https://$DEFAULT_IP:8443"
config:
ssl-hostname-verification: false
EOF
openssl req -nodes -new -x509 -keyout ~/.osm/client.key -out ~/.osm/client.crt -days 365 -subj "/C=FR/ST=Nice/L=Nice/O=ETSI/OU=OSM/CN=osm.etsi.org"
local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'`
local client_cert=`cat ~/.osm/client.crt | sed 's/^/ /'`
local client_key=`cat ~/.osm/client.key | sed 's/^/ /'`
cat << EOF > ~/.osm/lxd-credentials.yaml
credentials:
lxd-cloud:
lxd-cloud:
auth-type: certificate
server-cert: |
$server_cert
client-cert: |
$client_cert
client-key: |
$client_key
EOF
lxc config trust add local: ~/.osm/client.crt
juju add-cloud -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME ~/.osm/lxd-cloud.yaml --force || juju update-cloud lxd-cloud -c $CONTROLLER_NAME -f ~/.osm/lxd-cloud.yaml
juju add-credential -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME -f ~/.osm/lxd-credentials.yaml || juju update-credential lxd-cloud -c $CONTROLLER_NAME -f ~/.osm/lxd-credentials.yaml
fi
fi
[ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
[ -n "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`juju show-controller $CONTROLLER_NAME |grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
[ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
track juju_controller
if [ -z "$OSM_VCA_SECRET" ]; then
[ -z "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
[ -n "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $CONTROLLER_NAME)
[ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
if [ -z "$OSM_VCA_PUBKEY" ]; then
OSM_VCA_PUBKEY=$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)
[ -z "$OSM_VCA_PUBKEY" ] && FATAL "Cannot obtain juju public key"
fi
[ -z "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $OSM_STACK_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n)
[ -n "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $CONTROLLER_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n)
[ -z "$OSM_VCA_CACERT" ] && FATAL "Cannot obtain juju CA certificate"
fi
if [ -z "$OSM_VCA_APIPROXY" ]; then
OSM_VCA_APIPROXY=$DEFAULT_IP
[ -z "$OSM_VCA_APIPROXY" ] && FATAL "Cannot obtain juju api proxy"
fi
juju_createproxy
if [ -z "$OSM_DATABASE_COMMONKEY" ]; then
OSM_DATABASE_COMMONKEY=$(generate_secret)
[ -z "OSM_DATABASE_COMMONKEY" ] && FATAL "Cannot generate common db secret"
fi
[ -n "$INSTALL_NODOCKER" ] || install_docker_ce
garciadeblas
committed
track docker_ce
#Installs Kubernetes and deploys osm services
if [ -n "$KUBERNETES" ]; then
install_kube
track install_k8s
init_kubeadm $OSM_DOCKER_WORK_DIR/cluster-config.yaml
kube_config_dir
track init_k8s
else
#install_docker_compose
[ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
track docker_swarm
fi
[ -z "$DOCKER_NOBUILD" ] && generate_docker_images
garciadeblas
committed
track docker_build
generate_docker_env_files
if [ -n "$INSTALL_K8S_MONITOR" ]; then
# uninstall OSM MONITORING
uninstall_k8s_monitoring
fi
#remove old namespace
remove_k8s_namespace $OSM_STACK_NAME
deploy_cni_provider
kube_secrets
[ ! $OSM_DOCKER_TAG == "7" ] && parse_yaml $OSM_DOCKER_TAG
namespace_vol
deploy_osm_services
if [ -n "$INSTALL_PLA"]; then
# optional PLA install
deploy_osm_pla_service
fi
if [ -n "$INSTALL_K8S_MONITOR" ]; then
# install OSM MONITORING
install_k8s_monitoring
track install_k8s_monitoring
fi
else
# remove old stack
remove_stack $OSM_STACK_NAME
create_docker_network
deploy_lightweight
generate_osmclient_script
track docker_deploy
install_prometheus_nodeexporter
[ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
[ -n "$INSTALL_ELK" ] && deploy_elk && track elk
fi
[ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
garciadeblas
committed
track osmclient
wget -q -O- https://osm-download.etsi.org/ftp/osm-7.0-seven/README2.txt &> /dev/null
garciadeblas
committed
track end
return 0
}
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
function install_to_openstack() {
if [ -z "$2" ]; then
FATAL "OpenStack installer requires a valid external network name"
fi
# Install Pip for Python3
$WORKDIR_SUDO apt install -y python3-pip
$WORKDIR_SUDO -H LC_ALL=C python3 -m pip install -U pip
# Install Ansible, OpenStack client and SDK
$WORKDIR_SUDO -H LC_ALL=C python3 -m pip install -U python-openstackclient "openstacksdk<1" "ansible>=2.9,<3"
export ANSIBLE_CONFIG="$OSM_DEVOPS/installers/openstack/ansible.cfg"
OSM_INSTALLER_ARGS="${REPO_ARGS[@]}"
# Execute the Ansible playbook based on openrc or clouds.yaml
if [ -e "$1" ]; then
. $1
ansible-playbook -e external_network_name=$2 -e installer_args="\"$OSM_INSTALLER_ARGS\"" \
-e setup_volume=$3 $OSM_DEVOPS/installers/openstack/site.yml
else
ansible-playbook -e external_network_name=$2 -e installer_args="\"$OSM_INSTALLER_ARGS\"" \
-e setup_volume=$3 -e cloud_name=$1 $OSM_DEVOPS/installers/openstack/site.yml
fi
return 0
}
function install_vimemu() {
echo "\nInstalling vim-emu"
EMUTEMPDIR="$(mktemp -d -q --tmpdir "installosmvimemu.XXXXXX")"
trap 'rm -rf "${EMUTEMPDIR}"' EXIT
# install prerequisites (OVS is a must for the emulator to work)
sudo apt-get install openvswitch-switch
# clone vim-emu repository (attention: branch is currently master only)
echo "Cloning vim-emu repository ..."
git clone https://osm.etsi.org/gerrit/osm/vim-emu.git $EMUTEMPDIR
# build vim-emu docker
echo "Building vim-emu Docker container..."
sg docker -c "docker build -t vim-emu-img -f $EMUTEMPDIR/Dockerfile --no-cache $EMUTEMPDIR/" || FATAL "cannot build vim-emu-img docker image"
# start vim-emu container as daemon
echo "Starting vim-emu Docker container 'vim-emu' ..."
if [ -n "$INSTALL_LIGHTWEIGHT" ]; then
# in lightweight mode, the emulator needs to be attached to netOSM
sg docker -c "docker run --name vim-emu -t -d --restart always --privileged --pid='host' --network=net${OSM_STACK_NAME} -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py"
else
# classic build mode
sg docker -c "docker run --name vim-emu -t -d --restart always --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py"
echo "Waiting for 'vim-emu' container to start ..."
sleep 5
export VIMEMU_HOSTNAME=$(sg docker -c "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu")
echo "vim-emu running at ${VIMEMU_HOSTNAME} ..."
# print vim-emu connection info
echo -e "\nYou might be interested in adding the following vim-emu env variables to your .bashrc file:"
echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
echo -e "To add the emulated VIM to OSM you should do:"
echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://${VIMEMU_HOSTNAME}:6001/v2.0 --tenant tenantName --account_type openstack"
}
function install_k8s_monitoring() {
# install OSM monitoring
$WORKDIR_SUDO chmod +x $OSM_DEVOPS/installers/k8s/*.sh
$WORKDIR_SUDO $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh
}
function uninstall_k8s_monitoring() {
# uninstall OSM monitoring
$WORKDIR_SUDO $OSM_DEVOPS/installers/k8s/uninstall_osm_k8s_monitoring.sh
}
function dump_vars(){
echo "DEVELOP=$DEVELOP"
echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
echo "UNINSTALL=$UNINSTALL"
echo "UPDATE=$UPDATE"
echo "RECONFIGURE=$RECONFIGURE"
echo "TEST_INSTALLER=$TEST_INSTALLER"
echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
echo "INSTALL_LXD=$INSTALL_LXD"
echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT"
garciadeblas
committed
echo "INSTALL_ONLY=$INSTALL_ONLY"
echo "INSTALL_ELK=$INSTALL_ELK"
#echo "INSTALL_PERFMON=$INSTALL_PERFMON"
echo "INSTALL_TO_OPENSTACK=$INSTALL_TO_OPENSTACK"
echo "OPENSTACK_PUBLIC_NET_NAME=$OPENSTACK_PUBLIC_NET_NAME"
echo "OPENSTACK_OPENRC_FILE_OR_CLOUD=$OPENSTACK_OPENRC_FILE_OR_CLOUD"
echo "OPENSTACK_ATTACH_VOLUME=$OPENSTACK_ATTACH_VOLUME"
echo "INSTALL_K8S_MONITOR=$INSTALL_K8S_MONITOR"
echo "TO_REBUILD=$TO_REBUILD"
echo "INSTALL_NOLXD=$INSTALL_NOLXD"
echo "INSTALL_NODOCKER=$INSTALL_NODOCKER"
echo "INSTALL_NOJUJU=$INSTALL_NOJUJU"
echo "RELEASE=$RELEASE"
echo "REPOSITORY=$REPOSITORY"
echo "REPOSITORY_BASE=$REPOSITORY_BASE"
echo "REPOSITORY_KEY=$REPOSITORY_KEY"
echo "OSM_DEVOPS=$OSM_DEVOPS"
echo "OSM_VCA_HOST=$OSM_VCA_HOST"
echo "OSM_VCA_SECRET=$OSM_VCA_SECRET"
echo "OSM_VCA_PUBKEY=$OSM_VCA_PUBKEY"
echo "NO_HOST_PORTS=$NO_HOST_PORTS"
echo "DOCKER_NOBUILD=$DOCKER_NOBUILD"
echo "WORKDIR_SUDO=$WORKDIR_SUDO"
echo "OSM_WORK_DIR=$OSM_STACK_NAME"
echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
echo "DOCKER_USER=$DOCKER_USER"
echo "OSM_STACK_NAME=$OSM_STACK_NAME"
echo "PULL_IMAGES=$PULL_IMAGES"
echo "SHOWOPTS=$SHOWOPTS"
echo "Install from specific refspec (-b): $COMMIT_ID"
}
function track(){
ctime=`date +%s`
duration=$((ctime - SESSION_ID))
url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
#url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
event_name="bin"
garciadeblas
committed
[ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_SOURCE" ] && event_name="binsrc"
[ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
[ -n "$INSTALL_LIGHTWEIGHT" ] && event_name="lw"
event_name="${event_name}_$1"
url="${url}&event=${event_name}&ce_duration=${duration}"
wget -q -O /dev/null $url
}
UNINSTALL=""
DEVELOP=""
UPDATE=""
RECONFIGURE=""
TEST_INSTALLER=""
INSTALL_LXD=""
SHOWOPTS=""
COMMIT_ID=""
ASSUME_YES=""
INSTALL_FROM_SOURCE=""
INSTALL_VIMEMU=""
LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
LXD_REPOSITORY_PATH=""
INSTALL_LIGHTWEIGHT="y"
INSTALL_TO_OPENSTACK=""
OPENSTACK_OPENRC_FILE_OR_CLOUD=""
OPENSTACK_PUBLIC_NET_NAME=""
OPENSTACK_ATTACH_VOLUME="false"
garciadeblas
committed
INSTALL_ONLY=""
INSTALL_ELK=""
TO_REBUILD=""
INSTALL_NODOCKER=""
INSTALL_K8S_MONITOR=""
INSTALL_NOHOSTCLIENT=""
SESSION_ID=`date +%s`
OSM_DEVOPS=
OSM_VCA_HOST=
OSM_VCA_SECRET=
OSM_VCA_CLOUDNAME="localhost"
OSM_STACK_NAME=osm
NO_HOST_PORTS=""
DOCKER_NOBUILD=""
REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/debian"
WORKDIR_SUDO=sudo
OSM_WORK_DIR="/etc/osm"
OSM_DOCKER_WORK_DIR="/etc/osm/docker"
OSM_K8S_WORK_DIR="${OSM_DOCKER_WORK_DIR}/osm_pods"
OSM_HOST_VOL="/var/lib/osm"
OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
DOCKER_USER=opensourcemano
PULL_IMAGES="y"
GRAFANA_TAG=latest
PROMETHEUS_NODE_EXPORTER_TAG=0.18.1
PROMETHEUS_CADVISOR_TAG=latest
OSM_DATABASE_COMMONKEY=
ELASTIC_CURATOR_VERSION=5.5.4
POD_NETWORK_CIDR=10.244.0.0/16
K8S_MANIFEST_DIR="/etc/kubernetes/manifests"
RE_CHECK='^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
while getopts ":b:r:c:k:u:R:D:o:O:m:N:H:S:s:w:t:U:P:A:l:L:K:-: hy" o; do
case "${o}" in
b)
COMMIT_ID=${OPTARG}
REPOSITORY="${OPTARG}"
REPO_ARGS+=(-r "$REPOSITORY")
c)
[ "${OPTARG}" == "swarm" ] && continue
[ "${OPTARG}" == "k8s" ] && KUBERNETES="y" && continue
echo -e "Invalid argument for -i : ' $OPTARG'\n" >&2
usage && exit 1
;;
REPOSITORY_KEY="${OPTARG}"
REPO_ARGS+=(-k "$REPOSITORY_KEY")
REPOSITORY_BASE="${OPTARG}"
REPO_ARGS+=(-u "$REPOSITORY_BASE")
R)
RELEASE="${OPTARG}"
REPO_ARGS+=(-R "$RELEASE")
D)
OSM_DEVOPS="${OPTARG}"
;;
garciadeblas
committed
o)
INSTALL_ONLY="y"
[ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
[ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
[ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue
garciadeblas
committed
;;
O)
INSTALL_TO_OPENSTACK="y"
if [ -n "${OPTARG}" ]; then
OPENSTACK_OPENRC_FILE_OR_CLOUD="${OPTARG}"
else
echo -e "Invalid argument for -O : ' $OPTARG'\n" >&2
usage && exit 1
fi
;;
N)
OPENSTACK_PUBLIC_NET_NAME="${OPTARG}"
;;
m)
[ "${OPTARG}" == "LW-UI" ] && TO_REBUILD="$TO_REBUILD LW-UI" && continue
[ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue
[ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue
[ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue
[ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue
[ "${OPTARG}" == "POL" ] && TO_REBUILD="$TO_REBUILD POL" && continue
[ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue
[ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue
[ "${OPTARG}" == "PROMETHEUS" ] && TO_REBUILD="$TO_REBUILD PROMETHEUS" && continue
[ "${OPTARG}" == "PROMETHEUS-CADVISOR" ] && TO_REBUILD="$TO_REBUILD PROMETHEUS-CADVISOR" && continue
[ "${OPTARG}" == "KEYSTONE-DB" ] && TO_REBUILD="$TO_REBUILD KEYSTONE-DB" && continue
[ "${OPTARG}" == "GRAFANA" ] && TO_REBUILD="$TO_REBUILD GRAFANA" && continue
[ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue
[ "${OPTARG}" == "PLA" ] && TO_REBUILD="$TO_REBUILD PLA" && continue
;;
H)
OSM_VCA_HOST="${OPTARG}"
;;
S)
OSM_VCA_SECRET="${OPTARG}"
;;
s)
OSM_STACK_NAME="${OPTARG}" && [ -n "$KUBERNETES" ] && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0
;;
w)
# when specifying workdir, do not use sudo for access
WORKDIR_SUDO=
OSM_WORK_DIR="${OPTARG}"
;;
t)
OSM_DOCKER_TAG="${OPTARG}"
;;
U)
DOCKER_USER="${OPTARG}"
;;
P)
OSM_VCA_PUBKEY=$(cat ${OPTARG})
;;
A)
OSM_VCA_APIPROXY="${OPTARG}"
;;
l)
LXD_CLOUD_FILE="${OPTARG}"
;;
L)
LXD_CRED_FILE="${OPTARG}"
;;
K)
CONTROLLER_NAME="${OPTARG}"
;;
-)
[ "${OPTARG}" == "help" ] && usage && exit 0
[ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && PULL_IMAGES="" && continue
[ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
[ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
[ "${OPTARG}" == "update" ] && UPDATE="y" && continue
[ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
[ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
[ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
[ "${OPTARG}" == "nolxd" ] && INSTALL_NOLXD="y" && continue
[ "${OPTARG}" == "nodocker" ] && INSTALL_NODOCKER="y" && continue
[ "${OPTARG}" == "lightweight" ] && INSTALL_LIGHTWEIGHT="y" && continue
[ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
garciadeblas
committed
[ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
[ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
[ "${OPTARG}" == "nohostports" ] && NO_HOST_PORTS="y" && continue
[ "${OPTARG}" == "nojuju" ] && INSTALL_NOJUJU="y" && continue
[ "${OPTARG}" == "nodockerbuild" ] && DOCKER_NOBUILD="y" && continue
[ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
[ "${OPTARG}" == "pullimages" ] && continue
[ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue
[ "${OPTARG}" == "charmed" ] && CHARMED="y" && continue
[ "${OPTARG}" == "bundle" ] && continue
[ "${OPTARG}" == "k8s" ] && continue
[ "${OPTARG}" == "lxd" ] && continue
[ "${OPTARG}" == "lxd-cred" ] && continue
[ "${OPTARG}" == "tag" ] && continue
[ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue
[ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
usage && exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
usage && exit 1
;;
\?)
echo -e "Invalid option: '-$OPTARG'\n" >&2
usage && exit 1
;;
h)
usage && exit 0
;;
y)
ASSUME_YES="y"
;;
*)
usage && exit 1
;;
esac
done
[ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options"
[ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" == " PLA" ] && [ -z "$INSTALL_PLA" ] && FATAL "Incompatible option: -m PLA cannot be used without --pla option"
garciadeblas
committed
if [ -n "$SHOWOPTS" ]; then
dump_vars
exit 0
fi
if [ -n "$CHARMED" ]; then
if [ -n "$UNINSTALL" ]; then
/usr/share/osm-devops/installers/charmed_uninstall.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D /usr/share/osm-devops -t $DOCKER_TAG "$@"
else
/usr/share/osm-devops/installers/charmed_install.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D /usr/share/osm-devops -t $DOCKER_TAG "$@"
echo "Your installation is now complete, follow these steps for configuring the osmclient:"
echo
echo "1. Get the NBI IP with the following command:"
echo
echo NBI_IP='`juju status --format json | jq -rc '"'"'.applications."nbi-k8s".address'"'"'`'
echo
echo "2. Create the OSM_HOSTNAME environment variable with the NBI IP"
echo
echo "export OSM_HOSTNAME=\$NBI_IP"
echo
echo "3. Add the previous command to your .bashrc for other Shell sessions"
echo
echo "echo \"export OSM_HOSTNAME=\$NBI_IP\" >> ~/.bashrc"
echo
echo "DONE"
fi
# if develop, we force master
[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
need_packages="git wget curl tar"
[ -n "$INSTALL_TO_OPENSTACK" ] && install_to_openstack $OPENSTACK_OPENRC_FILE_OR_CLOUD $OPENSTACK_PUBLIC_NET_NAME $OPENSTACK_ATTACH_VOLUME && echo -e "\nDONE" && exit 0
echo -e "Checking required packages: $need_packages"
dpkg -l $need_packages &>/dev/null \
|| ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
|| sudo apt-get update \
|| FATAL "failed to run apt-get update"
dpkg -l $need_packages &>/dev/null \
|| ! echo -e "Installing $need_packages requires root privileges." \
|| sudo apt-get install -y $need_packages \
|| FATAL "failed to install $need_packages"
if [ -z "$OSM_DEVOPS" ]; then
if [ -n "$TEST_INSTALLER" ]; then
echo -e "\nUsing local devops repo for OSM installation"
OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))"
else
echo -e "\nCreating temporary dir for OSM installation"
OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
trap 'rm -rf "$OSM_DEVOPS"' EXIT
git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
if [ -z "$COMMIT_ID" ]; then
echo -e "\nGuessing the current stable release"
LATEST_STABLE_DEVOPS=`git -C $OSM_DEVOPS tag -l v[0-9].* | sort -V | tail -n1`
[ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
else
echo -e "\nDEVOPS Using commit $COMMIT_ID"
fi
git -C $OSM_DEVOPS checkout $COMMIT_ID
fi
fi
. $OSM_DEVOPS/common/all_funcs
[ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE" && exit 0
garciadeblas
committed
[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_ELK" ] && deploy_elk
#[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_PERFMON" ] && deploy_perfmon
garciadeblas
committed
[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_VIMEMU" ] && install_vimemu
[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_K8S_MONITOR" ] && install_k8s_monitoring
garciadeblas
committed
[ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0
#Installation starts here
wget -q -O- https://osm-download.etsi.org/ftp/osm-7.0-seven/README.txt &> /dev/null
garciadeblas
committed
track start
[ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE" && exit 0
echo -e "\nInstalling OSM from refspec: $COMMIT_ID"
if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1
fi
echo -e "Checking required packages: lxd"
lxd --version &>/dev/null || FATAL "lxd not present, exiting."
[ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
# use local devops for containers
export OSM_USE_LOCAL_DEVOPS=true
#Install osmclient
#Install vim-emu (optional)
[ -n "$INSTALL_VIMEMU" ] && install_docker_ce && install_vimemu
wget -q -O- https://osm-download.etsi.org/ftp/osm-7.0-seven/README2.txt &> /dev/null
track end
echo -e "\nDONE"