From 797e0df72ff246b0084ca244deded8fd4972bc6b Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Fri, 28 Jun 2013 16:14:16 +0300 Subject: [PATCH] Pass the Image instance to the os_type classes Those classes may need to access more Image data than the guestfs handler and the root device name --- image_creator/image.py | 2 +- image_creator/os_type/__init__.py | 11 +++++++---- image_creator/os_type/freebsd.py | 2 -- image_creator/os_type/linux.py | 4 ++-- image_creator/os_type/ubuntu.py | 2 -- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/image_creator/image.py b/image_creator/image.py index 86992b6..eca7673 100644 --- a/image_creator/image.py +++ b/image_creator/image.py @@ -118,7 +118,7 @@ class Image(object): self.enable() cls = os_cls(self.distro, self.ostype) - self._os = cls(self.root, self.g, self.out) + self._os = cls(self) self._os.collect_metadata() diff --git a/image_creator/os_type/__init__.py b/image_creator/os_type/__init__.py index ec4f20d..063b410 100644 --- a/image_creator/os_type/__init__.py +++ b/image_creator/os_type/__init__.py @@ -79,10 +79,13 @@ def sysprep(enabled=True): class OSBase(object): """Basic operating system class""" - def __init__(self, rootdev, ghandler, output): - self.root = rootdev - self.g = ghandler - self.out = output + def __init__(self, image): + self.image = image + + self.root = image.root + self.g = image.g + self.out = image.out + self.meta = {} def collect_metadata(self): diff --git a/image_creator/os_type/freebsd.py b/image_creator/os_type/freebsd.py index 02bd8dc..7dc8f43 100644 --- a/image_creator/os_type/freebsd.py +++ b/image_creator/os_type/freebsd.py @@ -42,8 +42,6 @@ import re class Freebsd(Unix): """OS class for FreeBSD Unix-like os""" - def __init__(self, rootdev, ghandler, output): - super(Freebsd, self).__init__(rootdev, ghandler, output) @sysprep() def cleanup_password(self, print_header=True): diff --git a/image_creator/os_type/linux.py b/image_creator/os_type/linux.py index 4724336..a0302d1 100644 --- a/image_creator/os_type/linux.py +++ b/image_creator/os_type/linux.py @@ -43,8 +43,8 @@ import time class Linux(Unix): """OS class for Linux""" - def __init__(self, rootdev, ghandler, output): - super(Linux, self).__init__(rootdev, ghandler, output) + def __init__(self, image): + super(Linux, self).__init__(image) self._uuid = dict() self._persistent = re.compile('/dev/[hsv]d[a-z][1-9]*') diff --git a/image_creator/os_type/ubuntu.py b/image_creator/os_type/ubuntu.py index b5706fc..bd2d6b5 100644 --- a/image_creator/os_type/ubuntu.py +++ b/image_creator/os_type/ubuntu.py @@ -40,8 +40,6 @@ from image_creator.os_type.linux import Linux class Ubuntu(Linux): """OS class for Ubuntu Linux variants""" - def __init__(self, rootdev, ghandler, output): - super(Ubuntu, self).__init__(rootdev, ghandler, output) def _do_collect_metadata(self): """Collect metadata about the OS""" -- 1.7.10.4