allow host name resolution for for voltha-api and etcd ingress

* the default virtual hostnames exposed by the voltha-api and etcd
  ingresses are 'voltha.voltha.local' and 'voltha-infra.local' for our
  setups
* to allow connections to those ingress endpoints from the host where
  the k8s cluster itself is running on, we can just create /etc/hosts
  entries to resolve those hostnames to localhost (aka set them as
  aliases for 127.0.0.1)
* add new method 'setHostEntries' to installVoltctl script to add those
  entries in the same context of installing voltctl itself (since they
  are solely used for voltctl atm)

Also include an extra change in jjb/ to trigger jenkins job in vars/.

Signed-off-by: Jan Klare <jan.klare@bisdn.de>
Change-Id: If96531af478b828c2140bbbfe34cdb6b224af7f0
Signed-off-by: Jan Klare <jan.klare@bisdn.de>
diff --git a/jjb/pipeline/voltha/physical-build.groovy b/jjb/pipeline/voltha/physical-build.groovy
index 17d48b3..9dfb588 100755
--- a/jjb/pipeline/voltha/physical-build.groovy
+++ b/jjb/pipeline/voltha/physical-build.groovy
@@ -16,6 +16,7 @@
 
 // NOTE we are importing the library even if it's global so that it's
 // easier to change the keywords during a replay
+
 library identifier: 'cord-jenkins-libraries@master',
     retriever: modernSCM([
       $class: 'GitSCMSource',
diff --git a/vars/installVoltctl.groovy b/vars/installVoltctl.groovy
index 14057b9..c5c48c2 100644
--- a/vars/installVoltctl.groovy
+++ b/vars/installVoltctl.groovy
@@ -47,6 +47,31 @@
 }
 
 // -----------------------------------------------------------------------
+// Intent: Add host entries to /etc/hosts to allow resolving the virtual hosts
+// used to expose the voltha api (voltha.voltha.local) and etcd
+// (voltha-infra.local) inside of k8s via ingress to localhost
+// -----------------------------------------------------------------------
+void setHostEntries() {
+    enter('setHostEntries')
+
+    sh(
+       label  : 'setHostEntries',
+       script: """#!/usr/bin/env bash
+for hostname in voltha.voltha.local voltha-infra.local; do
+  if grep \$hostname /etc/hosts; then
+    echo "host entry for \$hostname already exists"
+  else
+    echo "adding host entry for \$hostname"
+    sed -i "s/127.0.0.1 localhost/& \$hostname/" /etc/hosts
+  fi
+done
+""")
+
+    leave('setHostEntries')
+    return
+}
+
+// -----------------------------------------------------------------------
 // -----------------------------------------------------------------------
 Boolean process(String branch) {
     Boolean ans = true
@@ -165,6 +190,7 @@
 def call(String branch) {
     try {
         enter('main')
+        setHostEntries()
         process(branch)
     }
     catch (Exception err) {  // groovylint-disable-line CatchException