/**
 * Update mirror image
 *
 * Expected parameters:
 *   SALT_MASTER_CREDENTIALS    Credentials to the Salt API.
 *   SALT_MASTER_URL            Full Salt API address [https://10.10.10.1:8000].
 *
**/

def common = new com.mirantis.mk.Common()
def salt = new com.mirantis.mk.Salt()
def python = new com.mirantis.mk.Python()
def venvPepper = "venvPepper"

node() {
    try {

        python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)

        stage('Update Aptly packages'){
            common.infoMsg("Updating Aptly packages.")
            salt.enforceState(venvPepper, 'apt*', ['aptly'], true)
            salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['/srv/scripts/aptly-update.sh'], null, true)
        }

        stage('Update Docker images'){
            common.infoMsg("Updating Docker images.")
            salt.enforceState(venvPepper, 'apt*', ['docker.client.registry'], true)
        }

        stage('Update PyPi packages'){
            common.infoMsg("Updating PyPi packages.")
            salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['pip2pi /srv/pypi_mirror/packages/ -r /srv/pypi_mirror/requirements.txt'], null, true)
        }

        stage('Update Git repositories'){
            common.infoMsg("Updating Git repositories.")
            salt.enforceState(venvPepper, 'apt*', ['git.server'], true)
        }

        stage('Update VM images'){
            common.infoMsg("Updating VM images.")
            salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['/srv/scripts/update-images.sh'], null, true)
        }

    } 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
    }
}