X-Git-Url: https://code.grnet.gr/git/snf-image-creator/blobdiff_plain/c408053fabcc04a53440b0a2d602b89d7d22f1b1..fc54978ecb94d0803d88485477dee7ffea567a8f:/image_creator/os_type/__init__.py diff --git a/image_creator/os_type/__init__.py b/image_creator/os_type/__init__.py index 5fd00ab..b9fd4e0 100644 --- a/image_creator/os_type/__init__.py +++ b/image_creator/os_type/__init__.py @@ -1,6 +1,38 @@ -#!/usr/bin/env python +# Copyright 2012 GRNET S.A. All rights reserved. +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the following +# conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and +# documentation are those of the authors and should not be +# interpreted as representing official policies, either expressed +# or implied, of GRNET S.A. import re +from clint.textui import indent, puts def add_prefix(target): @@ -74,12 +106,40 @@ class OSBase(object): meta['ROOT_PARTITION'] = "%d" % self.g.part_to_partnum(self.root) meta['OSFAMILY'] = self.g.inspect_get_type(self.root) meta['OS'] = self.g.inspect_get_distro(self.root) - meta['description'] = self.g.inspect_get_product_name(self.root) + meta['DESCRIPTION'] = self.g.inspect_get_product_name(self.root) return meta def data_cleanup(self): """Cleanup sensitive data out of the OS image.""" - raise NotImplementedError + + puts('Cleaning up sensitive data out of the OS image:') + + is_cleanup = lambda x: x.startswith('data_cleanup_') and \ + callable(getattr(self, x)) + tasks = [getattr(self, x) for x in dir(self) if is_cleanup(x)] + size = len(tasks) + cnt = 0 + for task in tasks: + cnt += 1 + puts(('(%d/%d)' % (cnt, size)).ljust(7), False) + task() + puts() + + def sysprep(self): + """Prepere system for image creation.""" + + puts('Preparing system for image creation:') + + is_sysprep = lambda x: x.startswith('sysprep_') and \ + callable(getattr(self, x)) + tasks = [getattr(self, x) for x in dir(self) if is_sysprep(x)] + size = len(tasks) + cnt = 0 + for task in tasks: + cnt += 1 + puts(('(%d/%d)' % (cnt, size)).ljust(7), False) + task() + puts() # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :