Add job to automatically cleanup old images 47/53247/4
authorThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 13 Mar 2017 20:31:26 +0000 (16:31 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 16 Mar 2017 22:01:23 +0000 (18:01 -0400)
Depends on lftools>=0.0.8. Adds a jjb job to automatically cleanup
non-public images in the Private Cloud and Rackspace Public clouds.

Criteria:

    - Uses the sandbox account and checks only the sandbox tenant
    - Images 30 days or older
    - Non-public images

In ODL we mark images public when we want to allow the community to use
them. These are officially supported images that has passed testing
typically in the sandbox.

Change-Id: Id4ce204393408a087739ea18d1dd9700d346ad30
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/opendaylight-infra-cleanup-old-images.sh [new file with mode: 0644]
jjb/releng-jobs.yaml

diff --git a/jjb/opendaylight-infra-cleanup-old-images.sh b/jjb/opendaylight-infra-cleanup-old-images.sh
new file mode 100644 (file)
index 0000000..129ab13
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+LFTOOLS_DIR="$WORKSPACE/.venv-lftools"
+if [ ! -d "$LFTOOLS_DIR" ]
+then
+    virtualenv "$LFTOOLS_DIR"
+    # shellcheck disable=SC1090
+    source "$LFTOOLS_DIR/bin/activate"
+    pip install --upgrade pip
+    pip install "lftools>=0.0.10"
+    pip freeze
+fi
+# shellcheck disable=SC1090
+source "$LFTOOLS_DIR/bin/activate"
+
+lftools openstack --os-cloud odlpriv-sandbox \
+    image cleanup --hide-public=True \
+                  --days=30 \
+                  --clouds=odlpriv-sandbox,rackspace
index ba0563ebe53bbf01a2884d39150621e03d9ace61..45e3d44c2812d5f57fc394c8dd51212c0b76e026 100644 (file)
@@ -10,6 +10,7 @@
       - 'builder-verify-packer'
       - 'builder-merge-packer-{platforms}-{templates}'
       # OpenStack Related
+      - 'builder-cleanup-old-images'
       - 'builder-delete-stale-stacks'
       # Automation for docs and jobs
       - 'builder-update-csit-tests'
       - opendaylight-infra-shiplogs:
           maven-version: 'mvn33'
 
+- job-template:
+    name: 'builder-cleanup-old-images'
+    project-type: freestyle
+    node: centos7-java-builder-2c-4g
+
+    properties:
+      - opendaylight-infra-properties:
+          build-days-to-keep: 7
+
+    parameters:
+      - opendaylight-infra-parameters:
+          project: '{project}'
+          branch: '{branch}'
+          refspec: 'refs/heads/{branch}'
+          artifacts: '{archive-artifacts}'
+
+    scm:
+      - git-scm:
+          branch: '{branch}'
+
+    wrappers:
+      - opendaylight-infra-wrappers:
+          build-timeout: '{build-timeout}'
+      # Listed after to override openstack-infra-wrappers clouds.yaml definition
+      - config-file-provider:
+          files:
+            - file-id: opendaylight-private-clouds-yaml
+              target: '$HOME/.config/openstack/clouds.yaml'
+
+    triggers:
+      # Cleanup images on a weekly schedule
+      - timed: '@weekly'
+
+    builders:
+      - shell: !include-raw-escape: opendaylight-infra-cleanup-old-images.sh
+
+    publishers:
+      - email-notification:
+          email-recipients: '{email-recipients}'
+          email-prefix: '[releng]'
+      - opendaylight-infra-shiplogs:
+          maven-version: 'mvn33'
+
 - job-template:
     name: 'builder-update-image-list'
     project-type: freestyle