Merge "Remove logs from Salt Bootstrap"
diff --git a/day01-image/scripts/cleanup_day01.sh b/day01-image/scripts/cleanup_day01.sh
index 89cd6e7..b12cbb6 100644
--- a/day01-image/scripts/cleanup_day01.sh
+++ b/day01-image/scripts/cleanup_day01.sh
@@ -2,7 +2,7 @@
# stop and disable services, for healthy zerodisk
# They should be enabled after cfg01 init
-stop_services="postgresql.service salt-api salt-master salt-minion jenkins maas-rackd.service maas-regiond.service bind9"
+stop_services="postgresql.service salt-api salt-master salt-minion jenkins maas-rackd.service maas-regiond.service maas-dhcpd.service maas-dhcpd6.service bind9"
for s in ${stop_services} ; do
systemctl stop ${s} || true
systemctl disable ${s} || true
diff --git a/packer-image-buid.groovy b/packer-image-buid.groovy
index 87ef652..8d6c2c5 100644
--- a/packer-image-buid.groovy
+++ b/packer-image-buid.groovy
@@ -30,7 +30,7 @@
* OS_URL = Keystone auth endpoint of the OpenStack.
* OS_PROJECT =
*
- * PUBLISH_BACKEND = local|glance|http
+ * PUBLISH_BACKEND = local,glance,http
* UPLOAD_URL = URL of an WebDAV used to upload the image after creating.(Only in case PUBLISH_BACKEND == http)
*/
@@ -61,6 +61,7 @@
job_env['CLEANUP_AFTER'] = job_env.CLEANUP_AFTER.toBoolean()
job_env['BUILD_ONLY'] = job_env.BUILD_ONLY.toLowerCase()
job_env['PUBLISH_BACKEND'] = job_env.PUBLISH_BACKEND.toLowerCase()
+publishBackends = job_env['PUBLISH_BACKEND'].split(',')
//
defaultGitRef = job_env.get('REFSPEC', 'HEAD')
defaultGitUrl = job_env.get('DEFAULT_GIT_URL', null)
@@ -89,11 +90,9 @@
timeout(time: 6, unit: 'HOURS') {
node(slaveNode) {
def workspace = common.getWorkspace()
+ def openstackEnv = "${workspace}/venv"
+ def rcFile = ''
creds = common.getPasswordCredentials(job_env.CREDENTIALS_ID)
- if (job_env.BUILD_ONLY == 'openstack' || job_env.PUBLISH_BACKEND == 'glance') {
- rcFile = openstack.createOpenstackEnv(workspace, os_openrc.OS_AUTH_URL, job_env.OS_TENANT_ID, job_env.OS_TENANT_NAME, "default", "", "default", "2", "")
- def openstackEnv = "${workspace}/venv"
- }
stage("checkout") {
if (defaultGitRef && defaultGitUrl) {
@@ -103,6 +102,10 @@
}
}
+ if (job_env.BUILD_ONLY == 'openstack' || 'glance' in publishBackends) {
+ rcFile = openstack.createOpenstackEnv(workspace, os_openrc['OS_AUTH_URL'], os_openrc['OS_CREDENTIALS_ID'], os_openrc['OS_PROJECT_NAME'], "default", "", "default", "3", "")
+ }
+
try {
def _artifact_dir = "${workspace}/artifacts"
def _artifact_list = []
@@ -261,13 +264,14 @@
stage("Publish artifacts") {
dir(_artifact_dir) {
+ def published = false
common.infoMsg("Processing md5 for artifacts")
for (String x : _artifact_list) {
_md5 = sh(script: "md5sum ${x} > ${x}.md5; cat ${x}.md5", returnStdout: true).trim()
_size = sh(script: "ls -alh ${x}", returnStdout: true).trim()
common.infoMsg("Artifact file: ${_size}\n${_md5}")
}
- if (job_env.PUBLISH_BACKEND == 'local') {
+ if ('local' in publishBackends) {
common.infoMsg("Uploading to: local")
common.infoMsg("For local publish target - nothing to do, all files in: ${_artifact_dir}")
if (job_env.get('CLEANUP_AFTER', false)) {
@@ -275,30 +279,30 @@
common.warningMsg("Disabling CLEANUP_AFTER option, to save you'r data ;) ")
job_env.CLEANUP_AFTER = false
}
- } else if (job_env.PUBLISH_BACKEND == 'glance') {
+ published = true
+ }
+ if ('glance' in publishBackends) {
common.infoMsg("Uploading to: glance-openstack")
if (fileExists("${workspace}/venv")) {
common.infoMsg("cleaning virtualenv at:${workspace}/venv")
sh(script: "rm -rf ${workspace}/venv", returnStatus: true)
}
- openstack.setupOpenstackVirtualenv(openstackEnv, job_env.OS_VERSION)
+ openstack.setupOpenstackVirtualenv(openstackEnv)
for (String x : findFiles(glob: "*.*")) {
- if (x.endsWith('.md5')) {
- common.warningMsg("Skipping:${x} from openstack upload!")
- _md5sum = sh(script: "cat ${x}", returnStdout: true).trim().split()[0]
- continue
+ if (x.getName().endsWith('.qcow2')) {
+ _md5sum = sh(script: "cat ${x}.md5", returnStdout: true).trim().split()[0]
+ _property = "--property data=${dateTime} --property md5sum=${_md5sum} --property build='${env.BUILD_URL}' --container-format bare --disk-format qcow2"
+ _cmdline = String.format("glance image-create --visibility " +
+ "public %s --name '%s' --file %s", _property, imageName, x)
+ openstack.runOpenstackCommand(_cmdline, rcFile, openstackEnv)
}
- _property = "--property data=${dateTime} --property md5sum=${_md5sum}"
- _cmdline = String.format("glance image-create --visibility " +
- "public %s --name '%s' %s --file %s", _property, imageShortName, glanceRunArgs, imageName)
- openstack.runOpenstackCommand(_cmdline, rcFile, openstackEnv)
}
- // TODO
- currentBuild.description = "${imageName}.qcow2 uploaded tenant: "
-
- } else if (job_env.PUBLISH_BACKEND == 'http') {
+ currentBuild.description = "${imageName}.qcow2 uploaded tenant: ${job_env['OS_PROJECT_NAME']}"
+ published = true
+ }
+ if ('http' in publishBackends) {
for (String u_file : findFiles(glob: '*.*')) {
- common.infoMsg("Uploading image ${imageName}")
+ common.infoMsg("Uploading image ${u_file}")
def uploadImageStatus = ''
common.retry(3, 5) {
uploadImageStatus = sh(script: "curl -f -T ${u_file} ${job_env.UPLOAD_URL}", returnStatus: true)
@@ -309,9 +313,10 @@
// Fixme for correct path ?
currentBuild.description = "<a href='http://images.mcp.mirantis.net/${imageName}.qcow2'>${imageName}.qcow2</a>"
}
-
- } else {
- throw new Exception("Unsupported publish backend:${job_env.PUBLISH_BACKEND}")
+ published = true
+ }
+ if (! published) {
+ throw new Exception("Unsupported publish backend: ${publishBackends}")
}
}