From ce30568d12a1fd1856b73d1fcb7e6bef93060a1f Mon Sep 17 00:00:00 2001 From: Jeff Lane Date: Tue, 20 Dec 2016 14:00:19 -0500 Subject: Update MAAS version check to validate that version used is at least 2.0 LP: #1651555 --- bin/maas-version-check | 33 +++++++++++++++++++++++++++++++++ jobs/miscellanea.txt.in | 10 ++-------- 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100755 bin/maas-version-check diff --git a/bin/maas-version-check b/bin/maas-version-check new file mode 100755 index 0000000..412717d --- /dev/null +++ b/bin/maas-version-check @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright (C) 2012-2015 Canonical Ltd. + +# Authors +# Jeff Lane + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, +# as published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +MAAS_FILE="/etc/installed-by-maas" +MIN_VERSION="2.0" + +# Is the file there? +if [ -s $MAAS_FILE ]; then + maas_version=`cat $MAAS_FILE` + echo $maas_version +else + echo "ERROR: This system does not appear to have been installed by MAAS" + exit 1 +fi + +#is the version appropriate +exit `dpkg --compare-versions $maas_version "ge" $MIN_VERSION` diff --git a/jobs/miscellanea.txt.in b/jobs/miscellanea.txt.in index e018be5..80ccf02 100644 --- a/jobs/miscellanea.txt.in +++ b/jobs/miscellanea.txt.in @@ -289,15 +289,9 @@ plugin: shell category_id: 2013.com.canonical.plainbox::miscellanea estimated_duration: 0.1 id: miscellanea/get_maas_version -command: - if [ -s /etc/installed-by-maas ]; then - cat /etc/installed-by-maas - else - echo "MAAS VERSION NOT FOUND" >&2 - false - fi +command: maas-version-check _description: If system was installed via MAAS from a cert server, the MAAS version used should be contained in /etc/installed-by-maas -_summary: Attach MAAS version used to deploy the SUT +_summary: Verify MAAS version used to deploy the SUT plugin: shell category_id: 2013.com.canonical.plainbox::miscellanea -- cgit v1.2.3