Unify output by creating a seperated output module
[snf-image-creator] / image_creator / os_type / unix.py
index 7eb7f76..06eccbf 100644 (file)
@@ -35,7 +35,6 @@ import re
 import sys
 
 from image_creator.os_type import OSBase, sysprep
-from image_creator.util import warn, output
 
 
 class Unix(OSBase):
@@ -48,8 +47,8 @@ class Unix(OSBase):
         '.thunderbird'
     ]
 
-    def __init__(self, rootdev, ghandler):
-        super(Unix, self).__init__(rootdev, ghandler)
+    def __init__(self, rootdev, ghandler, output):
+        super(Unix, self).__init__(rootdev, ghandler, output)
 
         self.meta["USERS"] = " ".join(self._get_passworded_users())
 
@@ -75,7 +74,8 @@ class Unix(OSBase):
         """Remove all user accounts with id greater than 1000"""
 
         if print_header:
-            output('Removing all user accounts with id greater than 1000')
+            self.out.output(
+                    'Removing all user accounts with id greater than 1000')
 
         # Remove users from /etc/passwd
         passwd = []
@@ -123,7 +123,8 @@ class Unix(OSBase):
         """Remove all passwords and lock all user accounts"""
 
         if print_header:
-            output('Cleaning up passwords & locking all user accounts')
+            self.out.output(
+                    'Cleaning up passwords & locking all user accounts')
 
         shadow = []
 
@@ -141,7 +142,7 @@ class Unix(OSBase):
         """Remove all regular files under /var/cache"""
 
         if print_header:
-            output('Removing files under /var/cache')
+            self.out.output('Removing files under /var/cache')
 
         self.foreach_file('/var/cache', self.g.rm, ftype='r')
 
@@ -150,7 +151,7 @@ class Unix(OSBase):
         """Remove all files under /tmp and /var/tmp"""
 
         if print_header:
-            output('Removing files under /tmp and /var/tmp')
+            self.out.output('Removing files under /tmp and /var/tmp')
 
         self.foreach_file('/tmp', self.g.rm_rf, maxdepth=1)
         self.foreach_file('/var/tmp', self.g.rm_rf, maxdepth=1)
@@ -160,7 +161,7 @@ class Unix(OSBase):
         """Empty all files under /var/log"""
 
         if print_header:
-            output('Emptying all files under /var/log')
+            self.out.output('Emptying all files under /var/log')
 
         self.foreach_file('/var/log', self.g.truncate, ftype='r')
 
@@ -169,7 +170,7 @@ class Unix(OSBase):
         """Remove all files under /var/mail and /var/spool/mail"""
 
         if print_header:
-            output('Removing files under /var/mail and /var/spool/mail')
+            self.out.output('Removing files under /var/mail & /var/spool/mail')
 
         self.foreach_file('/var/spool/mail', self.g.rm_rf, maxdepth=1)
         self.foreach_file('/var/mail', self.g.rm_rf, maxdepth=1)
@@ -181,7 +182,7 @@ class Unix(OSBase):
         homedirs = ['/root'] + self.ls('/home/')
 
         if print_header:
-            output('Removing sensitive user data under %s' % " ".
+            self.out.output('Removing sensitive user data under %s' % " ".
                                                         join(homedirs))
 
         for homedir in homedirs: