Pass the Image instance to the os_type classes
authorNikos Skalkotos <skalkoto@grnet.gr>
Fri, 28 Jun 2013 13:14:16 +0000 (16:14 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Tue, 30 Jul 2013 13:43:58 +0000 (16:43 +0300)
Those classes may need to access more Image data than the guestfs
handler and the root device name

image_creator/image.py
image_creator/os_type/__init__.py
image_creator/os_type/freebsd.py
image_creator/os_type/linux.py
image_creator/os_type/ubuntu.py

index 86992b6..eca7673 100644 (file)
@@ -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()
 
index ec4f20d..063b410 100644 (file)
@@ -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):
index 02bd8dc..7dc8f43 100644 (file)
@@ -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):
index 4724336..a0302d1 100644 (file)
@@ -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]*')
 
index b5706fc..bd2d6b5 100644 (file)
@@ -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"""