Merge "Update k8s tools"
diff --git a/jjb/cord-test/att-workflow.yaml b/jjb/cord-test/att-workflow.yaml
index 2cd21aa..cc009d2 100644
--- a/jjb/cord-test/att-workflow.yaml
+++ b/jjb/cord-test/att-workflow.yaml
@@ -14,9 +14,9 @@
          config-pod: 'onlab-pod1'
          profile: 'att-workflow'
          branch: 'master'
-         scenario: ''
-         Jenkinsfile: 'Jenkinsfile-att-workflow'
+         Jenkinsfile: 'Jenkinsfile-attworkflow-build'
          oltDebVersion: 'openolt-master.deb'
+         configurePod: true
 
     # flex pod1 with olt/onu
       - 'build_pod_manual':
@@ -24,6 +24,6 @@
          config-pod: 'flex-pod1-olt'
          profile: 'att-workflow'
          branch: 'master'
-         scenario: ''
-         Jenkinsfile: 'Jenkinsfile-attworkflow'
+         Jenkinsfile: 'Jenkinsfile-attworkflow-build'
          oltDebVersion: 'openolt-master.deb'
+         configurePod: true
diff --git a/jjb/cord-test/nightly-build-pipeline.yaml b/jjb/cord-test/nightly-build-pipeline.yaml
index 5918318..949c741 100644
--- a/jjb/cord-test/nightly-build-pipeline.yaml
+++ b/jjb/cord-test/nightly-build-pipeline.yaml
@@ -15,7 +15,7 @@
 
 
 - job-template:
-    name: 'build_{profile}_{testvm}_{scenario}_{branch}'
+    name: 'build_{profile}_{config-pod}_{branch}'
     id: build_pod_manual
     description: |
                   <!-- Managed by Jenkins Job Builder -->
@@ -53,6 +53,11 @@
          description: 'The kubernetes config folder'
 
       - string:
+         name: configToscaDir
+         default: 'tosca-configs'
+         description: 'The tosca config folder'
+
+      - string:
          name: configFileName
          default: '{config-pod}'
          description: 'The config file'
@@ -67,6 +72,16 @@
          default: '{branch}'
 
       - string:
+         name: profile
+         default: '{profile}'
+         description: 'Profile in which this job installs'
+
+      - bool:
+          name: configurePod
+          default: true
+          description: "Configure POD via TOSCA post build"
+
+      - string:
          name: notificationEmail
          default: 'kailash@opennetworking.org, you@opennetworking.org, suchitra@opennetworking.org'
          description: ''
@@ -82,7 +97,7 @@
              - '{branch}'
 
 - job-template:
-    name: 'build_{profile}_{config-pod}_{scenario}_{branch}'
+    name: 'build_{profile}_{config-pod}_{branch}'
     id: build_pod_timer
     description: |
                   <!-- Managed by Jenkins Job Builder -->
@@ -120,6 +135,11 @@
          description: 'The kubernetes config folder'
 
       - string:
+         name: configToscaDir
+         default: 'tosca-configs'
+         description: 'The tosca config folder'
+
+      - string:
          name: configFileName
          default: '{config-pod}'
          description: 'The config file'
@@ -134,6 +154,88 @@
          default: '{branch}'
 
       - string:
