diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-07-16 20:32:51 +0000 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-07-16 20:32:51 +0000 |
| commit | 52f0ec017c04ad9356eb45d96bcab90a0807d914 (patch) | |
| tree | fc19b26289854b43b64d747f487463f788c32df9 | |
| parent | ae9e4e81d992fb81c01acd2dfcb1cb3d32956041 (diff) | |
| download | nova-52f0ec017c04ad9356eb45d96bcab90a0807d914.tar.gz nova-52f0ec017c04ad9356eb45d96bcab90a0807d914.tar.xz nova-52f0ec017c04ad9356eb45d96bcab90a0807d914.zip | |
make simple method wrapper for process pool simple_execute
| -rw-r--r-- | nova/compute/node.py | 12 | ||||
| -rw-r--r-- | nova/process.py | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/nova/compute/node.py b/nova/compute/node.py index 3abd20120..4683f1c8d 100644 --- a/nova/compute/node.py +++ b/nova/compute/node.py @@ -446,13 +446,13 @@ class Instance(object): def _fetch_s3_image(self, image, path): url = _image_url('%s/image' % image) - d = process.SharedPool().simple_execute( + d = process.simple_execute( 'curl --silent %s -o %s' % (url, path)) return d def _fetch_local_image(self, image, path): source = _image_path('%s/image' % image) - d = process.SharedPool().simple_execute('cp %s %s' % (source, path)) + d = process.simple_execute('cp %s %s' % (source, path)) return d @defer.inlineCallbacks @@ -462,9 +462,9 @@ class Instance(object): basepath = self.basepath # ensure directories exist and are writable - yield process.SharedPool().simple_execute( + yield process.simple_execute( 'mkdir -p %s' % basepath()) - yield process.SharedPool().simple_execute( + yield process.simple_execute( 'chmod 0777 %s' % basepath()) @@ -492,7 +492,7 @@ class Instance(object): yield _fetch_file(data['ramdisk_id'], basepath('ramdisk')) execute = lambda cmd, input=None: \ - process.SharedPool().simple_execute(cmd=cmd, + process.simple_execute(cmd=cmd, input=input, error_ok=1) @@ -511,7 +511,7 @@ class Instance(object): yield disk.inject_data(basepath('disk-raw'), key, net, execute=execute) if os.path.exists(basepath('disk')): - yield process.SharedPool().simple_execute( + yield process.simple_execute( 'rm -f %s' % basepath('disk')) bytes = (INSTANCE_TYPES[data['instance_type']]['local_gb'] diff --git a/nova/process.py b/nova/process.py index ebfb2f4ba..d3558ed2e 100644 --- a/nova/process.py +++ b/nova/process.py @@ -212,3 +212,6 @@ class SharedPool(ProcessPool): cls._instance = super(SharedPool, cls).__new__( cls, *args, **kwargs) return cls._instance + +def simple_execute(cmd, **kwargs): + return SharedPool().simple_execute(cmd, **kwargs) |
