From ce7ea2923f1dc8c8fbd5600f14e356ffed99072b Mon Sep 17 00:00:00 2001 From: Mark Doffman Date: Tue, 14 Apr 2015 20:23:30 +0000 Subject: Add strata, systems and cluster morpologies for google compute engine. Add the ability to create baserock images compatible with google compute engine. Add an example cluster morphology that does this. --- google-compute-engine.write | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 google-compute-engine.write (limited to 'google-compute-engine.write') diff --git a/google-compute-engine.write b/google-compute-engine.write new file mode 100755 index 00000000..a3226416 --- /dev/null +++ b/google-compute-engine.write @@ -0,0 +1,64 @@ +#!/usr/bin/python +# Copyright (C) 2012-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 +# 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, see . + + +'''A Morph deployment write extension for compressed raw disk images + that are compatible with google compute engine.''' + + +import cliapp +import os +import sys +import time +import tempfile +import shutil + +import morphlib.writeexts + +from subprocess import call + +class GoogleComputeEngineWriteExtension(morphlib.writeexts.WriteExtension): + + def process_args(self, args): + if len(args) != 2: + raise cliapp.AppException('Wrong number of command line args') + + DISK_NAME = 'disk.raw' + + temp_root, location = args + + try: + temp_dir = tempfile.mkdtemp() + disk_location = os.path.join(temp_dir, DISK_NAME) + + with self.created_disk_image(disk_location): + self.format_btrfs(disk_location) + self.create_system(temp_root, disk_location) + + self.status(msg='Compressing disk image') + call(["tar", '-czf', location, '-C', temp_dir, DISK_NAME]) + + self.status(msg='Compressed disk image has been created at %s' % location) + except Exception: + self.status(msg='Failure to deploy system to %s' % location) + raise + finally: + try: + shutil.rmtree(temp_dir) + except OSError as exc: + if exc.errno != errno.ENOENT: + raise + +GoogleComputeEngineWriteExtension().run() -- cgit v1.2.1