Add pre-upgrade verify pipeline
Move pre-upgrade checks to pipeline-library
PROD-36632
Change-Id: Ib5c0e17641ae94c1bdb1148f47c760a2bab0cad4
diff --git a/pre-upgrade-verify.groovy b/pre-upgrade-verify.groovy
new file mode 100644
index 0000000..d4e8e3b
--- /dev/null
+++ b/pre-upgrade-verify.groovy
@@ -0,0 +1,58 @@
+salt = new com.mirantis.mk.Salt()
+python = new com.mirantis.mk.Python()
+common = new com.mirantis.mk.Common()
+venvPepper = "venvPepper"
+upgradeChecks = new com.mirantis.mcp.UpgradeChecks()
+
+reportDir = 'reportDir/'
+waList =['check_34406', 'check_34645', 'check_35705', 'check_35884', 'check_36461', 'check_36461_2']
+
+timeout(time: PIPELINE_TIMEOUT, unit: 'HOURS') {
+ node('python') {
+ try {
+ python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+ def clusterName = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0]
+ def reportContent = ""
+ stage('Start checking work-arounds') {
+ for (wa in waList) {
+ //false - return status of check, true - raise exception
+ def waData = upgradeChecks."$wa"(salt, venvPepper, clusterName, false)
+ def reportTemplate = """
+ <tr>
+ <td class='row'>${waData.prodId}</td>
+ <td class='row'>${waData.isFixed}</td>
+ <td class='row'>${waData.waInfo}</td>
+ </tr>"""
+ reportContent = "${reportContent}${reportTemplate}"
+ }
+ }
+ stage('Generate report') {
+ sh "rm -rf ${reportDir}"
+ sh "mkdir -p ${reportDir}"
+ def reportHead = """<html>
+ <head>
+ <title>WA verify report</title>
+ </head>
+ <body>
+ <h1>WA verify report</h1>
+ <table border='1' cellpadding='5' cellspacing='0' style='border-collapse:collapse'>
+ <tr>
+ <th class='row'>Prod id</th>
+ <th class='row'>Status</th>
+ <th class='row'>Doc link</th>
+ </tr>"""
+ def reportTail = """
+ </table>
+ </body>
+</html>"""
+ writeFile file: "${reportDir}report.html", text: "${reportHead}${reportContent}${reportTail}"
+ archiveArtifacts artifacts: "${reportDir}/*"
+ }
+ } catch (Throwable e) {
+ // If there was an error or exception thrown, the build failed
+ currentBuild.result = "FAILURE"
+ currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
+ throw e
+ }
+ }
+}