mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
PEP8-ify things.
This commit is contained in:
parent
e1fc5ea972
commit
b5c5acf5b1
12 changed files with 38 additions and 27 deletions
12
CONTRIBUTING.md
Normal file
12
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Coding standards #
|
||||
* Specify the full path when invoking a command.
|
||||
* Use long options whenever possible, this makes the commands invoked a lot easier to understand.
|
||||
* Use tabs for indentation and spaces for alignment.
|
||||
* Max line length is 110 chars.
|
||||
* Multiple assignments may be aligned.
|
||||
* Follow PEP8 with the exception of the following rules
|
||||
* E101: Indenting with tabs and aligning with spaces
|
||||
* E221: Alignment of assignments
|
||||
* E241: Alignment of assignments
|
||||
* E501: The line length is 110 characters not 80
|
||||
* W191: We indent with tabs not spaces
|
|
@ -5,4 +5,4 @@ class BootstrapInformation(object):
|
|||
self.manifest = manifest
|
||||
self.debug = debug
|
||||
import random
|
||||
self.run_id = random.randrange(16**8)
|
||||
self.run_id = random.randrange(16 ** 8)
|
||||
|
|
|
@ -44,7 +44,7 @@ class TaskList(object):
|
|||
successors = []
|
||||
successors.extend([self.get(succ) for succ in task.before])
|
||||
successors.extend(filter(lambda succ: type(task) in succ.after, tasks))
|
||||
succeeding_phases = order[order.index(task.phase)+1:]
|
||||
succeeding_phases = order[order.index(task.phase) + 1:]
|
||||
successors.extend(filter(lambda succ: succ.phase in succeeding_phases, tasks))
|
||||
graph[task] = filter(lambda succ: succ in self.tasks, successors)
|
||||
|
||||
|
|
|
@ -21,6 +21,6 @@ order = [preparation,
|
|||
system_cleaning,
|
||||
volume_unmounting,
|
||||
image_registration,
|
||||
image_conversion,
|
||||
image_conversion,
|
||||
cleaning,
|
||||
]
|
||||
|
|
|
@ -22,8 +22,8 @@ class DisableGetTTYs(Task):
|
|||
from common.tools import sed_i
|
||||
inittab_path = os.path.join(info.root, 'etc/inittab')
|
||||
tty1 = '1:2345:respawn:/sbin/getty 38400 tty1'
|
||||
sed_i(inittab_path, '^'+tty1, '#'+tty1)
|
||||
sed_i(inittab_path, '^' + tty1, '#' + tty1)
|
||||
ttyx = ':23:respawn:/sbin/getty 38400 tty'
|
||||
for i in range(2, 6):
|
||||
i = str(i)
|
||||
sed_i(inittab_path, '^'+i+ttyx+i, '#'+i+ttyx+i)
|
||||
sed_i(inittab_path, '^' + i + ttyx + i, '#' + i + ttyx + i)
|
||||
|
|
|
@ -13,8 +13,8 @@ class Create(Task):
|
|||
import os.path
|
||||
info.loopback_file = os.path.join(info.manifest.volume['loopback_dir'], loopback_filename)
|
||||
log_check_call(['/bin/dd',
|
||||
'if=/dev/zero', 'of='+info.loopback_file,
|
||||
'bs=1M', 'seek='+str(info.manifest.volume['size']), 'count=0'])
|
||||
'if=/dev/zero', 'of=' + info.loopback_file,
|
||||
'bs=1M', 'seek=' + str(info.manifest.volume['size']), 'count=0'])
|
||||
|
||||
|
||||
class CreateQemuImg(Task):
|
||||
|
@ -26,7 +26,7 @@ class CreateQemuImg(Task):
|
|||
import os.path
|
||||
info.loopback_file = os.path.join(info.manifest.volume['loopback_dir'], loopback_filename)
|
||||
log_check_call(['/usr/bin/qemu-img', 'create', '-f', 'raw',
|
||||
info.loopback_file, str(info.manifest.volume['size'])+'M'])
|
||||
info.loopback_file, str(info.manifest.volume['size']) + 'M'])
|
||||
|
||||
|
||||
class Attach(Task):
|
||||
|
|
|
@ -25,7 +25,7 @@ class MapPartitions(Task):
|
|||
after = [PartitionVolume]
|
||||
|
||||
def run(self, info):
|
||||
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
|
||||
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper') + 'p1'
|
||||
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
|
||||
info.bootstrap_device['partitions'] = {'root_path': root_partition_path}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ def log_call(command, stdin=None):
|
|||
|
||||
if stdin is not None:
|
||||
process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
process.stdin.write(stdin+"\n")
|
||||
process.stdin.write(stdin + "\n")
|
||||
process.stdin.flush()
|
||||
process.stdin.close()
|
||||
else:
|
||||
|
|
|
@ -25,7 +25,7 @@ class CreateFromSnapshot(Task):
|
|||
before = [ebs.Attach]
|
||||
|
||||
def run(self, info):
|
||||
volume_size = int(info.manifest.volume['size']/1024)
|
||||
volume_size = int(info.manifest.volume['size'] / 1024)
|
||||
snapshot = info.manifest.plugins['prebootstrapped']['snapshot']
|
||||
info.volume = info.connection.create_volume(volume_size,
|
||||
info.host['availabilityZone'],
|
||||
|
|
|
@ -9,4 +9,4 @@ class SetRootPassword(Task):
|
|||
def run(self, info):
|
||||
from common.tools import log_check_call
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/chpasswd'],
|
||||
'root:'+info.manifest.plugins['root_password']['password'])
|
||||
'root:' + info.manifest.plugins['root_password']['password'])
|
||||
|
|
|
@ -25,7 +25,7 @@ class Attach(Task):
|
|||
def run(self, info):
|
||||
def char_range(c1, c2):
|
||||
"""Generates the characters from `c1` to `c2`, inclusive."""
|
||||
for c in xrange(ord(c1), ord(c2)+1):
|
||||
for c in xrange(ord(c1), ord(c2) + 1):
|
||||
yield chr(c)
|
||||
|
||||
import os.path
|
||||
|
|
|
@ -8,10 +8,9 @@ class ConfigureGrub(Task):
|
|||
|
||||
def run(self, info):
|
||||
import stat
|
||||
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
||||
stat.S_IRGRP | stat.S_IXGRP |
|
||||
stat.S_IROTH | stat.S_IXOTH)
|
||||
x_all = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
||||
stat.S_IRGRP | stat.S_IXGRP |
|
||||
stat.S_IROTH | stat.S_IXOTH)
|
||||
import os.path
|
||||
device_map_path = os.path.join(info.root, 'boot/grub/device.map')
|
||||
with open(device_map_path, 'w') as device_map:
|
||||
|
@ -20,16 +19,16 @@ class ConfigureGrub(Task):
|
|||
from common.tools import log_check_call
|
||||
|
||||
from shutil import copy
|
||||
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/10_linux'))
|
||||
script_dst = os.path.join(info.root, 'etc/grub.d/10_linux')
|
||||
copy(script_src, script_dst)
|
||||
os.chmod(script_dst, rwxr_xr_x)
|
||||
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/00_header'))
|
||||
script_dst = os.path.join(info.root, 'etc/grub.d/00_header')
|
||||
copy(script_src, script_dst)
|
||||
os.chmod(script_dst, rwxr_xr_x)
|
||||
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/10_linux'))
|
||||
script_dst = os.path.join(info.root, 'etc/grub.d/10_linux')
|
||||
copy(script_src, script_dst)
|
||||
os.chmod(script_dst, rwxr_xr_x)
|
||||
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/00_header'))
|
||||
script_dst = os.path.join(info.root, 'etc/grub.d/00_header')
|
||||
copy(script_src, script_dst)
|
||||
os.chmod(script_dst, rwxr_xr_x)
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-initramfs', '-u'])
|
||||
# Install grub in mbr
|
||||
log_check_call(['/usr/sbin/grub-install', '--boot-directory='+info.root+"/boot/", info.bootstrap_device['path']])
|
||||
|
||||
log_check_call(['/usr/sbin/grub-install', '--boot-directory=' + info.root + "/boot/",
|
||||
info.bootstrap_device['path']])
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
||||
|
|
Loading…
Add table
Reference in a new issue