Code reviewed

This commit is contained in:
Salvatore Orlando 2010-12-17 11:49:00 +00:00
parent 988d6c01b0
commit 6c9ec94d0c
4 changed files with 12 additions and 14 deletions

View File

@ -78,14 +78,14 @@ class ComputeAPI(base.Base):
if ramdisk_id is None:
ramdisk_id = image.get('ramdiskId', FLAGS.default_ramdisk)
#Salvatore - No kernel and ramdisk for raw images
if (kernel_id == str(FLAGS.null_kernel)):
if kernel_id == str(FLAGS.null_kernel):
kernel_id = None
ramdisk_id = None
logging.debug("Creating a raw instance")
# Make sure we have access to kernel and ramdisk (if not raw)
if (kernel_id != None):
if kernel_id:
image_service.show(context, kernel_id)
if (ramdisk_id != None):
if ramdisk_id:
image_service.show(context, ramdisk_id)
# Make sure we have access to kernel and ramdisk
self.image_service.show(context, kernel_id)
@ -109,7 +109,6 @@ class ComputeAPI(base.Base):
key_data = key_pair['public_key']
type_data = instance_types.INSTANCE_TYPES[instance_type]
#Salvatore TODO: PV or HVM
base_options = {
'reservation_id': utils.generate_uid('r'),
'image_id': image_id,

View File

@ -105,7 +105,7 @@ class VMHelper():
}
#Complete VM configuration record according to the image type
#non-raw/raw with PV kernel/raw in HVM mode
if (instance.kernel_id):
if instance.kernel_id:
rec['PV_bootloader'] = ''
rec['PV_kernel'] = kernel
rec['PV_ramdisk'] = ramdisk
@ -113,7 +113,7 @@ class VMHelper():
rec['PV_bootloader_args'] = ''
rec['PV_legacy_args'] = ''
else:
if (pv_kernel):
if pv_kernel:
rec['PV_args'] = 'noninteractive'
rec['PV_bootloader'] = 'pygrub'
else:

View File

@ -65,7 +65,7 @@ class VMOps(object):
user = AuthManager().get_user(instance.user_id)
project = AuthManager().get_project(instance.project_id)
#if kernel is not present we must download a raw disk
if (instance.kernel_id):
if instance.kernel_id:
disk_image_type = 1
else:
disk_image_type = 2
@ -74,14 +74,14 @@ class VMOps(object):
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
if (not instance.kernel_id):
if not instance.kernel_id:
pv_kernel = yield VMHelper.lookup_image(self._session, vdi_ref)
kernel = None
if (instance.kernel_id):
if instance.kernel_id:
kernel = yield VMHelper.fetch_image(self._session,
instance.kernel_id, user, project, 0)
ramdisk = None
if (instance.ramdisk_id):
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,

View File

@ -48,7 +48,7 @@ def is_vdi_pv(session,args):
vdi = exists(args, 'vdi-ref')
pv=with_vdi_in_dom0(session, vdi, False,
lambda dev: _is_vdi_pv('/dev/%s' % dev))
if (pv):
if pv:
return 'true'
else:
return 'false'
@ -58,11 +58,10 @@ def _is_vdi_pv(dest):
output=os.popen('pygrub -qn %s' % dest)
pv=False
for line in output.readlines():
#logging.debug("line:",line)
#try to find kernel string
m=re.search('(?<=kernel:)/.*(?:>)',line)
if (m<>None):
if m.group(0).find('xen')<>-1:
if m:
if m.group(0).find('xen')!=-1:
pv=True
logging.debug("PV:%d",pv)
return pv