+         name: profile
+         default: '{profile}'
+         description: 'Profile in which this job installs'
+
+      - bool:
+          name: configurePod
+          default: true
+          description: "Configure POD via TOSCA post build"
+
+      - string:
+         name: notificationEmail
+         default: 'kailash@opennetworking.org, you@opennetworking.org, suchitra@opennetworking.org'
+         description: ''
+
+    concurrent: true
+
+    pipeline-scm:
+      script-path: '{Jenkinsfile}'
+      scm:
+        - git:
+           url: '{gerrit-server-url}/cord-tester'
+           branches:
+             - '{branch}'
+
+    triggers:
+       - timed: |
+                 TZ=America/Los_Angeles
+                 H {time} {day} * *
+
+- job-template:
+    name: 'build_{profile}_{config-pod}_{branch}_test'
+    id: build_pod_test
+    description: |
+                  <!-- Managed by Jenkins Job Builder -->
+                  Post Tests on {config-pod} triggered by build_{config-pod}_{branch} <br /><br />
+                  Created from job-template {id} from ci-management/jjb/cord-test/cord-test-pipeline.yaml <br />
+                  Created by Kailash Khalasi - kailash@opennetworking.org <br />
+                  Copyright (c) 2017 Open Networking Foundation (ONF)
+
+    <<: *test-pipe-job-boiler-plate
+
+    parameters:
+      - string:
+         name: TestNodeName
+         default: '{testvm}'
+         description: 'Jenkins node name of TestVM Node'
+
+      - string:
+         name: cordRepoUrl
+         default: '{gerrit-server-url}'
+         description: 'The URL of the CORD Project repository'
+
+      - string:
+         name: configBaseDir
+         default: 'pod-configs'
+         description: 'The directory inside the POD configs repository'
+
+      - string:
+         name: configDeploymentDir
+         default: 'deployment-configs'
+         description: 'The deployment configs folder'
+
+      - string:
+         name: configKubernetesDir
+         default: 'kubernetes-configs'
+         description: 'The kubernetes config folder'
+
+      - string:
+         name: configToscaDir
+         default: 'tosca-configs'
+         description: 'The tosca config folder'
+
+      - string:
+         name: configFileName
+         default: '{config-pod}'
+         description: 'The config file'
+
+      - string:
+         name: branch
+         default: '{branch}'
+
+      - string:
          name: notificationEmail
          default: 'kailash@opennetworking.org, you@opennetworking.org, suchitra@opennetworking.org'
          description: ''
@@ -149,6 +251,6 @@
              - '{branch}'
 
     triggers:
-       - timed: |
-                 TZ=America/Los_Angeles
-                 H {time} {day} * *
+      - reverse:
+          jobs: 'build_{profile}_{config-pod}_{branch}'
+          result: 'success'
diff --git a/jjb/cord-test/rcord-lite.yaml b/jjb/cord-test/rcord-lite.yaml
index b10b1ba..1f22b11 100644
--- a/jjb/cord-test/rcord-lite.yaml
+++ b/jjb/cord-test/rcord-lite.yaml
@@ -10,26 +10,24 @@
 
     jobs:
       # flex onf pod 1 kubernetes build jobs (rcord lite)
-      - 'build_pod_timer':
+      - 'build_pod_manual':
          testvm: 'qa-testvm-pod'
          config-pod: 'flex-onf-pod1'
-         profile: 'rcord-lite'
-         scenario: ''
+         profile: 'rcord-topdown'
          branch: 'master'
-         Jenkinsfile: 'Jenkinsfile-rcordlite'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown-build'
          oltDebVersion: 'openolt-1.4.deb'
-         time: '20'
-         day: '0-31/1'
+         configurePod: true
 
      # flex pod1 with olt/onu  kubernetes build jobs (rcord lite)
       - 'build_pod_timer':
          testvm: 'qa-testvm-pod'
          config-pod: 'flex-pod1-olt'
-         profile: 'rcord-lite'
+         profile: 'rcord-zerotouch'
          branch: 'cord-6.0'
-         scenario: 'zerotouch'
-         Jenkinsfile: 'Jenkinsfile-rcordlite-zerotouch'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-zerotouch-build'
          oltDebVersion: 'openolt-1.4.deb'
+         configurePod: true
          time: '0'
          day: '1-31/2'
 
@@ -37,11 +35,11 @@
       - 'build_pod_timer':
          testvm: 'qa-testvm-pod'
          config-pod: 'flex-pod1-olt'
-         profile: 'rcord-lite'
+         profile: 'rcord-topdown'
          branch: 'cord-6.0'
-         scenario: 'topdown'
-         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown-build'
          oltDebVersion: 'openolt-1.4.deb'
+         configurePod: true
          time: '0'
          day: '2-30/2'
 
@@ -49,11 +47,11 @@
       - 'build_pod_timer':
          testvm: 'qa-testvm-pod'
          config-pod: 'flex-pod1-olt'
-         profile: 'rcord-lite'
+         profile: 'rcord-zerotouch'
          branch: 'master'
-         scenario: 'zerotouch'
-         Jenkinsfile: 'Jenkinsfile-rcordlite-zerotouch'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-zerotouch-build'
          oltDebVersion: 'openolt-master'
