summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorKevin L. Mitchell <kevin.mitchell@rackspace.com>2011-07-29 20:19:48 +0000
committerKevin L. Mitchell <kevin.mitchell@rackspace.com>2011-07-29 20:19:48 +0000
commit649b0da35dbc36ce15cd3ada6e4e4b814a244158 (patch)
treec7c8317fd4d5f8f045b5d3fe113730bd48eb011e /nova/virt
parent73711a9e260fd8b6f747b9c8f09511eba149a1fb (diff)
parentbdcfaa5b927a096f507fb0f7e2d81989173957f8 (diff)
pull-up from trunk and conflict resolution
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/hyperv.py6
-rw-r--r--nova/virt/images.py2
-rw-r--r--nova/virt/libvirt/connection.py19
-rw-r--r--nova/virt/xenapi/vm_utils.py24
-rw-r--r--nova/virt/xenapi/vmops.py21
5 files changed, 33 insertions, 39 deletions
diff --git a/nova/virt/hyperv.py b/nova/virt/hyperv.py
index 075594808..cbfe5fad1 100644
--- a/nova/virt/hyperv.py
+++ b/nova/virt/hyperv.py
@@ -66,7 +66,6 @@ import time
from nova import exception
from nova import flags
from nova import log as logging
-from nova.auth import manager
from nova.compute import power_state
from nova.virt import driver
from nova.virt import images
@@ -146,13 +145,12 @@ class HyperVConnection(driver.ComputeDriver):
if vm is not None:
raise exception.InstanceExists(name=instance.name)
- user = manager.AuthManager().get_user(instance['user_id'])
- project = manager.AuthManager().get_project(instance['project_id'])
#Fetch the file, assume it is a VHD file.
base_vhd_filename = os.path.join(FLAGS.instances_path,
instance.name)
vhdfile = "%s.vhd" % (base_vhd_filename)
- images.fetch(instance['image_ref'], vhdfile, user, project)
+ images.fetch(instance['image_ref'], vhdfile,
+ instance['user_id'], instance['project_id'])
try:
self._create_vm(instance)
diff --git a/nova/virt/images.py b/nova/virt/images.py
index 40bf6107c..2e9fca3d6 100644
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -33,7 +33,7 @@ FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.virt.images')
-def fetch(image_href, path, _user, _project):
+def fetch(image_href, path, _user_id, _project_id):
# TODO(vish): Improve context handling and add owner and auth data
# when it is added to glance. Right now there is no
# auth checking in glance, so we assume that access was
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 1e291000c..81d302ea6 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -770,9 +770,9 @@ class LibvirtConnection(driver.ComputeDriver):
else:
utils.execute('cp', base, target)
- def _fetch_image(self, target, image_id, user, project, size=None):
+ def _fetch_image(self, target, image_id, user_id, project_id, size=None):
"""Grab image and optionally attempt to resize it"""
- images.fetch(image_id, target, user, project)
+ images.fetch(image_id, target, user_id, project_id)
if size:
disk.extend(target, size)
@@ -810,9 +810,6 @@ class LibvirtConnection(driver.ComputeDriver):
os.close(os.open(basepath('console.log', ''),
os.O_CREAT | os.O_WRONLY, 0660))
- user = manager.AuthManager().get_user(inst['user_id'])
- project = manager.AuthManager().get_project(inst['project_id'])
-
if not disk_images:
disk_images = {'image_id': inst['image_ref'],
'kernel_id': inst['kernel_id'],
@@ -824,16 +821,16 @@ class LibvirtConnection(driver.ComputeDriver):
target=basepath('kernel'),
fname=fname,
image_id=disk_images['kernel_id'],
- user=user,
- project=project)
+ user_id=inst['user_id'],
+ project_id=inst['project_id'])
if disk_images['ramdisk_id']:
fname = '%08x' % int(disk_images['ramdisk_id'])
self._cache_image(fn=self._fetch_image,
target=basepath('ramdisk'),
fname=fname,
image_id=disk_images['ramdisk_id'],
- user=user,
- project=project)
+ user_id=inst['user_id'],
+ project_id=inst['project_id'])
root_fname = hashlib.sha1(disk_images['image_id']).hexdigest()
size = FLAGS.minimum_root_size
@@ -851,8 +848,8 @@ class LibvirtConnection(driver.ComputeDriver):
fname=root_fname,
cow=FLAGS.use_cow_images,
image_id=disk_images['image_id'],
- user=user,
- project=project,
+ user_id=inst['user_id'],
+ project_id=inst['project_id'],
size=size)
if inst_type['local_gb'] and not self._volume_in_mapping(
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 088160075..b696bdb02 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -37,7 +37,6 @@ import nova.image
from nova.image import glance as glance_image_service
from nova import log as logging
from nova import utils
-from nova.auth.manager import AuthManager
from nova.compute import instance_types
from nova.compute import power_state
from nova.virt import disk
@@ -369,7 +368,7 @@ class VMHelper(HelperBase):
session.wait_for_task(task, instance.id)
@classmethod
- def fetch_image(cls, ctx, session, instance_id, image, user, project,
+ def fetch_image(cls, ctx, session, instance_id, image, user_id, project_id,
image_type):
"""
image_type is interpreted as an ImageType instance
@@ -381,19 +380,24 @@ class VMHelper(HelperBase):
Returns: A single filename if image_type is KERNEL_RAMDISK
A list of dictionaries that describe VDIs, otherwise
"""
- access = AuthManager().get_access_key(user, project)
if FLAGS.xenapi_image_service == 'glance':
return cls._fetch_image_glance(ctx, session, instance_id,
- image, access, image_type)
+ image, image_type)
else:
+ # TODO(vish): this shouldn't be used anywhere anymore and
+ # can probably be removed
+ from nova.auth.manager import AuthManager
+ manager = AuthManager()
+ access = manager.get_access_key(user_id, project_id)
+ secret = manager.get_user(user_id).secret
return cls._fetch_image_objectstore(session, instance_id, image,
- access, user.secret,
+ access, secret,
image_type)
@classmethod
def _fetch_image_glance_vhd(cls, ctx, session, instance_id, image,
- access, image_type):
+ image_type):
"""Tell glance to download an image and put the VHDs into the SR
Returns: A list of dictionaries that describe VDIs
@@ -442,7 +446,7 @@ class VMHelper(HelperBase):
@classmethod
def _fetch_image_glance_disk(cls, ctx, session, instance_id, image,
- access, image_type):
+ image_type):
"""Fetch the image from Glance
NOTE:
@@ -576,7 +580,7 @@ class VMHelper(HelperBase):
return image_type
@classmethod
- def _fetch_image_glance(cls, ctx, session, instance_id, image, access,
+ def _fetch_image_glance(cls, ctx, session, instance_id, image,
image_type):
"""Fetch image from glance based on image type.
@@ -585,10 +589,10 @@ class VMHelper(HelperBase):
"""
if image_type == ImageType.DISK_VHD:
return cls._fetch_image_glance_vhd(ctx,
- session, instance_id, image, access, image_type)
+ session, instance_id, image, image_type)
else:
return cls._fetch_image_glance_disk(ctx,
- session, instance_id, image, access, image_type)
+ session, instance_id, image, image_type)
@classmethod
def _fetch_image_objectstore(cls, session, instance_id, image, access,
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index e01ffa046..f6c86566b 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -38,7 +38,6 @@ from nova import ipv6
from nova import log as logging
from nova import utils
-from nova.auth.manager import AuthManager
from nova.compute import power_state
from nova.virt import driver
from nova.virt.xenapi.network_utils import NetworkHelper
@@ -136,11 +135,10 @@ class VMOps(object):
self._session.call_xenapi('VM.start', vm_ref, False, False)
def _create_disks(self, ctx, instance):
- user = AuthManager().get_user(instance.user_id)
- project = AuthManager().get_project(instance.project_id)
disk_image_type = VMHelper.determine_disk_image_type(instance)
vdis = VMHelper.fetch_image(ctx, self._session,
- instance.id, instance.image_ref, user, project,
+ instance.id, instance.image_ref,
+ instance.user_id, instance.project_id,
disk_image_type)
return vdis
@@ -178,21 +176,18 @@ class VMOps(object):
power_state.SHUTDOWN)
return
- user = AuthManager().get_user(instance.user_id)
- project = AuthManager().get_project(instance.project_id)
-
disk_image_type = VMHelper.determine_disk_image_type(instance)
kernel = None
ramdisk = None
try:
if instance.kernel_id:
- kernel = VMHelper.fetch_image(ctx, self._session,
- instance.id, instance.kernel_id, user, project,
- ImageType.KERNEL)[0]
+ kernel = VMHelper.fetch_image(ctx, self._session, instance.id,
+ instance.kernel_id, instance.user_id,
+ instance.project_id, ImageType.KERNEL)[0]
if instance.ramdisk_id:
- ramdisk = VMHelper.fetch_image(ctx, self._session,
- instance.id, instance.ramdisk_id, user, project,
- ImageType.RAMDISK)[0]
+ ramdisk = VMHelper.fetch_image(ctx, self._session, instance.id,
+ instance.kernel_id, instance.user_id,
+ instance.project_id, ImageType.RAMDISK)[0]
# Create the VM ref and attach the first disk
first_vdi_ref = self._session.call_xenapi('VDI.get_by_uuid',
vdis[0]['vdi_uuid'])