Revision e77e66a9 image_creator/os_type/linux.py

b/image_creator/os_type/linux.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from image_creator.os_type.unix import Unix, sysprep
35
from image_creator.util import warn, output
36 35

  
37 36
import re
38 37
import time
39 38

  
40 39

  
41 40
class Linux(Unix):
42
    def __init__(self, rootdev, ghandler):
43
        super(Linux, self).__init__(rootdev, ghandler)
41
    def __init__(self, rootdev, ghandler, output):
42
        super(Linux, self).__init__(rootdev, ghandler, output)
44 43
        self._uuid = dict()
45 44
        self._persistent = re.compile('/dev/[hsv]d[a-z][1-9]*')
46 45

  
......
63 62
        """
64 63

  
65 64
        if print_header:
66
            output('Fixing acpid powerdown action')
65
            self.out.output('Fixing acpid powerdown action')
67 66

  
68 67
        powerbtn_action = '#!/bin/sh\n\nPATH=/sbin:/bin:/usr/bin\n' \
69 68
                                'shutdown -h now \"Power button pressed\"\n'
70 69

  
71 70
        events_dir = '/etc/acpi/events'
72 71
        if not self.g.is_dir(events_dir):
73
            warn("No acpid event directory found")
72
            self.out.warn("No acpid event directory found")
74 73
            return
75 74

  
76 75
        event_exp = re.compile('event=(.+)', re.I)
......
95 94
            if event.strip() == "button[ /]power":
96 95
                if action:
97 96
                    if not self.g.is_file(action):
98
                        warn("Acpid action file: %s does not exist" % action)
97
                        self.out.warn("Acpid action file: %s does not exist" %
98
                                                                        action)
99 99
                        return
100 100
                    self.g.copy_file_to_file(action, \
101 101
                      "%s.orig.snf-image-creator-%d" % (action, time.time()))
102 102
                    self.g.write(action, powerbtn_action)
103 103
                    return
104 104
                else:
105
                    warn("Acpid event file %s does not contain and action")
105
                    self.out.warn(
106
                            "Acpid event file %s does not contain and action")
106 107
                    return
107 108
            elif event.strip() == ".*":
108
                warn("Found action `.*'. Don't know how to handle this." \
109
                    " Please edit \%s' image file manually to make the " \
109
                self.out.warn(
110
                    "Found action `.*'. Don't know how to handle this. " \
111
                    "Please edit \%s' image file manually to make the " \
110 112
                    "system immediatelly shutdown when an power button acpi " \
111 113
                    "event occures" % action)
112 114
                return
......
119 121
        """
120 122

  
121 123
        if print_header:
122
            output('Removing persistent network interface names')
124
            self.out.output('Removing persistent network interface names')
123 125

  
124 126
        rule_file = '/etc/udev/rules.d/70-persistent-net.rules'
125 127
        if self.g.is_file(rule_file):
......
134 136
        """
135 137

  
136 138
        if print_header:
137
            output('Removing swap entry from fstab')
139
            self.out.output('Removing swap entry from fstab')
138 140

  
139 141
        new_fstab = ""
140 142
        fstab = self.g.cat('/etc/fstab')
......
155 157
        """
156 158

  
157 159
        if print_header:
158
            output('Replacing fstab & grub non-persistent device appearences')
160
            self.out.output(
161
                    'Replacing fstab & grub non-persistent device appearences')
159 162

  
160 163
        # convert all devices in fstab to persistent
161 164
        persistent_root = self._persistent_fstab()
......
217 220

  
218 221
        entry = line.split()
219 222
        if len(entry) != 6:
220
            warn("Detected abnormal entry in fstab")
223
            self.out.warn("Detected abnormal entry in fstab")
221 224
            return orig, "", ""
222 225

  
223 226
        dev = entry[0]

Also available in: Unified diff