+         configurePod: true
          time: '1'
          day: '1-31/2'
 
@@ -61,35 +59,40 @@
       - 'build_pod_timer':
          testvm: 'qa-testvm-pod'
          config-pod: 'flex-pod1-olt'
-         profile: 'rcord-lite'
+         profile: 'rcord-topdown'
          branch: 'master'
-         scenario: 'topdown'
-         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown'
-         oltDebVersion: 'openolt-master'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown-build'
+         oltDebVersion: 'openolt-master.deb'
+         configurePod: true
          time: '1'
          day: '2-30/2'
 
-     # qct pod1 kubernetes build jobs (rcord lite)
+     # qct pod1 kubernetes build jobs (rcord lite topdown)
       - 'build_pod_timer':
          testvm: 'qct-pod1'
          config-pod: 'qct-pod1'
-         profile: 'rcord-lite'
+         profile: 'rcord-topdown'
          branch: 'master'
-         scenario: ''
-         Jenkinsfile: 'Jenkinsfile-rcordlite'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown-build'
          oltDebVersion: 'openolt-1.4.deb'
+         configurePod: true
          time: '0'
          day: '*'
 
+     # qct pod1 test jobs (rcord lite topdown)
+      - 'build_pod_test':
+         testvm: 'qct-pod1'
+         config-pod: 'qct-pod1'
+         profile: 'rcord-topdown'
+         branch: 'master'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown-test'
+
      # flex ocp pod 2 kubernetes build jobs (rcord lite)
-      - 'build_pod_timer':
+      - 'build_pod_manual':
          testvm: 'flex-pod2'
          config-pod: 'flex-ocp-pod2'
-         profile: 'rcord-lite'
-         scenario: ''
+         profile: 'rcord-topdown'
          branch: 'master'
-         Jenkinsfile: 'Jenkinsfile-rcordlite'
+         Jenkinsfile: 'Jenkinsfile-rcordlite-topdown-build'
          oltDebVersion: 'openolt-1.4.deb'
-         time: '30'
-         day: '0-31/1'
-
+         configurePod: true
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index 3ab54c1..1447fc3 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -67,6 +67,9 @@
     # for matching repos that build docker images with imagebuilder
     imagebuilder-projects-regexp: '^(xos.*|cord-tester|chameleon|rcord|mcord|ecord|acordion|addressmanager|epc-service|exampleservice|fabric|fabric-crossconnect|globalxos|hippie-oss|hss_db|hypercache|internetemulator|kubernetes-service|monitoring|olt-service|onos-service|openstack|progran|sdn-controller|simpleexampleservice|templateservice|vEE|vEG|vBBU|venb|vHSS|vMME|vnaas|vPGWC|vPGWU|vrouter|vsg|vsg-hw|vSGW|vSM|vspgwc|vspgwu|vtn-service|vtr)$'
 
+    # strictness of version checks
+    semver-strict: 0
+
     # matching repos that should be version tagged by the version-tag job
     # (basically the same as imagebuilder projects + helm charts + tools
     version-tag-projects-regexp: '^(xos.*|helm-charts|automation-tools|cord-tester|chameleon|rcord|mcord|ecord|acordion|addressmanager|epc-service|exampleservice|fabric|fabric-crossconnect|globalxos|hippie-oss|hss_db|hypercache|internetemulator|kubernetes-service|monitoring|olt-service|onos-service|openstack|progran|sdn-controller|simpleexampleservice|templateservice|vEE|vEG|vBBU|venb|vHSS|vMME|vnaas|vPGWC|vPGWU|vrouter|vsg|vsg-hw|vSGW|vSM|vspgwc|vspgwu|vtn-service|vtr)$'
diff --git a/jjb/pipeline/all-xos-api-test-helm.groovy b/jjb/pipeline/all-xos-api-test-helm.groovy
index bc83a81..73e9dd7 100644
--- a/jjb/pipeline/all-xos-api-test-helm.groovy
+++ b/jjb/pipeline/all-xos-api-test-helm.groovy
@@ -109,6 +109,44 @@
       }
     }
 
