mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Simplify imports
This commit is contained in:
parent
b92f70e548
commit
f80b56b02f
2 changed files with 7 additions and 15 deletions
|
@ -44,7 +44,7 @@ class Bootstrap(Task):
|
||||||
executable, options, arguments = get_bootstrap_args(info)
|
executable, options, arguments = get_bootstrap_args(info)
|
||||||
if hasattr(info, 'tarball'):
|
if hasattr(info, 'tarball'):
|
||||||
options.extend(['--unpack-tarball=' + info.tarball])
|
options.extend(['--unpack-tarball=' + info.tarball])
|
||||||
|
|
||||||
command = executable + options + arguments
|
command = executable + options + arguments
|
||||||
command = executable + options + ['--make-tarball=' + info.tarball] + arguments
|
|
||||||
if log_command(command, log) != 0:
|
if log_command(command, log) != 0:
|
||||||
raise TaskError('Unable to bootstrap')
|
raise TaskError('Unable to bootstrap')
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from base import Task
|
from base import Task
|
||||||
from common import phases
|
from common import phases
|
||||||
from common.exceptions import TaskError
|
from common.exceptions import TaskError
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class FormatVolume(Task):
|
class FormatVolume(Task):
|
||||||
|
@ -8,11 +10,9 @@ class FormatVolume(Task):
|
||||||
phase = phases.volume_preparation
|
phase = phases.volume_preparation
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import subprocess
|
|
||||||
from os import devnull
|
|
||||||
dev_path = info.bootstrap_device['path']
|
dev_path = info.bootstrap_device['path']
|
||||||
mkfs = '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem'])
|
mkfs = '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem'])
|
||||||
with open(devnull, 'w') as dev_null:
|
with open(os.devnull, 'w') as dev_null:
|
||||||
subprocess.check_call([mkfs, dev_path], stdout=dev_null, stderr=dev_null)
|
subprocess.check_call([mkfs, dev_path], stdout=dev_null, stderr=dev_null)
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,11 +22,9 @@ class TuneVolumeFS(Task):
|
||||||
after = [FormatVolume]
|
after = [FormatVolume]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import subprocess
|
|
||||||
from os import devnull
|
|
||||||
dev_path = info.bootstrap_device['path']
|
dev_path = info.bootstrap_device['path']
|
||||||
# Disable the time based filesystem check
|
# Disable the time based filesystem check
|
||||||
with open(devnull, 'w') as dev_null:
|
with open(os.devnull, 'w') as dev_null:
|
||||||
subprocess.check_call(['/sbin/tune2fs', '-i', '0', dev_path], stdout=dev_null, stderr=dev_null)
|
subprocess.check_call(['/sbin/tune2fs', '-i', '0', dev_path], stdout=dev_null, stderr=dev_null)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +42,6 @@ class CreateMountDir(Task):
|
||||||
phase = phases.volume_mounting
|
phase = phases.volume_mounting
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import os
|
|
||||||
mount_dir = info.manifest.bootstrapper['mount_dir']
|
mount_dir = info.manifest.bootstrapper['mount_dir']
|
||||||
info.root = '{mount_dir}/{vol_id}'.format(mount_dir=mount_dir, vol_id=info.volume.id)
|
info.root = '{mount_dir}/{vol_id}'.format(mount_dir=mount_dir, vol_id=info.volume.id)
|
||||||
# Works recursively, fails if last part exists, which is exaclty what we want.
|
# Works recursively, fails if last part exists, which is exaclty what we want.
|
||||||
|
@ -63,10 +60,8 @@ class MountVolume(Task):
|
||||||
msg = 'Something is already mount at {root}'.format(root=info.root)
|
msg = 'Something is already mount at {root}'.format(root=info.root)
|
||||||
raise TaskError(msg)
|
raise TaskError(msg)
|
||||||
|
|
||||||
import subprocess
|
|
||||||
from os import devnull
|
|
||||||
dev_path = info.bootstrap_device['path']
|
dev_path = info.bootstrap_device['path']
|
||||||
with open(devnull, 'w') as dev_null:
|
with open(os.devnull, 'w') as dev_null:
|
||||||
subprocess.check_call(['mount', dev_path, info.root], stdout=dev_null, stderr=dev_null)
|
subprocess.check_call(['mount', dev_path, info.root], stdout=dev_null, stderr=dev_null)
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,9 +70,7 @@ class UnmountVolume(Task):
|
||||||
phase = phases.volume_unmounting
|
phase = phases.volume_unmounting
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import subprocess
|
with open(os.devnull, 'w') as dev_null:
|
||||||
from os import devnull
|
|
||||||
with open(devnull, 'w') as dev_null:
|
|
||||||
subprocess.check_call(['umount', info.root], stdout=dev_null, stderr=dev_null)
|
subprocess.check_call(['umount', info.root], stdout=dev_null, stderr=dev_null)
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,6 +80,5 @@ class DeleteMountDir(Task):
|
||||||
after = [UnmountVolume]
|
after = [UnmountVolume]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import os
|
|
||||||
os.rmdir(info.root)
|
os.rmdir(info.root)
|
||||||
del info.root
|
del info.root
|
||||||
|
|
Loading…
Add table
Reference in a new issue