diff options
| author | Salvatore Orlando <salvatore.orlando@eu.citrix.com> | 2010-12-15 17:58:55 +0000 |
|---|---|---|
| committer | Salvatore Orlando <salvatore.orlando@eu.citrix.com> | 2010-12-15 17:58:55 +0000 |
| commit | 57e839b1333e29a44a33dc2571dfb8a0a0c956e3 (patch) | |
| tree | d3dd44310874b4825990bf8eaba90271b7266067 /nova/virt | |
| parent | 9308d57ee06baab7eda304d0456544d1f9e587f0 (diff) | |
| download | nova-57e839b1333e29a44a33dc2571dfb8a0a0c956e3.tar.gz nova-57e839b1333e29a44a33dc2571dfb8a0a0c956e3.tar.xz nova-57e839b1333e29a44a33dc2571dfb8a0a0c956e3.zip | |
I made pep8 happy
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt_conn.py | 15 | ||||
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 42 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 16 |
3 files changed, 36 insertions, 37 deletions
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 8111e46b9..81fa5101f 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -448,31 +448,30 @@ class LibvirtConnection(object): 'kernel_id': inst['kernel_id'], 'ramdisk_id': inst['ramdisk_id']} if not os.path.exists(basepath('disk')): - yield images.fetch(inst.image_id, basepath('disk-raw'), user, + yield images.fetch(inst.image_id, basepath('disk-raw'), user, project) using_kernel = inst.kernel_id if using_kernel: if not os.path.exists(basepath('kernel')): - yield images.fetch(inst.kernel_id, basepath('kernel'), user, + yield images.fetch(inst.kernel_id, basepath('kernel'), user, project) if not os.path.exists(basepath('ramdisk')): - yield images.fetch(inst.ramdisk_id, basepath('ramdisk'), user, + yield images.fetch(inst.ramdisk_id, basepath('ramdisk'), user, project) - execute = lambda cmd, process_input = None, check_exit_code = True: \ process.simple_execute(cmd=cmd, process_input=process_input, check_exit_code=check_exit_code) - # For now, we assume that if we're not using a kernel, we're using a - # partitioned disk image where the target partition is the first + # For now, we assume that if we're not using a kernel, we're using a + # partitioned disk image where the target partition is the first # partition target_partition = None if not using_kernel: target_partition = "1" - + key = str(inst['key_data']) net = None network_ref = db.network_get_by_instance(context.get_admin_context(), @@ -495,7 +494,7 @@ class LibvirtConnection(object): inst['name'], inst.image_id) try: yield disk.inject_data(basepath('disk-raw'), key, net, - partition=target_partition, + partition=target_partition, execute=execute) except Exception as e: # This could be a windows image, or a vmdk format disk diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 2e0f957a5..8775aa91a 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -47,7 +47,7 @@ class VMHelper(): @classmethod @defer.inlineCallbacks - def create_vm(cls, session, instance, kernel, ramdisk,pv_kernel=False): + def create_vm(cls, session, instance, kernel, ramdisk, pv_kernel=False): """Create a VM record. Returns a Deferred that gives the new VM reference. the pv_kernel flag indicates whether the guest is HVM or PV @@ -81,7 +81,7 @@ class VMHelper(): 'platform': {}, 'PCI_bus': '', 'recommendations': '', - 'affinity': '', + 'affinity': '', 'user_version': '0', 'other_config': {}, } @@ -97,12 +97,12 @@ class VMHelper(): else: if (pv_kernel): rec['PV_args'] = 'noninteractive' - rec['PV_bootloader'] = 'pygrub' + rec['PV_bootloader'] = 'pygrub' else: rec['HVM_boot_policy'] = 'BIOS order' rec['HVM_boot_params'] = {'order': 'dc'} - rec['platform']={'acpi':'true','apic':'true','pae':'true', - 'viridian':'true'} + rec['platform'] = {'acpi': 'true', 'apic': 'true', + 'pae': 'true', 'viridian': 'true'} logging.debug('Created VM %s...', instance.name) vm_ref = yield session.call_xenapi('VM.create', rec) logging.debug('Created VM %s as %s.', instance.name, vm_ref) @@ -161,22 +161,22 @@ class VMHelper(): """type: integer field for specifying how to handle the image 0 - kernel/ramdisk image (goes on dom0's filesystem) 1 - disk image (local SR, partitioned by objectstore plugin) - 2 - raw disk image (local SR, NOT partitioned by objectstor plugin)""" - + 2 - raw disk image (local SR, NOT partitioned by plugin)""" + url = images.image_url(image) access = AuthManager().get_access_key(user, project) logging.debug("Asking xapi to fetch %s as %s", url, access) - fn = (type<>0) and 'get_vdi' or 'get_kernel' + fn = (type != 0) and 'get_vdi' or 'get_kernel' args = {} args['src_url'] = url args['username'] = access args['password'] = user.secret - args['add_partition']='false' - args['raw']='false' - if type<>0: + args['add_partition'] = 'false' + args['raw'] = 'false' + if type != 0: args['add_partition'] = 'true' - if type==2: - args['raw']='true' + if type == 2: + args['raw'] = 'true' task = yield session.async_call_plugin('objectstore', fn, args) uuid = yield session.wait_for_task(task) defer.returnValue(uuid) @@ -184,18 +184,18 @@ class VMHelper(): @classmethod @defer.inlineCallbacks def lookup_image(cls, session, vdi_ref): - logging.debug("Looking up vdi %s for PV kernel",vdi_ref) - fn="is_vdi_pv" - args={} - args['vdi-ref']=vdi_ref + logging.debug("Looking up vdi %s for PV kernel", vdi_ref) + fn = "is_vdi_pv" + args = {} + args['vdi-ref'] = vdi_ref #TODO: Call proper function in plugin task = yield session.async_call_plugin('objectstore', fn, args) - pv_str=yield session.wait_for_task(task) + pv_str = yield session.wait_for_task(task) if pv_str.lower() == 'true': - pv=True + pv = True elif pv_str.lower() == 'false': - pv=False - logging.debug("PV Kernel in VDI:%d",pv) + pv = False + logging.debug("PV Kernel in VDI:%d", pv) defer.returnValue(pv) @classmethod diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index d00d58c80..170d8af32 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -59,26 +59,26 @@ class VMOps(object): project = AuthManager().get_project(instance.project_id) #if kernel is not present we must download a raw disk if (instance.kernel_id): - disk_image_type=1 + disk_image_type = 1 else: - disk_image_type=2 + disk_image_type = 2 vdi_uuid = yield VMHelper.fetch_image(self._session, instance.image_id, user, project, disk_image_type) - vdi_ref = yield self._session.call_xenapi('VDI.get_by_uuid', vdi_uuid) + vdi_ref = yield self._session.call_xenapi('VDI.get_by_uuid', vdi_uuid) #Have a look at the VDI and see if it has a PV kernel - pv_kernel=False + pv_kernel = False if (not instance.kernel_id): - pv_kernel=yield VMHelper.lookup_image(self._session,vdi_ref) - kernel=None + pv_kernel = yield VMHelper.lookup_image(self._session, vdi_ref) + kernel = None if (instance.kernel_id): kernel = yield VMHelper.fetch_image(self._session, instance.kernel_id, user, project, 0) - ramdisk=None + ramdisk = None if (instance.ramdisk_id): ramdisk = yield VMHelper.fetch_image(self._session, instance.ramdisk_id, user, project, 0) vm_ref = yield VMHelper.create_vm(self._session, - instance, kernel, ramdisk,pv_kernel) + instance, kernel, ramdisk, pv_kernel) yield VMHelper.create_vbd(self._session, vm_ref, vdi_ref, 0, True) if network_ref: yield VMHelper.create_vif(self._session, vm_ref, |
