From cc059a443b1dbcd214075dcaf95d601e47ca655f Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 10 Jun 2014 17:18:37 +0000 Subject: Check for presence of btrfs before trying to use it If btrfs is not present in the kernel we end up with strange output like this: Error creating disk image2014-06-10 16:00:40 [devel-system-x86_64-generic][my-raw-disk-image][rawdisk.write]Failure to create disk image at /src/tmp/testdev.img ERROR: Command failed: mount -o loop /src/tmp/testdev.img /src/tmp/deployments/tmpQ7wXO1/tmp4lVDcu/tmpvHSzDE mount: mounting /dev/loop0 on /src/tmp/deployments/tmpQ7wXO1/tmp4lVDcu/tmpvHSzDE failed: Device or resource busy To avoid this confusing error, Morph should explicitly check first. --- rawdisk.check | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 rawdisk.check (limited to 'rawdisk.check') diff --git a/rawdisk.check b/rawdisk.check new file mode 100755 index 00000000..6a656ee7 --- /dev/null +++ b/rawdisk.check @@ -0,0 +1,31 @@ +#!/usr/bin/python +# Copyright (C) 2014 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +'''Preparatory checks for Morph 'rawdisk' write extension''' + +import cliapp + +import morphlib.writeexts + + +class RawdiskCheckExtension(morphlib.writeexts.WriteExtension): + def process_args(self, args): + if len(args) != 1: + raise cliapp.AppException('Wrong number of command line args') + + self.require_btrfs_in_deployment_host_kernel() + +RawdiskCheckExtension().run() -- cgit v1.2.1 From 59d03b0ae4d1643bba0f0b2b83e85b7068092819 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 19 Aug 2014 15:05:05 +0000 Subject: deploy: Check correct usage of --upgrade for rawdisk deployments This avoids confusion when the user expected to be doing an initial deployment and wasn't aware that a file with the same name as the target already existed. Previously rawdisk.write would try to mount the file and upgrade it. Now we require the user to pass '--upgrade' when they intend to upgrade, as with other deployment extensions. --- rawdisk.check | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'rawdisk.check') diff --git a/rawdisk.check b/rawdisk.check index 6a656ee7..5e75abe2 100755 --- a/rawdisk.check +++ b/rawdisk.check @@ -20,6 +20,8 @@ import cliapp import morphlib.writeexts +import os + class RawdiskCheckExtension(morphlib.writeexts.WriteExtension): def process_args(self, args): @@ -28,4 +30,23 @@ class RawdiskCheckExtension(morphlib.writeexts.WriteExtension): self.require_btrfs_in_deployment_host_kernel() + location = args[0] + upgrade = self.get_environment_boolean('UPGRADE') + if upgrade: + if not os.path.isfile(location): + raise cliapp.AppException( + 'Cannot upgrade %s: it is not an existing disk image' % + location) + + version_label = os.environ.get('VERSION_LABEL') + if version_label is None: + raise cliapp.AppException( + 'VERSION_LABEL was not given. It is required when ' + 'upgrading an existing system.') + else: + if os.path.exists(location): + raise cliapp.AppException( + 'Target %s already exists. Pass --upgrade if you want to ' + 'update an existing image.' % location) + RawdiskCheckExtension().run() -- cgit v1.2.1 From 8c4f5dd9adce099693c53d14c1a549d5b4fa88d1 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 29 Aug 2014 23:18:45 +0100 Subject: Add `morph upgrade` command, deprecate `morph deploy --upgrade` The arguments to `morph deploy` can get quite long, any way we can make it shorter and clearer is useful. We can also avoid having the strange --no-upgrade flag in future. --- rawdisk.check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rawdisk.check') diff --git a/rawdisk.check b/rawdisk.check index 5e75abe2..acdc4de1 100755 --- a/rawdisk.check +++ b/rawdisk.check @@ -46,7 +46,7 @@ class RawdiskCheckExtension(morphlib.writeexts.WriteExtension): else: if os.path.exists(location): raise cliapp.AppException( - 'Target %s already exists. Pass --upgrade if you want to ' - 'update an existing image.' % location) + 'Target %s already exists. Use `morph upgrade` if you ' + 'want to update an existing image.' % location) RawdiskCheckExtension().run() -- cgit v1.2.1 From b80fb87d383b74cf2827443ae24a3a304bdb0fc8 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 19 Nov 2014 17:19:40 +0000 Subject: Update rawdisk.check to support device deployments --- rawdisk.check | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'rawdisk.check') diff --git a/rawdisk.check b/rawdisk.check index acdc4de1..094adb72 100755 --- a/rawdisk.check +++ b/rawdisk.check @@ -33,10 +33,11 @@ class RawdiskCheckExtension(morphlib.writeexts.WriteExtension): location = args[0] upgrade = self.get_environment_boolean('UPGRADE') if upgrade: - if not os.path.isfile(location): - raise cliapp.AppException( - 'Cannot upgrade %s: it is not an existing disk image' % - location) + if not self.is_device(location): + if not os.path.isfile(location): + raise cliapp.AppException( + 'Cannot upgrade %s: it is not an existing disk image' % + location) version_label = os.environ.get('VERSION_LABEL') if version_label is None: @@ -44,9 +45,10 @@ class RawdiskCheckExtension(morphlib.writeexts.WriteExtension): 'VERSION_LABEL was not given. It is required when ' 'upgrading an existing system.') else: - if os.path.exists(location): - raise cliapp.AppException( - 'Target %s already exists. Use `morph upgrade` if you ' - 'want to update an existing image.' % location) + if not self.is_device(location): + if os.path.exists(location): + raise cliapp.AppException( + 'Target %s already exists. Use `morph upgrade` if you ' + 'want to update an existing image.' % location) RawdiskCheckExtension().run() -- cgit v1.2.1 From ed741d8d090086e2380f7b9d68ddc3bd122acb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 13 Mar 2015 18:18:55 +0000 Subject: Use the modern way of the GPL copyright header: URL instead real address Change-Id: I992dc0c1d40f563ade56a833162d409b02be90a0 --- rawdisk.check | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'rawdisk.check') diff --git a/rawdisk.check b/rawdisk.check index 094adb72..9be0ce91 100755 --- a/rawdisk.check +++ b/rawdisk.check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'rawdisk' write extension''' -- cgit v1.2.1