+ server_id = get_value('id', output)
+
+ if (server_id == null) {
+ println("VM launch output: ")
+ println(output)
+ throw new Exception("VM Launch failed")
+ }
+ println("Target VM is ${server_id}, waiting for IP address to be assigned")
+
+ IP_ADDRESS = ""
+
+ while (IP_ADDRESS == "") {
+ output=sh(returnStdout: true, script: """#!/bin/sh -e
+ for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
+ openstack server show ${server_id}
+ """).trim()
+ IP_ADDRESS = get_value('addresses', output)
+ }
+ IP_ADDRESS = IP_ADDRESS.split('=')[1]
+ println("Waiting for VM at ${IP_ADDRESS} to be reachable")
+
+ alive = false
+ while (! alive) {
+ output=sh(returnStdout: true, script: "sleep 1 ; nc -zv ${IP_ADDRESS} 22 2>&1 || true").trim()
+ println("output is [$output]")
+ alive = output.contains("succeeded")
+ }
+ println("VM is ready and accepting ssh connections")
+ }
+
+ stage("Install") {
+ commit_id = ''
+ repo_distro = ''
+ repo_key_name = ''
+ release = ''
+
+ if ( params.COMMIT_ID )
+ {
+ commit_id = "-b ${params.COMMIT_ID}"
+ }
+
+ if ( params.REPO_DISTRO )
+ {
+ repo_distro = "-r ${params.REPO_DISTRO}"
+ }
+
+ if ( params.REPO_KEY_NAME )
+ {
+ repo_key_name = "-k ${params.REPO_KEY_NAME}"
+ }
+
+ if ( params.RELEASE )
+ {
+ release = "-R ${params.RELEASE}"
+ }
+
+ if ( params.REPOSITORY_BASE )
+ {
+ repo_base_url = "-u ${params.REPOSITORY_BASE}"
+ }
+ else
+ {
+ repo_base_url = "-u http://${NODE_IP_ADDRESS}:${repo_port}"
+ }
+
+ remote.name = container_name
+ remote.host = IP_ADDRESS
+ remote.user = 'ubuntu'
+ remote.identityFile = SSH_KEY
+ remote.allowAnyHosts = true
+ remote.logLevel = 'INFO'
+
+ sshCommand remote: remote, command: """
+ wget https://osm-download.etsi.org/ftp/osm-8.0-eight/install_osm.sh
+ chmod +x ./install_osm.sh
+ """
+
+ if ( useCharmedInstaller ) {
+
+ // Use local proxy for docker hub
+ sshCommand remote: remote, command: '''
+ sudo snap install microk8s --classic
+ sudo sed -i "s|https://registry-1.docker.io|http://172.21.1.1:5000|" /var/snap/microk8s/current/args/containerd-template.toml
+ sudo systemctl restart snap.microk8s.daemon-containerd.service
+ sudo snap alias microk8s.kubectl kubectl
+ echo export PATH=/snap/bin:\${PATH} > ~/.bashrc
+ '''
+
+ withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
+ usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
+ sshCommand remote: remote, command: """
+ ./install_osm.sh -y \
+ ${repo_base_url} \
+ ${repo_key_name} \
+ ${release} -r unstable \
+ --charmed \
+ --registry ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
+ --tag ${container_name}
+ """
+ }
+ prometheusHostname = "prometheus."+IP_ADDRESS+".xip.io"
+ prometheusPort = 80
+ osmHostname = "nbi."+IP_ADDRESS+".xip.io:443"
+ } else {
+ // Run -k8s installer here
+ // Update to use 172.21.1.1 as the dockerhub proxy
+ // Specify registry to use for installer
+ // set osmHostname, prometheusHostname, prometheusPort as needed
+ }
+ }