echo -e " -s <stack name> user defined stack name, default is osm"
echo -e " -H <VCA host> use specific juju host controller IP"
echo -e " -S <VCA secret> use VCA/juju secret key"
+ echo -e " -P <VCA pubkey> use VCA/juju public key file"
echo -e " --vimemu: additionally deploy the VIM emulator as a docker container"
echo -e " --elk_stack: additionally deploy an ELK docker stack for event logging"
echo -e " --pm_stack: additionally deploy a Prometheus+Grafana stack for performance monitoring (PM)"
- echo -e " -m <MODULE>: install OSM but only rebuild the specified docker images (RO, LCM, NBI, LW-UI, MON, KAFKA, MONGO, NONE)"
+ echo -e " -m <MODULE>: install OSM but only rebuild the specified docker images (LW-UI, NBI, LCM, RO, MON, POL, KAFKA, MONGO, PROMETHEUS, KEYSTONE-DB, NONE)"
echo -e " -o <ADDON>: ONLY (un)installs one of the addons (vimemu, elk_stack, pm_stack)"
echo -e " -D <devops path> use local devops installation path"
echo -e " -w <work dir> Location to store runtime installation"
}
# takes a juju/accounts.yaml file and returns the password specific
-# for a controller. I wrote this using only bash tools to minimize
+# for a controller. I wrote this using only bash tools to minimize
# additions of other packages
function parse_juju_password {
password_file="${HOME}/.local/share/juju/accounts.yaml"
}'
}
+function generate_secret() {
+ head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32
+}
+
function remove_volumes() {
stack=$1
volumes="mongo_db mon_db osm_packages ro_db"
if [ -n "$INSTALL_PERFMON" ]; then
echo -e "\nUninstalling OSM Performance Monitoring stack"
remove_stack osm_metrics
- sg docker -c "docker image rm osm/kafka-exporter"
$WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR/osm_metrics
fi
else
remove_stack osm_metrics
echo "Now osm docker images and volumes will be deleted"
newgrp docker << EONG
- docker image rm ${DOCKERUSER}/ro
- docker image rm ${DOCKERUSER}/lcm
- docker image rm ${DOCKERUSER}/light-ui
- docker image rm ${DOCKERUSER}/keystone
- docker image rm ${DOCKERUSER}/nbi
- docker image rm ${DOCKERUSER}/mon
- docker image rm ${DOCKERUSER}/pm
- docker image rm ${DOCKERUSER}/kafka-exporter
+ docker image rm ${DOCKER_USER}/ro:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/lcm:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/keystone:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/nbi:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/mon:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/pol:${OSM_DOCKER_TAG}
+ docker image rm ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}
EONG
remove_volumes $OSM_STACK_NAME
remove_network $OSM_STACK_NAME
function configure_VCA(){
echo -e " Configuring VCA"
- JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
+ JUJU_PASSWD=$(generate_secret)
echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password
}
sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
sudo apt-get update
sudo apt-get install -y python-pip
- sudo -H pip install pip==9.0.3
- sudo -H pip install python-magic
+ sudo -H LC_ALL=C pip install pip==9.0.3
+ sudo -H LC_ALL=C pip install python-magic
sudo apt-get install -y python-osmclient
#sed 's,OSM_SOL005=[^$]*,OSM_SOL005=True,' -i ${HOME}/.bashrc
#echo 'export OSM_HOSTNAME=localhost' >> ${HOME}/.bashrc
#echo 'export OSM_SOL005=True' >> ${HOME}/.bashrc
[ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'`
[ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'`
- [ -n "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=127.0.0.1
echo -e "\nOSM client installed"
- echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
- echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
- [ -n "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_SOL005=True"
- [ -z "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
+ if [ -z "$INSTALL_LIGHTWEIGHT" ]; then
+ echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
+ echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
+ echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
+ else
+ echo -e "OSM client assumes that OSM host is running in localhost (127.0.0.1)."
+ echo -e "In case you want to interact with a different OSM host, you will have to configure this env variable in your .bashrc file:"
+ echo " export OSM_HOSTNAME=<OSM_host>"
+ fi
return 0
}
}
function juju_createcontroller() {
- if ! sg lxd -c "juju show-controller $OSM_STACK_NAME &> /dev/null"; then
+ if ! juju show-controller $OSM_STACK_NAME &> /dev/null; then
# Not found created, create the controller
sg lxd -c "juju bootstrap --bootstrap-series=xenial localhost $OSM_STACK_NAME"
fi
- [ $(sg lxd -c "juju controllers" | awk "/^${OSM_STACK_NAME}[\*| ]/{print $1}"|wc -l) -eq 1 ] || FATAL "Juju installation failed"
+ [ $(juju controllers | awk "/^${OSM_STACK_NAME}[\*| ]/{print $1}"|wc -l) -eq 1 ] || FATAL "Juju installation failed"
}
function generate_docker_images() {
BUILD_ARGS+=(--build-arg RELEASE="$RELEASE")
BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY")
BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE")
-
+
if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then
sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image"
sg docker -c "docker pull wurstmeister/kafka:${KAFKA_TAG}" || FATAL "cannot get kafka docker image"
sg docker -c "docker pull mongo" || FATAL "cannot get mongo docker image"
fi
+ if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q PROMETHEUS ; then
+ sg docker -c "docker pull prom/prometheus:${PROMETHEUS_TAG}" || FATAL "cannot get prometheus docker image"
+ fi
+
+ if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI || echo $TO_REBUILD | grep -q KEYSTONE-DB ; then
+ sg docker -c "docker pull mariadb:${KEYSTONEDB_TAG}" || FATAL "cannot get keystone-db docker image"
+ fi
+
+ if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q RO ; then
+ sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image"
+ fi
+
if [ -n "$PULL_IMAGES" ]; then
sg docker -c "docker pull ${DOCKER_USER}/mon:${OSM_DOCKER_TAG}" || FATAL "cannot pull MON docker image"
- sg docker -c "docker pull ${DOCKER_USER}/pol:${OSM_DOCKER_TAG}" || FATAL "cannot pull POL docker image"
elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MON ; then
git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON
git -C ${LWTEMPDIR}/MON checkout ${COMMIT_ID}
- sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon --no-cache" || FATAL "cannot build MON docker image"
- sg docker -c "docker build ${LWTEMPDIR}/MON/policy_module -f ${LWTEMPDIR}/MON/policy_module/Dockerfile -t osm/pm --no-cache" || FATAL "cannot build PM docker image"
+ sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t ${DOCKER_USER}/mon --no-cache" || FATAL "cannot build MON docker image"
+ fi
+
+ if [ -n "$PULL_IMAGES" ]; then
+ sg docker -c "docker pull ${DOCKER_USER}/pol:${OSM_DOCKER_TAG}" || FATAL "cannot pull POL docker image"
+ elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q POL ; then
+ git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/POL
+ git -C ${LWTEMPDIR}/POL checkout ${COMMIT_ID}
+ sg docker -c "docker build ${LWTEMPDIR}/POL -f ${LWTEMPDIR}/POL/docker/Dockerfile -t ${DOCKER_USER}/pol --no-cache" || FATAL "cannot build POL docker image"
fi
if [ -n "$PULL_IMAGES" ]; then
sg docker -c "docker pull ${DOCKER_USER}/nbi:${OSM_DOCKER_TAG}" || FATAL "cannot pull NBI docker image"
+ sg docker -c "docker pull ${DOCKER_USER}/keystone:${OSM_DOCKER_TAG}" || FATAL "cannot pull KEYSTONE docker image"
elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI ; then
git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI
git -C ${LWTEMPDIR}/NBI checkout ${COMMIT_ID}
- sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi --no-cache" || FATAL "cannot build NBI docker image"
+ sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t ${DOCKER_USER}/nbi --no-cache" || FATAL "cannot build NBI docker image"
+ sg docker -c "docker build ${LWTEMPDIR}/NBI/keystone -f ${LWTEMPDIR}/NBI/keystone/Dockerfile -t ${DOCKER_USER}/keystone --no-cache" || FATAL "cannot build KEYSTONE docker image"
fi
if [ -n "$PULL_IMAGES" ]; then
sg docker -c "docker pull ${DOCKER_USER}/ro:${OSM_DOCKER_TAG}" || FATAL "cannot pull RO docker image"
elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q RO ; then
- sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image"
git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO
git -C ${LWTEMPDIR}/RO checkout ${COMMIT_ID}
- sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro --no-cache" || FATAL "cannot build RO docker image"
+ sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t ${DOCKER_USER}/ro --no-cache" || FATAL "cannot build RO docker image"
fi
if [ -n "$PULL_IMAGES" ]; then
elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LCM ; then
git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LCM
git -C ${LWTEMPDIR}/LCM checkout ${COMMIT_ID}
- sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t osm/lcm --no-cache" || FATAL "cannot build LCM docker image"
+ sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t ${DOCKER_USER}/lcm --no-cache" || FATAL "cannot build LCM docker image"
fi
if [ -n "$PULL_IMAGES" ]; then
elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-UI ; then
git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI
git -C ${LWTEMPDIR}/LW-UI checkout ${COMMIT_ID}
- sg docker -c "docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/Dockerfile --no-cache" || FATAL "cannot build LW-UI docker image"
+ sg docker -c "docker build ${LWTEMPDIR}/LW-UI -f ${LWTEMPDIR}/LW-UI/docker/Dockerfile -t ${DOCKER_USER}/light-ui --no-cache" || FATAL "cannot build LW-UI docker image"
fi
if [ -n "$PULL_IMAGES" ]; then
sg docker -c "docker pull ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" || FATAL "cannot pull osmclient docker image"
elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-osmclient; then
- sg docker -c "docker build -t osm/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
+ sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
fi
echo "Finished generation of docker images"
}
function generate_config_log_folders() {
echo "Generating config and log folders"
$WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml
+ $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus.yml
echo "Finished generation of config and log folders"
}
function generate_docker_env_files() {
echo "Generating docker env files"
- echo "OSMLCM_VCA_HOST=${OSMLCM_VCA_HOST}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/lcm.env
- echo "OSMLCM_VCA_SECRET=${OSMLCM_VCA_SECRET}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
+ # LCM
+ if [ ! -f $OSM_DOCKER_WORK_DIR/lcm.env ]; then
+ echo "OSMLCM_DATABASE_COMMONKEY=${OSM_DATABASE_COMMONKEY}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
+ fi
+
+ if ! grep -Fq "OSMLCM_VCA_HOST" $OSM_DOCKER_WORK_DIR/lcm.env; then
+ echo "OSMLCM_VCA_HOST=${OSM_VCA_HOST}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
+ else
+ $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_HOST.*|OSMLCM_VCA_HOST=$OSM_VCA_HOST|g" $OSM_DOCKER_WORK_DIR/lcm.env
+ fi
- MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
+ if ! grep -Fq "OSMLCM_VCA_SECRET" $OSM_DOCKER_WORK_DIR/lcm.env; then
+ echo "OSMLCM_VCA_SECRET=${OSM_VCA_SECRET}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
+ else
+ $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_SECRET.*|OSMLCM_VCA_SECRET=$OSM_VCA_SECRET|g" $OSM_DOCKER_WORK_DIR/lcm.env
+ fi
+
+ if ! grep -Fq "OSMLCM_VCA_PUBKEY" $OSM_DOCKER_WORK_DIR/lcm.env; then
+ echo "OSMLCM_VCA_PUBKEY=${OSM_VCA_PUBKEY}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
+ else
+ $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_PUBKEY.*|OSMLCM_VCA_PUBKEY=$OSM_VCA_PUBKEY|g" $OSM_DOCKER_WORK_DIR/lcm.env
+ fi
+
+ # RO
+ MYSQL_ROOT_PASSWORD=$(generate_secret)
if [ ! -f $OSM_DOCKER_WORK_DIR/ro-db.env ]; then
echo "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/ro-db.env
fi
echo "RO_DB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/ro.env
fi
- MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` && sleep 1
- KEYSTONE_DB_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` && sleep 1
- #ADMIN_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` && sleep 1
- NBI_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
+ # Keystone
+ KEYSTONE_DB_PASSWORD=$(generate_secret)
+ SERVICE_PASSWORD=$(generate_secret)
if [ ! -f $OSM_DOCKER_WORK_DIR/keystone-db.env ]; then
echo "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone-db.env
fi
if [ ! -f $OSM_DOCKER_WORK_DIR/keystone.env ]; then
echo "ROOT_DB_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone.env
echo "KEYSTONE_DB_PASSWORD=${KEYSTONE_DB_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
- #echo "ADMIN_PASSWORD=${ADMIN_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
- echo "NBI_PASSWORD=${NBI_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
+ echo "SERVICE_PASSWORD=${SERVICE_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
fi
+ # NBI
if [ ! -f $OSM_DOCKER_WORK_DIR/nbi.env ]; then
- echo "OSMNBI_AUTHENTICATION_SERVICE_PASSWORD=${NBI_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/nbi.env
+ echo "OSMNBI_AUTHENTICATION_SERVICE_PASSWORD=${SERVICE_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/nbi.env
+ echo "OSMNBI_DATABASE_COMMONKEY=${OSM_DATABASE_COMMONKEY}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/nbi.env
+ fi
+
+ # MON
+ if [ ! -f $OSM_DOCKER_WORK_DIR/mon.env ]; then
+ echo "OSMMON_DATABASE_COMMONKEY=${OSM_DATABASE_COMMONKEY}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
+ echo "OSMMON_SQL_DATABASE_URI=mysql://root:${MYSQL_ROOT_PASSWORD}@mysql:3306/mon" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
+ fi
+
+ if ! grep -Fq "OS_NOTIFIER_URI" $OSM_DOCKER_WORK_DIR/mon.env; then
+ echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
+ else
+ $WORKDIR_SUDO sed -i "s|OS_NOTIFIER_URI.*|OS_NOTIFIER_URI=http://$DEFAULT_IP:8662|g" $OSM_DOCKER_WORK_DIR/mon.env
fi
- echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/mon.env
+ if ! grep -Fq "OSMMON_VCA_HOST" $OSM_DOCKER_WORK_DIR/mon.env; then
+ echo "OSMMON_VCA_HOST=${OSM_VCA_HOST}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
+ else
+ $WORKDIR_SUDO sed -i "s|OSMMON_VCA_HOST.*|OSMMON_VCA_HOST=$OSM_VCA_HOST|g" $OSM_DOCKER_WORK_DIR/mon.env
+ fi
+
+ if ! grep -Fq "OSMMON_VCA_SECRET" $OSM_DOCKER_WORK_DIR/mon.env; then
+ echo "OSMMON_VCA_SECRET=${OSM_VCA_SECRET}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
+ else
+ $WORKDIR_SUDO sed -i "s|OSMMON_VCA_SECRET.*|OSMMON_VCA_SECRET=$OSM_VCA_SECRET|g" $OSM_DOCKER_WORK_DIR/mon.env
+ fi
+
+ # POL
+ if [ ! -f $OSM_DOCKER_WORK_DIR/pol.env ]; then
+ echo "OSMPOL_SQL_DATABASE_URI=mysql://root:${MYSQL_ROOT_PASSWORD}@mysql:3306/pol" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/pol.env
+ fi
+
+ # LW-UI
+ if [ ! -f $OSM_DOCKER_WORK_DIR/lwui.env ]; then
+ echo "OSMUI_SQL_DATABASE_URI=mysql://root:${MYSQL_ROOT_PASSWORD}@mysql:3306/lwui" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lwui.env
+ fi
echo "Finished generation of docker env files"
}
function generate_osmclient_script () {
- echo "docker run -ti --network net${OSM_STACK_NAME} osm/osmclient:${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm
+ echo "docker run -ti --network net${OSM_STACK_NAME} ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm
$WORKDIR_SUDO chmod +x "$OSM_DOCKER_WORK_DIR/osm"
echo "osmclient sidecar container can be found at: $OSM_DOCKER_WORK_DIR/osm"
}
OSM_KEYSTONE_PORT=5000
OSM_UI_PORT=80
OSM_MON_PORT=8662
+ OSM_PROM_PORT=9090
+ OSM_PROM_HOSTPORT=9091
[ -n "$INSTALL_ELK" ] && OSM_ELK_PORT=5601
[ -n "$INSTALL_PERFMON" ] && OSM_PM_PORT=3000
-
+
if [ -n "$NO_HOST_PORTS" ]; then
OSM_PORTS+=(OSM_NBI_PORTS=$OSM_NBI_PORT)
OSM_PORTS+=(OSM_RO_PORTS=$OSM_RO_PORT)
OSM_PORTS+=(OSM_KEYSTONE_PORTS=$OSM_KEYSTONE_PORT)
OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT)
OSM_PORTS+=(OSM_MON_PORTS=$OSM_MON_PORT)
+ OSM_PORTS+=(OSM_PROM_PORTS=$OSM_PROM_PORT)
[ -n "$INSTALL_PERFMON" ] && OSM_PORTS+=(OSM_PM_PORTS=$OSM_PM_PORT)
[ -n "$INSTALL_ELK" ] && OSM_PORTS+=(OSM_ELK_PORTS=$OSM_ELK_PORT)
else
OSM_PORTS+=(OSM_KEYSTONE_PORTS=$OSM_KEYSTONE_PORT:$OSM_KEYSTONE_PORT)
OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT:$OSM_UI_PORT)
OSM_PORTS+=(OSM_MON_PORTS=$OSM_MON_PORT:$OSM_MON_PORT)
+ OSM_PORTS+=(OSM_PROM_PORTS=$OSM_PROM_HOSTPORT:$OSM_PROM_PORT)
[ -n "$INSTALL_PERFMON" ] && OSM_PORTS+=(OSM_PM_PORTS=$OSM_PM_PORT:$OSM_PM_PORT)
[ -n "$INSTALL_ELK" ] && OSM_PORTS+=(OSM_ELK_PORTS=$OSM_ELK_PORT:$OSM_ELK_PORT)
fi
echo "export TAG=${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
echo "export DOCKER_USER=${DOCKER_USER}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
echo "export KAFKA_TAG=${KAFKA_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
-
-
+ echo "export PROMETHEUS_TAG=${PROMETHEUS_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
+ echo "export KEYSTONEDB_TAG=${KEYSTONEDB_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
pushd $OSM_DOCKER_WORK_DIR
sg docker -c "source ./osm_ports.sh; docker stack deploy -c $OSM_DOCKER_WORK_DIR/docker-compose.yaml $OSM_STACK_NAME"
function deploy_elk() {
echo "Pulling docker images for ELK"
- sg docker -c "docker pull docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.3" || FATAL "cannot get elasticsearch docker image"
- sg docker -c "docker pull docker.elastic.co/logstash/logstash-oss:6.2.3" || FATAL "cannot get logstash docker image"
- sg docker -c "docker pull docker.elastic.co/kibana/kibana-oss:6.2.3" || FATAL "cannot get kibana docker image"
+ sg docker -c "docker pull docker.elastic.co/elasticsearch/elasticsearch-oss:${ELASTIC_VERSION}" || FATAL "cannot get elasticsearch docker image"
+ sg docker -c "docker pull docker.elastic.co/beats/metricbeat:${ELASTIC_VERSION}" || FATAL "cannot get metricbeat docker image"
+ sg docker -c "docker pull docker.elastic.co/beats/filebeat:${ELASTIC_VERSION}" || FATAL "cannot get filebeat docker image"
+ sg docker -c "docker pull docker.elastic.co/kibana/kibana-oss:${ELASTIC_VERSION}" || FATAL "cannot get kibana docker image"
+ sg docker -c "docker pull bobrik/curator:${ELASTIC_CURATOR_VERSION}" || FATAL "cannot get curator docker image"
echo "Finished pulling elk docker images"
$WORKDIR_SUDO mkdir -p "$OSM_DOCKER_WORK_DIR/osm_elk"
$WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_elk/* $OSM_DOCKER_WORK_DIR/osm_elk
echo "ELK is up and running. Trying to create index pattern..."
#Create index pattern
curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
- "http://127.0.0.1:5601/api/saved_objects/index-pattern/logstash-*" \
- -d"{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}" 2>/dev/null
+ "http://127.0.0.1:5601/api/saved_objects/index-pattern/filebeat-*" \
+ -d"{\"attributes\":{\"title\":\"filebeat-*\",\"timeFieldName\":\"@timestamp\"}}" 2>/dev/null
#Make it the default index
curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
"http://127.0.0.1:5601/api/kibana/settings/defaultIndex" \
- -d"{\"value\":\"logstash-*\"}" 2>/dev/null
+ -d"{\"value\":\"filebeat-*\"}" 2>/dev/null
else
echo "Cannot connect to Kibana to create index pattern."
echo "Once Kibana is running, you can use the following instructions to create index pattern:"
echo 'curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
- "http://127.0.0.1:5601/api/saved_objects/index-pattern/logstash-*" \
- -d"{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}"'
+ "http://127.0.0.1:5601/api/saved_objects/index-pattern/filebeat-*" \
+ -d"{\"attributes\":{\"title\":\"filebeat-*\",\"timeFieldName\":\"@timestamp\"}}"'
echo 'curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
"http://127.0.0.1:5601/api/kibana/settings/defaultIndex" \
- -d"{\"value\":\"logstash-*\"}"'
+ -d"{\"value\":\"filebeat-*\"}"'
fi
echo "Finished deployment of ELK stack"
return 0
}
function deploy_perfmon() {
- echo "Pulling docker images for PM (Grafana and Prometheus)"
- sg docker -c "docker pull prom/prometheus" || FATAL "cannot get prometheus docker image"
+ echo "Pulling docker images for PM (Grafana)"
sg docker -c "docker pull grafana/grafana" || FATAL "cannot get grafana docker image"
echo "Finished pulling PM docker images"
- echo "Generating osm/kafka-exporter docker image"
- sg docker -c "docker build ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter -f ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter/Dockerfile -t osm/kafka-exporter --no-cache" || FATAL "cannot build kafka-exporter docker image"
- echo "Finished generation of osm/kafka-exporter docker image"
$WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/osm_metrics
$WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.yml $OSM_DOCKER_WORK_DIR/osm_metrics
$WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.json $OSM_DOCKER_WORK_DIR/osm_metrics
remove_stack osm_metrics
- echo "Deploying PM stack (Kafka exporter + Prometheus + Grafana)"
+ echo "Deploying PM stack (Grafana)"
sg docker -c "OSM_NETWORK=net${OSM_STACK_NAME} docker stack deploy -c $OSM_DOCKER_WORK_DIR/osm_metrics/docker-compose.yml osm_metrics"
echo "Finished deployment of PM stack"
return 0
}
function install_lightweight() {
- OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME"
+ [ "${OSM_STACK_NAME}" == "osm" ] || OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME"
[ ! -d "$OSM_DOCKER_WORK_DIR" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR
+ track checkingroot
[ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges."
+ track noroot
[ -z "$ASSUME_YES" ] && ! ask_user "The installation will configure LXD, install juju, install docker CE and init a docker swarm, as pre-requirements. Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
track proceed
echo "Installing lightweight build of OSM"
DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
# if no host is passed in, we need to install lxd/juju, unless explicilty asked not to
- if [ -z "$OSMLCM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ]; then
+ if [ -z "$OSM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ]; then
need_packages_lw="lxd snapd"
echo -e "Checking required packages: $need_packages_lw"
dpkg -l $need_packages_lw &>/dev/null \
track prereqok
[ -z "$INSTALL_NOJUJU" ] && install_juju
- if [ -z "$OSMLCM_VCA_HOST" ]; then
+ track juju_install
+ if [ -z "$OSM_VCA_HOST" ]; then
juju_createcontroller
- OSMLCM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
- [ -z "$OSMLCM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
+ OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
+ [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
+ fi
+ track juju_controller
+ if [ -z "$OSM_VCA_SECRET" ]; then
+ OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
+ [ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
fi
- if [ -z "$OSMLCM_VCA_SECRET" ]; then
- OSMLCM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
- [ -z "$OSMLCM_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
+ if [ -z "$OSM_DATABASE_COMMONKEY" ]; then
+ OSM_DATABASE_COMMONKEY=$(generate_secret)
+ [ -z "OSM_DATABASE_COMMONKEY" ] && FATAL "Cannot generate common db secret"
fi
track juju
[ -n "$INSTALL_NODOCKER" ] || install_docker_ce
track docker_ce
#install_docker_compose
+ [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
+ track docker_swarm
[ -z "$DOCKER_NOBUILD" ] && generate_docker_images
track docker_build
generate_docker_env_files
generate_config_log_folders
- [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
# remove old stack
remove_stack $OSM_STACK_NAME
create_docker_network
[ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
[ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
track osmclient
- wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
+ wget -q -O- https://osm-download.etsi.org/ftp/osm-5.0-five/README2.txt &> /dev/null
track end
return 0
}
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 "NOCONFIGURE=$NOCONFIGURE"
+ 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"
}
COMMIT_ID=""
ASSUME_YES=""
INSTALL_FROM_SOURCE=""
-RELEASE="ReleaseFOUR"
+RELEASE="ReleaseFIVE"
REPOSITORY="stable"
INSTALL_VIMEMU=""
INSTALL_FROM_LXDIMAGES=""
INSTALL_NOLXD=""
INSTALL_NODOCKER=""
INSTALL_NOJUJU=""
+INSTALL_NOHOSTCLIENT=""
NOCONFIGURE=""
RELEASE_DAILY=""
SESSION_ID=`date +%s`
OSM_DEVOPS=
-OSMLCM_VCA_HOST=
-OSMLCM_VCA_SECRET=
+OSM_VCA_HOST=
+OSM_VCA_SECRET=
+OSM_VCA_PUBKEY=
OSM_STACK_NAME=osm
NO_HOST_PORTS=""
DOCKER_NOBUILD=""
REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
-REPOSITORY_BASE="http://osm-download.etsi.org/repository/osm/debian"
+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_DOCKER_TAG=latest
-DOCKER_USER=osm
+DOCKER_USER=opensourcemano
+PULL_IMAGES="y"
KAFKA_TAG=2.11-1.0.2
+PROMETHEUS_TAG=v2.4.3
+KEYSTONEDB_TAG=10
+OSM_DATABASE_COMMONKEY=
+ELASTIC_VERSION=6.4.2
+ELASTIC_CURATOR_VERSION=5.5.4
-while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:H:S:s:w:t:" o; do
+while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:H:S:s:w:t:U:P:" o; do
case "${o}" in
h)
usage && exit 0
;;
b)
COMMIT_ID=${OPTARG}
+ PULL_IMAGES=""
;;
r)
REPOSITORY="${OPTARG}"
REPOSITORY_BASE="${OPTARG}"
REPO_ARGS+=(-u "$REPOSITORY_BASE")
;;
+ U)
+ DOCKER_USER="${OPTARG}"
+ ;;
l)
LXD_REPOSITORY_BASE="${OPTARG}"
;;
OSM_STACK_NAME="${OPTARG}"
;;
H)
- OSMLCM_VCA_HOST="${OPTARG}"
+ OSM_VCA_HOST="${OPTARG}"
;;
S)
- OSMLCM_VCA_SECRET="${OPTARG}"
+ OSM_VCA_SECRET="${OPTARG}"
+ ;;
+ P)
+ OSM_VCA_PUBKEY=$(cat ${OPTARG})
;;
w)
# when specifying workdir, do not use sudo for access
[ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue
;;
m)
- [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue
- [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue
- [ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue
[ "${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}" == "KEYSTONE-DB" ] && TO_REBUILD="$TO_REBUILD KEYSTONE-DB" && continue
[ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue
;;
-)
[ "${OPTARG}" == "help" ] && usage && exit 0
- [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue
+ [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && PULL_IMAGES="" && continue
[ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
[ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
[ "${OPTARG}" == "nat" ] && NAT="y" && continue
[ "${OPTARG}" == "nojuju" ] && INSTALL_NOJUJU="y" && continue
[ "${OPTARG}" == "nodockerbuild" ] && DOCKER_NOBUILD="y" && continue
[ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
- [ "${OPTARG}" == "pullimages" ] && DOCKER_USER="opensourcemano" && PULL_IMAGES=true && continue
+ [ "${OPTARG}" == "pullimages" ] && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
usage && exit 1
;;
[ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0
#Installation starts here
-wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README.txt &> /dev/null
+wget -q -O- https://osm-download.etsi.org/ftp/osm-5.0-five/README.txt &> /dev/null
track start
[ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE" && exit 0
#Install vim-emu (optional)
[ -n "$INSTALL_VIMEMU" ] && install_docker_ce && install_vimemu
-wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
+wget -q -O- https://osm-download.etsi.org/ftp/osm-5.0-five/README2.txt &> /dev/null
track end
echo -e "\nDONE"
-