Merge "Add components and packages in promotePublish"
diff --git a/abort-long-running-jobs.groovy b/abort-long-running-jobs.groovy
new file mode 100644
index 0000000..0fb8d9a
--- /dev/null
+++ b/abort-long-running-jobs.groovy
@@ -0,0 +1,29 @@
+/**
+ * Long running jobs killer
+ *
+ *  MAX_DURATION_IN_HOURS - max permitted job duration in hours
+ */
+common = new com.mirantis.mk.Common()
+
+def MAX_ALLOWED_DURATION_IN_SECONDS = 3600 * Interger.parseInt(MAX_DURATION_IN_HOURS)
+
+for (int i=0; i < Jenkins.instance.items.size(); i++) {
+  def job = Jenkins.instance.items[i]
+  def runningBuilds = job.builds.findAll{build -> build.isBuilding()}
+  def jobName = job.name
+  for(int j=0; j < runningBuilds.size(); j++){
+    def build = runningBuilds[j]
+    int durationInSeconds = (System.currentTimeMillis() - build.getTimeInMillis())/1000.0
+    if(durationInSeconds > MAX_ALLOWED_DURATION_IN_SECONDS){
+      common.infoMsg("Aborting ${job.name}-${build.id} takes ${durationInSeconds}s")
+      try{
+        build.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
+      }catch(e){
+        common.errorMsg("Error occured during aborting build: Exception: ${e}")
+      }
+    }
+  }
+}
+
+
+
diff --git a/lab-pipeline.groovy b/lab-pipeline.groovy
index c391e16..00ba743 100644
--- a/lab-pipeline.groovy
+++ b/lab-pipeline.groovy
@@ -316,8 +316,8 @@
 
                     // Install and check nova service
                     //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1)
-                    salt.enforceState(saltMaster, 'I@nova:controller and *01*', 'nova', true)
-                    salt.enforceState(saltMaster, 'I@nova:controller', 'nova', true)
+                    salt.enforceState(saltMaster, 'I@nova:controller and *01*', 'nova.controller', true)
+                    salt.enforceState(saltMaster, 'I@nova:controller', 'nova.controller', true)
                     salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
 
                     // Install and check cinder service
@@ -329,8 +329,8 @@
                     // Install neutron service
                     //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1)
 
-                    salt.enforceState(saltMaster, 'I@neutron:server and *01*', 'neutron', true)
-                    salt.enforceState(saltMaster, 'I@neutron:server', 'neutron', true)
+                    salt.enforceState(saltMaster, 'I@neutron:server and *01*', 'neutron.server', true)
+                    salt.enforceState(saltMaster, 'I@neutron:server', 'neutron.server', true)
                     salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
 
                     // Install heat service
@@ -526,6 +526,13 @@
                 }
             }
 
+            stage('Finalize') {
+                try {
+                    salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
+                } catch (Exception e) {
+                    common.warningMsg('State apply failed but we should continue to run')
+                }
+            }
 
         } catch (Throwable e) {
             currentBuild.result = 'FAILURE'