projects
/
snf-image-creator
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add image properties help file
[snf-image-creator]
/
image_creator
/
os_type
/
linux.py
diff --git
a/image_creator/os_type/linux.py
b/image_creator/os_type/linux.py
index
e128396
..
7597703
100644
(file)
--- a/
image_creator/os_type/linux.py
+++ b/
image_creator/os_type/linux.py
@@
-32,15
+32,14
@@
# or implied, of GRNET S.A.
from image_creator.os_type.unix import Unix, sysprep
# or implied, of GRNET S.A.
from image_creator.os_type.unix import Unix, sysprep
-from image_creator.util import warn, output
import re
import time
class Linux(Unix):
import re
import time
class Linux(Unix):
- def __init__(self, rootdev, ghandler):
- super(Linux, self).__init__(rootdev, ghandler)
+ def __init__(self, rootdev, ghandler, output):
+ super(Linux, self).__init__(rootdev, ghandler, output)
self._uuid = dict()
self._persistent = re.compile('/dev/[hsv]d[a-z][1-9]*')
self._uuid = dict()
self._persistent = re.compile('/dev/[hsv]d[a-z][1-9]*')
@@
-51,10
+50,10
@@
class Linux(Unix):
if dev in self._uuid:
return self._uuid[dev]
if dev in self._uuid:
return self._uuid[dev]
- for attr in self.g.blkid(dev):
- if attr[0] == 'UUID':
- self._uuid[dev] = attr[1]
- return attr[1]
+ uuid = self.g.vfs_uuid(dev)
+ assert len(uuid)
+ self._uuid[dev] = uuid
+ return uuid
@sysprep()
def fix_acpid(self, print_header=True):
@sysprep()
def fix_acpid(self, print_header=True):
@@
-63,14
+62,14
@@
class Linux(Unix):
"""
if print_header:
"""
if print_header:
- output('Fixing acpid powerdown action')
+ self.out.output('Fixing acpid powerdown action')
powerbtn_action = '#!/bin/sh\n\nPATH=/sbin:/bin:/usr/bin\n' \
'shutdown -h now \"Power button pressed\"\n'
events_dir = '/etc/acpi/events'
if not self.g.is_dir(events_dir):
powerbtn_action = '#!/bin/sh\n\nPATH=/sbin:/bin:/usr/bin\n' \
'shutdown -h now \"Power button pressed\"\n'
events_dir = '/etc/acpi/events'
if not self.g.is_dir(events_dir):
- warn("No acpid event directory found")
+ self.out.warn("No acpid event directory found")
return
event_exp = re.compile('event=(.+)', re.I)
return
event_exp = re.compile('event=(.+)', re.I)
@@
-95,31
+94,34
@@
class Linux(Unix):
if event.strip() == "button[ /]power":
if action:
if not self.g.is_file(action):
if event.strip() == "button[ /]power":
if action:
if not self.g.is_file(action):
- warn("Acpid action file: %s does not exist" % action)
+ self.out.warn("Acpid action file: %s does not exist" %
+ action)
return
self.g.copy_file_to_file(action, \
"%s.orig.snf-image-creator-%d" % (action, time.time()))
self.g.write(action, powerbtn_action)
return
else:
return
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")
+ self.out.warn(
+ "Acpid event file %s does not contain and action")
return
elif event.strip() == ".*":
return
elif event.strip() == ".*":
- warn("Found action `.*'. Don't know how to handle this." \
- " Please edit \%s' image file manually to make the " \
+ self.out.warn(
+ "Found action `.*'. Don't know how to handle this. " \
+ "Please edit `%s' image file manually to make the " \
"system immediatelly shutdown when an power button acpi " \
"system immediatelly shutdown when an power button acpi " \
- "event occures" % action)
+ "event occures." % action.strip().split()[0])
return
@sysprep()
return
@sysprep()
- def persistent_net_rules(self, print_header=True):
+ def remove_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:
"""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:
- output('Removing persistent network interface names')
+ self.out.output('Removing persistent network interface names')
rule_file = '/etc/udev/rules.d/70-persistent-net.rules'
if self.g.is_file(rule_file):
rule_file = '/etc/udev/rules.d/70-persistent-net.rules'
if self.g.is_file(rule_file):
@@
-134,7
+136,7
@@
class Linux(Unix):
"""
if print_header:
"""
if print_header:
- output('Removing swap entry from fstab')
+ self.out.output('Removing swap entry from fstab')
new_fstab = ""
fstab = self.g.cat('/etc/fstab')
new_fstab = ""
fstab = self.g.cat('/etc/fstab')
@@
-149,13
+151,14
@@
class Linux(Unix):
self.g.write('/etc/fstab', new_fstab)
@sysprep()
self.g.write('/etc/fstab', new_fstab)
@sysprep()
- def persistent_devs(self, print_header=True):
+ def use_persistent_block_device_names(self, print_header=True):
"""Scan fstab & grub configuration files and replace all non-persistent
device appearences with UUIDs.
"""
if print_header:
"""Scan fstab & grub configuration files and replace all non-persistent
device appearences with UUIDs.
"""
if print_header:
- output('Replacing fstab & grub non-persistent device appearences')
+ self.out.output(
+ 'Replacing fstab & grub non-persistent device appearences')
# convert all devices in fstab to persistent
persistent_root = self._persistent_fstab()
# convert all devices in fstab to persistent
persistent_root = self._persistent_fstab()
@@
-217,7
+220,7
@@
class Linux(Unix):
entry = line.split()
if len(entry) != 6:
entry = line.split()
if len(entry) != 6:
- warn("Detected abnormal entry in fstab")
+ self.out.warn("Detected abnormal entry in fstab")
return orig, "", ""
dev = entry[0]
return orig, "", ""
dev = entry[0]