IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
PASSWORD_OVERLAY_FILE=~/.osm/password-overlay.yaml
PATH=/snap/bin:${PATH}
+OSM_DEVOPS="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd )"
+if [ -f ${OSM_DEVOPS}/common/all_funcs ] ; then
+ source ${OSM_DEVOPS}/common/all_funcs
+else
+ function track(){
+ true
+ }
+ function FATAL_TRACK(){
+ exit 1
+ }
+fi
MODEL_NAME=osm
function install_snaps(){
if [ ! -v KUBECFG ]; then
- sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable
+ KUBEGRP="microk8s"
+ sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable ||
+ FATAL_TRACK k8scluster "snap install microk8s ${MICROK8S_VERSION}/stable failed"
+ sudo usermod -a -G microk8s `whoami`
sudo cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || (
echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver
- microk8s.stop
- microk8s.start
+ sg ${KUBEGRP} -c microk8s.stop
+ sg ${KUBEGRP} -c microk8s.start
)
- sudo usermod -a -G microk8s `whoami`
mkdir -p ~/.kube
sudo chown -f -R `whoami` ~/.kube
- KUBEGRP="microk8s"
sg ${KUBEGRP} -c "microk8s status --wait-ready"
KUBECONFIG=~/.osm/microk8s-config.yaml
sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG}
+ track k8scluster k8scluster_ok
else
KUBECTL="kubectl"
sudo snap install kubectl --classic
export KUBECONFIG=${KUBECFG}
KUBEGRP=$(id -g -n)
fi
- sudo snap install juju --classic --channel=$JUJU_VERSION/stable
+ sudo snap install juju --classic --channel=$JUJU_VERSION/stable ||
+ FATAL_TRACK juju "snap install juju ${JUJU_VERSION}/stable failed"
+ track juju juju_ok
}
function bootstrap_k8s_lxd(){
Please retry the installation once this conflict has been resolved.
EOF
- exit 1
+ FATAL_TRACK bootstrap_k8s "VCA already present"
fi
else
CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l)
Please retry the installation with one of the solutions applied.
EOF
- exit 1
+ FATAL_TRACK bootstrap_k8s "Requested VCA not present"
fi
fi
if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
echo "Microk8s storage failed to enable"
sg ${KUBEGRP} -c "microk8s.status"
- exit 1
+ FATAL_TRACK bootstrap_k8s "Microk8s storage failed to enable"
fi
storage_status=`sg ${KUBEGRP} -c "microk8s.status -a storage"`
if [[ $storage_status == "enabled" ]]; then
"juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=$JUJU_AGENT_VERSION" \
&& K8S_CLOUD_NAME=microk8s
fi
+ track bootstrap_k8s bootstrap_k8s_ok
if [ -v LXD_CLOUD ]; then
if [ ! -v LXD_CREDENTIALS ]; then
echo "The installer needs the LXD server certificate if the LXD is external"
- exit 1
+ FATAL_TRACK bootstrap_lxd "No LXD certificate supplied"
fi
else
LXDENDPOINT=$DEFAULT_IP
juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS
sg lxd -c "lxd waitready"
juju controller-config features=[k8s-operators]
-}
-
-function wait_for_port(){
- SERVICE=$1
- INDEX=$2
- TIME_TO_WAIT=30
- start_time="$(date -u +%s)"
- while true
- do
- now="$(date -u +%s)"
- if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
- echo "Failed to expose external ${SERVICE} interface port"
- exit 1
- fi
-
- if [ $(sg ${KUBEGRP} -c "${KUBECTL} get ingresses.networking -n osm -o json | jq -r '.items[$INDEX].metadata.name'") == ${SERVICE} ] ; then
- break
- fi
- sleep 1
- done
+ track bootstrap_lxd bootstrap_lxd_ok
}
function deploy_charmed_osm(){
now="$(date -u +%s)"
if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
echo "Timed out waiting for OSM services to become ready"
- exit 1
+ FATAL_TRACK deploy_osm "Timed out waiting for services to become ready"
fi
sleep 10
done
}
function install_microstack() {
-
sudo snap install microstack --beta --devmode
CHECK=$(microstack.openstack server list)
echo "Use the following command to register the installed VCA to your OSM:"
echo -e " osm vca-add --endpoints $vca_host:$vca_port \\\n --user $vca_user \\\n --secret $vca_secret \\\n --cacert $vca_cacert \\\n --lxd-cloud lxd-cloud \\\n --lxd-credentials lxd-cloud \\\n --k8s-cloud microk8s \\\n --k8s-credentials microk8s\\\n $hostname-vca"
+ track deploy_osm deploy_vca_only_ok
else
deploy_charmed_osm
+ track deploy_osm deploy_osm_services_k8s_ok
install_osmclient
+ track osmclient osmclient_ok
export OSM_HOSTNAME=$(juju config -m $MODEL_NAME nbi site_url | sed "s/http.*\?:\/\///"):443
export OSM_PASSWORD=$keystone_admin_password
sleep 10
add_local_k8scluster
+ track final_ops add_local_k8scluster_ok
if [ -v MICROSTACK ]; then
install_microstack
+ track final_ops install_microstack_ok
fi
echo "Your installation is now complete, follow these steps for configuring the osmclient:"
echo "3. Login OSM GUI by using admin password: $OSM_PASSWORD"
echo
echo "DONE"
+ track end
fi
# Uninstall if "--uninstall"
if [ -n "$UNINSTALL" ]; then
if [ -n "$CHARMED" ]; then
- track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none
${OSM_DEVOPS}/installers/charmed_uninstall.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" || \
FATAL_TRACK charmed_uninstall "charmed_uninstall.sh failed"
else
# Charmed installation
if [ -n "$CHARMED" ]; then
- ${OSM_DEVOPS}/installers/charmed_install.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" || \
+ export OSM_TRACK_INSTALLATION_ID="$(date +%s)-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)"
+ track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none
+ ${OSM_DEVOPS}/installers/charmed_install.sh --tag $OSM_DOCKER_TAG "$@" || \
FATAL_TRACK charmed_install "charmed_install.sh failed"
+ wget -q -O- https://osm-download.etsi.org/ftp/osm-11.0-eleven/README2.txt &> /dev/null
+ track end installation_type $OSM_INSTALLATION_TYPE
echo -e "\nDONE"
exit 0
fi