From f80b56b02f563db17f0cc47bfeb7212631709892 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Thu, 27 Jun 2013 23:29:41 +0200 Subject: [PATCH] Simplify imports --- providers/ec2/tasks/bootstrap.py | 2 +- providers/ec2/tasks/filesystem.py | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/providers/ec2/tasks/bootstrap.py b/providers/ec2/tasks/bootstrap.py index 2293841..0d8e498 100644 --- a/providers/ec2/tasks/bootstrap.py +++ b/providers/ec2/tasks/bootstrap.py @@ -44,7 +44,7 @@ class Bootstrap(Task): executable, options, arguments = get_bootstrap_args(info) if hasattr(info, 'tarball'): options.extend(['--unpack-tarball=' + info.tarball]) + command = executable + options + arguments - command = executable + options + ['--make-tarball=' + info.tarball] + arguments if log_command(command, log) != 0: raise TaskError('Unable to bootstrap') diff --git a/providers/ec2/tasks/filesystem.py b/providers/ec2/tasks/filesystem.py index 5158bdb..a248cd5 100644 --- a/providers/ec2/tasks/filesystem.py +++ b/providers/ec2/tasks/filesystem.py @@ -1,6 +1,8 @@ from base import Task from common import phases from common.exceptions import TaskError +import subprocess +import os class FormatVolume(Task): @@ -8,11 +10,9 @@ class FormatVolume(Task): phase = phases.volume_preparation def run(self, info): - import subprocess - from os import devnull dev_path = info.bootstrap_device['path'] 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) @@ -22,11 +22,9 @@ class TuneVolumeFS(Task): after = [FormatVolume] def run(self, info): - import subprocess - from os import devnull dev_path = info.bootstrap_device['path'] # 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) @@ -44,7 +42,6 @@ class CreateMountDir(Task): phase = phases.volume_mounting def run(self, info): - import os mount_dir = info.manifest.bootstrapper['mount_dir'] 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. @@ -63,10 +60,8 @@ class MountVolume(Task): msg = 'Something is already mount at {root}'.format(root=info.root) raise TaskError(msg) - import subprocess - from os import devnull 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) @@ -75,9 +70,7 @@ class UnmountVolume(Task): phase = phases.volume_unmounting def run(self, info): - import subprocess - from os import devnull - with open(devnull, 'w') as dev_null: + with open(os.devnull, 'w') as dev_null: subprocess.check_call(['umount', info.root], stdout=dev_null, stderr=dev_null) @@ -87,6 +80,5 @@ class DeleteMountDir(Task): after = [UnmountVolume] def run(self, info): - import os os.rmdir(info.root) del info.root