Add time check

Related: PROD-26609 (PROD:26609)

Change-Id: I56c5535314bf2cd996cad9f1cb35dcabaf978ec5
diff --git a/galera-cluster-verify-restore.groovy b/galera-cluster-verify-restore.groovy
index 7e5c20b..0e37491 100644
--- a/galera-cluster-verify-restore.groovy
+++ b/galera-cluster-verify-restore.groovy
@@ -5,6 +5,7 @@
  *   SALT_MASTER_CREDENTIALS    Credentials to the Salt API.
  *   SALT_MASTER_URL            Full Salt API address [http://10.10.10.1:8000].
  *   ASK_CONFIRMATION           Ask confirmation for restore
+ *   CHECK_TIME_SYNC            Set to true to check time synchronization accross selected nodes.
  *
 **/
 
@@ -16,6 +17,7 @@
 def resultCode = 99
 
 askConfirmation = (env.getProperty('ASK_CONFIRMATION') ?: true).toBoolean()
+checkTimeSync = (env.getProperty('CHECK_TIME_SYNC') ?: true).toBoolean()
 
 timeout(time: 12, unit: 'HOURS') {
     node() {
@@ -23,11 +25,11 @@
             python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
         }
         stage('Verify status')
-            resultCode = openstack.verifyGaleraStatus(pepperEnv, false)
+            resultCode = openstack.verifyGaleraStatus(pepperEnv, false, checkTimeSync)
         stage('Restore') {
             if (resultCode == 128) {
                 common.errorMsg("Unable to connect to Galera Master. Trying slaves...")
-                resultCode = openstack.verifyGaleraStatus(pepperEnv, true)
+                resultCode = openstack.verifyGaleraStatus(pepperEnv, true, checkTimeSync)
                 if (resultCode == 129) {
                     common.errorMsg("Unable to obtain Galera slave minions list". "Without fixing this issue, pipeline cannot continue in verification and restoration.")
                     currentBuild.result = "FAILURE"
@@ -36,6 +38,10 @@
                     currentBuild.result = "FAILURE"
                 }
             }
+            if (resultCode == 131) {
+                common.errorMsg("Time desynced - Click proceed when the issue is fixed or abort.")
+                currentBuild.result = "FAILURE"
+            }
             if (resultCode == 1) {
                 if(askConfirmation){
                     common.warningMsg("There was a problem with parsing the status output or with determining it. Do you want to run a restore?")
@@ -67,7 +73,7 @@
             }
         }
         stage('Verify restoration result') {
-            exitCode = openstack.verifyGaleraStatus(pepperEnv, false)
+            exitCode = openstack.verifyGaleraStatus(pepperEnv, false, false)
             if (exitCode >= 1) {
                 common.errorMsg("Restoration procedure was probably not successful. See verification report for more information.")
                 currentBuild.result = "FAILURE"