Fix typos in var names
[snf-image-creator] / image_creator / os_type / linux.py
index 0cd4b61..de82e7d 100644 (file)
 # interpreted as representing official policies, either expressed
 # or implied, of GRNET S.A.
 
-from image_creator.os_type.unix import Unix
-from image_creator.util import warn
-
-from clint.textui import puts, indent
+from image_creator.os_type.unix import Unix, sysprep
+from image_creator.util import warn, output
 
 import re
 import time
@@ -58,16 +56,17 @@ class Linux(Unix):
                 self._uuid[dev] = attr[1]
                 return attr[1]
 
-    def sysprep_acpid(self, print_header=True):
-        """Replace acpid powerdown action scripts to automatically shutdown
-        the system without checking if a GUI is running.
+    @sysprep()
+    def fix_acpid(self, print_header=True):
+        """Replace acpid powerdown action scripts to immediately shutdown the
+        system without checking if a GUI is running.
         """
 
         if print_header:
-            print 'Fixing acpid powerdown action'
+            output('Fixing acpid powerdown action')
 
         powerbtn_action = '#!/bin/sh\n\nPATH=/sbin:/bin:/usr/bin\n' \
-                                'shutdown -h now \"Power button pressed\"'
+                                'shutdown -h now \"Power button pressed\"\n'
 
         events_dir = '/etc/acpi/events'
         if not self.g.is_dir(events_dir):
@@ -98,40 +97,42 @@ class Linux(Unix):
                     if not self.g.is_file(action):
                         warn("Acpid action file: %s does not exist" % action)
                         return
-                    self.g.copy_file_to_file(fullpath, \
-                      "%s.orig.snf-image-creator-%d" % (fullpath, time.time()))
-                    self.g.write(fullpath, powerbtn_action)
+                    self.g.copy_file_to_file(action, \
+                      "%s.orig.snf-image-creator-%d" % (action, time.time()))
+                    self.g.write(action, powerbtn_action)
                     return
                 else:
                     warn("Acpid event file %s does not contain and action")
                     return
             elif event.strip() == ".*":
                 warn("Found action `.*'. Don't know how to handle this." \
-                    " Please edit \%s' image file manually to make the "
+                    " Please edit \%s' image file manually to make the " \
                     "system immediatelly shutdown when an power button acpi " \
-                    "event occures")
+                    "event occures" % action)
                 return
 
-    def sysprep_persistent_net_rules(self, print_header=True):
+    @sysprep()
+    def persistent_net_rules(self, print_header=True):
         """Remove udev rules that will keep network interface names persistent
         after hardware changes and reboots. Those rules will be created again
         the next time the image runs.
         """
 
         if print_header:
-            puts('Removing persistent network interface names')
+            output('Removing persistent network interface names')
 
         rule_file = '/etc/udev/rules.d/70-persistent-net.rules'
         if self.g.is_file(rule_file):
             self.g.rm(rule_file)
 
-    def sysprep_persistent_devs(self, print_header=True):
-        """Scan fstab and grub configuration files and replace all
-        non-persistent device appearences with UUIDs.
+    @sysprep()
+    def persistent_devs(self, print_header=True):
+        """Scan fstab & grub configuration files and replace all non-persistent
+        device appearences with UUIDs.
         """
 
         if print_header:
-            puts('Replacing fstab & grub non-persistent device appearences')
+            output('Replacing fstab & grub non-persistent device appearences')
 
         # convert all devices in fstab to persistent
         persistent_root = self._persistent_fstab()