+    stage('tag update') {
+      steps {
+        sh """
+           #!/usr/bin/env bash
+           set -eu -o pipefail
+
+           # skip projects that aren't the XOS core repository
+           if [ "${gerrit_project}" != "xos" ]; then
+             exit 0
+           fi
+
+           echo "" > \${WORKSPACE}/updated_dockerfiles
+           XOS_MAJOR=\$(cut -b 1 cord/orchestration/xos/VERSION)
+           XOS_VERSION=\$(cat cord/orchestration/xos/VERSION)
+
+           # update services
+           for df in cord/orchestration/xos_services/*/Dockerfile.synchronizer cord/orchestration/profiles/*/Dockerfile.synchronizer
+           do
+             df_contents=\$(cat "\$df")
+             if [[ "\$df_contents" =~ "FROM xosproject/xos-synchronizer-base:\${XOS_MAJOR}" ||
+                   "\$df_contents" =~ "FROM xosproject/xos-synchronizer-base:master" ]]
+             then
+               sed -i "s/^FROM\\(.*\\):.*\$/FROM\\1:\$XOS_VERSION/" "\$df"
+               echo "\${WORKSPACE}/\$df" >> \${WORKSPACE}/updated_dockerfiles
+             fi
+           done
+
+           # create values file with core version tags
+           # not indented because heredoc requires it
+           cat << EOF > \${WORKSPACE}/xos_tags.yaml
+---
+xos_coreImage: 'xosproject/xos-core:\${XOS_VERSION}'
+xos_chameleonImage: 'xosproject/chameleon:\${XOS_VERSION}'
+xos_toscaImage: 'xosproject/xos-tosca:\${XOS_VERSION}'
+EOF
+           """
+      }
+    }
 
     stage('prep') {
       parallel {
@@ -170,6 +208,11 @@
 
            helm_install_args='-f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml'
 
+           # skip projects that aren't the XOS core repository
+           if [ "${gerrit_project}" != "xos" ]; then
+             helm_install_args+=' -f $WORKSPACE/xos_tags.yaml'
+           fi
+
            pushd cord/helm-charts
 
            helm dep up xos-core
diff --git a/jjb/pipeline/xos-synchronizer-update.groovy b/jjb/pipeline/xos-synchronizer-update.groovy
index d2cdfda..a4c715e 100644
--- a/jjb/pipeline/xos-synchronizer-update.groovy
+++ b/jjb/pipeline/xos-synchronizer-update.groovy
@@ -12,8 +12,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// Run XOS api tests after changing the containers to use the `candidate`
-// parent, which may include synchronizer changes
+// Run XOS api tests after changing the containers to use the current XOS
+// container versions as parent, which may include synchronizer framework
+// changes
 
 CORE_CONTAINER="null"
 
@@ -109,22 +110,36 @@
       }
     }
 
