mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Rely on $PATH to resolve commands. Fixes #12
This commit is contained in:
parent
0ef1d3ab69
commit
851389da09
30 changed files with 98 additions and 98 deletions
|
@ -37,13 +37,13 @@ class AbstractPartitionMap(FSMProxy):
|
||||||
def _before_map(self, event):
|
def _before_map(self, event):
|
||||||
volume = event.volume
|
volume = event.volume
|
||||||
try:
|
try:
|
||||||
mappings = log_check_call(['/sbin/kpartx', '-l', volume.device_path])
|
mappings = log_check_call(['kpartx', '-l', volume.device_path])
|
||||||
import re
|
import re
|
||||||
regexp = re.compile('^(?P<name>.+[^\d](?P<p_idx>\d+)) : '
|
regexp = re.compile('^(?P<name>.+[^\d](?P<p_idx>\d+)) : '
|
||||||
'(?P<start_blk>\d) (?P<num_blks>\d+) '
|
'(?P<start_blk>\d) (?P<num_blks>\d+) '
|
||||||
'{device_path} (?P<blk_offset>\d+)$'
|
'{device_path} (?P<blk_offset>\d+)$'
|
||||||
.format(device_path=volume.device_path))
|
.format(device_path=volume.device_path))
|
||||||
log_check_call(['/sbin/kpartx', '-a', volume.device_path])
|
log_check_call(['kpartx', '-a', volume.device_path])
|
||||||
import os.path
|
import os.path
|
||||||
for mapping in mappings:
|
for mapping in mappings:
|
||||||
match = regexp.match(mapping)
|
match = regexp.match(mapping)
|
||||||
|
@ -61,7 +61,7 @@ class AbstractPartitionMap(FSMProxy):
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
if not partition.fsm.can('unmap'):
|
if not partition.fsm.can('unmap'):
|
||||||
partition.unmap()
|
partition.unmap()
|
||||||
log_check_call(['/sbin/kpartx', '-d', volume.device_path])
|
log_check_call(['kpartx', '-d', volume.device_path])
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def unmap(self, volume):
|
def unmap(self, volume):
|
||||||
|
@ -73,6 +73,6 @@ class AbstractPartitionMap(FSMProxy):
|
||||||
if partition.fsm.cannot('unmap'):
|
if partition.fsm.cannot('unmap'):
|
||||||
msg = 'The partition {partition} prevents the unmap procedure'.format(partition=partition)
|
msg = 'The partition {partition} prevents the unmap procedure'.format(partition=partition)
|
||||||
raise PartitionError(msg)
|
raise PartitionError(msg)
|
||||||
log_check_call(['/sbin/kpartx', '-d', volume.device_path])
|
log_check_call(['kpartx', '-d', volume.device_path])
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
partition.unmap()
|
partition.unmap()
|
||||||
|
|
|
@ -46,7 +46,7 @@ class GPTPartitionMap(AbstractPartitionMap):
|
||||||
|
|
||||||
def _before_create(self, event):
|
def _before_create(self, event):
|
||||||
volume = event.volume
|
volume = event.volume
|
||||||
log_check_call(['/sbin/parted', '--script', '--align', 'none', volume.device_path,
|
log_check_call(['parted', '--script', '--align', 'none', volume.device_path,
|
||||||
'--', 'mklabel', 'gpt'])
|
'--', 'mklabel', 'gpt'])
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
partition.create(volume)
|
partition.create(volume)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class MSDOSPartitionMap(AbstractPartitionMap):
|
||||||
|
|
||||||
def _before_create(self, event):
|
def _before_create(self, event):
|
||||||
volume = event.volume
|
volume = event.volume
|
||||||
log_check_call(['/sbin/parted', '--script', '--align', 'none', volume.device_path,
|
log_check_call(['parted', '--script', '--align', 'none', volume.device_path,
|
||||||
'--', 'mklabel', 'msdos'])
|
'--', 'mklabel', 'msdos'])
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
partition.create(volume)
|
partition.create(volume)
|
||||||
|
|
|
@ -26,14 +26,14 @@ class AbstractPartition(FSMProxy):
|
||||||
if isinstance(self.source, AbstractPartition):
|
if isinstance(self.source, AbstractPartition):
|
||||||
self.source.mount(destination=mount_dir)
|
self.source.mount(destination=mount_dir)
|
||||||
else:
|
else:
|
||||||
log_check_call(['/bin/mount'] + self.opts + [self.source, mount_dir])
|
log_check_call(['mount'] + self.opts + [self.source, mount_dir])
|
||||||
self.mount_dir = mount_dir
|
self.mount_dir = mount_dir
|
||||||
|
|
||||||
def unmount(self):
|
def unmount(self):
|
||||||
if isinstance(self.source, AbstractPartition):
|
if isinstance(self.source, AbstractPartition):
|
||||||
self.source.unmount()
|
self.source.unmount()
|
||||||
else:
|
else:
|
||||||
log_check_call(['/bin/umount', self.mount_dir])
|
log_check_call(['umount', self.mount_dir])
|
||||||
del self.mount_dir
|
del self.mount_dir
|
||||||
|
|
||||||
def __init__(self, size, filesystem, format_command):
|
def __init__(self, size, filesystem, format_command):
|
||||||
|
@ -47,7 +47,7 @@ class AbstractPartition(FSMProxy):
|
||||||
super(AbstractPartition, self).__init__(cfg)
|
super(AbstractPartition, self).__init__(cfg)
|
||||||
|
|
||||||
def get_uuid(self):
|
def get_uuid(self):
|
||||||
[uuid] = log_check_call(['/sbin/blkid', '-s', 'UUID', '-o', 'value', self.device_path])
|
[uuid] = log_check_call(['blkid', '-s', 'UUID', '-o', 'value', self.device_path])
|
||||||
return uuid
|
return uuid
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
@ -59,7 +59,7 @@ class AbstractPartition(FSMProxy):
|
||||||
|
|
||||||
def _before_format(self, e):
|
def _before_format(self, e):
|
||||||
if self.format_command is None:
|
if self.format_command is None:
|
||||||
format_command = ['/sbin/mkfs.{fs}', '{device_path}']
|
format_command = ['mkfs.{fs}', '{device_path}']
|
||||||
else:
|
else:
|
||||||
format_command = self.format_command
|
format_command = self.format_command
|
||||||
variables = {'fs': self.filesystem,
|
variables = {'fs': self.filesystem,
|
||||||
|
@ -70,7 +70,7 @@ class AbstractPartition(FSMProxy):
|
||||||
log_check_call(command)
|
log_check_call(command)
|
||||||
|
|
||||||
def _before_mount(self, e):
|
def _before_mount(self, e):
|
||||||
log_check_call(['/bin/mount', '--types', self.filesystem, self.device_path, e.destination])
|
log_check_call(['mount', '--types', self.filesystem, self.device_path, e.destination])
|
||||||
self.mount_dir = e.destination
|
self.mount_dir = e.destination
|
||||||
|
|
||||||
def _after_mount(self, e):
|
def _after_mount(self, e):
|
||||||
|
@ -80,7 +80,7 @@ class AbstractPartition(FSMProxy):
|
||||||
def _before_unmount(self, e):
|
def _before_unmount(self, e):
|
||||||
for destination in sorted(self.mounts.iterkeys(), key=len, reverse=True):
|
for destination in sorted(self.mounts.iterkeys(), key=len, reverse=True):
|
||||||
self.mounts[destination].unmount()
|
self.mounts[destination].unmount()
|
||||||
log_check_call(['/bin/umount', self.mount_dir])
|
log_check_call(['umount', self.mount_dir])
|
||||||
del self.mount_dir
|
del self.mount_dir
|
||||||
|
|
||||||
def add_mount(self, source, destination, opts=[]):
|
def add_mount(self, source, destination, opts=[]):
|
||||||
|
|
|
@ -44,11 +44,11 @@ class BasePartition(AbstractPartition):
|
||||||
create_command = ('mkpart primary {start} {end}'
|
create_command = ('mkpart primary {start} {end}'
|
||||||
.format(start=str(self.get_start()),
|
.format(start=str(self.get_start()),
|
||||||
end=str(self.get_end())))
|
end=str(self.get_end())))
|
||||||
log_check_call(['/sbin/parted', '--script', '--align', 'none', e.volume.device_path,
|
log_check_call(['parted', '--script', '--align', 'none', e.volume.device_path,
|
||||||
'--', create_command])
|
'--', create_command])
|
||||||
|
|
||||||
for flag in self.flags:
|
for flag in self.flags:
|
||||||
log_check_call(['/sbin/parted', '--script', e.volume.device_path,
|
log_check_call(['parted', '--script', e.volume.device_path,
|
||||||
'--', ('set {idx} {flag} on'
|
'--', ('set {idx} {flag} on'
|
||||||
.format(idx=str(self.get_index()), flag=flag))])
|
.format(idx=str(self.get_index()), flag=flag))])
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,5 @@ class GPTPartition(BasePartition):
|
||||||
name_command = ('name {idx} {name}'
|
name_command = ('name {idx} {name}'
|
||||||
.format(idx=self.get_index(),
|
.format(idx=self.get_index(),
|
||||||
name=self.name))
|
name=self.name))
|
||||||
log_check_call(['/sbin/parted', '--script', e.volume.device_path,
|
log_check_call(['parted', '--script', e.volume.device_path,
|
||||||
'--', name_command])
|
'--', name_command])
|
||||||
|
|
|
@ -8,4 +8,4 @@ class GPTSwapPartition(GPTPartition):
|
||||||
super(GPTSwapPartition, self).__init__(size, 'swap', None, 'swap', previous)
|
super(GPTSwapPartition, self).__init__(size, 'swap', None, 'swap', previous)
|
||||||
|
|
||||||
def _before_format(self, e):
|
def _before_format(self, e):
|
||||||
log_check_call(['/sbin/mkswap', self.device_path])
|
log_check_call(['mkswap', self.device_path])
|
||||||
|
|
|
@ -8,4 +8,4 @@ class MSDOSSwapPartition(MSDOSPartition):
|
||||||
super(MSDOSSwapPartition, self).__init__(size, 'swap', None, previous)
|
super(MSDOSSwapPartition, self).__init__(size, 'swap', None, previous)
|
||||||
|
|
||||||
def _before_format(self, e):
|
def _before_format(self, e):
|
||||||
log_check_call(['/sbin/mkswap', self.device_path])
|
log_check_call(['mkswap', self.device_path])
|
||||||
|
|
|
@ -76,12 +76,12 @@ class Volume(FSMProxy):
|
||||||
if not hasattr(self, 'dm_node_name'):
|
if not hasattr(self, 'dm_node_name'):
|
||||||
raise VolumeError('Unable to find a free block device path for mounting the bootstrap volume')
|
raise VolumeError('Unable to find a free block device path for mounting the bootstrap volume')
|
||||||
|
|
||||||
log_check_call(['/sbin/dmsetup', 'create', self.dm_node_name], table)
|
log_check_call(['dmsetup', 'create', self.dm_node_name], table)
|
||||||
self.unlinked_device_path = self.device_path
|
self.unlinked_device_path = self.device_path
|
||||||
self.device_path = self.dm_node_path
|
self.device_path = self.dm_node_path
|
||||||
|
|
||||||
def _before_unlink_dm_node(self, e):
|
def _before_unlink_dm_node(self, e):
|
||||||
log_check_call(['/sbin/dmsetup', 'remove', self.dm_node_name])
|
log_check_call(['dmsetup', 'remove', self.dm_node_name])
|
||||||
del self.dm_node_name
|
del self.dm_node_name
|
||||||
del self.dm_node_path
|
del self.dm_node_path
|
||||||
self.device_path = self.unlinked_device_path
|
self.device_path = self.unlinked_device_path
|
||||||
|
|
|
@ -12,14 +12,14 @@ class LoopbackVolume(Volume):
|
||||||
def _before_create(self, e):
|
def _before_create(self, e):
|
||||||
self.image_path = e.image_path
|
self.image_path = e.image_path
|
||||||
vol_size = str(self.size.get_qty_in('MiB')) + 'M'
|
vol_size = str(self.size.get_qty_in('MiB')) + 'M'
|
||||||
log_check_call(['/usr/bin/qemu-img', 'create', '-f', 'raw', self.image_path, vol_size])
|
log_check_call(['qemu-img', 'create', '-f', 'raw', self.image_path, vol_size])
|
||||||
|
|
||||||
def _before_attach(self, e):
|
def _before_attach(self, e):
|
||||||
[self.loop_device_path] = log_check_call(['/sbin/losetup', '--show', '--find', self.image_path])
|
[self.loop_device_path] = log_check_call(['losetup', '--show', '--find', self.image_path])
|
||||||
self.device_path = self.loop_device_path
|
self.device_path = self.loop_device_path
|
||||||
|
|
||||||
def _before_detach(self, e):
|
def _before_detach(self, e):
|
||||||
log_check_call(['/sbin/losetup', '--detach', self.loop_device_path])
|
log_check_call(['losetup', '--detach', self.loop_device_path])
|
||||||
del self.loop_device_path
|
del self.loop_device_path
|
||||||
del self.device_path
|
del self.device_path
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class QEMUVolume(LoopbackVolume):
|
||||||
def _before_create(self, e):
|
def _before_create(self, e):
|
||||||
self.image_path = e.image_path
|
self.image_path = e.image_path
|
||||||
vol_size = str(self.size.get_qty_in('MiB')) + 'M'
|
vol_size = str(self.size.get_qty_in('MiB')) + 'M'
|
||||||
log_check_call(['/usr/bin/qemu-img', 'create', '-f', self.qemu_format, self.image_path, vol_size])
|
log_check_call(['qemu-img', 'create', '-f', self.qemu_format, self.image_path, vol_size])
|
||||||
|
|
||||||
def _check_nbd_module(self):
|
def _check_nbd_module(self):
|
||||||
from base.fs.partitionmaps.none import NoPartitions
|
from base.fs.partitionmaps.none import NoPartitions
|
||||||
|
@ -40,11 +40,11 @@ class QEMUVolume(LoopbackVolume):
|
||||||
def _before_attach(self, e):
|
def _before_attach(self, e):
|
||||||
self._check_nbd_module()
|
self._check_nbd_module()
|
||||||
self.loop_device_path = self._find_free_nbd_device()
|
self.loop_device_path = self._find_free_nbd_device()
|
||||||
log_check_call(['/usr/bin/qemu-nbd', '--connect', self.loop_device_path, self.image_path])
|
log_check_call(['qemu-nbd', '--connect', self.loop_device_path, self.image_path])
|
||||||
self.device_path = self.loop_device_path
|
self.device_path = self.loop_device_path
|
||||||
|
|
||||||
def _before_detach(self, e):
|
def _before_detach(self, e):
|
||||||
log_check_call(['/usr/bin/qemu-nbd', '--disconnect', self.loop_device_path])
|
log_check_call(['qemu-nbd', '--disconnect', self.loop_device_path])
|
||||||
del self.loop_device_path
|
del self.loop_device_path
|
||||||
del self.device_path
|
del self.device_path
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,8 @@ class AptUpdate(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/apt-get', 'update'])
|
'apt-get', 'update'])
|
||||||
|
|
||||||
|
|
||||||
class AptUpgrade(Task):
|
class AptUpgrade(Task):
|
||||||
|
@ -100,13 +100,13 @@ class AptUpgrade(Task):
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
try:
|
try:
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/apt-get', 'install',
|
'apt-get', 'install',
|
||||||
'--fix-broken',
|
'--fix-broken',
|
||||||
'--no-install-recommends',
|
'--no-install-recommends',
|
||||||
'--assume-yes'])
|
'--assume-yes'])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/apt-get', 'upgrade',
|
'apt-get', 'upgrade',
|
||||||
'--no-install-recommends',
|
'--no-install-recommends',
|
||||||
'--assume-yes'])
|
'--assume-yes'])
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
|
@ -125,8 +125,8 @@ class PurgeUnusedPackages(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/apt-get', 'autoremove',
|
'apt-get', 'autoremove',
|
||||||
'--purge'])
|
'--purge'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ class AptClean(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/apt-get', 'clean'])
|
'apt-get', 'clean'])
|
||||||
|
|
||||||
lists = os.path.join(info.root, 'var/lib/apt/lists')
|
lists = os.path.join(info.root, 'var/lib/apt/lists')
|
||||||
for list_file in [os.path.join(lists, f) for f in os.listdir(lists)]:
|
for list_file in [os.path.join(lists, f) for f in os.listdir(lists)]:
|
||||||
|
|
|
@ -91,9 +91,9 @@ class InstallGrub(Task):
|
||||||
idx=idx + 1))
|
idx=idx + 1))
|
||||||
|
|
||||||
# Install grub
|
# Install grub
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/sbin/grub-install', device_path])
|
'grub-install', device_path])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
log_check_call(['chroot', info.root, 'update-grub'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(info.volume, LoopbackVolume):
|
if isinstance(info.volume, LoopbackVolume):
|
||||||
remount(info.volume, unlink_fn)
|
remount(info.volume, unlink_fn)
|
||||||
|
@ -127,12 +127,12 @@ class InstallExtLinux(Task):
|
||||||
bootloader = '/usr/lib/syslinux/gptmbr.bin'
|
bootloader = '/usr/lib/syslinux/gptmbr.bin'
|
||||||
else:
|
else:
|
||||||
bootloader = '/usr/lib/extlinux/mbr.bin'
|
bootloader = '/usr/lib/extlinux/mbr.bin'
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/bin/dd', 'bs=440', 'count=1',
|
'dd', 'bs=440', 'count=1',
|
||||||
'if=' + bootloader,
|
'if=' + bootloader,
|
||||||
'of=' + info.volume.device_path])
|
'of=' + info.volume.device_path])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/extlinux',
|
'extlinux',
|
||||||
'--install', '/boot/extlinux'])
|
'--install', '/boot/extlinux'])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/sbin/extlinux-update'])
|
'extlinux-update'])
|
||||||
|
|
|
@ -17,7 +17,7 @@ class AddRequiredCommands(Task):
|
||||||
|
|
||||||
|
|
||||||
def get_bootstrap_args(info):
|
def get_bootstrap_args(info):
|
||||||
executable = ['/usr/sbin/debootstrap']
|
executable = ['debootstrap']
|
||||||
options = ['--arch=' + info.manifest.system['architecture']]
|
options = ['--arch=' + info.manifest.system['architecture']]
|
||||||
if len(info.include_packages) > 0:
|
if len(info.include_packages) > 0:
|
||||||
options.append('--include=' + ','.join(info.include_packages))
|
options.append('--include=' + ','.join(info.include_packages))
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ShredHostkeys(Task):
|
||||||
public = [path + '.pub' for path in private]
|
public = [path + '.pub' for path in private]
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/bin/shred', '--remove'] + private + public)
|
log_check_call(['shred', '--remove'] + private + public)
|
||||||
|
|
||||||
|
|
||||||
class CleanTMP(Task):
|
class CleanTMP(Task):
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TuneVolumeFS(Task):
|
||||||
for partition in info.volume.partition_map.partitions:
|
for partition in info.volume.partition_map.partitions:
|
||||||
if not isinstance(partition, UnformattedPartition):
|
if not isinstance(partition, UnformattedPartition):
|
||||||
if re.match('^ext[2-4]$', partition.filesystem) is not None:
|
if re.match('^ext[2-4]$', partition.filesystem) is not None:
|
||||||
log_check_call(['/sbin/tune2fs', '-i', '0', partition.device_path])
|
log_check_call(['tune2fs', '-i', '0', partition.device_path])
|
||||||
|
|
||||||
|
|
||||||
class AddXFSProgs(Task):
|
class AddXFSProgs(Task):
|
||||||
|
|
|
@ -21,10 +21,10 @@ class InstallInitScripts(Task):
|
||||||
dst = os.path.join(info.root, 'etc/init.d', name)
|
dst = os.path.join(info.root, 'etc/init.d', name)
|
||||||
copy(src, dst)
|
copy(src, dst)
|
||||||
os.chmod(dst, rwxr_xr_x)
|
os.chmod(dst, rwxr_xr_x)
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '--default', name])
|
log_check_call(['chroot', info.root, 'insserv', '--default', name])
|
||||||
|
|
||||||
for name in info.initd['disable']:
|
for name in info.initd['disable']:
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '--remove', name])
|
log_check_call(['chroot', info.root, 'insserv', '--remove', name])
|
||||||
|
|
||||||
|
|
||||||
class AddExpandRoot(Task):
|
class AddExpandRoot(Task):
|
||||||
|
@ -49,8 +49,8 @@ class AddSSHKeyGeneration(Task):
|
||||||
install = info.initd['install']
|
install = info.initd['install']
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
try:
|
try:
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/dpkg-query', '-W', 'openssh-server'])
|
'dpkg-query', '-W', 'openssh-server'])
|
||||||
if info.manifest.system['release'] == 'squeeze':
|
if info.manifest.system['release'] == 'squeeze':
|
||||||
install['generate-ssh-hostkeys'] = os.path.join(init_scripts_dir, 'squeeze/generate-ssh-hostkeys')
|
install['generate-ssh-hostkeys'] = os.path.join(init_scripts_dir, 'squeeze/generate-ssh-hostkeys')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -28,12 +28,12 @@ class GenerateLocale(Task):
|
||||||
search = '# ' + locale_str
|
search = '# ' + locale_str
|
||||||
sed_i(locale_gen, search, locale_str)
|
sed_i(locale_gen, search, locale_str)
|
||||||
|
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/locale-gen'])
|
log_check_call(['chroot', info.root, 'locale-gen'])
|
||||||
|
|
||||||
lang = '{locale}.{charmap}'.format(locale=info.manifest.system['locale'],
|
lang = '{locale}.{charmap}'.format(locale=info.manifest.system['locale'],
|
||||||
charmap=info.manifest.system['charmap'])
|
charmap=info.manifest.system['charmap'])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/sbin/update-locale', 'LANG=' + lang])
|
'update-locale', 'LANG=' + lang])
|
||||||
|
|
||||||
|
|
||||||
class SetTimezone(Task):
|
class SetTimezone(Task):
|
||||||
|
|
|
@ -45,8 +45,8 @@ class InstallPackages(Task):
|
||||||
try:
|
try:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['DEBIAN_FRONTEND'] = 'noninteractive'
|
env['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/apt-get', 'install',
|
'apt-get', 'install',
|
||||||
'--no-install-recommends',
|
'--no-install-recommends',
|
||||||
'--assume-yes']
|
'--assume-yes']
|
||||||
+ map(str, remote_packages),
|
+ map(str, remote_packages),
|
||||||
|
@ -90,8 +90,8 @@ class InstallPackages(Task):
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['DEBIAN_FRONTEND'] = 'noninteractive'
|
env['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/dpkg', '--install']
|
'dpkg', '--install']
|
||||||
+ chrooted_package_paths,
|
+ chrooted_package_paths,
|
||||||
env=env)
|
env=env)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class EnableShadowConfig(Task):
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/shadowconfig', 'on'])
|
log_check_call(['chroot', info.root, 'shadowconfig', 'on'])
|
||||||
|
|
||||||
|
|
||||||
class DisableSSHPasswordAuthentication(Task):
|
class DisableSSHPasswordAuthentication(Task):
|
||||||
|
|
|
@ -22,8 +22,8 @@ class CreateAdminUser(Task):
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/sbin/useradd',
|
'useradd',
|
||||||
'--create-home', '--shell', '/bin/bash',
|
'--create-home', '--shell', '/bin/bash',
|
||||||
info.manifest.plugins['admin_user']['username']])
|
info.manifest.plugins['admin_user']['username']])
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ class DisableRootLogin(Task):
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
try:
|
try:
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/dpkg-query', '-W', 'openssh-server'])
|
'dpkg-query', '-W', 'openssh-server'])
|
||||||
from common.tools import sed_i
|
from common.tools import sed_i
|
||||||
sshdconfig_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
sshdconfig_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
||||||
sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no')
|
sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no')
|
||||||
|
|
|
@ -68,7 +68,7 @@ class SetMetadataSource(Task):
|
||||||
logging.getLogger(__name__).warn(msg)
|
logging.getLogger(__name__).warn(msg)
|
||||||
return
|
return
|
||||||
sources = "cloud-init cloud-init/datasources multiselect " + sources
|
sources = "cloud-init cloud-init/datasources multiselect " + sources
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/debconf-set-selections'], sources)
|
log_check_call(['chroot', info.root, 'debconf-set-selections'], sources)
|
||||||
|
|
||||||
|
|
||||||
class DisableModules(Task):
|
class DisableModules(Task):
|
||||||
|
|
|
@ -27,7 +27,7 @@ class OpenNebulaContext(Task):
|
||||||
sed_i(vmcontext_def, '# Default-Start:', '# Default-Start: 2 3 4 5')
|
sed_i(vmcontext_def, '# Default-Start:', '# Default-Start: 2 3 4 5')
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, 'update-rc.d', 'vmcontext', 'start',
|
log_check_call(['chroot', info.root, 'update-rc.d', 'vmcontext', 'start',
|
||||||
'90', '2', '3', '4', '5', 'stop', '90', '0', '6'])
|
'90', '2', '3', '4', '5', 'stop', '90', '0', '6'])
|
||||||
|
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
|
|
|
@ -84,8 +84,8 @@ class ApplyPuppetManifest(Task):
|
||||||
|
|
||||||
manifest_path = os.path.join('/', manifest_rel_dst)
|
manifest_path = os.path.join('/', manifest_rel_dst)
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/puppet', 'apply', manifest_path])
|
'puppet', 'apply', manifest_path])
|
||||||
os.remove(manifest_dst)
|
os.remove(manifest_dst)
|
||||||
|
|
||||||
from common.tools import sed_i
|
from common.tools import sed_i
|
||||||
|
|
|
@ -9,5 +9,5 @@ class SetRootPassword(Task):
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/chpasswd'],
|
log_check_call(['chroot', info.root, 'chpasswd'],
|
||||||
'root:' + info.manifest.plugins['root_password']['password'])
|
'root:' + info.manifest.plugins['root_password']['password'])
|
||||||
|
|
|
@ -71,8 +71,8 @@ class CreateVagrantUser(Task):
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/sbin/useradd',
|
'useradd',
|
||||||
'--create-home', '--shell', '/bin/bash',
|
'--create-home', '--shell', '/bin/bash',
|
||||||
'vagrant'])
|
'vagrant'])
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ class AddInsecurePublicKey(Task):
|
||||||
|
|
||||||
# We can't do this directly with python, since getpwnam gets its info from the host
|
# We can't do this directly with python, since getpwnam gets its info from the host
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/bin/chown', 'vagrant:vagrant',
|
'chown', 'vagrant:vagrant',
|
||||||
'/home/vagrant/.ssh', '/home/vagrant/.ssh/authorized_keys'])
|
'/home/vagrant/.ssh', '/home/vagrant/.ssh/authorized_keys'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class SetRootPassword(Task):
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/chpasswd'], 'root:vagrant')
|
log_check_call(['chroot', info.root, 'chpasswd'], 'root:vagrant')
|
||||||
|
|
||||||
|
|
||||||
class PackageBox(Task):
|
class PackageBox(Task):
|
||||||
|
|
|
@ -39,7 +39,7 @@ class BundleImage(Task):
|
||||||
bundle_name = 'bundle-{id}'.format(id=info.run_id)
|
bundle_name = 'bundle-{id}'.format(id=info.run_id)
|
||||||
info.bundle_path = os.path.join(info.workspace, bundle_name)
|
info.bundle_path = os.path.join(info.workspace, bundle_name)
|
||||||
arch = {'i386': 'i386', 'amd64': 'x86_64'}.get(info.manifest.system['architecture'])
|
arch = {'i386': 'i386', 'amd64': 'x86_64'}.get(info.manifest.system['architecture'])
|
||||||
log_check_call(['/usr/bin/euca-bundle-image',
|
log_check_call(['euca-bundle-image',
|
||||||
'--image', info.volume.image_path,
|
'--image', info.volume.image_path,
|
||||||
'--arch', arch,
|
'--arch', arch,
|
||||||
'--user', info.credentials['user-id'],
|
'--user', info.credentials['user-id'],
|
||||||
|
@ -65,7 +65,7 @@ class UploadImage(Task):
|
||||||
else:
|
else:
|
||||||
s3_url = 'https://s3-{region}.amazonaws.com/'.format(region=info.host['region'])
|
s3_url = 'https://s3-{region}.amazonaws.com/'.format(region=info.host['region'])
|
||||||
info.manifest.manifest_location = info.manifest.image['bucket'] + '/' + info.ami_name + '.manifest.xml'
|
info.manifest.manifest_location = info.manifest.image['bucket'] + '/' + info.ami_name + '.manifest.xml'
|
||||||
log_check_call(['/usr/bin/euca-upload-bundle',
|
log_check_call(['euca-upload-bundle',
|
||||||
'--bucket', info.manifest.image['bucket'],
|
'--bucket', info.manifest.image['bucket'],
|
||||||
'--manifest', manifest_file,
|
'--manifest', manifest_file,
|
||||||
'--access-key', info.credentials['access-key'],
|
'--access-key', info.credentials['access-key'],
|
||||||
|
|
|
@ -45,6 +45,6 @@ class ConfigurePVGrub(Task):
|
||||||
'GRUB_HIDDEN_TIMEOUT=true')
|
'GRUB_HIDDEN_TIMEOUT=true')
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
log_check_call(['chroot', info.root, 'update-grub'])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/bin/ln', '--symbolic', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])
|
'ln', '--symbolic', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])
|
||||||
|
|
|
@ -40,16 +40,16 @@ class InstallEnhancedNetworking(Task):
|
||||||
urllib.urlretrieve(drivers_url, archive)
|
urllib.urlretrieve(drivers_url, archive)
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call('/bin/tar', '--ungzip',
|
log_check_call('tar', '--ungzip',
|
||||||
'--extract',
|
'--extract',
|
||||||
'--file', archive,
|
'--file', archive,
|
||||||
'--directory', os.path.join(info.root, 'tmp'))
|
'--directory', os.path.join(info.root, 'tmp'))
|
||||||
|
|
||||||
src_dir = os.path.join('/tmp', os.path.basename(drivers_url), 'src')
|
src_dir = os.path.join('/tmp', os.path.basename(drivers_url), 'src')
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/make', '--directory', src_dir])
|
'make', '--directory', src_dir])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root,
|
log_check_call(['chroot', info.root,
|
||||||
'/usr/bin/make', 'install',
|
'make', 'install',
|
||||||
'--directory', src_dir])
|
'--directory', src_dir])
|
||||||
|
|
||||||
ixgbevf_conf_path = os.path.join(info.root, 'etc/modprobe.d/ixgbevf.conf')
|
ixgbevf_conf_path = os.path.join(info.root, 'etc/modprobe.d/ixgbevf.conf')
|
||||||
|
|
|
@ -29,8 +29,8 @@ class AddGuestAdditionsPackages(Task):
|
||||||
info.packages.add('dkms')
|
info.packages.add('dkms')
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
[kernel_version] = log_check_call(['/usr/sbin/chroot', info.root,
|
[kernel_version] = log_check_call(['chroot', info.root,
|
||||||
'/bin/uname', '-r'])
|
'uname', '-r'])
|
||||||
kernel_headers_pkg = 'linux-headers-{version}'.format(version=kernel_version)
|
kernel_headers_pkg = 'linux-headers-{version}'.format(version=kernel_version)
|
||||||
info.packages.add(kernel_headers_pkg)
|
info.packages.add(kernel_headers_pkg)
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class InstallGuestAdditions(Task):
|
||||||
|
|
||||||
install_script = os.path.join('/', mount_dir, 'VBoxLinuxAdditions.run')
|
install_script = os.path.join('/', mount_dir, 'VBoxLinuxAdditions.run')
|
||||||
from common.tools import log_call
|
from common.tools import log_call
|
||||||
status, out, err = log_call(['/usr/sbin/chroot', info.root,
|
status, out, err = log_call(['chroot', info.root,
|
||||||
install_script, '--nox11'])
|
install_script, '--nox11'])
|
||||||
# Install will exit with $?=1 because X11 isn't installed
|
# Install will exit with $?=1 because X11 isn't installed
|
||||||
if status != 1:
|
if status != 1:
|
||||||
|
|
Loading…
Add table
Reference in a new issue