diff options
| author | Rick Harris <rick.harris@rackspace.com> | 2011-02-15 22:31:51 +0000 |
|---|---|---|
| committer | Rick Harris <rick.harris@rackspace.com> | 2011-02-15 22:31:51 +0000 |
| commit | c7cd7b755c86bd15e2b19f70a09f88f62361596c (patch) | |
| tree | 9cc2d3a812ce33d659810585880565a2eb9e23e8 /plugins | |
| parent | 28ba475d9c32a384570ce6eb0e2f9cfc3dc79a08 (diff) | |
| download | nova-c7cd7b755c86bd15e2b19f70a09f88f62361596c.tar.gz nova-c7cd7b755c86bd15e2b19f70a09f88f62361596c.tar.xz nova-c7cd7b755c86bd15e2b19f70a09f88f62361596c.zip | |
More pep8 fixes
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index 75bdda2c6..43c58dcff 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -39,20 +39,22 @@ configure_logging('glance') CHUNK_SIZE = 8192 KERNEL_DIR = '/boot/guest' -def _copy_kernel_vdi(dest,copy_args): - vdi_uuid=copy_args['vdi_uuid'] - vdi_size=copy_args['vdi_size'] - logging.debug("copying kernel/ramdisk file from %s to /boot/guest/%s",dest,vdi_uuid) - filename=KERNEL_DIR + '/' + vdi_uuid + +def _copy_kernel_vdi(dest, copy_args): + vdi_uuid = copy_args['vdi_uuid'] + vdi_size = copy_args['vdi_size'] + logging.debug("copying kernel/ramdisk file from %s to /boot/guest/%s", + dest, vdi_uuid) + filename = KERNEL_DIR + '/' + vdi_uuid #read data from /dev/ and write into a file on /boot/guest - of=open(filename,'wb') - f=open(dest,'rb') + of = open(filename, 'wb') + f = open(dest, 'rb') #copy only vdi_size bytes - data=f.read(vdi_size) + data = f.read(vdi_size) of.write(data) f.close() of.close() - logging.debug("Done. Filename: %s",filename) + logging.debug("Done. Filename: %s", filename) return filename @@ -101,9 +103,9 @@ def fixup_vhds(sr_path, staging_path, uuid_stack): 3. Linking the two VHDs together 4. Pseudo-atomically moving the images into the SR. (It's not really - atomic because it takes place as two os.rename operations; however, the - chances of an SR.scan occuring between the two rename() invocations is so - small that we can safely ignore it) + atomic because it takes place as two os.rename operations; however, + the chances of an SR.scan occuring between the two rename() + invocations is so small that we can safely ignore it) """ def rename_with_uuid(orig_path): """Rename VHD using UUID so that it will be recognized by SR on a @@ -118,7 +120,6 @@ def fixup_vhds(sr_path, staging_path, uuid_stack): os.rename(orig_path, new_path) return new_path, uuid - def link_vhds(child_path, parent_path): """Use vhd-util to associate the snapshot VHD with its base_copy. @@ -132,7 +133,6 @@ def fixup_vhds(sr_path, staging_path, uuid_stack): modify_args, stderr=subprocess.PIPE) _assert_process_success(modify_proc, "vhd-util") - def move_into_sr(orig_path): """Move a file into the SR""" filename = os.path.basename(orig_path) @@ -140,7 +140,6 @@ def fixup_vhds(sr_path, staging_path, uuid_stack): os.rename(orig_path, new_path) return new_path - image_path = os.path.join(staging_path, 'image') orig_base_copy_path = os.path.join(image_path, 'image.vhd') @@ -157,7 +156,7 @@ def fixup_vhds(sr_path, staging_path, uuid_stack): # NOTE(sirp): this step is necessary so that an SR scan won't # delete the base_copy out from under us (since it would be # orphaned) - link_vhds(snap_path, base_copy_path) + link_vhds(snap_path, base_copy_path) move_into_sr(snap_path) move_into_sr(base_copy_path) @@ -227,7 +226,7 @@ def _make_staging_area(sr_path): The staging area is a place where we can temporarily store and manipulate VHDs. The use of the staging area is different for upload and download: - + Download ======== @@ -241,7 +240,7 @@ def _make_staging_area(sr_path): Upload ====== - + On upload, we want to rename the VHDs to reflect what they are, 'snap.vhd' in the case of the snapshot VHD, and 'image.vhd' in the case of the base_copy. The staging area provides a directory in which we can create @@ -264,7 +263,7 @@ def _cleanup_staging_area(staging_path): On upload, the staging area contains hard-links to the VHDs in the SR; it's safe to remove the staging-area because the SR will keep the link - count > 0 (so the VHDs in the SR will not be deleted). + count > 0 (so the VHDs in the SR will not be deleted). """ shutil.rmtree(staging_path) @@ -320,15 +319,15 @@ def upload_image(session, args): return "" # Nothing useful to return on an upload -def copy_kernel_vdi(session,args): +def copy_kernel_vdi(session, args): vdi = exists(args, 'vdi-ref') - size = exists(args,'image-size') + size = exists(args, 'image-size') #Use the uuid as a filename - vdi_uuid=session.xenapi.VDI.get_uuid(vdi) - copy_args={'vdi_uuid':vdi_uuid,'vdi_size':int(size)} - filename=with_vdi_in_dom0(session, vdi, False, - lambda dev: - _copy_kernel_vdi('/dev/%s' % dev,copy_args)) + vdi_uuid = session.xenapi.VDI.get_uuid(vdi) + copy_args = {'vdi_uuid': vdi_uuid, 'vdi_size': int(size)} + filename = with_vdi_in_dom0(session, vdi, False, + lambda dev: + _copy_kernel_vdi('/dev/%s' % dev, copy_args)) return filename |