-    stage('candiate tag') {
+    stage('tag update') {
       steps {
         sh """
+           #!/usr/bin/env bash
+           set -eu -o pipefail
+
            echo "" > \${WORKSPACE}/updated_dockerfiles
            XOS_MAJOR=\$(cut -b 1 cord/orchestration/xos/VERSION)
+           XOS_VERSION=\$(cat cord/orchestration/xos/VERSION)
 
+           # update services
            for df in cord/orchestration/xos_services/*/Dockerfile.synchronizer cord/orchestration/profiles/*/Dockerfile.synchronizer
            do
              df_contents=\$(cat "\$df")
              if [[ "\$df_contents" =~ "FROM xosproject/xos-synchronizer-base:\${XOS_MAJOR}" ||
                    "\$df_contents" =~ "FROM xosproject/xos-synchronizer-base:master" ]]
              then
-               sed -i "s/^FROM\\(.*\\):.*\$/FROM\\1:candidate/" "\$df"
+               sed -i "s/^FROM\\(.*\\):.*\$/FROM\\1:\$XOS_VERSION/" "\$df"
                echo "\${WORKSPACE}/\$df" >> \${WORKSPACE}/updated_dockerfiles
              fi
            done
+
+           # create values file with core version tags
+           # not indented because heredoc requires it
+           cat << EOF > \${WORKSPACE}/xos_tags.yaml
+---
+xos_coreImage: 'xosproject/xos-core:\${XOS_VERSION}'
+xos_chameleonImage: 'xosproject/chameleon:\${XOS_VERSION}'
+xos_toscaImage: 'xosproject/xos-tosca:\${XOS_VERSION}'
+EOF
            """
       }
     }
@@ -218,7 +233,7 @@
            #!/usr/bin/env bash
            set -eu -o pipefail
 
-           helm_install_args='-f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml'
+           helm_install_args='-f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml -f $WORKSPACE/xos_tags.yaml'
 
            pushd cord/helm-charts
 
diff --git a/jjb/shell/tagcollisionreject.sh b/jjb/shell/tagcollisionreject.sh
index 86fe317..09c014c 100755
--- a/jjb/shell/tagcollisionreject.sh
+++ b/jjb/shell/tagcollisionreject.sh
@@ -22,6 +22,8 @@
 VERSIONFILE="" # file path to file containing version number
 NEW_VERSION="" # version number found in $VERSIONFILE
 
+SEMVER_STRICT=${SEMVER_STRICT:-0} # require semver versions
+
 releaseversion=0
 fail_validation=0
 
@@ -64,7 +66,13 @@
     echo "Version string '$NEW_VERSION' found in '$VERSIONFILE' is a SemVer released version!"
     releaseversion=1
   else
-    echo "Version string '$NEW_VERSION' found in '$VERSIONFILE' is not a SemVer released version, skipping."
+    if [ "$SEMVER_STRICT" -eq "1" ]
+    then
+      echo "Version string '$NEW_VERSION' in '$VERSIONFILE' is not a SemVer released version, SEMVER_STRICT enabled, failing!"
+      fail_validation=1
+    else
+      echo "Version string '$NEW_VERSION' in '$VERSIONFILE' is not a SemVer released version, skipping."
+    fi
   fi
 }
 
diff --git a/jjb/shell/versiontag.sh b/jjb/shell/versiontag.sh
index 4287914..60042d8 100755
--- a/jjb/shell/versiontag.sh
+++ b/jjb/shell/versiontag.sh
@@ -23,6 +23,8 @@
 VERSIONFILE="" # file path to file containing version number
 NEW_VERSION="" # version number found in $VERSIONFILE
 
+SEMVER_STRICT=${SEMVER_STRICT:-0} # require semver versions
+
 releaseversion=0
 fail_validation=0
 
@@ -53,7 +55,13 @@
     echo "Version string '$NEW_VERSION' in '$VERSIONFILE' is a SemVer released version!"
     releaseversion=1
   else
-    echo "Version string '$NEW_VERSION' in '$VERSIONFILE' is not a SemVer released version, skipping."
+    if [ "$SEMVER_STRICT" -eq "1" ]
+    then
+      echo "Version string '$NEW_VERSION' in '$VERSIONFILE' is not a SemVer released version, SEMVER_STRICT enabled, failing!"
+      fail_validation=1
+    else
+      echo "Version string '$NEW_VERSION' in '$VERSIONFILE' is not a SemVer released version, skipping."
+    fi
   fi
 }
 
diff --git a/jjb/verify/xos.yaml b/jjb/verify/xos.yaml
index fdf135b..4a474b6 100644
--- a/jjb/verify/xos.yaml
+++ b/jjb/verify/xos.yaml
@@ -8,6 +8,7 @@
     jobs:
       - 'verify-xos-jobs':
           branch-regexp: '{supported-branches-regexp}'
+          semver-strict: 1
 
 - job-group:
     name: 'verify-xos-jobs'
diff --git a/jjb/versioning.yaml b/jjb/versioning.yaml
index 420b13f..16e810b 100644
--- a/jjb/versioning.yaml
+++ b/jjb/versioning.yaml
@@ -67,6 +67,9 @@
     concurrent: true
 
     builders:
+      - inject:
+          properties-content:
+            SEMVER_STRICT={semver-strict}
       - shell: !include-raw-escape: shell/tagcollisionreject.sh
 
 
@@ -110,5 +113,8 @@
     concurrent: true
 
     builders:
+      - inject:
+          properties-content:
+            SEMVER_STRICT={semver-strict}
       - shell: !include-raw-escape: shell/versiontag.sh