From 655eb8fbd21376e694f8134e42f10ddbc1aafb0e Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 6 Apr 2011 18:22:03 -0700 Subject: ec2 api run_instances checks for image status must be 'available'. Overhauled test_run_instances for working set of test assertions --- nova/api/ec2/cloud.py | 10 +++++++- nova/tests/test_cloud.py | 62 +++++++++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 58effd134..0ea0e3603 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -814,10 +814,18 @@ class CloudController(object): if kwargs.get('ramdisk_id'): ramdisk = self._get_image(context, kwargs['ramdisk_id']) kwargs['ramdisk_id'] = ramdisk['id'] + image = self._get_image(context, kwargs['image_id']) + if not image: + raise exception.NotFound(_('Image %s not found') % + kwargs['image_id']) + if not 'properties' in image or \ + (not 'image_state' in image['properties']) or \ + (image['properties']['image_state'] is not 'available'): + raise exception.ApiError(_('Image must be available')) instances = self.compute_api.create(context, instance_type=instance_types.get_by_type( kwargs.get('instance_type', None)), - image_id=self._get_image(context, kwargs['image_id'])['id'], + image_id = image['id'], min_count=int(kwargs.get('min_count', max_count)), max_count=max_count, kernel_id=kwargs.get('kernel_id'), diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 5cb969979..85f3a8e87 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -36,12 +36,12 @@ from nova import rpc from nova import service from nova import test from nova import utils +from nova import exception from nova.auth import manager from nova.compute import power_state from nova.api.ec2 import cloud from nova.api.ec2 import ec2utils from nova.image import local -from nova.exception import NotFound FLAGS = flags.FLAGS @@ -226,7 +226,7 @@ class CloudTestCase(test.TestCase): 'type': 'machine'}}] def fake_show_none(meh, context, id): - raise NotFound + raise exception.NotFound self.stubs.Set(local.LocalImageService, 'detail', fake_detail) # list all @@ -244,7 +244,7 @@ class CloudTestCase(test.TestCase): self.stubs.UnsetAll() self.stubs.Set(local.LocalImageService, 'show', fake_show_none) self.stubs.Set(local.LocalImageService, 'show_by_name', fake_show_none) - self.assertRaises(NotFound, describe_images, + self.assertRaises(exception.NotFound, describe_images, self.context, ['ami-fake']) def test_console_output(self): @@ -307,39 +307,41 @@ class CloudTestCase(test.TestCase): self.cloud.delete_key_pair(self.context, 'test') def test_run_instances(self): - if FLAGS.connection_type == 'fake': - LOG.debug(_("Can't test instances without a real virtual env.")) - return + allinst = db.instance_get_all(context.get_admin_context()) + self.assertEqual(0, len(allinst)) + def fake_show_decrypt(meh, context, id): + return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, + 'type': 'machine', 'image_state': 'decrypting'}} + + def fake_show_avail(meh, context, id): + return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, + 'type': 'machine', 'image_state': 'available'}} + image_id = FLAGS.default_image instance_type = FLAGS.default_instance_type max_count = 1 kwargs = {'image_id': image_id, 'instance_type': instance_type, 'max_count': max_count} - rv = self.cloud.run_instances(self.context, **kwargs) - # TODO: check for proper response - instance_id = rv['reservationSet'][0].keys()[0] - instance = rv['reservationSet'][0][instance_id][0] - LOG.debug(_("Need to watch instance %s until it's running..."), - instance['instance_id']) - while True: - greenthread.sleep(1) - info = self.cloud._get_instance(instance['instance_id']) - LOG.debug(info['state']) - if info['state'] == power_state.RUNNING: - break - self.assert_(rv) - - if FLAGS.connection_type != 'fake': - time.sleep(45) # Should use boto for polling here - for reservations in rv['reservationSet']: - # for res_id in reservations.keys(): - # LOG.debug(reservations[res_id]) - # for instance in reservations[res_id]: - for instance in reservations[reservations.keys()[0]]: - instance_id = instance['instance_id'] - LOG.debug(_("Terminating instance %s"), instance_id) - rv = self.compute.terminate_instance(instance_id) + run_instances = self.cloud.run_instances + # when image doesn't have 'image_state' attr at all + self.assertRaises(exception.ApiError, run_instances, + self.context, **kwargs) + # when image has 'image_state' yet not 'available' + self.stubs.UnsetAll() + self.stubs.Set(local.LocalImageService, 'show', fake_show_decrypt) + self.assertRaises(exception.ApiError, run_instances, + self.context, **kwargs) + # when image has valid image_state + self.stubs.UnsetAll() + self.stubs.Set(local.LocalImageService, 'show', fake_show_avail) + result = run_instances(self.context, **kwargs) + instance = result['instancesSet'][0] + self.assertEqual(instance['imageId'], 'ami-00000001') + self.assertEqual(instance['displayName'], 'Server 1') + self.assertEqual(instance['instanceId'], 'i-00000001') + self.assertEqual(instance['instanceState']['name'], 'scheduling') + self.assertEqual(instance['instanceType'], 'm1.small') def test_update_of_instance_display_fields(self): inst = db.instance_create(self.context, {}) -- cgit From 1c13695a2c5e5d14ead3f5459d0b40bb875ecdf6 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 11 Apr 2011 14:16:17 -0400 Subject: Sudo chown the vbd device to the nova user before streaming data to it. This resolves an issue where nova-compute required 'root' privs to successfully create nodes with connection_type=xenapi. --- nova/virt/xenapi/vm_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index d2045a557..50fdf3e30 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -1012,6 +1012,8 @@ def _stream_disk(dev, image_type, virtual_size, image_file): offset = MBR_SIZE_BYTES _write_partition(virtual_size, dev) + utils.execute('sudo', 'chown', os.getuid(), '/dev/%s' % dev) + with open('/dev/%s' % dev, 'wb') as f: f.seek(offset) for chunk in image_file: -- cgit From 9d2513ea3a6d586e1fe3deae778a02bb089b9a5e Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 12 Apr 2011 10:25:07 -0400 Subject: Updated to use setfacl instead of chown. --- nova/virt/xenapi/vm_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 50fdf3e30..5cdd29057 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -1012,7 +1012,8 @@ def _stream_disk(dev, image_type, virtual_size, image_file): offset = MBR_SIZE_BYTES _write_partition(virtual_size, dev) - utils.execute('sudo', 'chown', os.getuid(), '/dev/%s' % dev) + utils.execute('sudo', 'setfacl', '-m', 'u:%s:rw' % os.getuid(), + '/dev/%s' % dev) with open('/dev/%s' % dev, 'wb') as f: f.seek(offset) -- cgit From 10db492376a8bb8409e3fb3c33707865ac0f3ee7 Mon Sep 17 00:00:00 2001 From: John Tran Date: Mon, 2 May 2011 14:25:21 -0700 Subject: implemented review suggestion EAFP style, and fixed test stub fake_show needs to have image_state = available or other tests will fail --- nova/api/ec2/cloud.py | 14 +++++++++----- nova/tests/test_cloud.py | 35 ++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 0ea0e3603..5dc608139 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -815,17 +815,21 @@ class CloudController(object): ramdisk = self._get_image(context, kwargs['ramdisk_id']) kwargs['ramdisk_id'] = ramdisk['id'] image = self._get_image(context, kwargs['image_id']) - if not image: + if not image: raise exception.NotFound(_('Image %s not found') % kwargs['image_id']) - if not 'properties' in image or \ - (not 'image_state' in image['properties']) or \ - (image['properties']['image_state'] is not 'available'): + try: + available = (image['properties']['image_state'] == 'available') + except KeyError: + available = False + + if not available: raise exception.ApiError(_('Image must be available')) + instances = self.compute_api.create(context, instance_type=instance_types.get_by_type( kwargs.get('instance_type', None)), - image_id = image['id'], + image_id=image['id'], min_count=int(kwargs.get('min_count', max_count)), max_count=max_count, kernel_id=kwargs.get('kernel_id'), diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 85f3a8e87..da2fce06b 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -30,13 +30,13 @@ from eventlet import greenthread from nova import context from nova import crypto from nova import db +from nova import exception from nova import flags from nova import log as logging from nova import rpc from nova import service from nova import test from nova import utils -from nova import exception from nova.auth import manager from nova.compute import power_state from nova.api.ec2 import cloud @@ -73,7 +73,7 @@ class CloudTestCase(test.TestCase): def fake_show(meh, context, id): return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, - 'type': 'machine'}} + 'type': 'machine', 'image_state': 'available'}} self.stubs.Set(local.LocalImageService, 'show', fake_show) self.stubs.Set(local.LocalImageService, 'show_by_name', fake_show) @@ -307,15 +307,16 @@ class CloudTestCase(test.TestCase): self.cloud.delete_key_pair(self.context, 'test') def test_run_instances(self): - allinst = db.instance_get_all(context.get_admin_context()) - self.assertEqual(0, len(allinst)) - def fake_show_decrypt(meh, context, id): + all_instances = db.instance_get_all(context.get_admin_context()) + self.assertEqual(0, len(all_instances)) + + def fake_show_decrypt(self, context, id): return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, 'type': 'machine', 'image_state': 'decrypting'}} - def fake_show_avail(meh, context, id): + def fake_show_no_state(self, context, id): return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, - 'type': 'machine', 'image_state': 'available'}} + 'type': 'machine'}} image_id = FLAGS.default_image instance_type = FLAGS.default_instance_type @@ -324,17 +325,7 @@ class CloudTestCase(test.TestCase): 'instance_type': instance_type, 'max_count': max_count} run_instances = self.cloud.run_instances - # when image doesn't have 'image_state' attr at all - self.assertRaises(exception.ApiError, run_instances, - self.context, **kwargs) - # when image has 'image_state' yet not 'available' - self.stubs.UnsetAll() - self.stubs.Set(local.LocalImageService, 'show', fake_show_decrypt) - self.assertRaises(exception.ApiError, run_instances, - self.context, **kwargs) # when image has valid image_state - self.stubs.UnsetAll() - self.stubs.Set(local.LocalImageService, 'show', fake_show_avail) result = run_instances(self.context, **kwargs) instance = result['instancesSet'][0] self.assertEqual(instance['imageId'], 'ami-00000001') @@ -342,6 +333,16 @@ class CloudTestCase(test.TestCase): self.assertEqual(instance['instanceId'], 'i-00000001') self.assertEqual(instance['instanceState']['name'], 'scheduling') self.assertEqual(instance['instanceType'], 'm1.small') + # when image doesn't have 'image_state' attr at all + self.stubs.UnsetAll() + self.stubs.Set(local.LocalImageService, 'show', fake_show_no_state) + self.assertRaises(exception.ApiError, run_instances, + self.context, **kwargs) + # when image has 'image_state' yet not 'available' + self.stubs.UnsetAll() + self.stubs.Set(local.LocalImageService, 'show', fake_show_decrypt) + self.assertRaises(exception.ApiError, run_instances, + self.context, **kwargs) def test_update_of_instance_display_fields(self): inst = db.instance_create(self.context, {}) -- cgit From 3ee0507ddc6bb7e15834144acc47c354396fbc70 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Thu, 5 May 2011 23:14:46 -0400 Subject: Publish errors via nova.notifier --- nova/log.py | 9 +++++++++ nova/tests/test_notifier.py | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/nova/log.py b/nova/log.py index 096279f7c..3e587891a 100644 --- a/nova/log.py +++ b/nova/log.py @@ -35,6 +35,7 @@ import os import sys import traceback +import nova from nova import flags from nova import version @@ -63,6 +64,7 @@ flags.DEFINE_list('default_log_levels', 'eventlet.wsgi.server=WARN'], 'list of logger=LEVEL pairs') flags.DEFINE_bool('use_syslog', False, 'output to syslog') +flags.DEFINE_bool('publish_errors', True, 'publish error events') flags.DEFINE_string('logfile', None, 'output to named file') @@ -258,12 +260,19 @@ class NovaRootLogger(NovaLogger): else: self.removeHandler(self.filelog) self.addHandler(self.streamlog) + if FLAGS.publish_errors: + self.addHandler(PublishErrorsHandler(ERROR)) if FLAGS.verbose: self.setLevel(DEBUG) else: self.setLevel(INFO) +class PublishErrorsHandler(logging.Handler): + def emit(self, record): + nova.notifier.notify('error', record) + + def handle_exception(type, value, tb): extra = {} if FLAGS.verbose: diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index 4d6289e6a..d18d3bc05 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -13,14 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. -import nova +import json + +import stubout +import nova +from nova import log as logging from nova import flags from nova import notifier from nova.notifier import no_op_notifier from nova import test -import stubout +LOG = logging.getLogger('nova.compute.api') class NotifierTestCase(test.TestCase): """Test case for notifications""" @@ -58,3 +62,16 @@ class NotifierTestCase(test.TestCase): notifier.notify('derp', Mock()) self.assertEqual(self.mock_cast, True) + + def test_error_notification(self): + self.stubs.Set(nova.flags.FLAGS, 'notification_driver', + 'nova.notifier.rabbit_notifier.RabbitNotifier') + msgs = [] + def mock_cast(context, topic, msg): + data = json.loads(msg) + msgs.append(data) + self.stubs.Set(nova.rpc, 'cast', mock_cast) + LOG.error('foo'); + msg = msgs[0] + self.assertEqual(msg['event_name'], 'error') + self.assertEqual(msg['model']['msg'], 'foo') -- cgit From 65595766706631a5c65193cfc0fa2ac9de1aeffc Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Fri, 6 May 2011 20:15:06 -0400 Subject: Set publish_errors default to False. --- nova/log.py | 2 +- nova/tests/test_notifier.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nova/log.py b/nova/log.py index 3e587891a..d2ed82c6c 100644 --- a/nova/log.py +++ b/nova/log.py @@ -64,7 +64,7 @@ flags.DEFINE_list('default_log_levels', 'eventlet.wsgi.server=WARN'], 'list of logger=LEVEL pairs') flags.DEFINE_bool('use_syslog', False, 'output to syslog') -flags.DEFINE_bool('publish_errors', True, 'publish error events') +flags.DEFINE_bool('publish_errors', False, 'publish error events') flags.DEFINE_string('logfile', None, 'output to named file') diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index d18d3bc05..c9c4ddde8 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -18,14 +18,12 @@ import json import stubout import nova -from nova import log as logging +from nova import log from nova import flags from nova import notifier from nova.notifier import no_op_notifier from nova import test -LOG = logging.getLogger('nova.compute.api') - class NotifierTestCase(test.TestCase): """Test case for notifications""" def setUp(self): @@ -66,12 +64,17 @@ class NotifierTestCase(test.TestCase): def test_error_notification(self): self.stubs.Set(nova.flags.FLAGS, 'notification_driver', 'nova.notifier.rabbit_notifier.RabbitNotifier') + self.stubs.Set(nova.flags.FLAGS, 'publish_errors', True) + LOG = log.getLogger('nova') + LOG.setup_from_flags() + msgs = [] def mock_cast(context, topic, msg): data = json.loads(msg) msgs.append(data) self.stubs.Set(nova.rpc, 'cast', mock_cast) LOG.error('foo'); + self.assertEqual(1, len(msgs)) msg = msgs[0] self.assertEqual(msg['event_name'], 'error') self.assertEqual(msg['model']['msg'], 'foo') -- cgit From 6c4059f20c85e9bc013a340de167151e7b5fa8c4 Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Wed, 11 May 2011 03:24:02 +0400 Subject: Bugfix #780784. KeyError when creating custom image. --- Authors | 1 + nova/virt/libvirt_conn.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Authors b/Authors index 60e1d2dad..72eb0b6ae 100644 --- a/Authors +++ b/Authors @@ -54,6 +54,7 @@ Mark Washenberger Masanori Itoh Matt Dietz Michael Gundlach +Mike Scherbakov Monsyne Dragon Monty Taylor MORITA Kazutaka diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 9780c69a6..71cedae54 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -456,7 +456,8 @@ class LibvirtConnection(driver.ComputeDriver): 'container_format': base['container_format'], 'is_public': False, 'name': '%s.%s' % (base['name'], image_id), - 'properties': {'architecture': base['architecture'], + 'properties': {'architecture': + base['properties']['architecture'], 'kernel_id': instance['kernel_id'], 'image_location': 'snapshot', 'image_state': 'available', -- cgit From 0a3da155228228d3f0eeac1efdea1e29eef2f3a0 Mon Sep 17 00:00:00 2001 From: John Tran Date: Thu, 12 May 2011 12:04:39 -0700 Subject: changed NotFound exception to ImageNotFound --- nova/api/ec2/cloud.py | 3 +-- nova/tests/test_cloud.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 8a54d23f2..ad8c3fe90 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -823,8 +823,7 @@ class CloudController(object): kwargs['ramdisk_id'] = ramdisk['id'] image = self._get_image(context, kwargs['image_id']) if not image: - raise exception.NotFound(_('Image %s not found') % - kwargs['image_id']) + raise exception.ImageNotFound(kwargs['image_id']) try: available = (image['properties']['image_state'] == 'available') except KeyError: diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 202dc36bc..ebfb5ee44 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -227,7 +227,7 @@ class CloudTestCase(test.TestCase): 'type': 'machine'}}] def fake_show_none(meh, context, id): - raise exception.NotFound + raise exception.ImageNotFound self.stubs.Set(local.LocalImageService, 'detail', fake_detail) # list all @@ -245,7 +245,7 @@ class CloudTestCase(test.TestCase): self.stubs.UnsetAll() self.stubs.Set(local.LocalImageService, 'show', fake_show_none) self.stubs.Set(local.LocalImageService, 'show_by_name', fake_show_none) - self.assertRaises(exception.NotFound, describe_images, + self.assertRaises(exception.ImageNotFound, describe_images, self.context, ['ami-fake']) def test_describe_image_attribute(self): -- cgit From 68e34c790612f3250bd902cc87a0ab9d3d69abfb Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Fri, 13 May 2011 15:36:42 -0500 Subject: first cut at weighted-sum tests --- nova/scheduler/zone_aware_scheduler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index b3d230bd2..38b395d52 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -89,6 +89,8 @@ class ZoneAwareScheduler(driver.Scheduler): # then weigh the selected hosts. # weighted = [{weight=weight, name=hostname}, ...] + # TODO(sirp): weigh_hosts should also be a function of 'topic' or + # resources, so that we can apply different objective functions to it weighted = self.weigh_hosts(num_instances, specs, host_list) # Next, tack on the best weights from the child zones ... -- cgit From f889f6c8a430d6411a81270a68025a27781b09a2 Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Sun, 15 May 2011 14:15:37 +0400 Subject: Unit test for snapshotting (creating custom image). --- nova/image/fake.py | 33 +++++++++++++++++++++------- nova/tests/test_virt.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 8 deletions(-) diff --git a/nova/image/fake.py b/nova/image/fake.py index b400b2adb..4bf25d9af 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -19,6 +19,7 @@ import copy import datetime +import random from nova import exception from nova import flags @@ -32,7 +33,7 @@ LOG = logging.getLogger('nova.image.fake') FLAGS = flags.FLAGS -class FakeImageService(service.BaseImageService): +class _FakeImageService(service.BaseImageService): """Mock (fake) image service for unit testing.""" def __init__(self): @@ -48,9 +49,10 @@ class FakeImageService(service.BaseImageService): 'container_format': 'ami', 'disk_format': 'raw', 'properties': {'kernel_id': FLAGS.null_kernel, - 'ramdisk_id': FLAGS.null_kernel}} + 'ramdisk_id': FLAGS.null_kernel, + 'architecture': 'x86_64'}} self.create(None, image) - super(FakeImageService, self).__init__() + super(_FakeImageService, self).__init__() def index(self, context): """Returns list of images.""" @@ -74,19 +76,28 @@ class FakeImageService(service.BaseImageService): image_id, self.images) raise exception.ImageNotFound(image_id=image_id) - def create(self, context, data): + def create(self, context, metadata, data=None): """Store the image data and return the new image id. :raises: Duplicate if the image already exist. """ - image_id = int(data['id']) + #image_id = int(metadata['id']) + # metadata['id'] may not exists, and since image_id is + # randomly generated in local.py, let us do the same here + try: + image_id = int(metadata['id']) + except: + image_id = random.randint(0, 2 ** 31 - 1) + if self.images.get(image_id): raise exception.Duplicate() - self.images[image_id] = copy.deepcopy(data) + metadata['id'] = image_id + self.images[image_id] = copy.deepcopy(metadata) + return self.images[image_id] - def update(self, context, image_id, data): + def update(self, context, image_id, metadata, data=None): """Replace the contents of the given image with the new data. :raises: ImageNotFound if the image does not exist. @@ -95,7 +106,7 @@ class FakeImageService(service.BaseImageService): image_id = int(image_id) if not self.images.get(image_id): raise exception.ImageNotFound(image_id=image_id) - self.images[image_id] = copy.deepcopy(data) + self.images[image_id] = copy.deepcopy(metadata) def delete(self, context, image_id): """Delete the given image. @@ -111,3 +122,9 @@ class FakeImageService(service.BaseImageService): def delete_all(self): """Clears out all images.""" self.images.clear() + +_fakeImageService = _FakeImageService() + + +def FakeImageService(): + return _fakeImageService diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 1311ba361..eb238e871 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -159,6 +159,7 @@ class LibvirtConnTestCase(test.TestCase): 'vcpus': 2, 'project_id': 'fake', 'bridge': 'br101', + 'image_id': '123456', 'instance_type_id': '5'} # m1.small def lazy_load_library_exists(self): @@ -279,6 +280,62 @@ class LibvirtConnTestCase(test.TestCase): instance_data = dict(self.test_instance) self._check_xml_and_container(instance_data) + def test_snapshot(self): + FLAGS.image_service = 'nova.image.fake.FakeImageService' + + # Only file-based instance storages are supported at the moment + test_xml = """ + + + + + + + + """ + + class FakeVirtDomain(object): + + def __init__(self): + pass + + def snapshotCreateXML(self, *args): + return None + + def XMLDesc(self, *args): + return test_xml + + def fake_lookup(instance_name): + if instance_name == instance_ref.name: + return FakeVirtDomain() + + def fake_execute(*args): + # Touch filename to pass 'with open(out_path)' + open(args[-1], "a").close() + + # Start test + image_service = utils.import_object(FLAGS.image_service) + + # Assuming that base image already exists in image_service + instance_ref = db.instance_create(self.context, self.test_instance) + properties = {'instance_id': instance_ref['id'], + 'user_id': str(self.context.user_id)} + sent_meta = {'name': 'test-snap', 'is_public': False, + 'properties': properties} + # Create new image. It will be updated in snapshot method + # To work with it from snapshot, the single image_service is needed + recv_meta = image_service.create(context, sent_meta) + + self.mox.StubOutWithMock(libvirt_conn.LibvirtConnection, '_conn') + libvirt_conn.LibvirtConnection._conn.lookupByName = fake_lookup + self.mox.StubOutWithMock(libvirt_conn.utils, 'execute') + libvirt_conn.utils.execute = fake_execute + + self.mox.ReplayAll() + + conn = libvirt_conn.LibvirtConnection(False) + conn.snapshot(instance_ref, recv_meta['id']) + def test_multi_nic(self): instance_data = dict(self.test_instance) network_info = _create_network_info(2) -- cgit From 818c2424a0547882fe6bdfe6613ee66a248d91db Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Sun, 15 May 2011 15:11:54 +0400 Subject: Define image state during snapshotting. Name snapshot to the name provided, not generate. --- nova/compute/api.py | 5 +++-- nova/tests/test_virt.py | 10 ++++++++-- nova/virt/libvirt_conn.py | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 63884be97..971c0732f 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -500,9 +500,10 @@ class API(base.Base): """ properties = {'instance_id': str(instance_id), - 'user_id': str(context.user_id)} + 'user_id': str(context.user_id), + 'image_state': 'creating'} sent_meta = {'name': name, 'is_public': False, - 'properties': properties} + 'status': 'creating', 'properties': properties} recv_meta = self.image_service.create(context, sent_meta) params = {'image_id': recv_meta['id']} self._cast_compute_message('snapshot_instance', context, instance_id, diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index eb238e871..c4fcc21cc 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -320,8 +320,9 @@ class LibvirtConnTestCase(test.TestCase): instance_ref = db.instance_create(self.context, self.test_instance) properties = {'instance_id': instance_ref['id'], 'user_id': str(self.context.user_id)} - sent_meta = {'name': 'test-snap', 'is_public': False, - 'properties': properties} + snapshot_name = 'test-snap' + sent_meta = {'name': snapshot_name, 'is_public': False, + 'status': 'creating', 'properties': properties} # Create new image. It will be updated in snapshot method # To work with it from snapshot, the single image_service is needed recv_meta = image_service.create(context, sent_meta) @@ -336,6 +337,11 @@ class LibvirtConnTestCase(test.TestCase): conn = libvirt_conn.LibvirtConnection(False) conn.snapshot(instance_ref, recv_meta['id']) + snapshot = image_service.show(context, recv_meta['id']) + self.assertEquals(snapshot['properties']['image_state'], 'available') + self.assertEquals(snapshot['status'], 'active') + self.assertEquals(snapshot['name'], snapshot_name) + def test_multi_nic(self): instance_data = dict(self.test_instance) network_info = _create_network_info(2) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 71cedae54..92d580314 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -451,11 +451,13 @@ class LibvirtConnection(driver.ComputeDriver): elevated = context.get_admin_context() base = image_service.show(elevated, instance['image_id']) + snapshot = image_service.show(elevated, image_id) metadata = {'disk_format': base['disk_format'], 'container_format': base['container_format'], 'is_public': False, - 'name': '%s.%s' % (base['name'], image_id), + 'status': 'active', + 'name': snapshot['name'], 'properties': {'architecture': base['properties']['architecture'], 'kernel_id': instance['kernel_id'], -- cgit From a4ea9ac61568ce5f8300a5ba138f0ac10c79b43c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 16 May 2011 15:59:01 -0700 Subject: fix for lp783705 - remove nwfilters when instance is terminated --- nova/tests/test_virt.py | 42 ++++++++++++++++++++++++++++++++++++++++++ nova/virt/libvirt_conn.py | 27 +++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 1311ba361..babb5de9b 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -1045,3 +1045,45 @@ class NWFilterTestCase(test.TestCase): network_info, "fake") self.assertEquals(len(result), 3) + + def test_unfilter_instance_undefines_nwfilters(self): + class FakeNWFilter: + def __init__(self): + self.undefine_call_count = 0 + + def undefine(self): + self.undefine_call_count += 1 + pass + + fakefilter = FakeNWFilter() + + def _nwfilterLookupByName(ignore): + return fakefilter + + def _filterDefineXMLMock(xml): + return True + + admin_ctxt = context.get_admin_context() + + self.fw._conn.nwfilterDefineXML = _filterDefineXMLMock + self.fw._conn.nwfilterLookupByName = _nwfilterLookupByName + + instance_ref = self._create_instance() + inst_id = instance_ref['id'] + instance = db.instance_get(self.context, inst_id) + + ip = '10.11.12.13' + network_ref = db.project_get_network(self.context, 'fake') + fixed_ip = {'address': ip, 'network_id': network_ref['id']} + db.fixed_ip_create(admin_ctxt, fixed_ip) + db.fixed_ip_update(admin_ctxt, ip, {'allocated': True, + 'instance_id': inst_id}) + self.fw.setup_basic_filtering(instance) + self.fw.prepare_instance_filter(instance) + self.fw.apply_instance_filter(instance) + self.fw.unfilter_instance(instance) + + # should attempt to undefine 2 filters: instance and instance-secgroup + self.assertEquals(fakefilter.undefine_call_count, 2) + + db.instance_destroy(admin_ctxt, instance_ref['id']) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 555e44ce2..706973176 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -1835,8 +1835,30 @@ class NWFilterFirewall(FirewallDriver): tpool.execute(self._conn.nwfilterDefineXML, xml) def unfilter_instance(self, instance): - # Nothing to do - pass + """Clear out the nwfilter rules.""" + network_info = _get_network_info(instance) + instance_name = instance.name + for (network, mapping) in network_info: + nic_id = mapping['mac'].replace(':', '') + instance_filter_name = self._instance_filter_name(instance, nic_id) + + try: + self._conn.nwfilterLookupByName(instance_filter_name).\ + undefine() + except libvirt.libvirtError: + LOG.debug(_('The nwfilter(%(instance_filter_name)s) for ' + '%(instance_name)s is not found.') % locals()) + + instance_secgroup_filter_name =\ + '%s-secgroup' % (self._instance_filter_name(instance)) + + try: + self._conn.nwfilterLookupByName(instance_secgroup_filter_name).\ + undefine() + except libvirt.libvirtError: + # This will happen if called by IptablesFirewallDriver + LOG.debug(_('The nwfilter(%(instance_secgroup_filter_name)s) for ' + '%(instance_name)s is not found.') % locals()) def prepare_instance_filter(self, instance, network_info=None): """ @@ -2000,6 +2022,7 @@ class IptablesFirewallDriver(FirewallDriver): if self.instances.pop(instance['id'], None): self.remove_filters_for_instance(instance) self.iptables.apply() + self.nwfilter.unfilter_instance(instance) else: LOG.info(_('Attempted to unfilter instance %s which is not ' 'filtered'), instance['id']) -- cgit From e96b904fea71159a43afdd28af9f6a5921af0418 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Mon, 16 May 2011 18:09:26 -0500 Subject: MySQL database tables are using the MyISAM engine. Created migration script to change all current tables to InnoDB. --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 546c9091f..b17c4f63e 100644 --- a/Authors +++ b/Authors @@ -28,6 +28,7 @@ Gabe Westmaas Hisaharu Ishii Hisaki Ohara Ilya Alekseyev +Jason Cannavale Jason Koelker Jay Pipes Jesse Andrews -- cgit From 2b5652b4ec191d3f31ce35684f0dd86f033416c2 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Mon, 16 May 2011 18:13:08 -0500 Subject: MySQL database tables are using the MyISAM engine. Created migration script to change all current tables to InnoDB. --- .../versions/017_set_engine_mysql_innodb.py | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py new file mode 100644 index 000000000..be7ff5abd --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py @@ -0,0 +1,57 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import MetaData, Table + +meta = MetaData() + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + if migrate_engine.name == "mysql": + migrate_engine.execute("ALTER TABLE auth_tokens Engine=InnoDB") + migrate_engine.execute("ALTER TABLE certificates Engine=InnoDB") + migrate_engine.execute("ALTER TABLE compute_nodes Engine=InnoDB") + migrate_engine.execute("ALTER TABLE console_pools Engine=InnoDB") + migrate_engine.execute("ALTER TABLE consoles Engine=InnoDB") + migrate_engine.execute("ALTER TABLE export_devices Engine=InnoDB") + migrate_engine.execute("ALTER TABLE fixed_ips Engine=InnoDB") + migrate_engine.execute("ALTER TABLE floating_ips Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_actions Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_metadata Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_types Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instances Engine=InnoDB") + migrate_engine.execute("ALTER TABLE iscsi_targets Engine=InnoDB") + migrate_engine.execute("ALTER TABLE key_pairs Engine=InnoDB") + migrate_engine.execute("ALTER TABLE migrate_version Engine=InnoDB") + migrate_engine.execute("ALTER TABLE migrations Engine=InnoDB") + migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") + migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") + migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") + migrate_engine.execute("ALTER TABLE services Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE users Engine=InnoDB") + migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") + migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") + +def downgrade(migrate_engine): + meta.bind = migrate_engine -- cgit From 0e2aba9e9869a66a1c3a6ece0fb08be631daa5bf Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Tue, 17 May 2011 17:38:44 +0400 Subject: Moved memcached connection in AuthManager to thread-local storage. Added caching of LDAP connection in thread-local storage. Optimized LDAP queries, added similar memcached support to LDAPDriver. Add "per-driver-request" caching of LDAP results. (should be per-api-request) --- nova/auth/ldapdriver.py | 93 ++++++++++++++++++++++++++++++++++++++++++++----- nova/auth/manager.py | 20 +++++++---- 2 files changed, 98 insertions(+), 15 deletions(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 3f8432851..7849d941e 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -24,7 +24,9 @@ other backends by creating another class that exposes the same public methods. """ +import functools import sys +import threading from nova import exception from nova import flags @@ -85,6 +87,7 @@ def _clean(attr): def sanitize(fn): """Decorator to sanitize all args""" + @functools.wraps(fn) def _wrapped(self, *args, **kwargs): args = [_clean(x) for x in args] kwargs = dict((k, _clean(v)) for (k, v) in kwargs) @@ -103,29 +106,74 @@ class LdapDriver(object): isadmin_attribute = 'isNovaAdmin' project_attribute = 'owner' project_objectclass = 'groupOfNames' + __local = threading.local() def __init__(self): """Imports the LDAP module""" self.ldap = __import__('ldap') - self.conn = None if FLAGS.ldap_schema_version == 1: LdapDriver.project_pattern = '(objectclass=novaProject)' LdapDriver.isadmin_attribute = 'isAdmin' LdapDriver.project_attribute = 'projectManager' LdapDriver.project_objectclass = 'novaProject' + self.__cache = None def __enter__(self): """Creates the connection to LDAP""" - self.conn = self.ldap.initialize(FLAGS.ldap_url) - self.conn.simple_bind_s(FLAGS.ldap_user_dn, FLAGS.ldap_password) + # TODO(yorik-sar): Should be per-request cache, not per-driver-request + self.__cache = {} return self def __exit__(self, exc_type, exc_value, traceback): """Destroys the connection to LDAP""" - self.conn.unbind_s() + self.__cache = None return False + def __local_cache(key_fmt): + """Wrap function to cache it's result in self.__cache. + Works only with functions with one fixed argument. + """ + def do_wrap(fn): + @functools.wraps(fn) + def inner(self, arg, **kwargs): + cache_key = key_fmt % (arg,) + try: + res = self.__cache[cache_key] + LOG.debug('Local cache hit for %s by key %s' % + (fn.__name__, cache_key)) + return res + except KeyError: + res = fn(self, arg, **kwargs) + self.__cache[cache_key] = res + return res + return inner + return do_wrap + + @property + def conn(self): + try: + return self.__local.conn + except AttributeError: + conn = self.ldap.initialize(FLAGS.ldap_url) + conn.simple_bind_s(FLAGS.ldap_user_dn, FLAGS.ldap_password) + self.__local.conn = conn + return conn + + @property + def mc(self): + try: + return self.__local.mc + except AttributeError: + if FLAGS.memcached_servers: + import memcache + else: + from nova import fakememcache as memcache + mc = memcache.Client(FLAGS.memcached_servers, debug=0) + self.__local.mc = mc + return mc + @sanitize + @__local_cache('uid_user-%s') def get_user(self, uid): """Retrieve user by id""" attr = self.__get_ldap_user(uid) @@ -134,15 +182,30 @@ class LdapDriver(object): @sanitize def get_user_from_access_key(self, access): """Retrieve user by access key""" + cache_key = 'uak_dn_%s'%(access,) + user_dn = self.mc.get(cache_key) + if user_dn: + user = self.__to_user( + self.__find_object(user_dn, scope=self.ldap.SCOPE_BASE)) + if user: + if user['access'] == access: + return user + else: + self.mc.set(cache_key, None) query = '(accessKey=%s)' % access dn = FLAGS.ldap_user_subtree - return self.__to_user(self.__find_object(dn, query)) + user_obj = self.__find_object(dn, query) + user = self.__to_user(user_obj) + if user: + self.mc.set(cache_key, user_obj['dn'][0]) + return user @sanitize + @__local_cache('pid_project-%s') def get_project(self, pid): """Retrieve project by id""" - dn = self.__project_to_dn(pid) - attr = self.__find_object(dn, LdapDriver.project_pattern) + dn = self.__project_to_dn(pid, search=False) + attr = self.__find_object(dn, LdapDriver.project_pattern, scope=self.ldap.SCOPE_BASE) return self.__to_project(attr) @sanitize @@ -395,6 +458,7 @@ class LdapDriver(object): """Check if project exists""" return self.get_project(project_id) is not None + @__local_cache('uid_attrs-%s') def __get_ldap_user(self, uid): """Retrieve LDAP user entry by id""" dn = FLAGS.ldap_user_subtree @@ -426,12 +490,20 @@ class LdapDriver(object): if scope is None: # One of the flags is 0! scope = self.ldap.SCOPE_SUBTREE + if query is None: + query = "(objectClass=*)" try: res = self.conn.search_s(dn, scope, query) except self.ldap.NO_SUCH_OBJECT: return [] # Just return the attributes - return [attributes for dn, attributes in res] + # FIXME(yorik-sar): Whole driver should be refactored to + # prevent this hack + res1 = [] + for dn, attrs in res: + attrs['dn'] = [dn] + res1.append(attrs) + return res1 def __find_role_dns(self, tree): """Find dns of role objects in given tree""" @@ -564,6 +636,7 @@ class LdapDriver(object): 'description': attr.get('description', [None])[0], 'member_ids': [self.__dn_to_uid(x) for x in member_dns]} + @__local_cache('uid_dn-%s') def __uid_to_dn(self, uid, search=True): """Convert uid to dn""" # By default return a generated DN @@ -576,6 +649,7 @@ class LdapDriver(object): userdn = user[0] return userdn + @__local_cache('pid_dn-%s') def __project_to_dn(self, pid, search=True): """Convert pid to dn""" # By default return a generated DN @@ -603,10 +677,11 @@ class LdapDriver(object): else: return None + @__local_cache('dn_uid-%s') def __dn_to_uid(self, dn): """Convert user dn to uid""" query = '(objectclass=novaUser)' - user = self.__find_object(dn, query) + user = self.__find_object(dn, query, scope=self.ldap.SCOPE_BASE) return user[FLAGS.ldap_user_id_attribute][0] diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 07235a2a7..c71f0f161 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -23,6 +23,7 @@ Nova authentication management import os import shutil import string # pylint: disable=W0402 +import threading import tempfile import uuid import zipfile @@ -206,6 +207,7 @@ class AuthManager(object): """ _instance = None + __local = threading.local() def __new__(cls, *args, **kwargs): """Returns the AuthManager singleton""" @@ -223,12 +225,18 @@ class AuthManager(object): if driver or not getattr(self, 'driver', None): self.driver = utils.import_class(driver or FLAGS.auth_driver) - if FLAGS.memcached_servers: - import memcache - else: - from nova import fakememcache as memcache - self.mc = memcache.Client(FLAGS.memcached_servers, - debug=0) + @property + def mc(self): + try: + return self.__local.mc + except AttributeError: + if FLAGS.memcached_servers: + import memcache + else: + from nova import fakememcache as memcache + mc = memcache.Client(FLAGS.memcached_servers, debug=0) + self.__local.mc = mc + return mc def authenticate(self, access, signature, params, verb='GET', server_string='127.0.0.1:8773', path='/', -- cgit From e4f8ef67065f1de36ceadf9dd97e07fbe9fc9d83 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Tue, 17 May 2011 17:39:19 +0400 Subject: Fixed mistyped key, caused huge performance leak. --- nova/flags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/flags.py b/nova/flags.py index 519793643..5c536f6d8 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -110,7 +110,7 @@ class FlagValues(gflags.FlagValues): return name in self.__dict__['__dirty'] def ClearDirty(self): - self.__dict__['__is_dirty'] = [] + self.__dict__['__dirty'] = [] def WasAlreadyParsed(self): return self.__dict__['__was_already_parsed'] -- cgit From 2fcc10656222bea6056742ef943c1b82724c0b56 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Tue, 17 May 2011 17:45:48 +0400 Subject: PEP8 fixes. --- nova/auth/ldapdriver.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 7849d941e..9fe0165a1 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -182,7 +182,7 @@ class LdapDriver(object): @sanitize def get_user_from_access_key(self, access): """Retrieve user by access key""" - cache_key = 'uak_dn_%s'%(access,) + cache_key = 'uak_dn_%s' % (access,) user_dn = self.mc.get(cache_key) if user_dn: user = self.__to_user( @@ -205,7 +205,8 @@ class LdapDriver(object): def get_project(self, pid): """Retrieve project by id""" dn = self.__project_to_dn(pid, search=False) - attr = self.__find_object(dn, LdapDriver.project_pattern, scope=self.ldap.SCOPE_BASE) + attr = self.__find_object(dn, LdapDriver.project_pattern, + scope=self.ldap.SCOPE_BASE) return self.__to_project(attr) @sanitize -- cgit From 23bbbfcd3317859d44dba7da7996a978ad922543 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 10:45:19 -0500 Subject: First cut at least cost scheduler --- nova/scheduler/least_cost.py | 79 +++++++++++++++++++++++++++++++++ nova/tests/test_least_cost_scheduler.py | 39 ++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 nova/scheduler/least_cost.py create mode 100644 nova/tests/test_least_cost_scheduler.py diff --git a/nova/scheduler/least_cost.py b/nova/scheduler/least_cost.py new file mode 100644 index 000000000..75dde81ca --- /dev/null +++ b/nova/scheduler/least_cost.py @@ -0,0 +1,79 @@ +import collections + +# TODO(sirp): this should be just `zone_aware` to match naming scheme +# TODO(sirp): perhaps all zone-aware stuff should go under a `zone_aware` +# module +from nova.scheduler import zone_aware_scheduler + +class LeastCostScheduler(zone_aware_scheduler.ZoneAwareScheduler): + def get_cost_fns(self): + """Returns a list of tuples containing weights and cost functions to + use for weighing hosts + """ + cost_fns = [] + + return cost_fns + + def weigh_hosts(self, num, specs, hosts): + """ + Returns a list of dictionaries of form: + [ {weight: weight, hostname: hostname} ] + """ + # FIXME(sirp): weigh_hosts should handle more than just instances + cost_fns = [] + hosts = [] + cost_hosts = weighted_sum(domain=hosts, weighted_fns=self.get_cost_fns()) + + # TODO convert hosts back to hostnames + weight_hostnames = [] + return weight_hostnames + +def normalize_list(L): + """Normalize an array of numbers such that each element satisfies: + 0 <= e <= 1 + """ + if not L: + return L + max_ = max(L) + if max_ > 0: + return [(float(e) / max_) for e in L] + return L + +def weighted_sum(domain, weighted_fns, normalize=True): + """ + Use the weighted-sum method to compute a score for an array of objects. + Normalize the results of the objective-functions so that the weights are + meaningful regardless of objective-function's range. + + domain - input to be scored + weighted_fns - list of weights and functions like: + [(weight, objective-functions)] + + Returns an unsorted list like: [(score, elem)] + """ + # Table of form: + # { domain1: [score1, score2, ..., scoreM] + # ... + # domainN: [score1, score2, ..., scoreM] } + score_table = collections.defaultdict(list) + + for weight, fn in weighted_fns: + scores = [fn(elem) for elem in domain] + + if normalize: + norm_scores = normalize_list(scores) + else: + norm_scores = scores + + for idx, score in enumerate(norm_scores): + weighted_score = score * weight + score_table[idx].append(weighted_score) + + # Sum rows in table to compute score for each element in domain + domain_scores = [] + for idx in sorted(score_table): + elem_score = sum(score_table[idx]) + elem = domain[idx] + domain_scores.append(elem_score) + + return domain_scores diff --git a/nova/tests/test_least_cost_scheduler.py b/nova/tests/test_least_cost_scheduler.py new file mode 100644 index 000000000..a3a18a09f --- /dev/null +++ b/nova/tests/test_least_cost_scheduler.py @@ -0,0 +1,39 @@ +from nova import test +from nova.scheduler import least_cost + +MB = 1024 * 1024 + +class FakeHost(object): + def __init__(self, host_id, free_ram, io): + self.id = host_id + self.free_ram = free_ram + self.io = io + +class WeightedSumTest(test.TestCase): + def test_empty_domain(self): + domain = [] + weighted_fns = [] + result = least_cost.weighted_sum(domain, weighted_fns) + expected = [] + self.assertEqual(expected, result) + + def test_basic_costing(self): + hosts = [ + FakeHost(1, 512 * MB, 100), + FakeHost(2, 256 * MB, 400), + FakeHost(3, 512 * MB, 100) + ] + + weighted_fns = [ + (1, lambda h: h.free_ram), # Fill-first, free_ram is a *cost* + (2, lambda h: h.io), # Avoid high I/O + ] + + costs = least_cost.weighted_sum(domain=hosts, weighted_fns=weighted_fns) + + # Each 256 MB unit of free-ram contributes 0.5 points by way of: + # cost = weight * (score/max_score) = 1 * (256/512) = 0.5 + # Each 100 iops of IO adds 0.5 points by way of: + # cost = 2 * (100/400) = 2 * 0.25 = 0.5 + expected = [1.5, 2.5, 1.5] + self.assertEqual(expected, costs) -- cgit From a4035df4d031d3d90f3f7ce938ff0b8305be6773 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 17:27:04 -0500 Subject: Adding fill first cost function --- nova/scheduler/least_cost.py | 12 ++++++++++++ nova/test.py | 16 +++++++++++++--- nova/tests/test_least_cost_scheduler.py | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/nova/scheduler/least_cost.py b/nova/scheduler/least_cost.py index e47951f17..79376c358 100644 --- a/nova/scheduler/least_cost.py +++ b/nova/scheduler/least_cost.py @@ -34,6 +34,8 @@ flags.DEFINE_list('least_cost_scheduler_cost_functions', 'Which cost functions the LeastCostScheduler should use.') +# TODO(sirp): Once we have enough of these rules, we can break them out into a +# cost_functions.py file (perhaps in a least_cost_scheduler directory) flags.DEFINE_integer('noop_cost_fn_weight', 1, 'How much weight to give the noop cost function') def noop_cost_fn(host): @@ -41,6 +43,16 @@ def noop_cost_fn(host): return 1 +flags.DEFINE_integer('fill_first_cost_fn_weight', 1, + 'How much weight to give the fill-first cost function') +def fill_first_cost_fn(host): + """Prefer hosts that have less ram available, filter_hosts will exclude + hosts that don't have enough ram""" + hostname, caps = host + free_mem = caps['compute']['host_memory_free'] + return free_mem + + class LeastCostScheduler(zone_aware_scheduler.ZoneAwareScheduler): def get_cost_fns(self): """Returns a list of tuples containing weights and cost functions to diff --git a/nova/test.py b/nova/test.py index 4deb2a175..401f82d38 100644 --- a/nova/test.py +++ b/nova/test.py @@ -181,7 +181,7 @@ class TestCase(unittest.TestCase): wsgi.Server.start = _wrapped_start # Useful assertions - def assertDictMatch(self, d1, d2): + def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001): """Assert two dicts are equivalent. This is a 'deep' match in the sense that it handles nested @@ -212,15 +212,24 @@ class TestCase(unittest.TestCase): for key in d1keys: d1value = d1[key] d2value = d2[key] + + try: + within_tolerance = abs(float(d1value) - float(d2value)) < tolerance + except ValueError: + # If both values aren't convertable to float, just ignore + within_tolerance = False + if hasattr(d1value, 'keys') and hasattr(d2value, 'keys'): self.assertDictMatch(d1value, d2value) elif 'DONTCARE' in (d1value, d2value): continue + elif approx_equal and within_tolerance: + continue elif d1value != d2value: raise_assertion("d1['%(key)s']=%(d1value)s != " "d2['%(key)s']=%(d2value)s" % locals()) - def assertDictListMatch(self, L1, L2): + def assertDictListMatch(self, L1, L2, approx_equal=False, tolerance=0.001): """Assert a list of dicts are equivalent.""" def raise_assertion(msg): L1str = str(L1) @@ -236,4 +245,5 @@ class TestCase(unittest.TestCase): 'len(L2)=%(L2count)d' % locals()) for d1, d2 in zip(L1, L2): - self.assertDictMatch(d1, d2) + self.assertDictMatch(d1, d2, approx_equal=approx_equal, + tolerance=tolerance) diff --git a/nova/tests/test_least_cost_scheduler.py b/nova/tests/test_least_cost_scheduler.py index b2318a3bf..b7bcd2f02 100644 --- a/nova/tests/test_least_cost_scheduler.py +++ b/nova/tests/test_least_cost_scheduler.py @@ -119,7 +119,7 @@ class LeastCostSchedulerTestCase(test.TestCase): def assertWeights(self, expected, num, request_spec, hosts): weighted = self.sched.weigh_hosts(num, request_spec, hosts) - self.assertDictListMatch(weighted, expected) + self.assertDictListMatch(weighted, expected, approx_equal=True) def test_no_hosts(self): num = 1 @@ -137,12 +137,41 @@ class LeastCostSchedulerTestCase(test.TestCase): num = 1 request_spec = {} - hosts = self.sched.filter_hosts(num, request_spec) expected = [ dict(weight=1, hostname=hostname) for hostname, caps in hosts] self.assertWeights(expected, num, request_spec, hosts) + def test_cost_fn_weights(self): + FLAGS.least_cost_scheduler_cost_functions = [ + 'nova.scheduler.least_cost.noop_cost_fn' + ] FLAGS.noop_cost_fn_weight = 2 + + num = 1 + request_spec = {} + hosts = self.sched.filter_hosts(num, request_spec) + expected = [ dict(weight=2, hostname=hostname) for hostname, caps in hosts] self.assertWeights(expected, num, request_spec, hosts) + + def test_fill_first_cost_fn(self): + FLAGS.least_cost_scheduler_cost_functions = [ + 'nova.scheduler.least_cost.fill_first_cost_fn' + ] + FLAGS.fill_first_cost_fn_weight = 1 + + num = 1 + request_spec = {} + hosts = self.sched.filter_hosts(num, request_spec) + + expected = [] + for idx, (hostname, caps) in enumerate(hosts): + # Costs are normalized so over 10 hosts, each host with increasing + # free ram will cost 1/N more. Since the lowest cost host has some + # free ram, we add in the 1/N for the base_cost + weight = 0.1 + (0.1 * idx) + weight_dict = dict(weight=weight, hostname=hostname) + expected.append(weight_dict) + + self.assertWeights(expected, num, request_spec, hosts) -- cgit From d6fbe417d7f8f7540cffe8c941c0591a22483978 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 17:44:08 -0500 Subject: Using import_class to import filter_host driver --- nova/scheduler/host_filter.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index 7cb41a433..117f08242 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -42,6 +42,7 @@ from nova import exception from nova import flags from nova import log as logging from nova.scheduler import zone_aware_scheduler +from nova import utils LOG = logging.getLogger('nova.scheduler.host_filter') @@ -283,11 +284,13 @@ def choose_driver(driver_name=None): if not driver_name: driver_name = FLAGS.default_host_filter_driver - # FIXME(sirp): use utils.import_class here - for driver in DRIVERS: - if "%s.%s" % (driver.__module__, driver.__name__) == driver_name: - return driver() - raise exception.SchedulerHostFilterDriverNotFound(driver_name=driver_name) + + try: + driver = utils.import_object(driver_name) + return driver + except exception.ClassNotFound: + raise exception.SchedulerHostFilterDriverNotFound( + driver_name=driver_name) class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): -- cgit From 41ea2f4babc474cad64d81c9c95cf02e399a0a64 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 17 May 2011 18:57:00 -0400 Subject: added util functions to get image service --- nova/utils.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/nova/utils.py b/nova/utils.py index 361fc9873..e7ce0a79b 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -724,3 +724,51 @@ def parse_server_string(server_str): except: LOG.debug(_('Invalid server_string: %s' % server_str)) return ('', '') + + +def parse_image_ref(image_ref): + """ + Parse an imageRef and return (id, host, port) + + If the image_ref passed in is an integer, it will + return (image_ref, None, None), otherwise it will + return (id, host, port) + + image_ref - imageRef for an image + + """ + + if is_int(image_ref): + return (image_ref, None, None) + + o = urlparse(image_ref) + # Default to port 80 if not passed, should this be 9292? + port = o.port or 80 + host = o.netloc.split(':', 1)[0] + id = o.path.split('/')[-1] + + return (id, host, port) + + +def get_image_service(image_ref): + """ + Get the proper image_service for an image_id + + image_ref - image ref/id for an image + """ + + (image_id, host, port) = parse_image_ref(image_ref) + + image_service = None + + if host: + GlanceImageService = utils.import_class(FLAGS.glance_image_service) + GlanceClient = utils.import_class('glance.client.Client') + + glance_client = GlanceClient(host, port) + image_service = GlanceImageService(glance_client) + else: + ImageService = utils.import_class(FLAGS.image_service) + image_service = ImageService() + + return (image_id, image_service) -- cgit From 5d35b548316eccd5a8454ccf7424ebe60aaf54e6 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 17 May 2011 19:07:44 -0400 Subject: updates to utils methods, initial usage in images.py --- nova/api/openstack/images.py | 14 ++++++-------- nova/utils.py | 10 +++++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 34d4c27fc..8d796c284 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -82,15 +82,12 @@ class Controller(common.OpenstackController): :param id: Image identifier (integer) """ context = req.environ['nova.context'] + image_id = id try: - image_id = int(id) - except ValueError: - explanation = _("Image not found.") - raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) - - try: - image = self._image_service.show(context, image_id) + (image_service, service_image_id) = utils.get_image_service( + image_id) + image = image_service.show(context, service_image_id) except exception.NotFound: explanation = _("Image '%d' not found.") % (image_id) raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) @@ -105,7 +102,8 @@ class Controller(common.OpenstackController): """ image_id = id context = req.environ['nova.context'] - self._image_service.delete(context, image_id) + (image_service, service_image_id) = utils.get_image_service(image_id) + image_service.delete(context, service_image_id) return webob.exc.HTTPNoContent() def create(self, req): diff --git a/nova/utils.py b/nova/utils.py index e7ce0a79b..c7da95a97 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -750,12 +750,17 @@ def parse_image_ref(image_ref): return (id, host, port) -def get_image_service(image_ref): +def get_image_service(image_ref=None): """ Get the proper image_service for an image_id + Returns (image_service, image_id) image_ref - image ref/id for an image """ + ImageService = utils.import_class(FLAGS.image_service) + + if not image_ref: + return (ImageService(), -1) (image_id, host, port) = parse_image_ref(image_ref) @@ -768,7 +773,6 @@ def get_image_service(image_ref): glance_client = GlanceClient(host, port) image_service = GlanceImageService(glance_client) else: - ImageService = utils.import_class(FLAGS.image_service) image_service = ImageService() - return (image_id, image_service) + return (image_service, id) -- cgit From dacb4899ea631840fd95ee0bd25d999fbb16b8b4 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 17 May 2011 19:10:11 -0400 Subject: use utils.get_image_service in compute_api --- nova/compute/api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index a12f8d515..930e4efaa 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -156,7 +156,8 @@ class API(base.Base): self._check_metadata_properties_quota(context, metadata) self._check_injected_file_quota(context, injected_files) - image = self.image_service.show(context, image_id) + (image_service, service_image_id) = utils.get_image_service(image_id) + image = image_service.show(context, service_image_id) os_type = None if 'properties' in image and 'os_type' in image['properties']: @@ -176,9 +177,9 @@ class API(base.Base): logging.debug("Using Kernel=%s, Ramdisk=%s" % (kernel_id, ramdisk_id)) if kernel_id: - self.image_service.show(context, kernel_id) + image_service.show(context, kernel_id) if ramdisk_id: - self.image_service.show(context, ramdisk_id) + image_service.show(context, ramdisk_id) if security_group is None: security_group = ['default'] @@ -515,6 +516,8 @@ class API(base.Base): 'user_id': str(context.user_id)} sent_meta = {'name': name, 'is_public': False, 'properties': properties} + # TODO(wwolf): not sure if we need to use + # utils.get_image_service() here ? recv_meta = self.image_service.create(context, sent_meta) params = {'image_id': recv_meta['id']} self._cast_compute_message('snapshot_instance', context, instance_id, -- cgit From eacb354c159aeb8f428232eb7d678ffb60bb73cd Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 17 May 2011 19:14:35 -0400 Subject: made get_image_service calls in servers.py --- nova/api/openstack/servers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 8f2de2afe..bf0f56373 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -142,7 +142,10 @@ class Controller(common.OpenstackController): requested_image_id = self._image_id_from_req_data(env) try: - image_id = common.get_image_id_from_image_hash(self._image_service, + (image_service, service_image_id) = utils.get_image_service( + requested_image_id) + + image_id = common.get_image_id_from_image_hash(image_service, context, requested_image_id) except: msg = _("Can not find requested image") @@ -556,7 +559,8 @@ class Controller(common.OpenstackController): associated kernel and ramdisk image IDs. """ context = req.environ['nova.context'] - image_meta = self._image_service.show(context, image_id) + (image_service, service_image_id) = utils.get_image_service(image_id) + image_meta = image_service.show(context, service_image_id) # NOTE(sirp): extracted to a separate method to aid unit-testing, the # new method doesn't need a request obj or an ImageService stub kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( -- cgit From 439787e7588b2409f319f2d86a41a3581cff8861 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 18:15:31 -0500 Subject: Pep8 fixes --- nova/exception.py | 3 +++ nova/scheduler/least_cost.py | 30 +++++++++++++++++++++--------- nova/scheduler/zone_aware_scheduler.py | 11 ++++++----- nova/test.py | 5 +++-- nova/tests/test_least_cost_scheduler.py | 18 +++++++++++------- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/nova/exception.py b/nova/exception.py index 63ed6dd5e..16c443c61 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -460,15 +460,18 @@ class FlavorNotFound(NotFound): class ZoneNotFound(NotFound): message = _("Zone %(zone_id)s could not be found.") + # TODO(sirp): move these into the schedule classes since they are internal? class SchedulerHostFilterDriverNotFound(NotFound): message = _("Scheduler Host Filter Driver %(driver_name)s could" " not be found.") + class SchedulerCostFunctionNotFound(NotFound): message = _("Scheduler cost function %(cost_fn_str)s could" " not be found.") + class SchedulerWeightFlagNotFound(NotFound): message = _("Scheduler weight flag not found: %(flag_name)s") diff --git a/nova/scheduler/least_cost.py b/nova/scheduler/least_cost.py index 79376c358..629fe2e42 100644 --- a/nova/scheduler/least_cost.py +++ b/nova/scheduler/least_cost.py @@ -13,16 +13,19 @@ # License for the specific language governing permissions and limitations # under the License. """ -Helpful docstring here +Least Cost Scheduler is a mechanism for choosing which host machines to +provision a set of resources to. The input of the least-cost-scheduler is a +set of objective-functions, called the 'cost-functions', a weight for each +cost-function, and a list of candidate hosts (gathered via FilterHosts). + +The cost-function and weights are tabulated, and the host with the least cost +is then selected for provisioning. """ import collections from nova import flags from nova import log as logging -# TODO(sirp): this should be just `zone_aware` to match naming scheme -# TODO(sirp): perhaps all zone-aware stuff should go under a `zone_aware` -# module from nova.scheduler import zone_aware_scheduler from nova import utils @@ -38,6 +41,8 @@ flags.DEFINE_list('least_cost_scheduler_cost_functions', # cost_functions.py file (perhaps in a least_cost_scheduler directory) flags.DEFINE_integer('noop_cost_fn_weight', 1, 'How much weight to give the noop cost function') + + def noop_cost_fn(host): """Return a pre-weight cost of 1 for each host""" return 1 @@ -45,6 +50,8 @@ def noop_cost_fn(host): flags.DEFINE_integer('fill_first_cost_fn_weight', 1, 'How much weight to give the fill-first cost function') + + def fill_first_cost_fn(host): """Prefer hosts that have less ram available, filter_hosts will exclude hosts that don't have enough ram""" @@ -68,7 +75,7 @@ class LeastCostScheduler(zone_aware_scheduler.ZoneAwareScheduler): except exception.ClassNotFound: raise exception.SchedulerCostFunctionNotFound( cost_fn_str=cost_fn_str) - + try: weight = getattr(FLAGS, "%s_weight" % cost_fn.__name__) except AttributeError: @@ -82,17 +89,22 @@ class LeastCostScheduler(zone_aware_scheduler.ZoneAwareScheduler): def weigh_hosts(self, num, request_spec, hosts): """Returns a list of dictionaries of form: [ {weight: weight, hostname: hostname} ]""" + # FIXME(sirp): weigh_hosts should handle more than just instances - hostnames = [hostname for hostname, _ in hosts] + hostnames = [hostname for hostname, caps in hosts] cost_fns = self.get_cost_fns() costs = weighted_sum(domain=hosts, weighted_fns=cost_fns) - + weighted = [] + weight_log = [] for cost, hostname in zip(costs, hostnames): + weight_log.append("%s: %s" % (hostname, "%.2f" % cost)) weight_dict = dict(weight=cost, hostname=hostname) weighted.append(weight_dict) - return weighted + + LOG.debug(_("Weighted Costs => %s") % weight_log) + return weighted def normalize_list(L): @@ -110,7 +122,7 @@ def weighted_sum(domain, weighted_fns, normalize=True): """Use the weighted-sum method to compute a score for an array of objects. Normalize the results of the objective-functions so that the weights are meaningful regardless of objective-function's range. - + domain - input to be scored weighted_fns - list of weights and functions like: [(weight, objective-functions)] diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index fa5b3b1b6..a1a68ce5e 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -80,7 +80,7 @@ class ZoneAwareScheduler(driver.Scheduler): LOG.debug(_("Casted to compute %(host)s for run_instance") % locals()) else: - # TODO(sandy) Provision in child zone ... + # TODO(sandy) Provision in child zone ... LOG.warning(_("Provision to Child Zone not supported (yet)") % locals()) pass @@ -117,11 +117,11 @@ class ZoneAwareScheduler(driver.Scheduler): # Filter local hosts based on requirements ... host_list = self.filter_hosts(num_instances, request_spec) - # then weigh the selected hosts. - # weighted = [{weight=weight, name=hostname}, ...] - # TODO(sirp): weigh_hosts should also be a function of 'topic' or # resources, so that we can apply different objective functions to it + + # then weigh the selected hosts. + # weighted = [{weight=weight, name=hostname}, ...] weighted = self.weigh_hosts(num_instances, request_spec, host_list) # Next, tack on the best weights from the child zones ... @@ -145,8 +145,9 @@ class ZoneAwareScheduler(driver.Scheduler): """Derived classes must override this method and return a list of hosts in [(hostname, capability_dict)] format.""" # NOTE(sirp): The default logic is the equivalent to AllHostsFilter + service_states = self.zone_manager.service_states return [(host, services) - for host, services in self.zone_manager.service_states.iteritems()] + for host, services in service_states.iteritems()] def weigh_hosts(self, num, request_spec, hosts): """Derived classes may override this to provide more sophisticated diff --git a/nova/test.py b/nova/test.py index 401f82d38..00a16dd68 100644 --- a/nova/test.py +++ b/nova/test.py @@ -212,9 +212,10 @@ class TestCase(unittest.TestCase): for key in d1keys: d1value = d1[key] d2value = d2[key] - + try: - within_tolerance = abs(float(d1value) - float(d2value)) < tolerance + error = abs(float(d1value) - float(d2value)) + within_tolerance = error <= tolerance except ValueError: # If both values aren't convertable to float, just ignore within_tolerance = False diff --git a/nova/tests/test_least_cost_scheduler.py b/nova/tests/test_least_cost_scheduler.py index b7bcd2f02..c8ce7892f 100644 --- a/nova/tests/test_least_cost_scheduler.py +++ b/nova/tests/test_least_cost_scheduler.py @@ -30,6 +30,7 @@ class FakeHost(object): self.free_ram = free_ram self.io = io + class WeightedSumTestCase(test.TestCase): def test_empty_domain(self): domain = [] @@ -50,14 +51,15 @@ class WeightedSumTestCase(test.TestCase): (2, lambda h: h.io), # Avoid high I/O ] - costs = least_cost.weighted_sum(domain=hosts, weighted_fns=weighted_fns) + costs = least_cost.weighted_sum( + domain=hosts, weighted_fns=weighted_fns) # Each 256 MB unit of free-ram contributes 0.5 points by way of: # cost = weight * (score/max_score) = 1 * (256/512) = 0.5 # Each 100 iops of IO adds 0.5 points by way of: # cost = 2 * (100/400) = 2 * 0.25 = 0.5 expected = [1.5, 2.5, 1.5] - self.assertEqual(expected, costs) + self.assertEqual(expected, costs) # TODO(sirp): unify this with test_host_filter tests? possibility of sharing @@ -65,6 +67,7 @@ class WeightedSumTestCase(test.TestCase): class FakeZoneManager: pass + class LeastCostSchedulerTestCase(test.TestCase): def _host_caps(self, multiplier): # Returns host capabilities in the following way: @@ -116,7 +119,6 @@ class LeastCostSchedulerTestCase(test.TestCase): #FLAGS.default_host_filter_driver = self.old_flag super(LeastCostSchedulerTestCase, self).tearDown() - def assertWeights(self, expected, num, request_spec, hosts): weighted = self.sched.weigh_hosts(num, request_spec, hosts) self.assertDictListMatch(weighted, expected, approx_equal=True) @@ -138,8 +140,9 @@ class LeastCostSchedulerTestCase(test.TestCase): num = 1 request_spec = {} hosts = self.sched.filter_hosts(num, request_spec) - - expected = [ dict(weight=1, hostname=hostname) for hostname, caps in hosts] + + expected = [dict(weight=1, hostname=hostname) + for hostname, caps in hosts] self.assertWeights(expected, num, request_spec, hosts) def test_cost_fn_weights(self): @@ -152,7 +155,8 @@ class LeastCostSchedulerTestCase(test.TestCase): request_spec = {} hosts = self.sched.filter_hosts(num, request_spec) - expected = [ dict(weight=2, hostname=hostname) for hostname, caps in hosts] + expected = [dict(weight=2, hostname=hostname) + for hostname, caps in hosts] self.assertWeights(expected, num, request_spec, hosts) def test_fill_first_cost_fn(self): @@ -164,7 +168,7 @@ class LeastCostSchedulerTestCase(test.TestCase): num = 1 request_spec = {} hosts = self.sched.filter_hosts(num, request_spec) - + expected = [] for idx, (hostname, caps) in enumerate(hosts): # Costs are normalized so over 10 hosts, each host with increasing -- cgit From d24f59a251173826817e5f5c53a4f54dfe927f2d Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 17 May 2011 19:30:29 -0400 Subject: added is_int function to utils --- nova/utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nova/utils.py b/nova/utils.py index c7da95a97..fff916527 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -726,6 +726,11 @@ def parse_server_string(server_str): return ('', '') +def is_int(x): + """ Return if passed in variable is integer or not """ + return re.match(r'\d+$', str(x)) + + def parse_image_ref(image_ref): """ Parse an imageRef and return (id, host, port) @@ -757,18 +762,18 @@ def get_image_service(image_ref=None): image_ref - image ref/id for an image """ - ImageService = utils.import_class(FLAGS.image_service) + ImageService = import_class(FLAGS.image_service) if not image_ref: - return (ImageService(), -1) + return (ImageService(), None) (image_id, host, port) = parse_image_ref(image_ref) image_service = None if host: - GlanceImageService = utils.import_class(FLAGS.glance_image_service) - GlanceClient = utils.import_class('glance.client.Client') + GlanceImageService = import_class(FLAGS.glance_image_service) + GlanceClient = import_class('glance.client.Client') glance_client = GlanceClient(host, port) image_service = GlanceImageService(glance_client) -- cgit From 4ba215224e6c75037fd4f20be57d632da5d07469 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 18:32:56 -0500 Subject: Moving tests into scheduler subdirectory --- nova/scheduler/host_filter.py | 5 - nova/tests/scheduler/test_scheduler.py | 1118 +++++++++++++++++++++ nova/tests/scheduler/test_zone_aware_scheduler.py | 121 +++ nova/tests/test_host_filter.py | 211 ---- nova/tests/test_least_cost_scheduler.py | 181 ---- nova/tests/test_scheduler.py | 1118 --------------------- nova/tests/test_zone_aware_scheduler.py | 121 --- 7 files changed, 1239 insertions(+), 1636 deletions(-) create mode 100644 nova/tests/scheduler/test_scheduler.py create mode 100644 nova/tests/scheduler/test_zone_aware_scheduler.py delete mode 100644 nova/tests/test_host_filter.py delete mode 100644 nova/tests/test_least_cost_scheduler.py delete mode 100644 nova/tests/test_scheduler.py delete mode 100644 nova/tests/test_zone_aware_scheduler.py diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index 117f08242..79e9f3159 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -313,8 +313,3 @@ class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): instance_type = request_spec['instance_type'] name, query = driver.instance_type_to_filter(instance_type) return driver.filter_hosts(self.zone_manager, query) - - def weigh_hosts(self, num, request_spec, hosts): - """Derived classes must override this method and return - a lists of hosts in [{weight, hostname}] format.""" - return [dict(weight=1, hostname=host) for host, caps in hosts] diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py new file mode 100644 index 000000000..54b3f80fb --- /dev/null +++ b/nova/tests/scheduler/test_scheduler.py @@ -0,0 +1,1118 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +Tests For Scheduler +""" + +import datetime +import mox +import novaclient.exceptions +import stubout +import webob + +from mox import IgnoreArg +from nova import context +from nova import db +from nova import exception +from nova import flags +from nova import service +from nova import test +from nova import rpc +from nova import utils +from nova.auth import manager as auth_manager +from nova.scheduler import api +from nova.scheduler import manager +from nova.scheduler import driver +from nova.compute import power_state +from nova.db.sqlalchemy import models + + +FLAGS = flags.FLAGS +flags.DECLARE('max_cores', 'nova.scheduler.simple') +flags.DECLARE('stub_network', 'nova.compute.manager') +flags.DECLARE('instances_path', 'nova.compute.manager') + + +class TestDriver(driver.Scheduler): + """Scheduler Driver for Tests""" + def schedule(context, topic, *args, **kwargs): + return 'fallback_host' + + def schedule_named_method(context, topic, num): + return 'named_host' + + +class SchedulerTestCase(test.TestCase): + """Test case for scheduler""" + def setUp(self): + super(SchedulerTestCase, self).setUp() + self.flags(scheduler_driver='nova.tests.test_scheduler.TestDriver') + + def _create_compute_service(self): + """Create compute-manager(ComputeNode and Service record).""" + ctxt = context.get_admin_context() + dic = {'host': 'dummy', 'binary': 'nova-compute', 'topic': 'compute', + 'report_count': 0, 'availability_zone': 'dummyzone'} + s_ref = db.service_create(ctxt, dic) + + dic = {'service_id': s_ref['id'], + 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, + 'vcpus_used': 16, 'memory_mb_used': 32, 'local_gb_used': 10, + 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, + 'cpu_info': ''} + db.compute_node_create(ctxt, dic) + + return db.service_get(ctxt, s_ref['id']) + + def _create_instance(self, **kwargs): + """Create a test instance""" + ctxt = context.get_admin_context() + inst = {} + inst['user_id'] = 'admin' + inst['project_id'] = kwargs.get('project_id', 'fake') + inst['host'] = kwargs.get('host', 'dummy') + inst['vcpus'] = kwargs.get('vcpus', 1) + inst['memory_mb'] = kwargs.get('memory_mb', 10) + inst['local_gb'] = kwargs.get('local_gb', 20) + return db.instance_create(ctxt, inst) + + def test_fallback(self): + scheduler = manager.SchedulerManager() + self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) + ctxt = context.get_admin_context() + rpc.cast(ctxt, + 'topic.fallback_host', + {'method': 'noexist', + 'args': {'num': 7}}) + self.mox.ReplayAll() + scheduler.noexist(ctxt, 'topic', num=7) + + def test_named_method(self): + scheduler = manager.SchedulerManager() + self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) + ctxt = context.get_admin_context() + rpc.cast(ctxt, + 'topic.named_host', + {'method': 'named_method', + 'args': {'num': 7}}) + self.mox.ReplayAll() + scheduler.named_method(ctxt, 'topic', num=7) + + def test_show_host_resources_host_not_exit(self): + """A host given as an argument does not exists.""" + + scheduler = manager.SchedulerManager() + dest = 'dummydest' + ctxt = context.get_admin_context() + + self.assertRaises(exception.NotFound, scheduler.show_host_resources, + ctxt, dest) + #TODO(bcwaldon): reimplement this functionality + #c1 = (e.message.find(_("does not exist or is not a " + # "compute node.")) >= 0) + + def _dic_is_equal(self, dic1, dic2, keys=None): + """Compares 2 dictionary contents(Helper method)""" + if not keys: + keys = ['vcpus', 'memory_mb', 'local_gb', + 'vcpus_used', 'memory_mb_used', 'local_gb_used'] + + for key in keys: + if not (dic1[key] == dic2[key]): + return False + return True + + def test_show_host_resources_no_project(self): + """No instance are running on the given host.""" + + scheduler = manager.SchedulerManager() + ctxt = context.get_admin_context() + s_ref = self._create_compute_service() + + result = scheduler.show_host_resources(ctxt, s_ref['host']) + + # result checking + c1 = ('resource' in result and 'usage' in result) + compute_node = s_ref['compute_node'][0] + c2 = self._dic_is_equal(result['resource'], compute_node) + c3 = result['usage'] == {} + self.assertTrue(c1 and c2 and c3) + db.service_destroy(ctxt, s_ref['id']) + + def test_show_host_resources_works_correctly(self): + """Show_host_resources() works correctly as expected.""" + + scheduler = manager.SchedulerManager() + ctxt = context.get_admin_context() + s_ref = self._create_compute_service() + i_ref1 = self._create_instance(project_id='p-01', host=s_ref['host']) + i_ref2 = self._create_instance(project_id='p-02', vcpus=3, + host=s_ref['host']) + + result = scheduler.show_host_resources(ctxt, s_ref['host']) + + c1 = ('resource' in result and 'usage' in result) + compute_node = s_ref['compute_node'][0] + c2 = self._dic_is_equal(result['resource'], compute_node) + c3 = result['usage'].keys() == ['p-01', 'p-02'] + keys = ['vcpus', 'memory_mb', 'local_gb'] + c4 = self._dic_is_equal(result['usage']['p-01'], i_ref1, keys) + c5 = self._dic_is_equal(result['usage']['p-02'], i_ref2, keys) + self.assertTrue(c1 and c2 and c3 and c4 and c5) + + db.service_destroy(ctxt, s_ref['id']) + db.instance_destroy(ctxt, i_ref1['id']) + db.instance_destroy(ctxt, i_ref2['id']) + + +class ZoneSchedulerTestCase(test.TestCase): + """Test case for zone scheduler""" + def setUp(self): + super(ZoneSchedulerTestCase, self).setUp() + self.flags(scheduler_driver='nova.scheduler.zone.ZoneScheduler') + + def _create_service_model(self, **kwargs): + service = db.sqlalchemy.models.Service() + service.host = kwargs['host'] + service.disabled = False + service.deleted = False + service.report_count = 0 + service.binary = 'nova-compute' + service.topic = 'compute' + service.id = kwargs['id'] + service.availability_zone = kwargs['zone'] + service.created_at = datetime.datetime.utcnow() + return service + + def test_with_two_zones(self): + scheduler = manager.SchedulerManager() + ctxt = context.get_admin_context() + service_list = [self._create_service_model(id=1, + host='host1', + zone='zone1'), + self._create_service_model(id=2, + host='host2', + zone='zone2'), + self._create_service_model(id=3, + host='host3', + zone='zone2'), + self._create_service_model(id=4, + host='host4', + zone='zone2'), + self._create_service_model(id=5, + host='host5', + zone='zone2')] + self.mox.StubOutWithMock(db, 'service_get_all_by_topic') + arg = IgnoreArg() + db.service_get_all_by_topic(arg, arg).AndReturn(service_list) + self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) + rpc.cast(ctxt, + 'compute.host1', + {'method': 'run_instance', + 'args': {'instance_id': 'i-ffffffff', + 'availability_zone': 'zone1'}}) + self.mox.ReplayAll() + scheduler.run_instance(ctxt, + 'compute', + instance_id='i-ffffffff', + availability_zone='zone1') + + +class SimpleDriverTestCase(test.TestCase): + """Test case for simple driver""" + def setUp(self): + super(SimpleDriverTestCase, self).setUp() + self.flags(connection_type='fake', + stub_network=True, + max_cores=4, + max_gigabytes=4, + network_manager='nova.network.manager.FlatManager', + volume_driver='nova.volume.driver.FakeISCSIDriver', + scheduler_driver='nova.scheduler.simple.SimpleScheduler') + self.scheduler = manager.SchedulerManager() + self.manager = auth_manager.AuthManager() + self.user = self.manager.create_user('fake', 'fake', 'fake') + self.project = self.manager.create_project('fake', 'fake', 'fake') + self.context = context.get_admin_context() + + def tearDown(self): + self.manager.delete_user(self.user) + self.manager.delete_project(self.project) + super(SimpleDriverTestCase, self).tearDown() + + def _create_instance(self, **kwargs): + """Create a test instance""" + inst = {} + inst['image_id'] = 1 + inst['reservation_id'] = 'r-fakeres' + inst['user_id'] = self.user.id + inst['project_id'] = self.project.id + inst['instance_type_id'] = '1' + inst['mac_address'] = utils.generate_mac() + inst['vcpus'] = kwargs.get('vcpus', 1) + inst['ami_launch_index'] = 0 + inst['availability_zone'] = kwargs.get('availability_zone', None) + inst['host'] = kwargs.get('host', 'dummy') + inst['memory_mb'] = kwargs.get('memory_mb', 20) + inst['local_gb'] = kwargs.get('local_gb', 30) + inst['launched_on'] = kwargs.get('launghed_on', 'dummy') + inst['state_description'] = kwargs.get('state_description', 'running') + inst['state'] = kwargs.get('state', power_state.RUNNING) + return db.instance_create(self.context, inst)['id'] + + def _create_volume(self): + """Create a test volume""" + vol = {} + vol['size'] = 1 + vol['availability_zone'] = 'test' + return db.volume_create(self.context, vol)['id'] + + def _create_compute_service(self, **kwargs): + """Create a compute service.""" + + dic = {'binary': 'nova-compute', 'topic': 'compute', + 'report_count': 0, 'availability_zone': 'dummyzone'} + dic['host'] = kwargs.get('host', 'dummy') + s_ref = db.service_create(self.context, dic) + if 'created_at' in kwargs.keys() or 'updated_at' in kwargs.keys(): + t = datetime.datetime.utcnow() - datetime.timedelta(0) + dic['created_at'] = kwargs.get('created_at', t) + dic['updated_at'] = kwargs.get('updated_at', t) + db.service_update(self.context, s_ref['id'], dic) + + dic = {'service_id': s_ref['id'], + 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, + 'vcpus_used': 16, 'local_gb_used': 10, + 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, + 'cpu_info': ''} + dic['memory_mb_used'] = kwargs.get('memory_mb_used', 32) + dic['hypervisor_type'] = kwargs.get('hypervisor_type', 'qemu') + dic['hypervisor_version'] = kwargs.get('hypervisor_version', 12003) + db.compute_node_create(self.context, dic) + return db.service_get(self.context, s_ref['id']) + + def test_doesnt_report_disabled_hosts_as_up(self): + """Ensures driver doesn't find hosts before they are enabled""" + # NOTE(vish): constructing service without create method + # because we are going to use it without queue + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + compute2 = service.Service('host2', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute2.start() + s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') + s2 = db.service_get_by_args(self.context, 'host2', 'nova-compute') + db.service_update(self.context, s1['id'], {'disabled': True}) + db.service_update(self.context, s2['id'], {'disabled': True}) + hosts = self.scheduler.driver.hosts_up(self.context, 'compute') + self.assertEqual(0, len(hosts)) + compute1.kill() + compute2.kill() + + def test_reports_enabled_hosts_as_up(self): + """Ensures driver can find the hosts that are up""" + # NOTE(vish): constructing service without create method + # because we are going to use it without queue + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + compute2 = service.Service('host2', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute2.start() + hosts = self.scheduler.driver.hosts_up(self.context, 'compute') + self.assertEqual(2, len(hosts)) + compute1.kill() + compute2.kill() + + def test_least_busy_host_gets_instance(self): + """Ensures the host with less cores gets the next one""" + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + compute2 = service.Service('host2', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute2.start() + instance_id1 = self._create_instance() + compute1.run_instance(self.context, instance_id1) + instance_id2 = self._create_instance() + host = self.scheduler.driver.schedule_run_instance(self.context, + instance_id2) + self.assertEqual(host, 'host2') + compute1.terminate_instance(self.context, instance_id1) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + compute2.kill() + + def test_specific_host_gets_instance(self): + """Ensures if you set availability_zone it launches on that zone""" + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + compute2 = service.Service('host2', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute2.start() + instance_id1 = self._create_instance() + compute1.run_instance(self.context, instance_id1) + instance_id2 = self._create_instance(availability_zone='nova:host1') + host = self.scheduler.driver.schedule_run_instance(self.context, + instance_id2) + self.assertEqual('host1', host) + compute1.terminate_instance(self.context, instance_id1) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + compute2.kill() + + def test_wont_sechedule_if_specified_host_is_down(self): + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') + now = datetime.datetime.utcnow() + delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) + past = now - delta + db.service_update(self.context, s1['id'], {'updated_at': past}) + instance_id2 = self._create_instance(availability_zone='nova:host1') + self.assertRaises(driver.WillNotSchedule, + self.scheduler.driver.schedule_run_instance, + self.context, + instance_id2) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + + def test_will_schedule_on_disabled_host_if_specified(self): + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') + db.service_update(self.context, s1['id'], {'disabled': True}) + instance_id2 = self._create_instance(availability_zone='nova:host1') + host = self.scheduler.driver.schedule_run_instance(self.context, + instance_id2) + self.assertEqual('host1', host) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + + def test_too_many_cores(self): + """Ensures we don't go over max cores""" + compute1 = service.Service('host1', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute1.start() + compute2 = service.Service('host2', + 'nova-compute', + 'compute', + FLAGS.compute_manager) + compute2.start() + instance_ids1 = [] + instance_ids2 = [] + for index in xrange(FLAGS.max_cores): + instance_id = self._create_instance() + compute1.run_instance(self.context, instance_id) + instance_ids1.append(instance_id) + instance_id = self._create_instance() + compute2.run_instance(self.context, instance_id) + instance_ids2.append(instance_id) + instance_id = self._create_instance() + self.assertRaises(driver.NoValidHost, + self.scheduler.driver.schedule_run_instance, + self.context, + instance_id) + for instance_id in instance_ids1: + compute1.terminate_instance(self.context, instance_id) + for instance_id in instance_ids2: + compute2.terminate_instance(self.context, instance_id) + compute1.kill() + compute2.kill() + + def test_least_busy_host_gets_volume(self): + """Ensures the host with less gigabytes gets the next one""" + volume1 = service.Service('host1', + 'nova-volume', + 'volume', + FLAGS.volume_manager) + volume1.start() + volume2 = service.Service('host2', + 'nova-volume', + 'volume', + FLAGS.volume_manager) + volume2.start() + volume_id1 = self._create_volume() + volume1.create_volume(self.context, volume_id1) + volume_id2 = self._create_volume() + host = self.scheduler.driver.schedule_create_volume(self.context, + volume_id2) + self.assertEqual(host, 'host2') + volume1.delete_volume(self.context, volume_id1) + db.volume_destroy(self.context, volume_id2) + dic = {'service_id': s_ref['id'], + 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, + 'vcpus_used': 16, 'memory_mb_used': 12, 'local_gb_used': 10, + 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, + 'cpu_info': ''} + + def test_doesnt_report_disabled_hosts_as_up(self): + """Ensures driver doesn't find hosts before they are enabled""" + compute1 = self.start_service('compute', host='host1') + compute2 = self.start_service('compute', host='host2') + s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') + s2 = db.service_get_by_args(self.context, 'host2', 'nova-compute') + db.service_update(self.context, s1['id'], {'disabled': True}) + db.service_update(self.context, s2['id'], {'disabled': True}) + hosts = self.scheduler.driver.hosts_up(self.context, 'compute') + self.assertEqual(0, len(hosts)) + compute1.kill() + compute2.kill() + + def test_reports_enabled_hosts_as_up(self): + """Ensures driver can find the hosts that are up""" + compute1 = self.start_service('compute', host='host1') + compute2 = self.start_service('compute', host='host2') + hosts = self.scheduler.driver.hosts_up(self.context, 'compute') + self.assertEqual(2, len(hosts)) + compute1.kill() + compute2.kill() + + def test_least_busy_host_gets_instance(self): + """Ensures the host with less cores gets the next one""" + compute1 = self.start_service('compute', host='host1') + compute2 = self.start_service('compute', host='host2') + instance_id1 = self._create_instance() + compute1.run_instance(self.context, instance_id1) + instance_id2 = self._create_instance() + host = self.scheduler.driver.schedule_run_instance(self.context, + instance_id2) + self.assertEqual(host, 'host2') + compute1.terminate_instance(self.context, instance_id1) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + compute2.kill() + + def test_specific_host_gets_instance(self): + """Ensures if you set availability_zone it launches on that zone""" + compute1 = self.start_service('compute', host='host1') + compute2 = self.start_service('compute', host='host2') + instance_id1 = self._create_instance() + compute1.run_instance(self.context, instance_id1) + instance_id2 = self._create_instance(availability_zone='nova:host1') + host = self.scheduler.driver.schedule_run_instance(self.context, + instance_id2) + self.assertEqual('host1', host) + compute1.terminate_instance(self.context, instance_id1) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + compute2.kill() + + def test_wont_sechedule_if_specified_host_is_down(self): + compute1 = self.start_service('compute', host='host1') + s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') + now = datetime.datetime.utcnow() + delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) + past = now - delta + db.service_update(self.context, s1['id'], {'updated_at': past}) + instance_id2 = self._create_instance(availability_zone='nova:host1') + self.assertRaises(driver.WillNotSchedule, + self.scheduler.driver.schedule_run_instance, + self.context, + instance_id2) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + + def test_will_schedule_on_disabled_host_if_specified(self): + compute1 = self.start_service('compute', host='host1') + s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') + db.service_update(self.context, s1['id'], {'disabled': True}) + instance_id2 = self._create_instance(availability_zone='nova:host1') + host = self.scheduler.driver.schedule_run_instance(self.context, + instance_id2) + self.assertEqual('host1', host) + db.instance_destroy(self.context, instance_id2) + compute1.kill() + + def test_too_many_cores(self): + """Ensures we don't go over max cores""" + compute1 = self.start_service('compute', host='host1') + compute2 = self.start_service('compute', host='host2') + instance_ids1 = [] + instance_ids2 = [] + for index in xrange(FLAGS.max_cores): + instance_id = self._create_instance() + compute1.run_instance(self.context, instance_id) + instance_ids1.append(instance_id) + instance_id = self._create_instance() + compute2.run_instance(self.context, instance_id) + instance_ids2.append(instance_id) + instance_id = self._create_instance() + self.assertRaises(driver.NoValidHost, + self.scheduler.driver.schedule_run_instance, + self.context, + instance_id) + db.instance_destroy(self.context, instance_id) + for instance_id in instance_ids1: + compute1.terminate_instance(self.context, instance_id) + for instance_id in instance_ids2: + compute2.terminate_instance(self.context, instance_id) + compute1.kill() + compute2.kill() + + def test_least_busy_host_gets_volume(self): + """Ensures the host with less gigabytes gets the next one""" + volume1 = self.start_service('volume', host='host1') + volume2 = self.start_service('volume', host='host2') + volume_id1 = self._create_volume() + volume1.create_volume(self.context, volume_id1) + volume_id2 = self._create_volume() + host = self.scheduler.driver.schedule_create_volume(self.context, + volume_id2) + self.assertEqual(host, 'host2') + volume1.delete_volume(self.context, volume_id1) + db.volume_destroy(self.context, volume_id2) + volume1.kill() + volume2.kill() + + def test_too_many_gigabytes(self): + """Ensures we don't go over max gigabytes""" + volume1 = self.start_service('volume', host='host1') + volume2 = self.start_service('volume', host='host2') + volume_ids1 = [] + volume_ids2 = [] + for index in xrange(FLAGS.max_gigabytes): + volume_id = self._create_volume() + volume1.create_volume(self.context, volume_id) + volume_ids1.append(volume_id) + volume_id = self._create_volume() + volume2.create_volume(self.context, volume_id) + volume_ids2.append(volume_id) + volume_id = self._create_volume() + self.assertRaises(driver.NoValidHost, + self.scheduler.driver.schedule_create_volume, + self.context, + volume_id) + for volume_id in volume_ids1: + volume1.delete_volume(self.context, volume_id) + for volume_id in volume_ids2: + volume2.delete_volume(self.context, volume_id) + volume1.kill() + volume2.kill() + + def test_scheduler_live_migration_with_volume(self): + """scheduler_live_migration() works correctly as expected. + + Also, checks instance state is changed from 'running' -> 'migrating'. + + """ + + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + dic = {'instance_id': instance_id, 'size': 1} + v_ref = db.volume_create(self.context, dic) + + # cannot check 2nd argument b/c the addresses of instance object + # is different. + driver_i = self.scheduler.driver + nocare = mox.IgnoreArg() + self.mox.StubOutWithMock(driver_i, '_live_migration_src_check') + self.mox.StubOutWithMock(driver_i, '_live_migration_dest_check') + self.mox.StubOutWithMock(driver_i, '_live_migration_common_check') + driver_i._live_migration_src_check(nocare, nocare) + driver_i._live_migration_dest_check(nocare, nocare, i_ref['host']) + driver_i._live_migration_common_check(nocare, nocare, i_ref['host']) + self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) + kwargs = {'instance_id': instance_id, 'dest': i_ref['host']} + rpc.cast(self.context, + db.queue_get_for(nocare, FLAGS.compute_topic, i_ref['host']), + {"method": 'live_migration', "args": kwargs}) + + self.mox.ReplayAll() + self.scheduler.live_migration(self.context, FLAGS.compute_topic, + instance_id=instance_id, + dest=i_ref['host']) + + i_ref = db.instance_get(self.context, instance_id) + self.assertTrue(i_ref['state_description'] == 'migrating') + db.instance_destroy(self.context, instance_id) + db.volume_destroy(self.context, v_ref['id']) + + def test_live_migration_src_check_instance_not_running(self): + """The instance given by instance_id is not running.""" + + instance_id = self._create_instance(state_description='migrating') + i_ref = db.instance_get(self.context, instance_id) + + try: + self.scheduler.driver._live_migration_src_check(self.context, + i_ref) + except exception.Invalid, e: + c = (e.message.find('is not running') > 0) + + self.assertTrue(c) + db.instance_destroy(self.context, instance_id) + + def test_live_migration_src_check_volume_node_not_alive(self): + """Raise exception when volume node is not alive.""" + + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + dic = {'instance_id': instance_id, 'size': 1} + v_ref = db.volume_create(self.context, {'instance_id': instance_id, + 'size': 1}) + t1 = datetime.datetime.utcnow() - datetime.timedelta(1) + dic = {'created_at': t1, 'updated_at': t1, 'binary': 'nova-volume', + 'topic': 'volume', 'report_count': 0} + s_ref = db.service_create(self.context, dic) + + self.assertRaises(exception.VolumeServiceUnavailable, + self.scheduler.driver.schedule_live_migration, + self.context, instance_id, i_ref['host']) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + db.volume_destroy(self.context, v_ref['id']) + + def test_live_migration_src_check_compute_node_not_alive(self): + """Confirms src-compute node is alive.""" + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + t = datetime.datetime.utcnow() - datetime.timedelta(10) + s_ref = self._create_compute_service(created_at=t, updated_at=t, + host=i_ref['host']) + + self.assertRaises(exception.ComputeServiceUnavailable, + self.scheduler.driver._live_migration_src_check, + self.context, i_ref) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_src_check_works_correctly(self): + """Confirms this method finishes with no error.""" + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + s_ref = self._create_compute_service(host=i_ref['host']) + + ret = self.scheduler.driver._live_migration_src_check(self.context, + i_ref) + + self.assertTrue(ret is None) + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_dest_check_not_alive(self): + """Confirms exception raises in case dest host does not exist.""" + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + t = datetime.datetime.utcnow() - datetime.timedelta(10) + s_ref = self._create_compute_service(created_at=t, updated_at=t, + host=i_ref['host']) + + self.assertRaises(exception.ComputeServiceUnavailable, + self.scheduler.driver._live_migration_dest_check, + self.context, i_ref, i_ref['host']) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_dest_check_service_same_host(self): + """Confirms exceptioin raises in case dest and src is same host.""" + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + s_ref = self._create_compute_service(host=i_ref['host']) + + self.assertRaises(exception.UnableToMigrateToSelf, + self.scheduler.driver._live_migration_dest_check, + self.context, i_ref, i_ref['host']) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_dest_check_service_lack_memory(self): + """Confirms exception raises when dest doesn't have enough memory.""" + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + s_ref = self._create_compute_service(host='somewhere', + memory_mb_used=12) + + self.assertRaises(exception.MigrationError, + self.scheduler.driver._live_migration_dest_check, + self.context, i_ref, 'somewhere') + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_dest_check_service_works_correctly(self): + """Confirms method finishes with no error.""" + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + s_ref = self._create_compute_service(host='somewhere', + memory_mb_used=5) + + ret = self.scheduler.driver._live_migration_dest_check(self.context, + i_ref, + 'somewhere') + self.assertTrue(ret is None) + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_common_check_service_orig_not_exists(self): + """Destination host does not exist.""" + + dest = 'dummydest' + # mocks for live_migration_common_check() + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + t1 = datetime.datetime.utcnow() - datetime.timedelta(10) + s_ref = self._create_compute_service(created_at=t1, updated_at=t1, + host=dest) + + # mocks for mounted_on_same_shared_storage() + fpath = '/test/20110127120000' + self.mox.StubOutWithMock(driver, 'rpc', use_mock_anything=True) + topic = FLAGS.compute_topic + driver.rpc.call(mox.IgnoreArg(), + db.queue_get_for(self.context, topic, dest), + {"method": 'create_shared_storage_test_file'}).AndReturn(fpath) + driver.rpc.call(mox.IgnoreArg(), + db.queue_get_for(mox.IgnoreArg(), topic, i_ref['host']), + {"method": 'check_shared_storage_test_file', + "args": {'filename': fpath}}) + driver.rpc.call(mox.IgnoreArg(), + db.queue_get_for(mox.IgnoreArg(), topic, dest), + {"method": 'cleanup_shared_storage_test_file', + "args": {'filename': fpath}}) + + self.mox.ReplayAll() + self.assertRaises(exception.SourceHostUnavailable, + self.scheduler.driver._live_migration_common_check, + self.context, i_ref, dest) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + + def test_live_migration_common_check_service_different_hypervisor(self): + """Original host and dest host has different hypervisor type.""" + dest = 'dummydest' + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + + # compute service for destination + s_ref = self._create_compute_service(host=i_ref['host']) + # compute service for original host + s_ref2 = self._create_compute_service(host=dest, hypervisor_type='xen') + + # mocks + driver = self.scheduler.driver + self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') + driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) + + self.mox.ReplayAll() + self.assertRaises(exception.InvalidHypervisorType, + self.scheduler.driver._live_migration_common_check, + self.context, i_ref, dest) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + db.service_destroy(self.context, s_ref2['id']) + + def test_live_migration_common_check_service_different_version(self): + """Original host and dest host has different hypervisor version.""" + dest = 'dummydest' + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + + # compute service for destination + s_ref = self._create_compute_service(host=i_ref['host']) + # compute service for original host + s_ref2 = self._create_compute_service(host=dest, + hypervisor_version=12002) + + # mocks + driver = self.scheduler.driver + self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') + driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) + + self.mox.ReplayAll() + self.assertRaises(exception.DestinationHypervisorTooOld, + self.scheduler.driver._live_migration_common_check, + self.context, i_ref, dest) + + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + db.service_destroy(self.context, s_ref2['id']) + + def test_live_migration_common_check_checking_cpuinfo_fail(self): + """Raise excetion when original host doen't have compatible cpu.""" + + dest = 'dummydest' + instance_id = self._create_instance() + i_ref = db.instance_get(self.context, instance_id) + + # compute service for destination + s_ref = self._create_compute_service(host=i_ref['host']) + # compute service for original host + s_ref2 = self._create_compute_service(host=dest) + + # mocks + driver = self.scheduler.driver + self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') + driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) + self.mox.StubOutWithMock(rpc, 'call', use_mock_anything=True) + rpc.call(mox.IgnoreArg(), mox.IgnoreArg(), + {"method": 'compare_cpu', + "args": {'cpu_info': s_ref2['compute_node'][0]['cpu_info']}}).\ + AndRaise(rpc.RemoteError("doesn't have compatibility to", "", "")) + + self.mox.ReplayAll() + try: + self.scheduler.driver._live_migration_common_check(self.context, + i_ref, + dest) + except rpc.RemoteError, e: + c = (e.message.find(_("doesn't have compatibility to")) >= 0) + + self.assertTrue(c) + db.instance_destroy(self.context, instance_id) + db.service_destroy(self.context, s_ref['id']) + db.service_destroy(self.context, s_ref2['id']) + + +class FakeZone(object): + def __init__(self, id, api_url, username, password): + self.id = id + self.api_url = api_url + self.username = username + self.password = password + + +def zone_get_all(context): + return [ + FakeZone(1, 'http://example.com', 'bob', 'xxx'), + ] + + +class FakeRerouteCompute(api.reroute_compute): + def _call_child_zones(self, zones, function): + return [] + + def get_collection_context_and_id(self, args, kwargs): + return ("servers", None, 1) + + def unmarshall_result(self, zone_responses): + return dict(magic="found me") + + +def go_boom(self, context, instance): + raise exception.InstanceNotFound(instance_id=instance) + + +def found_instance(self, context, instance): + return dict(name='myserver') + + +class FakeResource(object): + def __init__(self, attribute_dict): + for k, v in attribute_dict.iteritems(): + setattr(self, k, v) + + def pause(self): + pass + + +class ZoneRedirectTest(test.TestCase): + def setUp(self): + super(ZoneRedirectTest, self).setUp() + self.stubs = stubout.StubOutForTesting() + + self.stubs.Set(db, 'zone_get_all', zone_get_all) + + self.enable_zone_routing = FLAGS.enable_zone_routing + FLAGS.enable_zone_routing = True + + def tearDown(self): + self.stubs.UnsetAll() + FLAGS.enable_zone_routing = self.enable_zone_routing + super(ZoneRedirectTest, self).tearDown() + + def test_trap_found_locally(self): + decorator = FakeRerouteCompute("foo") + try: + result = decorator(found_instance)(None, None, 1) + except api.RedirectResult, e: + self.fail(_("Successful database hit should succeed")) + + def test_trap_not_found_locally(self): + decorator = FakeRerouteCompute("foo") + try: + result = decorator(go_boom)(None, None, 1) + self.assertFail(_("Should have rerouted.")) + except api.RedirectResult, e: + self.assertEquals(e.results['magic'], 'found me') + + def test_routing_flags(self): + FLAGS.enable_zone_routing = False + decorator = FakeRerouteCompute("foo") + self.assertRaises(exception.InstanceNotFound, decorator(go_boom), + None, None, 1) + + def test_get_collection_context_and_id(self): + decorator = api.reroute_compute("foo") + self.assertEquals(decorator.get_collection_context_and_id( + (None, 10, 20), {}), ("servers", 10, 20)) + self.assertEquals(decorator.get_collection_context_and_id( + (None, 11,), dict(instance_id=21)), ("servers", 11, 21)) + self.assertEquals(decorator.get_collection_context_and_id( + (None,), dict(context=12, instance_id=22)), ("servers", 12, 22)) + + def test_unmarshal_single_server(self): + decorator = api.reroute_compute("foo") + self.assertEquals(decorator.unmarshall_result([]), {}) + self.assertEquals(decorator.unmarshall_result( + [FakeResource(dict(a=1, b=2)), ]), + dict(server=dict(a=1, b=2))) + self.assertEquals(decorator.unmarshall_result( + [FakeResource(dict(a=1, _b=2)), ]), + dict(server=dict(a=1,))) + self.assertEquals(decorator.unmarshall_result( + [FakeResource(dict(a=1, manager=2)), ]), + dict(server=dict(a=1,))) + self.assertEquals(decorator.unmarshall_result( + [FakeResource(dict(_a=1, manager=2)), ]), + dict(server={})) + + +class FakeServerCollection(object): + def get(self, instance_id): + return FakeResource(dict(a=10, b=20)) + + def find(self, name): + return FakeResource(dict(a=11, b=22)) + + +class FakeEmptyServerCollection(object): + def get(self, f): + raise novaclient.NotFound(1) + + def find(self, name): + raise novaclient.NotFound(2) + + +class FakeNovaClient(object): + def __init__(self, collection): + self.servers = collection + + +class DynamicNovaClientTest(test.TestCase): + def test_issue_novaclient_command_found(self): + zone = FakeZone(1, 'http://example.com', 'bob', 'xxx') + self.assertEquals(api._issue_novaclient_command( + FakeNovaClient(FakeServerCollection()), + zone, "servers", "get", 100).a, 10) + + self.assertEquals(api._issue_novaclient_command( + FakeNovaClient(FakeServerCollection()), + zone, "servers", "find", "name").b, 22) + + self.assertEquals(api._issue_novaclient_command( + FakeNovaClient(FakeServerCollection()), + zone, "servers", "pause", 100), None) + + def test_issue_novaclient_command_not_found(self): + zone = FakeZone(1, 'http://example.com', 'bob', 'xxx') + self.assertEquals(api._issue_novaclient_command( + FakeNovaClient(FakeEmptyServerCollection()), + zone, "servers", "get", 100), None) + + self.assertEquals(api._issue_novaclient_command( + FakeNovaClient(FakeEmptyServerCollection()), + zone, "servers", "find", "name"), None) + + self.assertEquals(api._issue_novaclient_command( + FakeNovaClient(FakeEmptyServerCollection()), + zone, "servers", "any", "name"), None) + + +class FakeZonesProxy(object): + def do_something(*args, **kwargs): + return 42 + + def raises_exception(*args, **kwargs): + raise Exception('testing') + + +class FakeNovaClientOpenStack(object): + def __init__(self, *args, **kwargs): + self.zones = FakeZonesProxy() + + def authenticate(self): + pass + + +class CallZoneMethodTest(test.TestCase): + def setUp(self): + super(CallZoneMethodTest, self).setUp() + self.stubs = stubout.StubOutForTesting() + self.stubs.Set(db, 'zone_get_all', zone_get_all) + self.stubs.Set(novaclient, 'OpenStack', FakeNovaClientOpenStack) + + def tearDown(self): + self.stubs.UnsetAll() + super(CallZoneMethodTest, self).tearDown() + + def test_call_zone_method(self): + context = {} + method = 'do_something' + results = api.call_zone_method(context, method) + expected = [(1, 42)] + self.assertEqual(expected, results) + + def test_call_zone_method_not_present(self): + context = {} + method = 'not_present' + self.assertRaises(AttributeError, api.call_zone_method, + context, method) + + def test_call_zone_method_generates_exception(self): + context = {} + method = 'raises_exception' + results = api.call_zone_method(context, method) + + # FIXME(sirp): for now the _error_trap code is catching errors and + # converting them to a ("ERROR", "string") tuples. The code (and this + # test) should eventually handle real exceptions. + expected = [(1, ('ERROR', 'testing'))] + self.assertEqual(expected, results) diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py new file mode 100644 index 000000000..37169fb97 --- /dev/null +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -0,0 +1,121 @@ +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +Tests For Zone Aware Scheduler. +""" + +from nova import test +from nova.scheduler import driver +from nova.scheduler import zone_aware_scheduler +from nova.scheduler import zone_manager + + +class FakeZoneAwareScheduler(zone_aware_scheduler.ZoneAwareScheduler): + def filter_hosts(self, num, specs): + # NOTE(sirp): this is returning [(hostname, services)] + return self.zone_manager.service_states.items() + + def weigh_hosts(self, num, specs, hosts): + fake_weight = 99 + weighted = [] + for hostname, caps in hosts: + weighted.append(dict(weight=fake_weight, name=hostname)) + return weighted + + +class FakeZoneManager(zone_manager.ZoneManager): + def __init__(self): + self.service_states = { + 'host1': { + 'compute': {'ram': 1000} + }, + 'host2': { + 'compute': {'ram': 2000} + }, + 'host3': { + 'compute': {'ram': 3000} + } + } + + +class FakeEmptyZoneManager(zone_manager.ZoneManager): + def __init__(self): + self.service_states = {} + + +def fake_empty_call_zone_method(context, method, specs): + return [] + + +def fake_call_zone_method(context, method, specs): + return [ + ('zone1', [ + dict(weight=1, blob='AAAAAAA'), + dict(weight=111, blob='BBBBBBB'), + dict(weight=112, blob='CCCCCCC'), + dict(weight=113, blob='DDDDDDD'), + ]), + ('zone2', [ + dict(weight=120, blob='EEEEEEE'), + dict(weight=2, blob='FFFFFFF'), + dict(weight=122, blob='GGGGGGG'), + dict(weight=123, blob='HHHHHHH'), + ]), + ('zone3', [ + dict(weight=130, blob='IIIIIII'), + dict(weight=131, blob='JJJJJJJ'), + dict(weight=132, blob='KKKKKKK'), + dict(weight=3, blob='LLLLLLL'), + ]), + ] + + +class ZoneAwareSchedulerTestCase(test.TestCase): + """Test case for Zone Aware Scheduler.""" + + def test_zone_aware_scheduler(self): + """ + Create a nested set of FakeZones, ensure that a select call returns the + appropriate build plan. + """ + sched = FakeZoneAwareScheduler() + self.stubs.Set(sched, '_call_zone_method', fake_call_zone_method) + + zm = FakeZoneManager() + sched.set_zone_manager(zm) + + fake_context = {} + build_plan = sched.select(fake_context, {}) + + self.assertEqual(15, len(build_plan)) + + hostnames = [plan_item['name'] + for plan_item in build_plan if 'name' in plan_item] + self.assertEqual(3, len(hostnames)) + + def test_empty_zone_aware_scheduler(self): + """ + Ensure empty hosts & child_zones result in NoValidHosts exception. + """ + sched = FakeZoneAwareScheduler() + self.stubs.Set(sched, '_call_zone_method', fake_empty_call_zone_method) + + zm = FakeEmptyZoneManager() + sched.set_zone_manager(zm) + + fake_context = {} + self.assertRaises(driver.NoValidHost, sched.schedule_run_instance, + fake_context, 1, + dict(host_filter=None, instance_type={})) diff --git a/nova/tests/test_host_filter.py b/nova/tests/test_host_filter.py deleted file mode 100644 index 1a2a86a79..000000000 --- a/nova/tests/test_host_filter.py +++ /dev/null @@ -1,211 +0,0 @@ -# Copyright 2011 OpenStack LLC. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -""" -Tests For Scheduler Host Filter Drivers. -""" - -import json - -from nova import exception -from nova import flags -from nova import test -from nova.scheduler import host_filter - -FLAGS = flags.FLAGS - - -class FakeZoneManager: - pass - - -class HostFilterTestCase(test.TestCase): - """Test case for host filter drivers.""" - - def _host_caps(self, multiplier): - # Returns host capabilities in the following way: - # host1 = memory:free 10 (100max) - # disk:available 100 (1000max) - # hostN = memory:free 10 + 10N - # disk:available 100 + 100N - # in other words: hostN has more resources than host0 - # which means ... don't go above 10 hosts. - return {'host_name-description': 'XenServer %s' % multiplier, - 'host_hostname': 'xs-%s' % multiplier, - 'host_memory_total': 100, - 'host_memory_overhead': 10, - 'host_memory_free': 10 + multiplier * 10, - 'host_memory_free-computed': 10 + multiplier * 10, - 'host_other-config': {}, - 'host_ip_address': '192.168.1.%d' % (100 + multiplier), - 'host_cpu_info': {}, - 'disk_available': 100 + multiplier * 100, - 'disk_total': 1000, - 'disk_used': 0, - 'host_uuid': 'xxx-%d' % multiplier, - 'host_name-label': 'xs-%s' % multiplier} - - def setUp(self): - super(HostFilterTestCase, self).setUp() - self.old_flag = FLAGS.default_host_filter_driver - FLAGS.default_host_filter_driver = \ - 'nova.scheduler.host_filter.AllHostsFilter' - self.instance_type = dict(name='tiny', - memory_mb=50, - vcpus=10, - local_gb=500, - flavorid=1, - swap=500, - rxtx_quota=30000, - rxtx_cap=200) - - self.zone_manager = FakeZoneManager() - states = {} - for x in xrange(10): - states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)} - self.zone_manager.service_states = states - - def tearDown(self): - FLAGS.default_host_filter_driver = self.old_flag - super(HostFilterTestCase, self).tearDown() - - def test_choose_driver(self): - # Test default driver ... - driver = host_filter.choose_driver() - self.assertEquals(driver._full_name(), - 'nova.scheduler.host_filter.AllHostsFilter') - # Test valid driver ... - driver = host_filter.choose_driver( - 'nova.scheduler.host_filter.InstanceTypeFilter') - self.assertEquals(driver._full_name(), - 'nova.scheduler.host_filter.InstanceTypeFilter') - # Test invalid driver ... - try: - host_filter.choose_driver('does not exist') - self.fail("Should not find driver") - except exception.SchedulerHostFilterDriverNotFound: - pass - - def test_all_host_driver(self): - driver = host_filter.AllHostsFilter() - cooked = driver.instance_type_to_filter(self.instance_type) - hosts = driver.filter_hosts(self.zone_manager, cooked) - self.assertEquals(10, len(hosts)) - for host, capabilities in hosts: - self.assertTrue(host.startswith('host')) - - def test_instance_type_driver(self): - driver = host_filter.InstanceTypeFilter() - # filter all hosts that can support 50 ram and 500 disk - name, cooked = driver.instance_type_to_filter(self.instance_type) - self.assertEquals('nova.scheduler.host_filter.InstanceTypeFilter', - name) - hosts = driver.filter_hosts(self.zone_manager, cooked) - self.assertEquals(6, len(hosts)) - just_hosts = [host for host, caps in hosts] - just_hosts.sort() - self.assertEquals('host05', just_hosts[0]) - self.assertEquals('host10', just_hosts[5]) - - def test_json_driver(self): - driver = host_filter.JsonFilter() - # filter all hosts that can support 50 ram and 500 disk - name, cooked = driver.instance_type_to_filter(self.instance_type) - self.assertEquals('nova.scheduler.host_filter.JsonFilter', name) - hosts = driver.filter_hosts(self.zone_manager, cooked) - self.assertEquals(6, len(hosts)) - just_hosts = [host for host, caps in hosts] - just_hosts.sort() - self.assertEquals('host05', just_hosts[0]) - self.assertEquals('host10', just_hosts[5]) - - # Try some custom queries - - raw = ['or', - ['and', - ['<', '$compute.host_memory_free', 30], - ['<', '$compute.disk_available', 300] - ], - ['and', - ['>', '$compute.host_memory_free', 70], - ['>', '$compute.disk_available', 700] - ] - ] - cooked = json.dumps(raw) - hosts = driver.filter_hosts(self.zone_manager, cooked) - - self.assertEquals(5, len(hosts)) - just_hosts = [host for host, caps in hosts] - just_hosts.sort() - for index, host in zip([1, 2, 8, 9, 10], just_hosts): - self.assertEquals('host%02d' % index, host) - - raw = ['not', - ['=', '$compute.host_memory_free', 30], - ] - cooked = json.dumps(raw) - hosts = driver.filter_hosts(self.zone_manager, cooked) - - self.assertEquals(9, len(hosts)) - just_hosts = [host for host, caps in hosts] - just_hosts.sort() - for index, host in zip([1, 2, 4, 5, 6, 7, 8, 9, 10], just_hosts): - self.assertEquals('host%02d' % index, host) - - raw = ['in', '$compute.host_memory_free', 20, 40, 60, 80, 100] - cooked = json.dumps(raw) - hosts = driver.filter_hosts(self.zone_manager, cooked) - - self.assertEquals(5, len(hosts)) - just_hosts = [host for host, caps in hosts] - just_hosts.sort() - for index, host in zip([2, 4, 6, 8, 10], just_hosts): - self.assertEquals('host%02d' % index, host) - - # Try some bogus input ... - raw = ['unknown command', ] - cooked = json.dumps(raw) - try: - driver.filter_hosts(self.zone_manager, cooked) - self.fail("Should give KeyError") - except KeyError, e: - pass - - self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps([]))) - self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps({}))) - self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps( - ['not', True, False, True, False] - ))) - - try: - driver.filter_hosts(self.zone_manager, json.dumps( - 'not', True, False, True, False - )) - self.fail("Should give KeyError") - except KeyError, e: - pass - - self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( - ['=', '$foo', 100] - ))) - self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( - ['=', '$.....', 100] - ))) - self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( - ['>', ['and', ['or', ['not', ['<', ['>=', ['<=', ['in', ]]]]]]]] - ))) - - self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( - ['=', {}, ['>', '$missing....foo']] - ))) diff --git a/nova/tests/test_least_cost_scheduler.py b/nova/tests/test_least_cost_scheduler.py deleted file mode 100644 index c8ce7892f..000000000 --- a/nova/tests/test_least_cost_scheduler.py +++ /dev/null @@ -1,181 +0,0 @@ -# Copyright 2011 OpenStack LLC. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -""" -Tests For Least Cost Scheduler -""" - -from nova import flags -from nova import test -from nova.scheduler import least_cost - -MB = 1024 * 1024 -FLAGS = flags.FLAGS - - -class FakeHost(object): - def __init__(self, host_id, free_ram, io): - self.id = host_id - self.free_ram = free_ram - self.io = io - - -class WeightedSumTestCase(test.TestCase): - def test_empty_domain(self): - domain = [] - weighted_fns = [] - result = least_cost.weighted_sum(domain, weighted_fns) - expected = [] - self.assertEqual(expected, result) - - def test_basic_costing(self): - hosts = [ - FakeHost(1, 512 * MB, 100), - FakeHost(2, 256 * MB, 400), - FakeHost(3, 512 * MB, 100) - ] - - weighted_fns = [ - (1, lambda h: h.free_ram), # Fill-first, free_ram is a *cost* - (2, lambda h: h.io), # Avoid high I/O - ] - - costs = least_cost.weighted_sum( - domain=hosts, weighted_fns=weighted_fns) - - # Each 256 MB unit of free-ram contributes 0.5 points by way of: - # cost = weight * (score/max_score) = 1 * (256/512) = 0.5 - # Each 100 iops of IO adds 0.5 points by way of: - # cost = 2 * (100/400) = 2 * 0.25 = 0.5 - expected = [1.5, 2.5, 1.5] - self.assertEqual(expected, costs) - - -# TODO(sirp): unify this with test_host_filter tests? possibility of sharing -# test setup code -class FakeZoneManager: - pass - - -class LeastCostSchedulerTestCase(test.TestCase): - def _host_caps(self, multiplier): - # Returns host capabilities in the following way: - # host1 = memory:free 10 (100max) - # disk:available 100 (1000max) - # hostN = memory:free 10 + 10N - # disk:available 100 + 100N - # in other words: hostN has more resources than host0 - # which means ... don't go above 10 hosts. - return {'host_name-description': 'XenServer %s' % multiplier, - 'host_hostname': 'xs-%s' % multiplier, - 'host_memory_total': 100, - 'host_memory_overhead': 10, - 'host_memory_free': 10 + multiplier * 10, - 'host_memory_free-computed': 10 + multiplier * 10, - 'host_other-config': {}, - 'host_ip_address': '192.168.1.%d' % (100 + multiplier), - 'host_cpu_info': {}, - 'disk_available': 100 + multiplier * 100, - 'disk_total': 1000, - 'disk_used': 0, - 'host_uuid': 'xxx-%d' % multiplier, - 'host_name-label': 'xs-%s' % multiplier} - - def setUp(self): - super(LeastCostSchedulerTestCase, self).setUp() - #self.old_flag = FLAGS.default_host_filter_driver - #FLAGS.default_host_filter_driver = \ - # 'nova.scheduler.host_filter.AllHostsFilter' - self.instance_type = dict(name='tiny', - memory_mb=50, - vcpus=10, - local_gb=500, - flavorid=1, - swap=500, - rxtx_quota=30000, - rxtx_cap=200) - - zone_manager = FakeZoneManager() - states = {} - for x in xrange(10): - states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)} - zone_manager.service_states = states - - self.sched = least_cost.LeastCostScheduler() - self.sched.zone_manager = zone_manager - - def tearDown(self): - #FLAGS.default_host_filter_driver = self.old_flag - super(LeastCostSchedulerTestCase, self).tearDown() - - def assertWeights(self, expected, num, request_spec, hosts): - weighted = self.sched.weigh_hosts(num, request_spec, hosts) - self.assertDictListMatch(weighted, expected, approx_equal=True) - - def test_no_hosts(self): - num = 1 - request_spec = {} - hosts = [] - - expected = [] - self.assertWeights(expected, num, request_spec, hosts) - - def test_noop_cost_fn(self): - FLAGS.least_cost_scheduler_cost_functions = [ - 'nova.scheduler.least_cost.noop_cost_fn' - ] - FLAGS.noop_cost_fn_weight = 1 - - num = 1 - request_spec = {} - hosts = self.sched.filter_hosts(num, request_spec) - - expected = [dict(weight=1, hostname=hostname) - for hostname, caps in hosts] - self.assertWeights(expected, num, request_spec, hosts) - - def test_cost_fn_weights(self): - FLAGS.least_cost_scheduler_cost_functions = [ - 'nova.scheduler.least_cost.noop_cost_fn' - ] - FLAGS.noop_cost_fn_weight = 2 - - num = 1 - request_spec = {} - hosts = self.sched.filter_hosts(num, request_spec) - - expected = [dict(weight=2, hostname=hostname) - for hostname, caps in hosts] - self.assertWeights(expected, num, request_spec, hosts) - - def test_fill_first_cost_fn(self): - FLAGS.least_cost_scheduler_cost_functions = [ - 'nova.scheduler.least_cost.fill_first_cost_fn' - ] - FLAGS.fill_first_cost_fn_weight = 1 - - num = 1 - request_spec = {} - hosts = self.sched.filter_hosts(num, request_spec) - - expected = [] - for idx, (hostname, caps) in enumerate(hosts): - # Costs are normalized so over 10 hosts, each host with increasing - # free ram will cost 1/N more. Since the lowest cost host has some - # free ram, we add in the 1/N for the base_cost - weight = 0.1 + (0.1 * idx) - weight_dict = dict(weight=weight, hostname=hostname) - expected.append(weight_dict) - - self.assertWeights(expected, num, request_spec, hosts) diff --git a/nova/tests/test_scheduler.py b/nova/tests/test_scheduler.py deleted file mode 100644 index 54b3f80fb..000000000 --- a/nova/tests/test_scheduler.py +++ /dev/null @@ -1,1118 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -""" -Tests For Scheduler -""" - -import datetime -import mox -import novaclient.exceptions -import stubout -import webob - -from mox import IgnoreArg -from nova import context -from nova import db -from nova import exception -from nova import flags -from nova import service -from nova import test -from nova import rpc -from nova import utils -from nova.auth import manager as auth_manager -from nova.scheduler import api -from nova.scheduler import manager -from nova.scheduler import driver -from nova.compute import power_state -from nova.db.sqlalchemy import models - - -FLAGS = flags.FLAGS -flags.DECLARE('max_cores', 'nova.scheduler.simple') -flags.DECLARE('stub_network', 'nova.compute.manager') -flags.DECLARE('instances_path', 'nova.compute.manager') - - -class TestDriver(driver.Scheduler): - """Scheduler Driver for Tests""" - def schedule(context, topic, *args, **kwargs): - return 'fallback_host' - - def schedule_named_method(context, topic, num): - return 'named_host' - - -class SchedulerTestCase(test.TestCase): - """Test case for scheduler""" - def setUp(self): - super(SchedulerTestCase, self).setUp() - self.flags(scheduler_driver='nova.tests.test_scheduler.TestDriver') - - def _create_compute_service(self): - """Create compute-manager(ComputeNode and Service record).""" - ctxt = context.get_admin_context() - dic = {'host': 'dummy', 'binary': 'nova-compute', 'topic': 'compute', - 'report_count': 0, 'availability_zone': 'dummyzone'} - s_ref = db.service_create(ctxt, dic) - - dic = {'service_id': s_ref['id'], - 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, - 'vcpus_used': 16, 'memory_mb_used': 32, 'local_gb_used': 10, - 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, - 'cpu_info': ''} - db.compute_node_create(ctxt, dic) - - return db.service_get(ctxt, s_ref['id']) - - def _create_instance(self, **kwargs): - """Create a test instance""" - ctxt = context.get_admin_context() - inst = {} - inst['user_id'] = 'admin' - inst['project_id'] = kwargs.get('project_id', 'fake') - inst['host'] = kwargs.get('host', 'dummy') - inst['vcpus'] = kwargs.get('vcpus', 1) - inst['memory_mb'] = kwargs.get('memory_mb', 10) - inst['local_gb'] = kwargs.get('local_gb', 20) - return db.instance_create(ctxt, inst) - - def test_fallback(self): - scheduler = manager.SchedulerManager() - self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) - ctxt = context.get_admin_context() - rpc.cast(ctxt, - 'topic.fallback_host', - {'method': 'noexist', - 'args': {'num': 7}}) - self.mox.ReplayAll() - scheduler.noexist(ctxt, 'topic', num=7) - - def test_named_method(self): - scheduler = manager.SchedulerManager() - self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) - ctxt = context.get_admin_context() - rpc.cast(ctxt, - 'topic.named_host', - {'method': 'named_method', - 'args': {'num': 7}}) - self.mox.ReplayAll() - scheduler.named_method(ctxt, 'topic', num=7) - - def test_show_host_resources_host_not_exit(self): - """A host given as an argument does not exists.""" - - scheduler = manager.SchedulerManager() - dest = 'dummydest' - ctxt = context.get_admin_context() - - self.assertRaises(exception.NotFound, scheduler.show_host_resources, - ctxt, dest) - #TODO(bcwaldon): reimplement this functionality - #c1 = (e.message.find(_("does not exist or is not a " - # "compute node.")) >= 0) - - def _dic_is_equal(self, dic1, dic2, keys=None): - """Compares 2 dictionary contents(Helper method)""" - if not keys: - keys = ['vcpus', 'memory_mb', 'local_gb', - 'vcpus_used', 'memory_mb_used', 'local_gb_used'] - - for key in keys: - if not (dic1[key] == dic2[key]): - return False - return True - - def test_show_host_resources_no_project(self): - """No instance are running on the given host.""" - - scheduler = manager.SchedulerManager() - ctxt = context.get_admin_context() - s_ref = self._create_compute_service() - - result = scheduler.show_host_resources(ctxt, s_ref['host']) - - # result checking - c1 = ('resource' in result and 'usage' in result) - compute_node = s_ref['compute_node'][0] - c2 = self._dic_is_equal(result['resource'], compute_node) - c3 = result['usage'] == {} - self.assertTrue(c1 and c2 and c3) - db.service_destroy(ctxt, s_ref['id']) - - def test_show_host_resources_works_correctly(self): - """Show_host_resources() works correctly as expected.""" - - scheduler = manager.SchedulerManager() - ctxt = context.get_admin_context() - s_ref = self._create_compute_service() - i_ref1 = self._create_instance(project_id='p-01', host=s_ref['host']) - i_ref2 = self._create_instance(project_id='p-02', vcpus=3, - host=s_ref['host']) - - result = scheduler.show_host_resources(ctxt, s_ref['host']) - - c1 = ('resource' in result and 'usage' in result) - compute_node = s_ref['compute_node'][0] - c2 = self._dic_is_equal(result['resource'], compute_node) - c3 = result['usage'].keys() == ['p-01', 'p-02'] - keys = ['vcpus', 'memory_mb', 'local_gb'] - c4 = self._dic_is_equal(result['usage']['p-01'], i_ref1, keys) - c5 = self._dic_is_equal(result['usage']['p-02'], i_ref2, keys) - self.assertTrue(c1 and c2 and c3 and c4 and c5) - - db.service_destroy(ctxt, s_ref['id']) - db.instance_destroy(ctxt, i_ref1['id']) - db.instance_destroy(ctxt, i_ref2['id']) - - -class ZoneSchedulerTestCase(test.TestCase): - """Test case for zone scheduler""" - def setUp(self): - super(ZoneSchedulerTestCase, self).setUp() - self.flags(scheduler_driver='nova.scheduler.zone.ZoneScheduler') - - def _create_service_model(self, **kwargs): - service = db.sqlalchemy.models.Service() - service.host = kwargs['host'] - service.disabled = False - service.deleted = False - service.report_count = 0 - service.binary = 'nova-compute' - service.topic = 'compute' - service.id = kwargs['id'] - service.availability_zone = kwargs['zone'] - service.created_at = datetime.datetime.utcnow() - return service - - def test_with_two_zones(self): - scheduler = manager.SchedulerManager() - ctxt = context.get_admin_context() - service_list = [self._create_service_model(id=1, - host='host1', - zone='zone1'), - self._create_service_model(id=2, - host='host2', - zone='zone2'), - self._create_service_model(id=3, - host='host3', - zone='zone2'), - self._create_service_model(id=4, - host='host4', - zone='zone2'), - self._create_service_model(id=5, - host='host5', - zone='zone2')] - self.mox.StubOutWithMock(db, 'service_get_all_by_topic') - arg = IgnoreArg() - db.service_get_all_by_topic(arg, arg).AndReturn(service_list) - self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) - rpc.cast(ctxt, - 'compute.host1', - {'method': 'run_instance', - 'args': {'instance_id': 'i-ffffffff', - 'availability_zone': 'zone1'}}) - self.mox.ReplayAll() - scheduler.run_instance(ctxt, - 'compute', - instance_id='i-ffffffff', - availability_zone='zone1') - - -class SimpleDriverTestCase(test.TestCase): - """Test case for simple driver""" - def setUp(self): - super(SimpleDriverTestCase, self).setUp() - self.flags(connection_type='fake', - stub_network=True, - max_cores=4, - max_gigabytes=4, - network_manager='nova.network.manager.FlatManager', - volume_driver='nova.volume.driver.FakeISCSIDriver', - scheduler_driver='nova.scheduler.simple.SimpleScheduler') - self.scheduler = manager.SchedulerManager() - self.manager = auth_manager.AuthManager() - self.user = self.manager.create_user('fake', 'fake', 'fake') - self.project = self.manager.create_project('fake', 'fake', 'fake') - self.context = context.get_admin_context() - - def tearDown(self): - self.manager.delete_user(self.user) - self.manager.delete_project(self.project) - super(SimpleDriverTestCase, self).tearDown() - - def _create_instance(self, **kwargs): - """Create a test instance""" - inst = {} - inst['image_id'] = 1 - inst['reservation_id'] = 'r-fakeres' - inst['user_id'] = self.user.id - inst['project_id'] = self.project.id - inst['instance_type_id'] = '1' - inst['mac_address'] = utils.generate_mac() - inst['vcpus'] = kwargs.get('vcpus', 1) - inst['ami_launch_index'] = 0 - inst['availability_zone'] = kwargs.get('availability_zone', None) - inst['host'] = kwargs.get('host', 'dummy') - inst['memory_mb'] = kwargs.get('memory_mb', 20) - inst['local_gb'] = kwargs.get('local_gb', 30) - inst['launched_on'] = kwargs.get('launghed_on', 'dummy') - inst['state_description'] = kwargs.get('state_description', 'running') - inst['state'] = kwargs.get('state', power_state.RUNNING) - return db.instance_create(self.context, inst)['id'] - - def _create_volume(self): - """Create a test volume""" - vol = {} - vol['size'] = 1 - vol['availability_zone'] = 'test' - return db.volume_create(self.context, vol)['id'] - - def _create_compute_service(self, **kwargs): - """Create a compute service.""" - - dic = {'binary': 'nova-compute', 'topic': 'compute', - 'report_count': 0, 'availability_zone': 'dummyzone'} - dic['host'] = kwargs.get('host', 'dummy') - s_ref = db.service_create(self.context, dic) - if 'created_at' in kwargs.keys() or 'updated_at' in kwargs.keys(): - t = datetime.datetime.utcnow() - datetime.timedelta(0) - dic['created_at'] = kwargs.get('created_at', t) - dic['updated_at'] = kwargs.get('updated_at', t) - db.service_update(self.context, s_ref['id'], dic) - - dic = {'service_id': s_ref['id'], - 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, - 'vcpus_used': 16, 'local_gb_used': 10, - 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, - 'cpu_info': ''} - dic['memory_mb_used'] = kwargs.get('memory_mb_used', 32) - dic['hypervisor_type'] = kwargs.get('hypervisor_type', 'qemu') - dic['hypervisor_version'] = kwargs.get('hypervisor_version', 12003) - db.compute_node_create(self.context, dic) - return db.service_get(self.context, s_ref['id']) - - def test_doesnt_report_disabled_hosts_as_up(self): - """Ensures driver doesn't find hosts before they are enabled""" - # NOTE(vish): constructing service without create method - # because we are going to use it without queue - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - compute2 = service.Service('host2', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute2.start() - s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - s2 = db.service_get_by_args(self.context, 'host2', 'nova-compute') - db.service_update(self.context, s1['id'], {'disabled': True}) - db.service_update(self.context, s2['id'], {'disabled': True}) - hosts = self.scheduler.driver.hosts_up(self.context, 'compute') - self.assertEqual(0, len(hosts)) - compute1.kill() - compute2.kill() - - def test_reports_enabled_hosts_as_up(self): - """Ensures driver can find the hosts that are up""" - # NOTE(vish): constructing service without create method - # because we are going to use it without queue - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - compute2 = service.Service('host2', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute2.start() - hosts = self.scheduler.driver.hosts_up(self.context, 'compute') - self.assertEqual(2, len(hosts)) - compute1.kill() - compute2.kill() - - def test_least_busy_host_gets_instance(self): - """Ensures the host with less cores gets the next one""" - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - compute2 = service.Service('host2', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute2.start() - instance_id1 = self._create_instance() - compute1.run_instance(self.context, instance_id1) - instance_id2 = self._create_instance() - host = self.scheduler.driver.schedule_run_instance(self.context, - instance_id2) - self.assertEqual(host, 'host2') - compute1.terminate_instance(self.context, instance_id1) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - compute2.kill() - - def test_specific_host_gets_instance(self): - """Ensures if you set availability_zone it launches on that zone""" - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - compute2 = service.Service('host2', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute2.start() - instance_id1 = self._create_instance() - compute1.run_instance(self.context, instance_id1) - instance_id2 = self._create_instance(availability_zone='nova:host1') - host = self.scheduler.driver.schedule_run_instance(self.context, - instance_id2) - self.assertEqual('host1', host) - compute1.terminate_instance(self.context, instance_id1) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - compute2.kill() - - def test_wont_sechedule_if_specified_host_is_down(self): - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - now = datetime.datetime.utcnow() - delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) - past = now - delta - db.service_update(self.context, s1['id'], {'updated_at': past}) - instance_id2 = self._create_instance(availability_zone='nova:host1') - self.assertRaises(driver.WillNotSchedule, - self.scheduler.driver.schedule_run_instance, - self.context, - instance_id2) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - - def test_will_schedule_on_disabled_host_if_specified(self): - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - db.service_update(self.context, s1['id'], {'disabled': True}) - instance_id2 = self._create_instance(availability_zone='nova:host1') - host = self.scheduler.driver.schedule_run_instance(self.context, - instance_id2) - self.assertEqual('host1', host) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - - def test_too_many_cores(self): - """Ensures we don't go over max cores""" - compute1 = service.Service('host1', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute1.start() - compute2 = service.Service('host2', - 'nova-compute', - 'compute', - FLAGS.compute_manager) - compute2.start() - instance_ids1 = [] - instance_ids2 = [] - for index in xrange(FLAGS.max_cores): - instance_id = self._create_instance() - compute1.run_instance(self.context, instance_id) - instance_ids1.append(instance_id) - instance_id = self._create_instance() - compute2.run_instance(self.context, instance_id) - instance_ids2.append(instance_id) - instance_id = self._create_instance() - self.assertRaises(driver.NoValidHost, - self.scheduler.driver.schedule_run_instance, - self.context, - instance_id) - for instance_id in instance_ids1: - compute1.terminate_instance(self.context, instance_id) - for instance_id in instance_ids2: - compute2.terminate_instance(self.context, instance_id) - compute1.kill() - compute2.kill() - - def test_least_busy_host_gets_volume(self): - """Ensures the host with less gigabytes gets the next one""" - volume1 = service.Service('host1', - 'nova-volume', - 'volume', - FLAGS.volume_manager) - volume1.start() - volume2 = service.Service('host2', - 'nova-volume', - 'volume', - FLAGS.volume_manager) - volume2.start() - volume_id1 = self._create_volume() - volume1.create_volume(self.context, volume_id1) - volume_id2 = self._create_volume() - host = self.scheduler.driver.schedule_create_volume(self.context, - volume_id2) - self.assertEqual(host, 'host2') - volume1.delete_volume(self.context, volume_id1) - db.volume_destroy(self.context, volume_id2) - dic = {'service_id': s_ref['id'], - 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, - 'vcpus_used': 16, 'memory_mb_used': 12, 'local_gb_used': 10, - 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, - 'cpu_info': ''} - - def test_doesnt_report_disabled_hosts_as_up(self): - """Ensures driver doesn't find hosts before they are enabled""" - compute1 = self.start_service('compute', host='host1') - compute2 = self.start_service('compute', host='host2') - s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - s2 = db.service_get_by_args(self.context, 'host2', 'nova-compute') - db.service_update(self.context, s1['id'], {'disabled': True}) - db.service_update(self.context, s2['id'], {'disabled': True}) - hosts = self.scheduler.driver.hosts_up(self.context, 'compute') - self.assertEqual(0, len(hosts)) - compute1.kill() - compute2.kill() - - def test_reports_enabled_hosts_as_up(self): - """Ensures driver can find the hosts that are up""" - compute1 = self.start_service('compute', host='host1') - compute2 = self.start_service('compute', host='host2') - hosts = self.scheduler.driver.hosts_up(self.context, 'compute') - self.assertEqual(2, len(hosts)) - compute1.kill() - compute2.kill() - - def test_least_busy_host_gets_instance(self): - """Ensures the host with less cores gets the next one""" - compute1 = self.start_service('compute', host='host1') - compute2 = self.start_service('compute', host='host2') - instance_id1 = self._create_instance() - compute1.run_instance(self.context, instance_id1) - instance_id2 = self._create_instance() - host = self.scheduler.driver.schedule_run_instance(self.context, - instance_id2) - self.assertEqual(host, 'host2') - compute1.terminate_instance(self.context, instance_id1) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - compute2.kill() - - def test_specific_host_gets_instance(self): - """Ensures if you set availability_zone it launches on that zone""" - compute1 = self.start_service('compute', host='host1') - compute2 = self.start_service('compute', host='host2') - instance_id1 = self._create_instance() - compute1.run_instance(self.context, instance_id1) - instance_id2 = self._create_instance(availability_zone='nova:host1') - host = self.scheduler.driver.schedule_run_instance(self.context, - instance_id2) - self.assertEqual('host1', host) - compute1.terminate_instance(self.context, instance_id1) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - compute2.kill() - - def test_wont_sechedule_if_specified_host_is_down(self): - compute1 = self.start_service('compute', host='host1') - s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - now = datetime.datetime.utcnow() - delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) - past = now - delta - db.service_update(self.context, s1['id'], {'updated_at': past}) - instance_id2 = self._create_instance(availability_zone='nova:host1') - self.assertRaises(driver.WillNotSchedule, - self.scheduler.driver.schedule_run_instance, - self.context, - instance_id2) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - - def test_will_schedule_on_disabled_host_if_specified(self): - compute1 = self.start_service('compute', host='host1') - s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - db.service_update(self.context, s1['id'], {'disabled': True}) - instance_id2 = self._create_instance(availability_zone='nova:host1') - host = self.scheduler.driver.schedule_run_instance(self.context, - instance_id2) - self.assertEqual('host1', host) - db.instance_destroy(self.context, instance_id2) - compute1.kill() - - def test_too_many_cores(self): - """Ensures we don't go over max cores""" - compute1 = self.start_service('compute', host='host1') - compute2 = self.start_service('compute', host='host2') - instance_ids1 = [] - instance_ids2 = [] - for index in xrange(FLAGS.max_cores): - instance_id = self._create_instance() - compute1.run_instance(self.context, instance_id) - instance_ids1.append(instance_id) - instance_id = self._create_instance() - compute2.run_instance(self.context, instance_id) - instance_ids2.append(instance_id) - instance_id = self._create_instance() - self.assertRaises(driver.NoValidHost, - self.scheduler.driver.schedule_run_instance, - self.context, - instance_id) - db.instance_destroy(self.context, instance_id) - for instance_id in instance_ids1: - compute1.terminate_instance(self.context, instance_id) - for instance_id in instance_ids2: - compute2.terminate_instance(self.context, instance_id) - compute1.kill() - compute2.kill() - - def test_least_busy_host_gets_volume(self): - """Ensures the host with less gigabytes gets the next one""" - volume1 = self.start_service('volume', host='host1') - volume2 = self.start_service('volume', host='host2') - volume_id1 = self._create_volume() - volume1.create_volume(self.context, volume_id1) - volume_id2 = self._create_volume() - host = self.scheduler.driver.schedule_create_volume(self.context, - volume_id2) - self.assertEqual(host, 'host2') - volume1.delete_volume(self.context, volume_id1) - db.volume_destroy(self.context, volume_id2) - volume1.kill() - volume2.kill() - - def test_too_many_gigabytes(self): - """Ensures we don't go over max gigabytes""" - volume1 = self.start_service('volume', host='host1') - volume2 = self.start_service('volume', host='host2') - volume_ids1 = [] - volume_ids2 = [] - for index in xrange(FLAGS.max_gigabytes): - volume_id = self._create_volume() - volume1.create_volume(self.context, volume_id) - volume_ids1.append(volume_id) - volume_id = self._create_volume() - volume2.create_volume(self.context, volume_id) - volume_ids2.append(volume_id) - volume_id = self._create_volume() - self.assertRaises(driver.NoValidHost, - self.scheduler.driver.schedule_create_volume, - self.context, - volume_id) - for volume_id in volume_ids1: - volume1.delete_volume(self.context, volume_id) - for volume_id in volume_ids2: - volume2.delete_volume(self.context, volume_id) - volume1.kill() - volume2.kill() - - def test_scheduler_live_migration_with_volume(self): - """scheduler_live_migration() works correctly as expected. - - Also, checks instance state is changed from 'running' -> 'migrating'. - - """ - - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - dic = {'instance_id': instance_id, 'size': 1} - v_ref = db.volume_create(self.context, dic) - - # cannot check 2nd argument b/c the addresses of instance object - # is different. - driver_i = self.scheduler.driver - nocare = mox.IgnoreArg() - self.mox.StubOutWithMock(driver_i, '_live_migration_src_check') - self.mox.StubOutWithMock(driver_i, '_live_migration_dest_check') - self.mox.StubOutWithMock(driver_i, '_live_migration_common_check') - driver_i._live_migration_src_check(nocare, nocare) - driver_i._live_migration_dest_check(nocare, nocare, i_ref['host']) - driver_i._live_migration_common_check(nocare, nocare, i_ref['host']) - self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) - kwargs = {'instance_id': instance_id, 'dest': i_ref['host']} - rpc.cast(self.context, - db.queue_get_for(nocare, FLAGS.compute_topic, i_ref['host']), - {"method": 'live_migration', "args": kwargs}) - - self.mox.ReplayAll() - self.scheduler.live_migration(self.context, FLAGS.compute_topic, - instance_id=instance_id, - dest=i_ref['host']) - - i_ref = db.instance_get(self.context, instance_id) - self.assertTrue(i_ref['state_description'] == 'migrating') - db.instance_destroy(self.context, instance_id) - db.volume_destroy(self.context, v_ref['id']) - - def test_live_migration_src_check_instance_not_running(self): - """The instance given by instance_id is not running.""" - - instance_id = self._create_instance(state_description='migrating') - i_ref = db.instance_get(self.context, instance_id) - - try: - self.scheduler.driver._live_migration_src_check(self.context, - i_ref) - except exception.Invalid, e: - c = (e.message.find('is not running') > 0) - - self.assertTrue(c) - db.instance_destroy(self.context, instance_id) - - def test_live_migration_src_check_volume_node_not_alive(self): - """Raise exception when volume node is not alive.""" - - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - dic = {'instance_id': instance_id, 'size': 1} - v_ref = db.volume_create(self.context, {'instance_id': instance_id, - 'size': 1}) - t1 = datetime.datetime.utcnow() - datetime.timedelta(1) - dic = {'created_at': t1, 'updated_at': t1, 'binary': 'nova-volume', - 'topic': 'volume', 'report_count': 0} - s_ref = db.service_create(self.context, dic) - - self.assertRaises(exception.VolumeServiceUnavailable, - self.scheduler.driver.schedule_live_migration, - self.context, instance_id, i_ref['host']) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - db.volume_destroy(self.context, v_ref['id']) - - def test_live_migration_src_check_compute_node_not_alive(self): - """Confirms src-compute node is alive.""" - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - t = datetime.datetime.utcnow() - datetime.timedelta(10) - s_ref = self._create_compute_service(created_at=t, updated_at=t, - host=i_ref['host']) - - self.assertRaises(exception.ComputeServiceUnavailable, - self.scheduler.driver._live_migration_src_check, - self.context, i_ref) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_src_check_works_correctly(self): - """Confirms this method finishes with no error.""" - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - s_ref = self._create_compute_service(host=i_ref['host']) - - ret = self.scheduler.driver._live_migration_src_check(self.context, - i_ref) - - self.assertTrue(ret is None) - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_dest_check_not_alive(self): - """Confirms exception raises in case dest host does not exist.""" - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - t = datetime.datetime.utcnow() - datetime.timedelta(10) - s_ref = self._create_compute_service(created_at=t, updated_at=t, - host=i_ref['host']) - - self.assertRaises(exception.ComputeServiceUnavailable, - self.scheduler.driver._live_migration_dest_check, - self.context, i_ref, i_ref['host']) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_dest_check_service_same_host(self): - """Confirms exceptioin raises in case dest and src is same host.""" - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - s_ref = self._create_compute_service(host=i_ref['host']) - - self.assertRaises(exception.UnableToMigrateToSelf, - self.scheduler.driver._live_migration_dest_check, - self.context, i_ref, i_ref['host']) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_dest_check_service_lack_memory(self): - """Confirms exception raises when dest doesn't have enough memory.""" - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - s_ref = self._create_compute_service(host='somewhere', - memory_mb_used=12) - - self.assertRaises(exception.MigrationError, - self.scheduler.driver._live_migration_dest_check, - self.context, i_ref, 'somewhere') - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_dest_check_service_works_correctly(self): - """Confirms method finishes with no error.""" - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - s_ref = self._create_compute_service(host='somewhere', - memory_mb_used=5) - - ret = self.scheduler.driver._live_migration_dest_check(self.context, - i_ref, - 'somewhere') - self.assertTrue(ret is None) - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_common_check_service_orig_not_exists(self): - """Destination host does not exist.""" - - dest = 'dummydest' - # mocks for live_migration_common_check() - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - t1 = datetime.datetime.utcnow() - datetime.timedelta(10) - s_ref = self._create_compute_service(created_at=t1, updated_at=t1, - host=dest) - - # mocks for mounted_on_same_shared_storage() - fpath = '/test/20110127120000' - self.mox.StubOutWithMock(driver, 'rpc', use_mock_anything=True) - topic = FLAGS.compute_topic - driver.rpc.call(mox.IgnoreArg(), - db.queue_get_for(self.context, topic, dest), - {"method": 'create_shared_storage_test_file'}).AndReturn(fpath) - driver.rpc.call(mox.IgnoreArg(), - db.queue_get_for(mox.IgnoreArg(), topic, i_ref['host']), - {"method": 'check_shared_storage_test_file', - "args": {'filename': fpath}}) - driver.rpc.call(mox.IgnoreArg(), - db.queue_get_for(mox.IgnoreArg(), topic, dest), - {"method": 'cleanup_shared_storage_test_file', - "args": {'filename': fpath}}) - - self.mox.ReplayAll() - self.assertRaises(exception.SourceHostUnavailable, - self.scheduler.driver._live_migration_common_check, - self.context, i_ref, dest) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - - def test_live_migration_common_check_service_different_hypervisor(self): - """Original host and dest host has different hypervisor type.""" - dest = 'dummydest' - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - - # compute service for destination - s_ref = self._create_compute_service(host=i_ref['host']) - # compute service for original host - s_ref2 = self._create_compute_service(host=dest, hypervisor_type='xen') - - # mocks - driver = self.scheduler.driver - self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') - driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) - - self.mox.ReplayAll() - self.assertRaises(exception.InvalidHypervisorType, - self.scheduler.driver._live_migration_common_check, - self.context, i_ref, dest) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - db.service_destroy(self.context, s_ref2['id']) - - def test_live_migration_common_check_service_different_version(self): - """Original host and dest host has different hypervisor version.""" - dest = 'dummydest' - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - - # compute service for destination - s_ref = self._create_compute_service(host=i_ref['host']) - # compute service for original host - s_ref2 = self._create_compute_service(host=dest, - hypervisor_version=12002) - - # mocks - driver = self.scheduler.driver - self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') - driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) - - self.mox.ReplayAll() - self.assertRaises(exception.DestinationHypervisorTooOld, - self.scheduler.driver._live_migration_common_check, - self.context, i_ref, dest) - - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - db.service_destroy(self.context, s_ref2['id']) - - def test_live_migration_common_check_checking_cpuinfo_fail(self): - """Raise excetion when original host doen't have compatible cpu.""" - - dest = 'dummydest' - instance_id = self._create_instance() - i_ref = db.instance_get(self.context, instance_id) - - # compute service for destination - s_ref = self._create_compute_service(host=i_ref['host']) - # compute service for original host - s_ref2 = self._create_compute_service(host=dest) - - # mocks - driver = self.scheduler.driver - self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') - driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) - self.mox.StubOutWithMock(rpc, 'call', use_mock_anything=True) - rpc.call(mox.IgnoreArg(), mox.IgnoreArg(), - {"method": 'compare_cpu', - "args": {'cpu_info': s_ref2['compute_node'][0]['cpu_info']}}).\ - AndRaise(rpc.RemoteError("doesn't have compatibility to", "", "")) - - self.mox.ReplayAll() - try: - self.scheduler.driver._live_migration_common_check(self.context, - i_ref, - dest) - except rpc.RemoteError, e: - c = (e.message.find(_("doesn't have compatibility to")) >= 0) - - self.assertTrue(c) - db.instance_destroy(self.context, instance_id) - db.service_destroy(self.context, s_ref['id']) - db.service_destroy(self.context, s_ref2['id']) - - -class FakeZone(object): - def __init__(self, id, api_url, username, password): - self.id = id - self.api_url = api_url - self.username = username - self.password = password - - -def zone_get_all(context): - return [ - FakeZone(1, 'http://example.com', 'bob', 'xxx'), - ] - - -class FakeRerouteCompute(api.reroute_compute): - def _call_child_zones(self, zones, function): - return [] - - def get_collection_context_and_id(self, args, kwargs): - return ("servers", None, 1) - - def unmarshall_result(self, zone_responses): - return dict(magic="found me") - - -def go_boom(self, context, instance): - raise exception.InstanceNotFound(instance_id=instance) - - -def found_instance(self, context, instance): - return dict(name='myserver') - - -class FakeResource(object): - def __init__(self, attribute_dict): - for k, v in attribute_dict.iteritems(): - setattr(self, k, v) - - def pause(self): - pass - - -class ZoneRedirectTest(test.TestCase): - def setUp(self): - super(ZoneRedirectTest, self).setUp() - self.stubs = stubout.StubOutForTesting() - - self.stubs.Set(db, 'zone_get_all', zone_get_all) - - self.enable_zone_routing = FLAGS.enable_zone_routing - FLAGS.enable_zone_routing = True - - def tearDown(self): - self.stubs.UnsetAll() - FLAGS.enable_zone_routing = self.enable_zone_routing - super(ZoneRedirectTest, self).tearDown() - - def test_trap_found_locally(self): - decorator = FakeRerouteCompute("foo") - try: - result = decorator(found_instance)(None, None, 1) - except api.RedirectResult, e: - self.fail(_("Successful database hit should succeed")) - - def test_trap_not_found_locally(self): - decorator = FakeRerouteCompute("foo") - try: - result = decorator(go_boom)(None, None, 1) - self.assertFail(_("Should have rerouted.")) - except api.RedirectResult, e: - self.assertEquals(e.results['magic'], 'found me') - - def test_routing_flags(self): - FLAGS.enable_zone_routing = False - decorator = FakeRerouteCompute("foo") - self.assertRaises(exception.InstanceNotFound, decorator(go_boom), - None, None, 1) - - def test_get_collection_context_and_id(self): - decorator = api.reroute_compute("foo") - self.assertEquals(decorator.get_collection_context_and_id( - (None, 10, 20), {}), ("servers", 10, 20)) - self.assertEquals(decorator.get_collection_context_and_id( - (None, 11,), dict(instance_id=21)), ("servers", 11, 21)) - self.assertEquals(decorator.get_collection_context_and_id( - (None,), dict(context=12, instance_id=22)), ("servers", 12, 22)) - - def test_unmarshal_single_server(self): - decorator = api.reroute_compute("foo") - self.assertEquals(decorator.unmarshall_result([]), {}) - self.assertEquals(decorator.unmarshall_result( - [FakeResource(dict(a=1, b=2)), ]), - dict(server=dict(a=1, b=2))) - self.assertEquals(decorator.unmarshall_result( - [FakeResource(dict(a=1, _b=2)), ]), - dict(server=dict(a=1,))) - self.assertEquals(decorator.unmarshall_result( - [FakeResource(dict(a=1, manager=2)), ]), - dict(server=dict(a=1,))) - self.assertEquals(decorator.unmarshall_result( - [FakeResource(dict(_a=1, manager=2)), ]), - dict(server={})) - - -class FakeServerCollection(object): - def get(self, instance_id): - return FakeResource(dict(a=10, b=20)) - - def find(self, name): - return FakeResource(dict(a=11, b=22)) - - -class FakeEmptyServerCollection(object): - def get(self, f): - raise novaclient.NotFound(1) - - def find(self, name): - raise novaclient.NotFound(2) - - -class FakeNovaClient(object): - def __init__(self, collection): - self.servers = collection - - -class DynamicNovaClientTest(test.TestCase): - def test_issue_novaclient_command_found(self): - zone = FakeZone(1, 'http://example.com', 'bob', 'xxx') - self.assertEquals(api._issue_novaclient_command( - FakeNovaClient(FakeServerCollection()), - zone, "servers", "get", 100).a, 10) - - self.assertEquals(api._issue_novaclient_command( - FakeNovaClient(FakeServerCollection()), - zone, "servers", "find", "name").b, 22) - - self.assertEquals(api._issue_novaclient_command( - FakeNovaClient(FakeServerCollection()), - zone, "servers", "pause", 100), None) - - def test_issue_novaclient_command_not_found(self): - zone = FakeZone(1, 'http://example.com', 'bob', 'xxx') - self.assertEquals(api._issue_novaclient_command( - FakeNovaClient(FakeEmptyServerCollection()), - zone, "servers", "get", 100), None) - - self.assertEquals(api._issue_novaclient_command( - FakeNovaClient(FakeEmptyServerCollection()), - zone, "servers", "find", "name"), None) - - self.assertEquals(api._issue_novaclient_command( - FakeNovaClient(FakeEmptyServerCollection()), - zone, "servers", "any", "name"), None) - - -class FakeZonesProxy(object): - def do_something(*args, **kwargs): - return 42 - - def raises_exception(*args, **kwargs): - raise Exception('testing') - - -class FakeNovaClientOpenStack(object): - def __init__(self, *args, **kwargs): - self.zones = FakeZonesProxy() - - def authenticate(self): - pass - - -class CallZoneMethodTest(test.TestCase): - def setUp(self): - super(CallZoneMethodTest, self).setUp() - self.stubs = stubout.StubOutForTesting() - self.stubs.Set(db, 'zone_get_all', zone_get_all) - self.stubs.Set(novaclient, 'OpenStack', FakeNovaClientOpenStack) - - def tearDown(self): - self.stubs.UnsetAll() - super(CallZoneMethodTest, self).tearDown() - - def test_call_zone_method(self): - context = {} - method = 'do_something' - results = api.call_zone_method(context, method) - expected = [(1, 42)] - self.assertEqual(expected, results) - - def test_call_zone_method_not_present(self): - context = {} - method = 'not_present' - self.assertRaises(AttributeError, api.call_zone_method, - context, method) - - def test_call_zone_method_generates_exception(self): - context = {} - method = 'raises_exception' - results = api.call_zone_method(context, method) - - # FIXME(sirp): for now the _error_trap code is catching errors and - # converting them to a ("ERROR", "string") tuples. The code (and this - # test) should eventually handle real exceptions. - expected = [(1, ('ERROR', 'testing'))] - self.assertEqual(expected, results) diff --git a/nova/tests/test_zone_aware_scheduler.py b/nova/tests/test_zone_aware_scheduler.py deleted file mode 100644 index 37169fb97..000000000 --- a/nova/tests/test_zone_aware_scheduler.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2011 OpenStack LLC. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -""" -Tests For Zone Aware Scheduler. -""" - -from nova import test -from nova.scheduler import driver -from nova.scheduler import zone_aware_scheduler -from nova.scheduler import zone_manager - - -class FakeZoneAwareScheduler(zone_aware_scheduler.ZoneAwareScheduler): - def filter_hosts(self, num, specs): - # NOTE(sirp): this is returning [(hostname, services)] - return self.zone_manager.service_states.items() - - def weigh_hosts(self, num, specs, hosts): - fake_weight = 99 - weighted = [] - for hostname, caps in hosts: - weighted.append(dict(weight=fake_weight, name=hostname)) - return weighted - - -class FakeZoneManager(zone_manager.ZoneManager): - def __init__(self): - self.service_states = { - 'host1': { - 'compute': {'ram': 1000} - }, - 'host2': { - 'compute': {'ram': 2000} - }, - 'host3': { - 'compute': {'ram': 3000} - } - } - - -class FakeEmptyZoneManager(zone_manager.ZoneManager): - def __init__(self): - self.service_states = {} - - -def fake_empty_call_zone_method(context, method, specs): - return [] - - -def fake_call_zone_method(context, method, specs): - return [ - ('zone1', [ - dict(weight=1, blob='AAAAAAA'), - dict(weight=111, blob='BBBBBBB'), - dict(weight=112, blob='CCCCCCC'), - dict(weight=113, blob='DDDDDDD'), - ]), - ('zone2', [ - dict(weight=120, blob='EEEEEEE'), - dict(weight=2, blob='FFFFFFF'), - dict(weight=122, blob='GGGGGGG'), - dict(weight=123, blob='HHHHHHH'), - ]), - ('zone3', [ - dict(weight=130, blob='IIIIIII'), - dict(weight=131, blob='JJJJJJJ'), - dict(weight=132, blob='KKKKKKK'), - dict(weight=3, blob='LLLLLLL'), - ]), - ] - - -class ZoneAwareSchedulerTestCase(test.TestCase): - """Test case for Zone Aware Scheduler.""" - - def test_zone_aware_scheduler(self): - """ - Create a nested set of FakeZones, ensure that a select call returns the - appropriate build plan. - """ - sched = FakeZoneAwareScheduler() - self.stubs.Set(sched, '_call_zone_method', fake_call_zone_method) - - zm = FakeZoneManager() - sched.set_zone_manager(zm) - - fake_context = {} - build_plan = sched.select(fake_context, {}) - - self.assertEqual(15, len(build_plan)) - - hostnames = [plan_item['name'] - for plan_item in build_plan if 'name' in plan_item] - self.assertEqual(3, len(hostnames)) - - def test_empty_zone_aware_scheduler(self): - """ - Ensure empty hosts & child_zones result in NoValidHosts exception. - """ - sched = FakeZoneAwareScheduler() - self.stubs.Set(sched, '_call_zone_method', fake_empty_call_zone_method) - - zm = FakeEmptyZoneManager() - sched.set_zone_manager(zm) - - fake_context = {} - self.assertRaises(driver.NoValidHost, sched.schedule_run_instance, - fake_context, 1, - dict(host_filter=None, instance_type={})) -- cgit From 967d82669ae07b2add3289e3decad60aea2657d8 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 18:49:21 -0500 Subject: Moving into scheduler subdir and refactoring out common code --- nova/tests/scheduler/__init__.py | 0 nova/tests/scheduler/test_host_filter.py | 189 ++++++++++++++++++++++ nova/tests/scheduler/test_least_cost_scheduler.py | 146 +++++++++++++++++ nova/tests/scheduler/test_zone_aware_scheduler.py | 31 ++++ 4 files changed, 366 insertions(+) create mode 100644 nova/tests/scheduler/__init__.py create mode 100644 nova/tests/scheduler/test_host_filter.py create mode 100644 nova/tests/scheduler/test_least_cost_scheduler.py diff --git a/nova/tests/scheduler/__init__.py b/nova/tests/scheduler/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/nova/tests/scheduler/test_host_filter.py b/nova/tests/scheduler/test_host_filter.py new file mode 100644 index 000000000..c3af50a6e --- /dev/null +++ b/nova/tests/scheduler/test_host_filter.py @@ -0,0 +1,189 @@ +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +Tests For Scheduler Host Filter Drivers. +""" + +import json + +from nova import exception +from nova import flags +from nova import test +from nova.scheduler import host_filter +from nova.tests.scheduler import test_zone_aware_scheduler + +FLAGS = flags.FLAGS + + +class FakeZoneManager: + pass + + +class HostFilterTestCase(test.TestCase): + """Test case for host filter drivers.""" + + def setUp(self): + super(HostFilterTestCase, self).setUp() + self.old_flag = FLAGS.default_host_filter_driver + FLAGS.default_host_filter_driver = \ + 'nova.scheduler.host_filter.AllHostsFilter' + self.instance_type = dict(name='tiny', + memory_mb=50, + vcpus=10, + local_gb=500, + flavorid=1, + swap=500, + rxtx_quota=30000, + rxtx_cap=200) + + self.zone_manager = FakeZoneManager() + + states = test_zone_aware_scheduler.fake_zone_manager_service_states( + num_hosts=10) + self.zone_manager.service_states = states + + def tearDown(self): + FLAGS.default_host_filter_driver = self.old_flag + super(HostFilterTestCase, self).tearDown() + + def test_choose_driver(self): + # Test default driver ... + driver = host_filter.choose_driver() + self.assertEquals(driver._full_name(), + 'nova.scheduler.host_filter.AllHostsFilter') + # Test valid driver ... + driver = host_filter.choose_driver( + 'nova.scheduler.host_filter.InstanceTypeFilter') + self.assertEquals(driver._full_name(), + 'nova.scheduler.host_filter.InstanceTypeFilter') + # Test invalid driver ... + try: + host_filter.choose_driver('does not exist') + self.fail("Should not find driver") + except exception.SchedulerHostFilterDriverNotFound: + pass + + def test_all_host_driver(self): + driver = host_filter.AllHostsFilter() + cooked = driver.instance_type_to_filter(self.instance_type) + hosts = driver.filter_hosts(self.zone_manager, cooked) + self.assertEquals(10, len(hosts)) + for host, capabilities in hosts: + self.assertTrue(host.startswith('host')) + + def test_instance_type_driver(self): + driver = host_filter.InstanceTypeFilter() + # filter all hosts that can support 50 ram and 500 disk + name, cooked = driver.instance_type_to_filter(self.instance_type) + self.assertEquals('nova.scheduler.host_filter.InstanceTypeFilter', + name) + hosts = driver.filter_hosts(self.zone_manager, cooked) + self.assertEquals(6, len(hosts)) + just_hosts = [host for host, caps in hosts] + just_hosts.sort() + self.assertEquals('host05', just_hosts[0]) + self.assertEquals('host10', just_hosts[5]) + + def test_json_driver(self): + driver = host_filter.JsonFilter() + # filter all hosts that can support 50 ram and 500 disk + name, cooked = driver.instance_type_to_filter(self.instance_type) + self.assertEquals('nova.scheduler.host_filter.JsonFilter', name) + hosts = driver.filter_hosts(self.zone_manager, cooked) + self.assertEquals(6, len(hosts)) + just_hosts = [host for host, caps in hosts] + just_hosts.sort() + self.assertEquals('host05', just_hosts[0]) + self.assertEquals('host10', just_hosts[5]) + + # Try some custom queries + + raw = ['or', + ['and', + ['<', '$compute.host_memory_free', 30], + ['<', '$compute.disk_available', 300] + ], + ['and', + ['>', '$compute.host_memory_free', 70], + ['>', '$compute.disk_available', 700] + ] + ] + cooked = json.dumps(raw) + hosts = driver.filter_hosts(self.zone_manager, cooked) + + self.assertEquals(5, len(hosts)) + just_hosts = [host for host, caps in hosts] + just_hosts.sort() + for index, host in zip([1, 2, 8, 9, 10], just_hosts): + self.assertEquals('host%02d' % index, host) + + raw = ['not', + ['=', '$compute.host_memory_free', 30], + ] + cooked = json.dumps(raw) + hosts = driver.filter_hosts(self.zone_manager, cooked) + + self.assertEquals(9, len(hosts)) + just_hosts = [host for host, caps in hosts] + just_hosts.sort() + for index, host in zip([1, 2, 4, 5, 6, 7, 8, 9, 10], just_hosts): + self.assertEquals('host%02d' % index, host) + + raw = ['in', '$compute.host_memory_free', 20, 40, 60, 80, 100] + cooked = json.dumps(raw) + hosts = driver.filter_hosts(self.zone_manager, cooked) + + self.assertEquals(5, len(hosts)) + just_hosts = [host for host, caps in hosts] + just_hosts.sort() + for index, host in zip([2, 4, 6, 8, 10], just_hosts): + self.assertEquals('host%02d' % index, host) + + # Try some bogus input ... + raw = ['unknown command', ] + cooked = json.dumps(raw) + try: + driver.filter_hosts(self.zone_manager, cooked) + self.fail("Should give KeyError") + except KeyError, e: + pass + + self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps([]))) + self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps({}))) + self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps( + ['not', True, False, True, False] + ))) + + try: + driver.filter_hosts(self.zone_manager, json.dumps( + 'not', True, False, True, False + )) + self.fail("Should give KeyError") + except KeyError, e: + pass + + self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( + ['=', '$foo', 100] + ))) + self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( + ['=', '$.....', 100] + ))) + self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( + ['>', ['and', ['or', ['not', ['<', ['>=', ['<=', ['in', ]]]]]]]] + ))) + + self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps( + ['=', {}, ['>', '$missing....foo']] + ))) diff --git a/nova/tests/scheduler/test_least_cost_scheduler.py b/nova/tests/scheduler/test_least_cost_scheduler.py new file mode 100644 index 000000000..e0ed61417 --- /dev/null +++ b/nova/tests/scheduler/test_least_cost_scheduler.py @@ -0,0 +1,146 @@ +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +Tests For Least Cost Scheduler +""" + +from nova import flags +from nova import test +from nova.scheduler import least_cost +from nova.tests.scheduler import test_zone_aware_scheduler + +MB = 1024 * 1024 +FLAGS = flags.FLAGS + + +class FakeHost(object): + def __init__(self, host_id, free_ram, io): + self.id = host_id + self.free_ram = free_ram + self.io = io + + +class WeightedSumTestCase(test.TestCase): + def test_empty_domain(self): + domain = [] + weighted_fns = [] + result = least_cost.weighted_sum(domain, weighted_fns) + expected = [] + self.assertEqual(expected, result) + + def test_basic_costing(self): + hosts = [ + FakeHost(1, 512 * MB, 100), + FakeHost(2, 256 * MB, 400), + FakeHost(3, 512 * MB, 100) + ] + + weighted_fns = [ + (1, lambda h: h.free_ram), # Fill-first, free_ram is a *cost* + (2, lambda h: h.io), # Avoid high I/O + ] + + costs = least_cost.weighted_sum( + domain=hosts, weighted_fns=weighted_fns) + + # Each 256 MB unit of free-ram contributes 0.5 points by way of: + # cost = weight * (score/max_score) = 1 * (256/512) = 0.5 + # Each 100 iops of IO adds 0.5 points by way of: + # cost = 2 * (100/400) = 2 * 0.25 = 0.5 + expected = [1.5, 2.5, 1.5] + self.assertEqual(expected, costs) + + +# TODO(sirp): unify this with test_host_filter tests? possibility of sharing +# test setup code +class FakeZoneManager: + pass + + +class LeastCostSchedulerTestCase(test.TestCase): + def setUp(self): + super(LeastCostSchedulerTestCase, self).setUp() + zone_manager = FakeZoneManager() + + states = test_zone_aware_scheduler.fake_zone_manager_service_states( + num_hosts=10) + zone_manager.service_states = states + + self.sched = least_cost.LeastCostScheduler() + self.sched.zone_manager = zone_manager + + def tearDown(self): + super(LeastCostSchedulerTestCase, self).tearDown() + + def assertWeights(self, expected, num, request_spec, hosts): + weighted = self.sched.weigh_hosts(num, request_spec, hosts) + self.assertDictListMatch(weighted, expected, approx_equal=True) + + def test_no_hosts(self): + num = 1 + request_spec = {} + hosts = [] + + expected = [] + self.assertWeights(expected, num, request_spec, hosts) + + def test_noop_cost_fn(self): + FLAGS.least_cost_scheduler_cost_functions = [ + 'nova.scheduler.least_cost.noop_cost_fn' + ] + FLAGS.noop_cost_fn_weight = 1 + + num = 1 + request_spec = {} + hosts = self.sched.filter_hosts(num, request_spec) + + expected = [dict(weight=1, hostname=hostname) + for hostname, caps in hosts] + self.assertWeights(expected, num, request_spec, hosts) + + def test_cost_fn_weights(self): + FLAGS.least_cost_scheduler_cost_functions = [ + 'nova.scheduler.least_cost.noop_cost_fn' + ] + FLAGS.noop_cost_fn_weight = 2 + + num = 1 + request_spec = {} + hosts = self.sched.filter_hosts(num, request_spec) + + expected = [dict(weight=2, hostname=hostname) + for hostname, caps in hosts] + self.assertWeights(expected, num, request_spec, hosts) + + def test_fill_first_cost_fn(self): + FLAGS.least_cost_scheduler_cost_functions = [ + 'nova.scheduler.least_cost.fill_first_cost_fn' + ] + FLAGS.fill_first_cost_fn_weight = 1 + + num = 1 + request_spec = {} + hosts = self.sched.filter_hosts(num, request_spec) + + expected = [] + for idx, (hostname, caps) in enumerate(hosts): + # Costs are normalized so over 10 hosts, each host with increasing + # free ram will cost 1/N more. Since the lowest cost host has some + # free ram, we add in the 1/N for the base_cost + weight = 0.1 + (0.1 * idx) + weight_dict = dict(weight=weight, hostname=hostname) + expected.append(weight_dict) + + self.assertWeights(expected, num, request_spec, hosts) diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index 37169fb97..b2cc4fe23 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -22,6 +22,37 @@ from nova.scheduler import zone_aware_scheduler from nova.scheduler import zone_manager +def _host_caps(multiplier): + # Returns host capabilities in the following way: + # host1 = memory:free 10 (100max) + # disk:available 100 (1000max) + # hostN = memory:free 10 + 10N + # disk:available 100 + 100N + # in other words: hostN has more resources than host0 + # which means ... don't go above 10 hosts. + return {'host_name-description': 'XenServer %s' % multiplier, + 'host_hostname': 'xs-%s' % multiplier, + 'host_memory_total': 100, + 'host_memory_overhead': 10, + 'host_memory_free': 10 + multiplier * 10, + 'host_memory_free-computed': 10 + multiplier * 10, + 'host_other-config': {}, + 'host_ip_address': '192.168.1.%d' % (100 + multiplier), + 'host_cpu_info': {}, + 'disk_available': 100 + multiplier * 100, + 'disk_total': 1000, + 'disk_used': 0, + 'host_uuid': 'xxx-%d' % multiplier, + 'host_name-label': 'xs-%s' % multiplier} + + +def fake_zone_manager_service_states(num_hosts): + states = {} + for x in xrange(num_hosts): + states['host%02d' % (x + 1)] = {'compute': _host_caps(x)} + return states + + class FakeZoneAwareScheduler(zone_aware_scheduler.ZoneAwareScheduler): def filter_hosts(self, num, specs): # NOTE(sirp): this is returning [(hostname, services)] -- cgit From 1b610e28e40c77271191349b6bfaa56c8f522c24 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 17 May 2011 18:53:00 -0500 Subject: Small cleanups --- nova/tests/scheduler/test_host_filter.py | 7 +++---- nova/tests/scheduler/test_least_cost_scheduler.py | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nova/tests/scheduler/test_host_filter.py b/nova/tests/scheduler/test_host_filter.py index c3af50a6e..edbab7ab4 100644 --- a/nova/tests/scheduler/test_host_filter.py +++ b/nova/tests/scheduler/test_host_filter.py @@ -27,10 +27,6 @@ from nova.tests.scheduler import test_zone_aware_scheduler FLAGS = flags.FLAGS -class FakeZoneManager: - pass - - class HostFilterTestCase(test.TestCase): """Test case for host filter drivers.""" @@ -48,6 +44,9 @@ class HostFilterTestCase(test.TestCase): rxtx_quota=30000, rxtx_cap=200) + class FakeZoneManager: + pass + self.zone_manager = FakeZoneManager() states = test_zone_aware_scheduler.fake_zone_manager_service_states( diff --git a/nova/tests/scheduler/test_least_cost_scheduler.py b/nova/tests/scheduler/test_least_cost_scheduler.py index e0ed61417..506fa62fb 100644 --- a/nova/tests/scheduler/test_least_cost_scheduler.py +++ b/nova/tests/scheduler/test_least_cost_scheduler.py @@ -63,15 +63,13 @@ class WeightedSumTestCase(test.TestCase): self.assertEqual(expected, costs) -# TODO(sirp): unify this with test_host_filter tests? possibility of sharing -# test setup code -class FakeZoneManager: - pass - - class LeastCostSchedulerTestCase(test.TestCase): def setUp(self): super(LeastCostSchedulerTestCase, self).setUp() + + class FakeZoneManager: + pass + zone_manager = FakeZoneManager() states = test_zone_aware_scheduler.fake_zone_manager_service_states( -- cgit From 3ff9051c2ae60493d39d7e276c61689ffca2ac8d Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 17 May 2011 20:38:02 -0500 Subject: MySQL database tables are using the MyISAM engine. Created migration script to change all current tables to InnoDB, updated version to 019 --- .../versions/017_set_engine_mysql_innodb.py | 57 ---------------------- 1 file changed, 57 deletions(-) delete mode 100644 nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py deleted file mode 100644 index be7ff5abd..000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/017_set_engine_mysql_innodb.py +++ /dev/null @@ -1,57 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2011 OpenStack LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from sqlalchemy import MetaData, Table - -meta = MetaData() - -def upgrade(migrate_engine): - # Upgrade operations go here. Don't create your own engine; - # bind migrate_engine to your metadata - meta.bind = migrate_engine - if migrate_engine.name == "mysql": - migrate_engine.execute("ALTER TABLE auth_tokens Engine=InnoDB") - migrate_engine.execute("ALTER TABLE certificates Engine=InnoDB") - migrate_engine.execute("ALTER TABLE compute_nodes Engine=InnoDB") - migrate_engine.execute("ALTER TABLE console_pools Engine=InnoDB") - migrate_engine.execute("ALTER TABLE consoles Engine=InnoDB") - migrate_engine.execute("ALTER TABLE export_devices Engine=InnoDB") - migrate_engine.execute("ALTER TABLE fixed_ips Engine=InnoDB") - migrate_engine.execute("ALTER TABLE floating_ips Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instance_actions Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instance_metadata Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instance_types Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instances Engine=InnoDB") - migrate_engine.execute("ALTER TABLE iscsi_targets Engine=InnoDB") - migrate_engine.execute("ALTER TABLE key_pairs Engine=InnoDB") - migrate_engine.execute("ALTER TABLE migrate_version Engine=InnoDB") - migrate_engine.execute("ALTER TABLE migrations Engine=InnoDB") - migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") - migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") - migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") - migrate_engine.execute("ALTER TABLE services Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE users Engine=InnoDB") - migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") - migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") - -def downgrade(migrate_engine): - meta.bind = migrate_engine -- cgit From d43603e2702f41936a9a85915280b9d773d6c74c Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 17 May 2011 20:38:18 -0500 Subject: MySQL database tables are using the MyISAM engine. Created migration script to change all current tables to InnoDB, updated version to 019 --- .../versions/019_set_engine_mysql_innodb.py | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py new file mode 100644 index 000000000..be7ff5abd --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py @@ -0,0 +1,57 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import MetaData, Table + +meta = MetaData() + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + if migrate_engine.name == "mysql": + migrate_engine.execute("ALTER TABLE auth_tokens Engine=InnoDB") + migrate_engine.execute("ALTER TABLE certificates Engine=InnoDB") + migrate_engine.execute("ALTER TABLE compute_nodes Engine=InnoDB") + migrate_engine.execute("ALTER TABLE console_pools Engine=InnoDB") + migrate_engine.execute("ALTER TABLE consoles Engine=InnoDB") + migrate_engine.execute("ALTER TABLE export_devices Engine=InnoDB") + migrate_engine.execute("ALTER TABLE fixed_ips Engine=InnoDB") + migrate_engine.execute("ALTER TABLE floating_ips Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_actions Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_metadata Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_types Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instances Engine=InnoDB") + migrate_engine.execute("ALTER TABLE iscsi_targets Engine=InnoDB") + migrate_engine.execute("ALTER TABLE key_pairs Engine=InnoDB") + migrate_engine.execute("ALTER TABLE migrate_version Engine=InnoDB") + migrate_engine.execute("ALTER TABLE migrations Engine=InnoDB") + migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") + migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") + migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") + migrate_engine.execute("ALTER TABLE services Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE users Engine=InnoDB") + migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") + migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") + +def downgrade(migrate_engine): + meta.bind = migrate_engine -- cgit From 6c151bfbfeb728d6e38f777640d483c1e344113d Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Wed, 18 May 2011 03:51:25 -0400 Subject: Removed all utils.import_object(FLAGS.image_service) and replaced with utils.get_default_image_service(). --- bin/nova-manage | 2 +- nova/api/openstack/image_metadata.py | 2 +- nova/api/openstack/images.py | 5 ++- nova/api/openstack/servers.py | 22 ++++++------ nova/api/openstack/views/servers.py | 10 +++--- nova/compute/api.py | 4 +-- nova/image/s3.py | 4 +-- nova/tests/api/openstack/test_servers.py | 11 +++--- nova/utils.py | 60 +++++++++++++++----------------- nova/virt/images.py | 2 +- nova/virt/libvirt_conn.py | 2 +- 11 files changed, 58 insertions(+), 66 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index db964064d..3f3fd72a6 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -905,7 +905,7 @@ class ImageCommands(object): """Methods for dealing with a cloud in an odd state""" def __init__(self, *args, **kwargs): - self.image_service = utils.import_object(FLAGS.image_service) + self.image_service = utils.get_default_image_service() def _register(self, container_format, disk_format, path, owner, name=None, is_public='T', diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index 1eccc0174..f6913ffc6 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -32,7 +32,7 @@ class Controller(common.OpenstackController): """The image metadata API controller for the Openstack API""" def __init__(self): - self.image_service = utils.import_object(FLAGS.image_service) + self.image_service = utils.get_default_image_service() super(Controller, self).__init__() def _get_metadata(self, context, image_id, image=None): diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 8d796c284..8a90b4c4d 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -47,11 +47,10 @@ class Controller(common.OpenstackController): :param compute_service: `nova.compute.api:API` :param image_service: `nova.image.service:BaseImageService` - """ - _default_service = utils.import_object(flags.FLAGS.image_service) + """ self._compute_service = compute_service or compute.API() - self._image_service = image_service or _default_service + self._image_service = image_service or utils.get_default_image_service() def index(self, req): """Return an index listing of images available to the request. diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index bf0f56373..4e8574994 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -64,7 +64,6 @@ class Controller(common.OpenstackController): def __init__(self): self.compute_api = compute.API() - self._image_service = utils.import_object(FLAGS.image_service) super(Controller, self).__init__() def index(self, req): @@ -75,7 +74,7 @@ class Controller(common.OpenstackController): """ Returns a list of server details for a given user """ return self._items(req, is_detail=True) - def _image_id_from_req_data(self, data): + def _image_ref_from_req_data(self, data): raise NotImplementedError() def _flavor_id_from_req_data(self, data): @@ -140,13 +139,13 @@ class Controller(common.OpenstackController): key_name = key_pair['name'] key_data = key_pair['public_key'] - requested_image_id = self._image_id_from_req_data(env) + image_ref = self._image_ref_from_req_data(env) try: - (image_service, service_image_id) = utils.get_image_service( - requested_image_id) + (image_service, image_id) = utils.get_image_service( image_ref) - image_id = common.get_image_id_from_image_hash(image_service, - context, requested_image_id) + #TODO: need to assert image exists a better way + #image_id = common.get_image_id_from_image_hash(image_service, + #context, image_ref) except: msg = _("Can not find requested image") return faults.Fault(exc.HTTPBadRequest(msg)) @@ -188,7 +187,7 @@ class Controller(common.OpenstackController): self._handle_quota_error(error) inst['instance_type'] = inst_type - inst['image_id'] = requested_image_id + inst['image_id'] = image_ref builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) @@ -596,7 +595,7 @@ class Controller(common.OpenstackController): class ControllerV10(Controller): - def _image_id_from_req_data(self, data): + def _image_ref_from_req_data(self, data): return data['server']['imageId'] def _flavor_id_from_req_data(self, data): @@ -639,9 +638,8 @@ class ControllerV10(Controller): class ControllerV11(Controller): - def _image_id_from_req_data(self, data): - href = data['server']['imageRef'] - return common.get_id_from_href(href) + def _image_ref_from_req_data(self, data): + return data['server']['imageRef'] def _flavor_id_from_req_data(self, data): href = data['server']['flavorRef'] diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 0be468edc..70a942594 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -113,7 +113,7 @@ class ViewBuilderV10(ViewBuilder): def _build_image(self, response, inst): if 'image_id' in dict(inst): - response['imageId'] = inst['image_id'] + response['imageId'] = int(inst['image_id']) def _build_flavor(self, response, inst): if 'instance_type' in dict(inst): @@ -130,9 +130,11 @@ class ViewBuilderV11(ViewBuilder): self.base_url = base_url def _build_image(self, response, inst): - if "image_id" in dict(inst): - image_id = inst.get("image_id") - response["imageRef"] = self.image_builder.generate_href(image_id) + if 'image_id' in dict(inst): + image_id = inst['image_id'] + if utils.is_int(image_id): + image_id = int(image_id) + response['imageRef'] = image_id def _build_flavor(self, response, inst): if "instance_type" in dict(inst): diff --git a/nova/compute/api.py b/nova/compute/api.py index 930e4efaa..4e7af7421 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -58,9 +58,7 @@ class API(base.Base): def __init__(self, image_service=None, network_api=None, volume_api=None, hostname_factory=generate_default_hostname, **kwargs): - if not image_service: - image_service = utils.import_object(FLAGS.image_service) - self.image_service = image_service + self.image_service = image_service or utils.get_default_image_service() if not network_api: network_api = network.API() self.network_api = network_api diff --git a/nova/image/s3.py b/nova/image/s3.py index c38c58d95..ed685ea51 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -46,9 +46,7 @@ class S3ImageService(service.BaseImageService): """Wraps an existing image service to support s3 based register.""" def __init__(self, service=None, *args, **kwargs): - if service is None: - service = utils.import_object(FLAGS.image_service) - self.service = service + self.service = service or utils.get_default_image_service() self.service.__init__(*args, **kwargs) def create(self, context, metadata, data=None): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index e8182b6a9..cfa8d2556 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -628,13 +628,12 @@ class ServersTest(test.TestCase): def test_create_instance_v1_1_local_href(self): self._setup_for_create_instance() - image_ref = 'http://localhost/v1.1/images/2' - image_ref_local = '2' + image_ref = 2 flavor_ref = 'http://localhost/v1.1/flavors/3' body = { 'server': { 'name': 'server_test', - 'imageRef': image_ref_local, + 'imageRef': image_ref, 'flavorRef': flavor_ref, }, } @@ -852,7 +851,7 @@ class ServersTest(test.TestCase): self.assertEqual(s['id'], i) self.assertEqual(s['hostId'], '') self.assertEqual(s['name'], 'server%d' % i) - self.assertEqual(s['imageId'], '10') + self.assertEqual(s['imageId'], 10) self.assertEqual(s['flavorId'], 1) self.assertEqual(s['status'], 'BUILD') self.assertEqual(s['metadata']['seq'], str(i)) @@ -866,7 +865,7 @@ class ServersTest(test.TestCase): self.assertEqual(s['id'], i) self.assertEqual(s['hostId'], '') self.assertEqual(s['name'], 'server%d' % i) - self.assertEqual(s['imageRef'], 'http://localhost/v1.1/images/10') + self.assertEqual(s['imageRef'], 10) self.assertEqual(s['flavorRef'], 'http://localhost/v1.1/flavors/1') self.assertEqual(s['status'], 'BUILD') self.assertEqual(s['metadata']['seq'], str(i)) @@ -898,7 +897,7 @@ class ServersTest(test.TestCase): self.assertEqual(s['id'], i) self.assertEqual(s['hostId'], host_ids[i % 2]) self.assertEqual(s['name'], 'server%d' % i) - self.assertEqual(s['imageId'], '10') + self.assertEqual(s['imageId'], 10) self.assertEqual(s['flavorId'], 1) def test_server_pause(self): diff --git a/nova/utils.py b/nova/utils.py index fff916527..3c8c82281 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -35,6 +35,7 @@ import struct import sys import time import types +from urlparse import urlparse from xml.sax import saxutils from eventlet import event @@ -42,6 +43,7 @@ from eventlet import greenthread from eventlet import semaphore from eventlet.green import subprocess +import nova from nova import exception from nova import flags from nova import log as logging @@ -727,57 +729,53 @@ def parse_server_string(server_str): def is_int(x): - """ Return if passed in variable is integer or not """ return re.match(r'\d+$', str(x)) def parse_image_ref(image_ref): - """ - Parse an imageRef and return (id, host, port) + """Parse an image href into composite parts. If the image_ref passed in is an integer, it will return (image_ref, None, None), otherwise it will - return (id, host, port) + return (image_id, host, port) - image_ref - imageRef for an image + :param image_ref: href or id of an image """ - if is_int(image_ref): - return (image_ref, None, None) + return (int(image_ref), None, None) o = urlparse(image_ref) - # Default to port 80 if not passed, should this be 9292? - port = o.port or 80 + port = o.port host = o.netloc.split(':', 1)[0] - id = o.path.split('/')[-1] - - return (id, host, port) + image_id = o.path.split('/')[-1] + if is_int(image_id): + image_id = int(image_id) + else: + raise Exception(_('image_ref [%s] is missing a proper id') % image_ref) + return (image_id, host, port) -def get_image_service(image_ref=None): - """ - Get the proper image_service for an image_id - Returns (image_service, image_id) - image_ref - image ref/id for an image - """ +def get_default_image_service(): ImageService = import_class(FLAGS.image_service) + return ImageService() - if not image_ref: - return (ImageService(), None) - - (image_id, host, port) = parse_image_ref(image_ref) +def get_image_service(image_ref): + """Get the proper image_service and id for the given image_ref. - image_service = None + The image_ref param can be an href of the form + http://myglanceserver:9292/images/42, or just an int such as 42. If the + image_ref is an int, then the default image service is returned. - if host: - GlanceImageService = import_class(FLAGS.glance_image_service) - GlanceClient = import_class('glance.client.Client') + :param image_ref: image ref/id for an image + :returns: a tuple of the form (image_service, image_id) - glance_client = GlanceClient(host, port) - image_service = GlanceImageService(glance_client) - else: - image_service = ImageService() + """ + if is_int(image_ref): + return (get_default_image_service(), int(image_ref)) - return (image_service, id) + (image_id, host, port) = parse_image_ref(image_ref) + glance_client = nova.image.glance.GlanceClient(host, port) + image_service = nova.image.glance.GlanceImageService(glance_client) + return (image_service, image_id) diff --git a/nova/virt/images.py b/nova/virt/images.py index 2e3f2ee4d..0828a1fd0 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -45,7 +45,7 @@ def fetch(image_id, path, _user, _project): # when it is added to glance. Right now there is no # auth checking in glance, so we assume that access was # checked before we got here. - image_service = utils.import_object(FLAGS.image_service) + image_service = utils.get_default_image_service() with open(path, "wb") as image_file: elevated = context.get_admin_context() metadata = image_service.get(elevated, image_id, image_file) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index fa918b0a3..23fa5bdfc 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -448,7 +448,7 @@ class LibvirtConnection(driver.ComputeDriver): to support this command. """ - image_service = utils.import_object(FLAGS.image_service) + image_service = utils.get_default_image_service() virt_dom = self._lookup_by_name(instance['name']) elevated = context.get_admin_context() -- cgit From 375fdc745fc5915098f11585ccd6a91e86747086 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 09:50:18 -0400 Subject: get integrated server_tests passing --- nova/flags.py | 3 +++ nova/image/fake.py | 2 +- nova/tests/integrated/integrated_helpers.py | 4 +--- nova/tests/integrated/test_servers.py | 17 +++++++++-------- nova/utils.py | 5 +++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index 519793643..2481a10af 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -362,6 +362,9 @@ DEFINE_string('scheduler_manager', 'nova.scheduler.manager.SchedulerManager', # The service to use for image search and retrieval DEFINE_string('image_service', 'nova.image.local.LocalImageService', 'The service to use for retrieving and searching for images.') +DEFINE_string('glance_image_service', 'nova.image.local.LocalImageService', + 'The service to use for retrieving and searching for ' + + 'glance images.') DEFINE_string('host', socket.gethostname(), 'name of this node') diff --git a/nova/image/fake.py b/nova/image/fake.py index b400b2adb..8918c0c14 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -35,7 +35,7 @@ FLAGS = flags.FLAGS class FakeImageService(service.BaseImageService): """Mock (fake) image service for unit testing.""" - def __init__(self): + def __init__(self, client=None): self.images = {} # NOTE(justinsb): The OpenStack API can't upload an image? # So, make sure we've got one.. diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index 2e5d67017..e6efc16c5 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -185,6 +185,7 @@ class _IntegratedTestBase(test.TestCase): """An opportunity to setup flags, before the services are started.""" f = {} f['image_service'] = 'nova.image.fake.FakeImageService' + f['glance_image_service'] = 'nova.image.fake.FakeImageService' f['fake_network'] = True return f @@ -201,9 +202,6 @@ class _IntegratedTestBase(test.TestCase): LOG.warning("imageRef not yet in images output") image_ref = image['id'] - # TODO(justinsb): This is FUBAR - image_ref = abs(hash(image_ref)) - image_ref = 'http://fake.server/%s' % image_ref # We now have a valid imageId diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index e89d0100a..ba764907a 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -51,14 +51,14 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Without an imageRef, this throws 500. # TODO(justinsb): Check whatever the spec says should be thrown here - self.assertRaises(client.OpenStackApiException, - self.api.post_server, post) + #self.assertRaises(client.OpenStackApiException, + #self.api.post_server, post) # With an invalid imageRef, this throws 500. server['imageRef'] = self.user.get_invalid_image() # TODO(justinsb): Check whatever the spec says should be thrown here - self.assertRaises(client.OpenStackApiException, - self.api.post_server, post) + #self.assertRaises(client.OpenStackApiException, + #self.api.post_server, post) # Add a valid imageId/imageRef server['imageId'] = good_server.get('imageId') @@ -66,8 +66,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Without flavorId, this throws 500 # TODO(justinsb): Check whatever the spec says should be thrown here - self.assertRaises(client.OpenStackApiException, - self.api.post_server, post) + #self.assertRaises(client.OpenStackApiException, + #self.api.post_server, post) # Set a valid flavorId/flavorRef server['flavorRef'] = good_server.get('flavorRef') @@ -75,8 +75,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Without a name, this throws 500 # TODO(justinsb): Check whatever the spec says should be thrown here - self.assertRaises(client.OpenStackApiException, - self.api.post_server, post) + #self.assertRaises(client.OpenStackApiException, + #self.api.post_server, post) # Set a valid server name server['name'] = good_server['name'] @@ -85,6 +85,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): LOG.debug("created_server: %s" % created_server) self.assertTrue(created_server['id']) created_server_id = created_server['id'] + return # Check it's there found_server = self.api.get_server(created_server_id) diff --git a/nova/utils.py b/nova/utils.py index 3c8c82281..46dfc82e9 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -776,6 +776,7 @@ def get_image_service(image_ref): return (get_default_image_service(), int(image_ref)) (image_id, host, port) = parse_image_ref(image_ref) - glance_client = nova.image.glance.GlanceClient(host, port) - image_service = nova.image.glance.GlanceImageService(glance_client) + glance_client = import_class('nova.image.glance.GlanceClient')(host, + port) + image_service = import_class(FLAGS.glance_image_service)(glance_client) return (image_service, image_id) -- cgit From d3f67f97d81185158f611c3bc9bd5542a7fed788 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 09:52:37 -0400 Subject: fixed test_servers small tests as well --- nova/tests/api/openstack/test_servers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index cfa8d2556..6982f87a8 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -464,6 +464,8 @@ class ServersTest(test.TestCase): def image_id_from_hash(*args, **kwargs): return 2 + + FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' self.stubs.Set(nova.db.api, 'project_get_network', project_get_network) self.stubs.Set(nova.db.api, 'instance_create', instance_create) self.stubs.Set(nova.rpc, 'cast', fake_method) -- cgit From a9738fe5196cc1ed0715c3d96c692e782e77fec6 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 10:10:10 -0400 Subject: made ImageControllerWithGlanceServiceTests pass --- nova/api/openstack/images.py | 2 +- nova/api/openstack/servers.py | 7 +++---- nova/utils.py | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 8a90b4c4d..6d3e50b56 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -88,7 +88,7 @@ class Controller(common.OpenstackController): image_id) image = image_service.show(context, service_image_id) except exception.NotFound: - explanation = _("Image '%d' not found.") % (image_id) + explanation = _("Image not found.") raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) return dict(image=self.get_builder(req).build(image, detail=True)) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 4e8574994..ca13a8669 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -141,7 +141,9 @@ class Controller(common.OpenstackController): image_ref = self._image_ref_from_req_data(env) try: - (image_service, image_id) = utils.get_image_service( image_ref) + (image_service, image_id) = utils.get_image_service(image_ref) + kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( + req, image_id) #TODO: need to assert image exists a better way #image_id = common.get_image_id_from_image_hash(image_service, @@ -150,9 +152,6 @@ class Controller(common.OpenstackController): msg = _("Can not find requested image") return faults.Fault(exc.HTTPBadRequest(msg)) - kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( - req, image_id) - personality = env['server'].get('personality') injected_files = [] if personality: diff --git a/nova/utils.py b/nova/utils.py index 46dfc82e9..04acfc417 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -752,7 +752,8 @@ def parse_image_ref(image_ref): if is_int(image_id): image_id = int(image_id) else: - raise Exception(_('image_ref [%s] is missing a proper id') % image_ref) + raise exception.ImageNotFound( + _('image_ref [%s] is missing a proper id') % image_ref) return (image_id, host, port) -- cgit From 3c36abb43eea4ff7a740278085690aa057aba502 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 10:16:51 -0400 Subject: fixed ComputeTestCase tests --- nova/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/utils.py b/nova/utils.py index 04acfc417..dcaaab602 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -773,6 +773,7 @@ def get_image_service(image_ref): :returns: a tuple of the form (image_service, image_id) """ + image_ref = image_ref or 0 if is_int(image_ref): return (get_default_image_service(), int(image_ref)) -- cgit From 96c888312fb7a2ba2cc9120282d29128a18342a8 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 10:41:33 -0400 Subject: fixed QuotaTestCases --- nova/flags.py | 2 +- nova/image/fake.py | 18 ++++++++++++++---- nova/tests/test_quota.py | 2 ++ nova/utils.py | 4 +--- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index 2481a10af..d3f72d412 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -362,7 +362,7 @@ DEFINE_string('scheduler_manager', 'nova.scheduler.manager.SchedulerManager', # The service to use for image search and retrieval DEFINE_string('image_service', 'nova.image.local.LocalImageService', 'The service to use for retrieving and searching for images.') -DEFINE_string('glance_image_service', 'nova.image.local.LocalImageService', +DEFINE_string('glance_image_service', 'nova.image.glance.GlanceImageService', 'The service to use for retrieving and searching for ' + 'glance images.') diff --git a/nova/image/fake.py b/nova/image/fake.py index 8918c0c14..3ada0d8d0 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -40,7 +40,7 @@ class FakeImageService(service.BaseImageService): # NOTE(justinsb): The OpenStack API can't upload an image? # So, make sure we've got one.. timestamp = datetime.datetime(2011, 01, 01, 01, 02, 03) - image = {'id': '123456', + image1 = {'id': '123456', 'name': 'fakeimage123456', 'created_at': timestamp, 'updated_at': timestamp, @@ -49,7 +49,18 @@ class FakeImageService(service.BaseImageService): 'disk_format': 'raw', 'properties': {'kernel_id': FLAGS.null_kernel, 'ramdisk_id': FLAGS.null_kernel}} - self.create(None, image) + + image2 = {'id': 'fake', + 'name': 'fakeimage123456', + 'created_at': timestamp, + 'updated_at': timestamp, + 'status': 'active', + 'container_format': 'ami', + 'disk_format': 'raw', + 'properties': {'kernel_id': FLAGS.null_kernel, + 'ramdisk_id': FLAGS.null_kernel}} + self.create(None, image1) + self.create(None, image2) super(FakeImageService, self).__init__() def index(self, context): @@ -66,7 +77,6 @@ class FakeImageService(service.BaseImageService): Returns a dict containing image data for the given opaque image id. """ - image_id = int(image_id) image = self.images.get(image_id) if image: return copy.deepcopy(image) @@ -80,7 +90,7 @@ class FakeImageService(service.BaseImageService): :raises: Duplicate if the image already exist. """ - image_id = int(data['id']) + image_id = data['id'] if self.images.get(image_id): raise exception.Duplicate() diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py index 7ace2ad7d..9ede0786f 100644 --- a/nova/tests/test_quota.py +++ b/nova/tests/test_quota.py @@ -280,6 +280,7 @@ class QuotaTestCase(test.TestCase): FLAGS.quota_max_injected_files) def _create_with_injected_files(self, files): + FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' api = compute.API(image_service=self.StubImageService()) inst_type = instance_types.get_instance_type_by_name('m1.small') api.create(self.context, min_count=1, max_count=1, @@ -287,6 +288,7 @@ class QuotaTestCase(test.TestCase): injected_files=files) def test_no_injected_files(self): + FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' api = compute.API(image_service=self.StubImageService()) inst_type = instance_types.get_instance_type_by_name('m1.small') api.create(self.context, instance_type=inst_type, image_id='fake') diff --git a/nova/utils.py b/nova/utils.py index dcaaab602..252f5e9a6 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -749,11 +749,9 @@ def parse_image_ref(image_ref): port = o.port host = o.netloc.split(':', 1)[0] image_id = o.path.split('/')[-1] + if is_int(image_id): image_id = int(image_id) - else: - raise exception.ImageNotFound( - _('image_ref [%s] is missing a proper id') % image_ref) return (image_id, host, port) -- cgit From d94d040986e00409ed031b591b39a43edc111e28 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 10:45:33 -0400 Subject: fixed api.openstack.test_servers tests...again --- nova/api/openstack/servers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index ca13a8669..17d286748 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -184,6 +184,10 @@ class Controller(common.OpenstackController): injected_files=injected_files) except quota.QuotaError as error: self._handle_quota_error(error) + except exception.ImageNotFound as error: + msg = _("Can not find requested image") + return faults.Fault(exc.HTTPBadRequest(msg)) + inst['instance_type'] = inst_type inst['image_id'] = image_ref -- cgit From 980ceb71fdc97e92954239b843e7cec60c786a97 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 10:59:22 -0400 Subject: oops, took out commented out tests in integrated.test_servers and made tests pass again --- nova/image/fake.py | 4 ++-- nova/tests/integrated/test_servers.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/nova/image/fake.py b/nova/image/fake.py index 3ada0d8d0..2c0b87952 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -77,7 +77,7 @@ class FakeImageService(service.BaseImageService): Returns a dict containing image data for the given opaque image id. """ - image = self.images.get(image_id) + image = self.images.get(str(image_id)) if image: return copy.deepcopy(image) LOG.warn('Unable to find image id %s. Have images: %s', @@ -90,7 +90,7 @@ class FakeImageService(service.BaseImageService): :raises: Duplicate if the image already exist. """ - image_id = data['id'] + image_id = str(data['id']) if self.images.get(image_id): raise exception.Duplicate() diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index ba764907a..e89d0100a 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -51,14 +51,14 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Without an imageRef, this throws 500. # TODO(justinsb): Check whatever the spec says should be thrown here - #self.assertRaises(client.OpenStackApiException, - #self.api.post_server, post) + self.assertRaises(client.OpenStackApiException, + self.api.post_server, post) # With an invalid imageRef, this throws 500. server['imageRef'] = self.user.get_invalid_image() # TODO(justinsb): Check whatever the spec says should be thrown here - #self.assertRaises(client.OpenStackApiException, - #self.api.post_server, post) + self.assertRaises(client.OpenStackApiException, + self.api.post_server, post) # Add a valid imageId/imageRef server['imageId'] = good_server.get('imageId') @@ -66,8 +66,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Without flavorId, this throws 500 # TODO(justinsb): Check whatever the spec says should be thrown here - #self.assertRaises(client.OpenStackApiException, - #self.api.post_server, post) + self.assertRaises(client.OpenStackApiException, + self.api.post_server, post) # Set a valid flavorId/flavorRef server['flavorRef'] = good_server.get('flavorRef') @@ -75,8 +75,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Without a name, this throws 500 # TODO(justinsb): Check whatever the spec says should be thrown here - #self.assertRaises(client.OpenStackApiException, - #self.api.post_server, post) + self.assertRaises(client.OpenStackApiException, + self.api.post_server, post) # Set a valid server name server['name'] = good_server['name'] @@ -85,7 +85,6 @@ class ServersTest(integrated_helpers._IntegratedTestBase): LOG.debug("created_server: %s" % created_server) self.assertTrue(created_server['id']) created_server_id = created_server['id'] - return # Check it's there found_server = self.api.get_server(created_server_id) -- cgit From 9407bbfc61f165bca0a854d59dd516193334a4b4 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 11:13:22 -0400 Subject: fix pep8 issues --- nova/api/openstack/images.py | 3 ++- nova/api/openstack/servers.py | 1 - nova/flags.py | 2 +- nova/tests/api/openstack/test_servers.py | 1 - nova/utils.py | 3 ++- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 6d3e50b56..c2511b99f 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -50,7 +50,8 @@ class Controller(common.OpenstackController): """ self._compute_service = compute_service or compute.API() - self._image_service = image_service or utils.get_default_image_service() + self._image_service = image_service or \ + utils.get_default_image_service() def index(self, req): """Return an index listing of images available to the request. diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 17d286748..ae7df3fe5 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -188,7 +188,6 @@ class Controller(common.OpenstackController): msg = _("Can not find requested image") return faults.Fault(exc.HTTPBadRequest(msg)) - inst['instance_type'] = inst_type inst['image_id'] = image_ref diff --git a/nova/flags.py b/nova/flags.py index d3f72d412..b45d252c7 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -363,7 +363,7 @@ DEFINE_string('scheduler_manager', 'nova.scheduler.manager.SchedulerManager', DEFINE_string('image_service', 'nova.image.local.LocalImageService', 'The service to use for retrieving and searching for images.') DEFINE_string('glance_image_service', 'nova.image.glance.GlanceImageService', - 'The service to use for retrieving and searching for ' + + 'The service to use for retrieving and searching for ' + 'glance images.') DEFINE_string('host', socket.gethostname(), diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 6982f87a8..bced2b910 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -464,7 +464,6 @@ class ServersTest(test.TestCase): def image_id_from_hash(*args, **kwargs): return 2 - FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' self.stubs.Set(nova.db.api, 'project_get_network', project_get_network) self.stubs.Set(nova.db.api, 'instance_create', instance_create) diff --git a/nova/utils.py b/nova/utils.py index 252f5e9a6..82d0dd7a4 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -760,6 +760,7 @@ def get_default_image_service(): ImageService = import_class(FLAGS.image_service) return ImageService() + def get_image_service(image_ref): """Get the proper image_service and id for the given image_ref. @@ -776,7 +777,7 @@ def get_image_service(image_ref): return (get_default_image_service(), int(image_ref)) (image_id, host, port) = parse_image_ref(image_ref) - glance_client = import_class('nova.image.glance.GlanceClient')(host, + glance_client = import_class('nova.image.glance.GlanceClient')(host, port) image_service = import_class(FLAGS.glance_image_service)(glance_client) return (image_service, image_id) -- cgit From 048dda438c9670998e9c91f6a906373a12ea294d Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 13:03:05 -0400 Subject: fixed bug with compute_api not having actual image_ref to use proper image service --- nova/api/openstack/servers.py | 1 + nova/compute/api.py | 7 ++++--- nova/image/fake.py | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index ae7df3fe5..a4e679242 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -174,6 +174,7 @@ class Controller(common.OpenstackController): context, inst_type, image_id, + image_ref=image_ref, kernel_id=kernel_id, ramdisk_id=ramdisk_id, display_name=name, diff --git a/nova/compute/api.py b/nova/compute/api.py index 4e7af7421..40d011132 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -132,7 +132,7 @@ class API(base.Base): display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, - injected_files=None): + injected_files=None, image_ref=None): """Create the number and type of instances requested. Verifies that quota and other arguments are valid. @@ -154,7 +154,8 @@ class API(base.Base): self._check_metadata_properties_quota(context, metadata) self._check_injected_file_quota(context, injected_files) - (image_service, service_image_id) = utils.get_image_service(image_id) + (image_service, service_image_id) = utils.get_image_service( + image_ref or image_id) image = image_service.show(context, service_image_id) os_type = None @@ -198,7 +199,7 @@ class API(base.Base): base_options = { 'reservation_id': utils.generate_uid('r'), - 'image_id': image_id, + 'image_id': image_ref or image_id, 'kernel_id': kernel_id or '', 'ramdisk_id': ramdisk_id or '', 'state': 0, diff --git a/nova/image/fake.py b/nova/image/fake.py index 2c0b87952..2a60c7743 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -59,8 +59,30 @@ class FakeImageService(service.BaseImageService): 'disk_format': 'raw', 'properties': {'kernel_id': FLAGS.null_kernel, 'ramdisk_id': FLAGS.null_kernel}} + + image3 = {'id': '2', + 'name': 'fakeimage123456', + 'created_at': timestamp, + 'updated_at': timestamp, + 'status': 'active', + 'container_format': 'ami', + 'disk_format': 'raw', + 'properties': {'kernel_id': FLAGS.null_kernel, + 'ramdisk_id': FLAGS.null_kernel}} + + image4 = {'id': '1', + 'name': 'fakeimage123456', + 'created_at': timestamp, + 'updated_at': timestamp, + 'status': 'active', + 'container_format': 'ami', + 'disk_format': 'raw', + 'properties': {'kernel_id': FLAGS.null_kernel, + 'ramdisk_id': FLAGS.null_kernel}} self.create(None, image1) self.create(None, image2) + self.create(None, image3) + self.create(None, image4) super(FakeImageService, self).__init__() def index(self, context): -- cgit From 62328a6437f238228152f460b1bd53e7254aa89c Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 16:26:42 -0400 Subject: libvirt fixes to use new image_service stuff --- nova/virt/images.py | 4 ++-- nova/virt/libvirt_conn.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nova/virt/images.py b/nova/virt/images.py index 0828a1fd0..fd433ea0c 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -45,10 +45,10 @@ def fetch(image_id, path, _user, _project): # when it is added to glance. Right now there is no # auth checking in glance, so we assume that access was # checked before we got here. - image_service = utils.get_default_image_service() + (image_service, service_image_id) = utils.get_image_service(image_id) with open(path, "wb") as image_file: elevated = context.get_admin_context() - metadata = image_service.get(elevated, image_id, image_file) + metadata = image_service.get(elevated, service_image_id, image_file) return metadata diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 23fa5bdfc..ab47493fd 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -36,6 +36,7 @@ Supports KVM, LXC, QEMU, UML, and XEN. """ +import hashlib import multiprocessing import os import random @@ -843,7 +844,9 @@ class LibvirtConnection(driver.ComputeDriver): 'ramdisk_id': inst['ramdisk_id']} if disk_images['kernel_id']: - fname = '%08x' % int(disk_images['kernel_id']) + fname_hash = hashlib.sha1() + fname_hash.update(disk_images['kernel_id']) + fname = fname_hash.hexdigest() self._cache_image(fn=self._fetch_image, target=basepath('kernel'), fname=fname, @@ -851,7 +854,9 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) if disk_images['ramdisk_id']: - fname = '%08x' % int(disk_images['ramdisk_id']) + fname_hash = hashlib.sha1() + fname_hash.update(disk_images['ramdisk_id']) + fname = fname_hash.hexdigest() self._cache_image(fn=self._fetch_image, target=basepath('ramdisk'), fname=fname, @@ -859,7 +864,10 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) - root_fname = '%08x' % int(disk_images['image_id']) + fname_hash = hashlib.sha1() + fname_hash.update(disk_images['image_id']) + root_fname = fname_hash.hexdigest() + size = FLAGS.minimum_root_size inst_type_id = inst['instance_type_id'] -- cgit From 76c98e277a405127d85cf2c264a20ec3a18e023a Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 17:30:43 -0400 Subject: hackish patch to fix hrefs asking for their metadata in boot (this really shouldnt be in ec2 api?) --- nova/api/ec2/cloud.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 1fa07d042..06b5f662f 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -157,7 +157,12 @@ class CloudController(object): floating_ip = db.instance_get_floating_address(ctxt, instance_ref['id']) ec2_id = ec2utils.id_to_ec2_id(instance_ref['id']) - image_ec2_id = self.image_ec2_id(instance_ref['image_id']) + try: + image_ec2_id = self.image_ec2_id(instance_ref['image_id']) + except ValueError: + # not really an ec2_id here + image_ec2_id = instance_ref['image_id'] + data = { 'user-data': base64.b64decode(instance_ref['user_data']), 'meta-data': { -- cgit From c69a1b0d9ef15ecc06217ec2c1ec4d73a755d14b Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 17:57:44 -0400 Subject: return dummy id per vishs suggestion --- nova/api/ec2/cloud.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 06b5f662f..950b72e72 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -157,12 +157,7 @@ class CloudController(object): floating_ip = db.instance_get_floating_address(ctxt, instance_ref['id']) ec2_id = ec2utils.id_to_ec2_id(instance_ref['id']) - try: - image_ec2_id = self.image_ec2_id(instance_ref['image_id']) - except ValueError: - # not really an ec2_id here - image_ec2_id = instance_ref['image_id'] - + image_ec2_id = self.image_ec2_id(instance_ref['image_id']) data = { 'user-data': base64.b64decode(instance_ref['user_data']), 'meta-data': { @@ -907,7 +902,12 @@ class CloudController(object): def image_ec2_id(image_id, image_type='ami'): """Returns image ec2_id using id and three letter type.""" template = image_type + '-%08x' - return ec2utils.id_to_ec2_id(int(image_id), template=template) + try: + return ec2utils.id_to_ec2_id(int(image_id), template=template) + except ValueError: + #TODO(wwolf): once we have ec2_id -> glance_id mapping + # in place, this wont be necessary + return "ami-00000000" def _get_image(self, context, ec2_id): try: -- cgit From 64e9aa6daa416662a25eeab0d943b23906695e92 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 18 May 2011 18:09:37 -0400 Subject: default to port 80 if it isnt in the href/uri --- nova/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/utils.py b/nova/utils.py index 82d0dd7a4..85934813e 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -746,7 +746,7 @@ def parse_image_ref(image_ref): return (int(image_ref), None, None) o = urlparse(image_ref) - port = o.port + port = o.port or 80 host = o.netloc.split(':', 1)[0] image_id = o.path.split('/')[-1] -- cgit From 5e722ea7b912f189c0a3b9434e9a38d08095ad00 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 18 May 2011 19:13:22 -0400 Subject: refactoring wsgi to separate controller/serialization/deserialization logic; creating osapi-specific module --- nova/api/openstack/__init__.py | 43 ++--- nova/api/openstack/accounts.py | 33 ++-- nova/api/openstack/backup_schedules.py | 27 ++- nova/api/openstack/consoles.py | 26 ++- nova/api/openstack/flavors.py | 34 ++-- nova/api/openstack/image_metadata.py | 19 +- nova/api/openstack/images.py | 40 +++-- nova/api/openstack/ips.py | 33 ++-- nova/api/openstack/limits.py | 50 ++++-- nova/api/openstack/server_metadata.py | 21 ++- nova/api/openstack/servers.py | 124 +++++++------ nova/api/openstack/shared_ip_groups.py | 28 +-- nova/api/openstack/users.py | 43 +++-- nova/api/openstack/wsgi.py | 291 +++++++++++++++++++++++++++++++ nova/api/openstack/zones.py | 33 ++-- nova/tests/api/openstack/test_limits.py | 4 +- nova/tests/api/openstack/test_servers.py | 2 - nova/tests/api/test_wsgi.py | 135 -------------- nova/tests/integrated/test_xml.py | 4 +- 19 files changed, 624 insertions(+), 366 deletions(-) create mode 100644 nova/api/openstack/wsgi.py diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 348b70d5b..fbbd99cb9 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -26,7 +26,7 @@ import webob.exc from nova import flags from nova import log as logging -from nova import wsgi +from nova import wsgi as base_wsgi from nova.api.openstack import accounts from nova.api.openstack import faults from nova.api.openstack import backup_schedules @@ -40,6 +40,7 @@ from nova.api.openstack import servers from nova.api.openstack import server_metadata from nova.api.openstack import shared_ip_groups from nova.api.openstack import users +from nova.api.openstack import wsgi from nova.api.openstack import zones @@ -50,7 +51,7 @@ flags.DEFINE_bool('allow_admin_api', 'When True, this API service will accept admin operations.') -class FaultWrapper(wsgi.Middleware): +class FaultWrapper(base_wsgi.Middleware): """Calls down the middleware stack, making exceptions into faults.""" @webob.dec.wsgify(RequestClass=wsgi.Request) @@ -63,7 +64,7 @@ class FaultWrapper(wsgi.Middleware): return faults.Fault(exc) -class APIRouter(wsgi.Router): +class APIRouter(base_wsgi.Router): """ Routes requests on the OpenStack API to the appropriate controller and method. @@ -97,18 +98,20 @@ class APIRouter(wsgi.Router): server_members['reset_network'] = 'POST' server_members['inject_network_info'] = 'POST' - mapper.resource("zone", "zones", controller=zones.Controller(), + mapper.resource("zone", "zones", + controller=zones.resource_factory(), collection={'detail': 'GET', 'info': 'GET'}), - mapper.resource("user", "users", controller=users.Controller(), + mapper.resource("user", "users", + controller=users.resource_factory(), collection={'detail': 'GET'}) mapper.resource("account", "accounts", - controller=accounts.Controller(), + controller=accounts.resource_factory(), collection={'detail': 'GET'}) mapper.resource("console", "consoles", - controller=consoles.Controller(), + controller=consoles.resource_factory(), parent_resource=dict(member_name='server', collection_name='servers')) @@ -121,31 +124,31 @@ class APIRouterV10(APIRouter): def _setup_routes(self, mapper): super(APIRouterV10, self)._setup_routes(mapper) mapper.resource("server", "servers", - controller=servers.ControllerV10(), + controller=servers.resource_factory('1.0'), collection={'detail': 'GET'}, member=self.server_members) mapper.resource("image", "images", - controller=images.ControllerV10(), + controller=images.resource_factory('1.0'), collection={'detail': 'GET'}) mapper.resource("flavor", "flavors", - controller=flavors.ControllerV10(), + controller=flavors.resource_factory('1.0'), collection={'detail': 'GET'}) mapper.resource("shared_ip_group", "shared_ip_groups", collection={'detail': 'GET'}, - controller=shared_ip_groups.Controller()) + controller=shared_ip_groups.resource_factory()) mapper.resource("backup_schedule", "backup_schedule", - controller=backup_schedules.Controller(), + controller=backup_schedules.resource_factory(), parent_resource=dict(member_name='server', collection_name='servers')) mapper.resource("limit", "limits", - controller=limits.LimitsControllerV10()) + controller=limits.resource_factory('1.0')) - mapper.resource("ip", "ips", controller=ips.Controller(), + mapper.resource("ip", "ips", controller=ips.resource_factory(), collection=dict(public='GET', private='GET'), parent_resource=dict(member_name='server', collection_name='servers')) @@ -157,27 +160,27 @@ class APIRouterV11(APIRouter): def _setup_routes(self, mapper): super(APIRouterV11, self)._setup_routes(mapper) mapper.resource("server", "servers", - controller=servers.ControllerV11(), + controller=servers.resource_factory('1.1'), collection={'detail': 'GET'}, member=self.server_members) mapper.resource("image", "images", - controller=images.ControllerV11(), + controller=images.resource_factory('1.1'), collection={'detail': 'GET'}) mapper.resource("image_meta", "meta", - controller=image_metadata.Controller(), + controller=image_metadata.resource_factory(), parent_resource=dict(member_name='image', collection_name='images')) mapper.resource("server_meta", "meta", - controller=server_metadata.Controller(), + controller=server_metadata.resource_factory(), parent_resource=dict(member_name='server', collection_name='servers')) mapper.resource("flavor", "flavors", - controller=flavors.ControllerV11(), + controller=flavors.resource_factory('1.1'), collection={'detail': 'GET'}) mapper.resource("limit", "limits", - controller=limits.LimitsControllerV11()) + controller=limits.resource_factory('1.1')) diff --git a/nova/api/openstack/accounts.py b/nova/api/openstack/accounts.py index 00fdd4540..d8a9d1909 100644 --- a/nova/api/openstack/accounts.py +++ b/nova/api/openstack/accounts.py @@ -20,8 +20,9 @@ from nova import flags from nova import log as logging from nova.auth import manager -from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi + FLAGS = flags.FLAGS LOG = logging.getLogger('nova.api.openstack') @@ -34,12 +35,7 @@ def _translate_keys(account): manager=account.project_manager_id) -class Controller(common.OpenstackController): - - _serialization_metadata = { - 'application/xml': { - "attributes": { - "account": ["id", "name", "description", "manager"]}}} +class Controller(object): def __init__(self): self.manager = manager.AuthManager() @@ -66,20 +62,33 @@ class Controller(common.OpenstackController): self.manager.delete_project(id) return {} - def create(self, req): + def create(self, req, body): """We use update with create-or-update semantics because the id comes from an external source""" raise faults.Fault(webob.exc.HTTPNotImplemented()) - def update(self, req, id): + def update(self, req, id, body): """This is really create or update.""" self._check_admin(req.environ['nova.context']) - env = self._deserialize(req.body, req.get_content_type()) - description = env['account'].get('description') - manager = env['account'].get('manager') + description = body['account'].get('description') + manager = body['account'].get('manager') try: account = self.manager.get_project(id) self.manager.modify_project(id, manager, description) except exception.NotFound: account = self.manager.create_project(id, manager, description) return dict(account=_translate_keys(account)) + + +def resource_factory(): + metadata = { + "attributes": { + "account": ["id", "name", "description", "manager"], + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/backup_schedules.py b/nova/api/openstack/backup_schedules.py index 4bf744046..4153c90c1 100644 --- a/nova/api/openstack/backup_schedules.py +++ b/nova/api/openstack/backup_schedules.py @@ -19,9 +19,8 @@ import time from webob import exc -from nova.api.openstack import common from nova.api.openstack import faults -import nova.image.service +from nova.api.openstack import wsgi def _translate_keys(inst): @@ -29,14 +28,9 @@ def _translate_keys(inst): return dict(backupSchedule=inst) -class Controller(common.OpenstackController): +class Controller(object): """ The backup schedule API controller for the Openstack API """ - _serialization_metadata = { - 'application/xml': { - 'attributes': { - 'backupSchedule': []}}} - def __init__(self): pass @@ -48,7 +42,7 @@ class Controller(common.OpenstackController): """ Returns a single backup schedule for a given instance """ return faults.Fault(exc.HTTPNotImplemented()) - def create(self, req, server_id): + def create(self, req, server_id, body): """ No actual update method required, since the existing API allows both create and update through a POST """ return faults.Fault(exc.HTTPNotImplemented()) @@ -56,3 +50,18 @@ class Controller(common.OpenstackController): def delete(self, req, server_id, id): """ Deletes an existing backup schedule """ return faults.Fault(exc.HTTPNotImplemented()) + + +def resource_factory(): + metadata = { + 'attributes': { + 'backupSchedule': [], + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V10, + metadata=metadata), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/consoles.py b/nova/api/openstack/consoles.py index 1a77f25d7..36d570803 100644 --- a/nova/api/openstack/consoles.py +++ b/nova/api/openstack/consoles.py @@ -19,8 +19,8 @@ from webob import exc from nova import console from nova import exception -from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi def _translate_keys(cons): @@ -43,14 +43,9 @@ def _translate_detail_keys(cons): return dict(console=info) -class Controller(common.OpenstackController): +class Controller(object): """The Consoles Controller for the Openstack API""" - _serialization_metadata = { - 'application/xml': { - 'attributes': { - 'console': []}}} - def __init__(self): self.console_api = console.API() super(Controller, self).__init__() @@ -63,9 +58,8 @@ class Controller(common.OpenstackController): return dict(consoles=[_translate_keys(console) for console in consoles]) - def create(self, req, server_id): + def create(self, req, server_id, body): """Creates a new console""" - #info = self._deserialize(req.body, req.get_content_type()) self.console_api.create_console( req.environ['nova.context'], int(server_id)) @@ -94,3 +88,17 @@ class Controller(common.OpenstackController): except exception.NotFound: return faults.Fault(exc.HTTPNotFound()) return exc.HTTPAccepted() + + +def resource_factory(): + metadata = { + 'attributes': { + 'console': [], + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/flavors.py index 4c5971cf6..46056a27a 100644 --- a/nova/api/openstack/flavors.py +++ b/nova/api/openstack/flavors.py @@ -19,22 +19,13 @@ import webob from nova import db from nova import exception -from nova.api.openstack import common from nova.api.openstack import views +from nova.api.openstack import wsgi -class Controller(common.OpenstackController): +class Controller(object): """Flavor controller for the OpenStack API.""" - _serialization_metadata = { - 'application/xml': { - "attributes": { - "flavor": ["id", "name", "ram", "disk"], - "link": ["rel", "type", "href"], - } - } - } - def index(self, req): """Return all flavors in brief.""" items = self._get_flavors(req, is_detail=False) @@ -71,14 +62,31 @@ class Controller(common.OpenstackController): class ControllerV10(Controller): + def _get_view_builder(self, req): return views.flavors.ViewBuilder() class ControllerV11(Controller): + def _get_view_builder(self, req): base_url = req.application_url return views.flavors.ViewBuilderV11(base_url) - def get_default_xmlns(self, req): - return common.XML_NS_V11 + +def resource_factory(version='1.0'): + controller = { + '1.0': ControllerV10, + '1.1': ControllerV11, + }[version]() + + xmlns = { + '1.0': wsgi.XMLNS_V10, + '1.1': wsgi.XMLNS_V11, + }[version] + + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=xmlns), + } + + return wsgi.Resource(controller, serializers=serializers) diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index 1eccc0174..ce0140265 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -21,19 +21,18 @@ from nova import flags from nova import quota from nova import utils from nova import wsgi -from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi FLAGS = flags.FLAGS -class Controller(common.OpenstackController): +class Controller(object): """The image metadata API controller for the Openstack API""" def __init__(self): self.image_service = utils.import_object(FLAGS.image_service) - super(Controller, self).__init__() def _get_metadata(self, context, image_id, image=None): if not image: @@ -64,9 +63,8 @@ class Controller(common.OpenstackController): else: return faults.Fault(exc.HTTPNotFound()) - def create(self, req, image_id): + def create(self, req, image_id, body): context = req.environ['nova.context'] - body = self._deserialize(req.body, req.get_content_type()) img = self.image_service.show(context, image_id) metadata = self._get_metadata(context, image_id, img) if 'metadata' in body: @@ -77,9 +75,8 @@ class Controller(common.OpenstackController): self.image_service.update(context, image_id, img, None) return dict(metadata=metadata) - def update(self, req, image_id, id): + def update(self, req, image_id, id, body): context = req.environ['nova.context'] - body = self._deserialize(req.body, req.get_content_type()) if not id in body: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) @@ -104,3 +101,11 @@ class Controller(common.OpenstackController): metadata.pop(id) img['properties'] = metadata self.image_service.update(context, image_id, img, None) + + +def resource_factory(): + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V11), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 34d4c27fc..e22854ebf 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -23,25 +23,16 @@ from nova import utils from nova.api.openstack import common from nova.api.openstack import faults from nova.api.openstack.views import images as images_view +from nova.api.openstack import wsgi LOG = log.getLogger('nova.api.openstack.images') FLAGS = flags.FLAGS -class Controller(common.OpenstackController): +class Controller(object): """Base `wsgi.Controller` for retrieving/displaying images.""" - _serialization_metadata = { - 'application/xml': { - "attributes": { - "image": ["id", "name", "updated", "created", "status", - "serverId", "progress"], - "link": ["rel", "type", "href"], - }, - }, - } - def __init__(self, image_service=None, compute_service=None): """Initialize new `ImageController`. @@ -153,3 +144,30 @@ class ControllerV11(Controller): def get_default_xmlns(self, req): return common.XML_NS_V11 + + +def resource_factory(version='1.0'): + controller = { + '1.0': ControllerV10, + '1.1': ControllerV11, + }[version]() + + xmlns = { + '1.0': wsgi.XMLNS_V10, + '1.1': wsgi.XMLNS_V11, + }[version] + + metadata = { + "attributes": { + "image": ["id", "name", "updated", "created", "status", + "serverId", "progress"], + "link": ["rel", "type", "href"], + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=xmlns, + metadata=metadata), + } + + return wsgi.Resource(controller, serializers=serializers) diff --git a/nova/api/openstack/ips.py b/nova/api/openstack/ips.py index 778e9ba1a..24612eafb 100644 --- a/nova/api/openstack/ips.py +++ b/nova/api/openstack/ips.py @@ -20,23 +20,14 @@ import time from webob import exc import nova -import nova.api.openstack.views.addresses -from nova.api.openstack import common from nova.api.openstack import faults +import nova.api.openstack.views.addresses +from nova.api.openstack import wsgi -class Controller(common.OpenstackController): +class Controller(object): """The servers addresses API controller for the Openstack API.""" - _serialization_metadata = { - 'application/xml': { - 'list_collections': { - 'public': {'item_name': 'ip', 'item_key': 'addr'}, - 'private': {'item_name': 'ip', 'item_key': 'addr'}, - }, - }, - } - def __init__(self): self.compute_api = nova.compute.API() self.builder = nova.api.openstack.views.addresses.ViewBuilderV10() @@ -65,8 +56,24 @@ class Controller(common.OpenstackController): def show(self, req, server_id, id): return faults.Fault(exc.HTTPNotImplemented()) - def create(self, req, server_id): + def create(self, req, server_id, body): return faults.Fault(exc.HTTPNotImplemented()) def delete(self, req, server_id, id): return faults.Fault(exc.HTTPNotImplemented()) + + +def resource_factory(): + metadata = { + 'list_collections': { + 'public': {'item_name': 'ip', 'item_key': 'addr'}, + 'private': {'item_name': 'ip', 'item_key': 'addr'}, + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata, + xmlns=wsgi.XMLNS_V10), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/limits.py b/nova/api/openstack/limits.py index 47bc238f1..306048d8f 100644 --- a/nova/api/openstack/limits.py +++ b/nova/api/openstack/limits.py @@ -30,10 +30,11 @@ from collections import defaultdict from webob.dec import wsgify -from nova import wsgi +from nova import wsgi as base_wsgi from nova.api.openstack import common from nova.api.openstack import faults from nova.api.openstack.views import limits as limits_views +from nova.api.openstack import wsgi # Convenience constants for the limits dictionary passed to Limiter(). @@ -43,23 +44,11 @@ PER_HOUR = 60 * 60 PER_DAY = 60 * 60 * 24 -class LimitsController(common.OpenstackController): +class LimitsController(object): """ Controller for accessing limits in the OpenStack API. """ - _serialization_metadata = { - "application/xml": { - "attributes": { - "limit": ["verb", "URI", "uri", "regex", "value", "unit", - "resetTime", "next-available", "remaining", "name"], - }, - "plurals": { - "rate": "limit", - }, - }, - } - def index(self, req): """ Return all global and rate limit information. @@ -84,6 +73,35 @@ class LimitsControllerV11(LimitsController): return limits_views.ViewBuilderV11() +def resource_factory(version='1.0'): + controller = { + '1.0': LimitsControllerV10, + '1.1': LimitsControllerV11, + }[version]() + + xmlns = { + '1.0': wsgi.XMLNS_V10, + '1.1': wsgi.XMLNS_V11, + }[version] + + metadata = { + "attributes": { + "limit": ["verb", "URI", "uri", "regex", "value", "unit", + "resetTime", "next-available", "remaining", "name"], + }, + "plurals": { + "rate": "limit", + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=xmlns, + metadata=metadata) + } + + return wsgi.Resource(controller, serializers=serializers) + + class Limit(object): """ Stores information about a limit for HTTP requets. @@ -195,7 +213,7 @@ DEFAULT_LIMITS = [ ] -class RateLimitingMiddleware(wsgi.Middleware): +class RateLimitingMiddleware(base_wsgi.Middleware): """ Rate-limits requests passing through this middleware. All limit information is stored in memory for this implementation. @@ -209,7 +227,7 @@ class RateLimitingMiddleware(wsgi.Middleware): @param application: WSGI application to wrap @param limits: List of dictionaries describing limits """ - wsgi.Middleware.__init__(self, application) + base_wsgi.Middleware.__init__(self, application) self._limiter = Limiter(limits or DEFAULT_LIMITS) @wsgify(RequestClass=wsgi.Request) diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/server_metadata.py index fd64ee4fb..fb9449b4c 100644 --- a/nova/api/openstack/server_metadata.py +++ b/nova/api/openstack/server_metadata.py @@ -19,12 +19,11 @@ from webob import exc from nova import compute from nova import quota -from nova import wsgi -from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi -class Controller(common.OpenstackController): +class Controller(object): """ The server metadata API controller for the Openstack API """ def __init__(self): @@ -43,10 +42,9 @@ class Controller(common.OpenstackController): context = req.environ['nova.context'] return self._get_metadata(context, server_id) - def create(self, req, server_id): + def create(self, req, server_id, body): context = req.environ['nova.context'] - data = self._deserialize(req.body, req.get_content_type()) - metadata = data.get('metadata') + metadata = body.get('metadata') try: self.compute_api.update_or_create_instance_metadata(context, server_id, @@ -55,9 +53,8 @@ class Controller(common.OpenstackController): self._handle_quota_error(error) return req.body - def update(self, req, server_id, id): + def update(self, req, server_id, id, body): context = req.environ['nova.context'] - body = self._deserialize(req.body, req.get_content_type()) if not id in body: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) @@ -92,3 +89,11 @@ class Controller(common.OpenstackController): if error.code == "MetadataLimitExceeded": raise exc.HTTPBadRequest(explanation=error.message) raise error + + +def resource_factory(): + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V11), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 8f2de2afe..78f8bb1b7 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -31,6 +31,7 @@ import nova.api.openstack.views.addresses import nova.api.openstack.views.flavors import nova.api.openstack.views.images import nova.api.openstack.views.servers +from nova.api.openstack import wsgi from nova.auth import manager as auth_manager from nova.compute import instance_types import nova.api.openstack @@ -41,31 +42,12 @@ LOG = logging.getLogger('nova.api.openstack.servers') FLAGS = flags.FLAGS -class Controller(common.OpenstackController): +class Controller(object): """ The Server API controller for the OpenStack API """ - _serialization_metadata = { - "application/xml": { - "attributes": { - "server": ["id", "imageId", "name", "flavorId", "hostId", - "status", "progress", "adminPass", "flavorRef", - "imageRef"], - "link": ["rel", "type", "href"], - }, - "dict_collections": { - "metadata": {"item_name": "meta", "item_key": "key"}, - }, - "list_collections": { - "public": {"item_name": "ip", "item_key": "addr"}, - "private": {"item_name": "ip", "item_key": "addr"}, - }, - }, - } - def __init__(self): self.compute_api = compute.API() self._image_service = utils.import_object(FLAGS.image_service) - super(Controller, self).__init__() def index(self, req): """ Returns a list of server names and ids for a given user """ @@ -122,15 +104,14 @@ class Controller(common.OpenstackController): return faults.Fault(exc.HTTPNotFound()) return exc.HTTPAccepted() - def create(self, req): + def create(self, req, body): """ Creates a new server for a given user """ - env = self._deserialize_create(req) - if not env: + if not body: return faults.Fault(exc.HTTPUnprocessableEntity()) context = req.environ['nova.context'] - password = self._get_server_admin_password(env['server']) + password = self._get_server_admin_password(body['server']) key_name = None key_data = None @@ -140,7 +121,7 @@ class Controller(common.OpenstackController): key_name = key_pair['name'] key_data = key_pair['public_key'] - requested_image_id = self._image_id_from_req_data(env) + requested_image_id = self._image_id_from_req_data(body) try: image_id = common.get_image_id_from_image_hash(self._image_service, context, requested_image_id) @@ -151,18 +132,18 @@ class Controller(common.OpenstackController): kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) - personality = env['server'].get('personality') + personality = body['server'].get('personality') injected_files = [] if personality: injected_files = self._get_injected_files(personality) - flavor_id = self._flavor_id_from_req_data(env) + flavor_id = self._flavor_id_from_req_data(body) - if not 'name' in env['server']: + if not 'name' in body['server']: msg = _("Server name is not defined") return exc.HTTPBadRequest(msg) - name = env['server']['name'] + name = body['server']['name'] self._validate_server_name(name) name = name.strip() @@ -179,7 +160,7 @@ class Controller(common.OpenstackController): display_description=name, key_name=key_name, key_data=key_data, - metadata=env['server'].get('metadata', {}), + metadata=body['server'].get('metadata', {}), injected_files=injected_files) except quota.QuotaError as error: self._handle_quota_error(error) @@ -194,18 +175,6 @@ class Controller(common.OpenstackController): password) return server - def _deserialize_create(self, request): - """ - Deserialize a create request - - Overrides normal behavior in the case of xml content - """ - if request.content_type == "application/xml": - deserializer = ServerCreateRequestXMLDeserializer() - return deserializer.deserialize(request.body) - else: - return self._deserialize(request.body, request.get_content_type()) - def _get_injected_files(self, personality): """ Create a list of injected files from the personality attribute @@ -255,24 +224,23 @@ class Controller(common.OpenstackController): return utils.generate_password(16) @scheduler_api.redirect_handler - def update(self, req, id): + def update(self, req, id, body): """ Updates the server name or password """ if len(req.body) == 0: raise exc.HTTPUnprocessableEntity() - inst_dict = self._deserialize(req.body, req.get_content_type()) - if not inst_dict: + if not body: return faults.Fault(exc.HTTPUnprocessableEntity()) ctxt = req.environ['nova.context'] update_dict = {} - if 'name' in inst_dict['server']: - name = inst_dict['server']['name'] + if 'name' in body['server']: + name = body['server']['name'] self._validate_server_name(name) update_dict['display_name'] = name.strip() - self._parse_update(ctxt, id, inst_dict, update_dict) + self._parse_update(ctxt, id, body, update_dict) try: self.compute_api.update(ctxt, id, **update_dict) @@ -294,7 +262,7 @@ class Controller(common.OpenstackController): pass @scheduler_api.redirect_handler - def action(self, req, id): + def action(self, req, id, body): """Multi-purpose method used to reboot, rebuild, or resize a server""" @@ -307,10 +275,9 @@ class Controller(common.OpenstackController): 'rebuild': self._action_rebuild, } - input_dict = self._deserialize(req.body, req.get_content_type()) for key in actions.keys(): - if key in input_dict: - return actions[key](input_dict, req, id) + if key in body: + return actions[key](body, req, id) return faults.Fault(exc.HTTPNotImplemented()) def _action_change_password(self, input_dict, req, id): @@ -410,7 +377,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() @scheduler_api.redirect_handler - def reset_network(self, req, id): + def reset_network(self, req, id, body): """ Reset networking on an instance (admin only). @@ -425,7 +392,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() @scheduler_api.redirect_handler - def inject_network_info(self, req, id): + def inject_network_info(self, req, id, body): """ Inject network info for an instance (admin only). @@ -440,7 +407,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() @scheduler_api.redirect_handler - def pause(self, req, id): + def pause(self, req, id, body): """ Permit Admins to Pause the server. """ ctxt = req.environ['nova.context'] try: @@ -452,7 +419,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() @scheduler_api.redirect_handler - def unpause(self, req, id): + def unpause(self, req, id, body): """ Permit Admins to Unpause the server. """ ctxt = req.environ['nova.context'] try: @@ -464,7 +431,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() @scheduler_api.redirect_handler - def suspend(self, req, id): + def suspend(self, req, id, body): """permit admins to suspend the server""" context = req.environ['nova.context'] try: @@ -476,7 +443,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() @scheduler_api.redirect_handler - def resume(self, req, id): + def resume(self, req, id, body): """permit admins to resume the server from suspend""" context = req.environ['nova.context'] try: @@ -815,3 +782,44 @@ class ServerCreateRequestXMLDeserializer(object): if child.nodeType == child.TEXT_NODE: return child.nodeValue return "" + + +def resource_factory(version='1.0'): + controller = { + '1.0': ControllerV10, + '1.1': ControllerV11, + }[version]() + + metadata = { + "attributes": { + "server": ["id", "imageId", "name", "flavorId", "hostId", + "status", "progress", "adminPass", "flavorRef", + "imageRef"], + "link": ["rel", "type", "href"], + }, + "dict_collections": { + "metadata": {"item_name": "meta", "item_key": "key"}, + }, + "list_collections": { + "public": {"item_name": "ip", "item_key": "addr"}, + "private": {"item_name": "ip", "item_key": "addr"}, + }, + } + + xmlns = { + '1.0': wsgi.XMLNS_V10, + '1.1': wsgi.XMLNS_V11, + }[version] + + serializers = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata, + xmlns=xmlns), + } + + deserializers = { + 'application/xml': ServerCreateRequestXMLDeserializer(), + } + + return wsgi.Resource(controller, serializers=serializers, + deserializers=deserializers) + diff --git a/nova/api/openstack/shared_ip_groups.py b/nova/api/openstack/shared_ip_groups.py index 996db3648..db178f2a2 100644 --- a/nova/api/openstack/shared_ip_groups.py +++ b/nova/api/openstack/shared_ip_groups.py @@ -17,29 +17,13 @@ from webob import exc -from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi -def _translate_keys(inst): - """ Coerces a shared IP group instance into proper dictionary format """ - return dict(sharedIpGroup=inst) - - -def _translate_detail_keys(inst): - """ Coerces a shared IP group instance into proper dictionary format with - correctly mapped attributes """ - return dict(sharedIpGroups=inst) - - -class Controller(common.OpenstackController): +class Controller(object): """ The Shared IP Groups Controller for the Openstack API """ - _serialization_metadata = { - 'application/xml': { - 'attributes': { - 'sharedIpGroup': []}}} - def index(self, req): """ Returns a list of Shared IP Groups for the user """ raise faults.Fault(exc.HTTPNotImplemented()) @@ -48,7 +32,7 @@ class Controller(common.OpenstackController): """ Shows in-depth information on a specific Shared IP Group """ raise faults.Fault(exc.HTTPNotImplemented()) - def update(self, req, id): + def update(self, req, id, body): """ You can't update a Shared IP Group """ raise faults.Fault(exc.HTTPNotImplemented()) @@ -60,6 +44,10 @@ class Controller(common.OpenstackController): """ Returns a complete list of Shared IP Groups """ raise faults.Fault(exc.HTTPNotImplemented()) - def create(self, req): + def create(self, req, body): """ Creates a new Shared IP group """ raise faults.Fault(exc.HTTPNotImplemented()) + + +def resource_factory(): + return wsgi.Resource(Controller()) diff --git a/nova/api/openstack/users.py b/nova/api/openstack/users.py index 7ae4c3232..35b6a502e 100644 --- a/nova/api/openstack/users.py +++ b/nova/api/openstack/users.py @@ -20,8 +20,10 @@ from nova import flags from nova import log as logging from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi from nova.auth import manager + FLAGS = flags.FLAGS LOG = logging.getLogger('nova.api.openstack') @@ -34,12 +36,7 @@ def _translate_keys(user): admin=user.admin) -class Controller(common.OpenstackController): - - _serialization_metadata = { - 'application/xml': { - "attributes": { - "user": ["id", "name", "access", "secret", "admin"]}}} +class Controller(object): def __init__(self): self.manager = manager.AuthManager() @@ -81,23 +78,35 @@ class Controller(common.OpenstackController): self.manager.delete_user(id) return {} - def create(self, req): + def create(self, req, body): self._check_admin(req.environ['nova.context']) - env = self._deserialize(req.body, req.get_content_type()) - is_admin = env['user'].get('admin') in ('T', 'True', True) - name = env['user'].get('name') - access = env['user'].get('access') - secret = env['user'].get('secret') + is_admin = body['user'].get('admin') in ('T', 'True', True) + name = body['user'].get('name') + access = body['user'].get('access') + secret = body['user'].get('secret') user = self.manager.create_user(name, access, secret, is_admin) return dict(user=_translate_keys(user)) - def update(self, req, id): + def update(self, req, id, body): self._check_admin(req.environ['nova.context']) - env = self._deserialize(req.body, req.get_content_type()) - is_admin = env['user'].get('admin') + is_admin = body['user'].get('admin') if is_admin is not None: is_admin = is_admin in ('T', 'True', True) - access = env['user'].get('access') - secret = env['user'].get('secret') + access = body['user'].get('access') + secret = body['user'].get('secret') self.manager.modify_user(id, access, secret, is_admin) return dict(user=_translate_keys(self.manager.get_user(id))) + + +def resource_factory(): + metadata = { + "attributes": { + "user": ["id", "name", "access", "secret", "admin"], + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py new file mode 100644 index 000000000..9e0077932 --- /dev/null +++ b/nova/api/openstack/wsgi.py @@ -0,0 +1,291 @@ + +import json +import webob +from xml.dom import minidom + +from nova import exception +from nova import log as logging +from nova import utils + + +XMLNS_V10 = 'http://docs.rackspacecloud.com/servers/api/v1.0' +XMLNS_V11 = 'http://docs.openstack.org/compute/api/v1.1' + +LOG = logging.getLogger('nova.api.openstack.wsgi') + + +class Request(webob.Request): + def best_match_content_type(self, supported=None): + """Determine the requested content-type. + + Based on the query extension then the Accept header. + + :param supported: list of content-types to override defaults + + """ + supported = supported or ['application/json', 'application/xml'] + parts = self.path.rsplit('.', 1) + + if len(parts) > 1: + ctype = 'application/{0}'.format(parts[1]) + if ctype in supported: + return ctype + + bm = self.accept.best_match(supported) + + return bm or 'application/json' + + def get_content_type(self): + if not "Content-Type" in self.headers: + raise exception.InvalidContentType(content_type=None) + + allowed_types = ("application/xml", "application/json") + type = self.content_type + + if type not in allowed_types: + raise exception.InvalidContentType(content_type=type) + else: + return type + + +class JSONDeserializer(object): + def deserialize(self, datastring): + return utils.loads(datastring) + + +class JSONSerializer(object): + def serialize(self, data): + return utils.dumps(data) + + +class XMLDeserializer(object): + def __init__(self, metadata=None): + """ + :param metadata: information needed to deserialize xml into + a dictionary. + """ + super(XMLDeserializer, self).__init__() + self.metadata = metadata or {} + + def deserialize(self, datastring): + """XML deserialization entry point.""" + plurals = set(self.metadata.get('plurals', {})) + node = minidom.parseString(datastring).childNodes[0] + return {node.nodeName: self._from_xml_node(node, plurals)} + + def _from_xml_node(self, node, listnames): + """Convert a minidom node to a simple Python type. + + :param listnames: list of XML node names whose subnodes should + be considered list items. + + """ + if len(node.childNodes) == 1 and node.childNodes[0].nodeType == 3: + return node.childNodes[0].nodeValue + elif node.nodeName in listnames: + return [self._from_xml_node(n, listnames) for n in node.childNodes] + else: + result = dict() + for attr in node.attributes.keys(): + result[attr] = node.attributes[attr].nodeValue + for child in node.childNodes: + if child.nodeType != node.TEXT_NODE: + result[child.nodeName] = self._from_xml_node(child, + listnames) + return result + + +class XMLSerializer(object): + def __init__(self, metadata=None, xmlns=None): + """ + :param metadata: information needed to deserialize xml into + a dictionary. + :param xmlns: XML namespace to include with serialized xml + """ + super(XMLSerializer, self).__init__() + self.metadata = metadata or {} + self.xmlns = xmlns + + def serialize(self, data): + # We expect data to contain a single key which is the XML root. + root_key = data.keys()[0] + doc = minidom.Document() + node = self._to_xml_node(doc, self.metadata, root_key, data[root_key]) + + xmlns = node.getAttribute('xmlns') + if not xmlns and self.xmlns: + node.setAttribute('xmlns', self.xmlns) + + return node.toprettyxml(indent=' ') + + def _to_xml_node(self, doc, metadata, nodename, data): + """Recursive method to convert data members to XML nodes.""" + result = doc.createElement(nodename) + + # Set the xml namespace if one is specified + # TODO(justinsb): We could also use prefixes on the keys + xmlns = metadata.get('xmlns', None) + if xmlns: + result.setAttribute('xmlns', xmlns) + + if type(data) is list: + collections = metadata.get('list_collections', {}) + if nodename in collections: + metadata = collections[nodename] + for item in data: + node = doc.createElement(metadata['item_name']) + node.setAttribute(metadata['item_key'], str(item)) + result.appendChild(node) + return result + singular = metadata.get('plurals', {}).get(nodename, None) + if singular is None: + if nodename.endswith('s'): + singular = nodename[:-1] + else: + singular = 'item' + for item in data: + node = self._to_xml_node(doc, metadata, singular, item) + result.appendChild(node) + elif type(data) is dict: + collections = metadata.get('dict_collections', {}) + if nodename in collections: + metadata = collections[nodename] + for k, v in data.items(): + node = doc.createElement(metadata['item_name']) + node.setAttribute(metadata['item_key'], str(k)) + text = doc.createTextNode(str(v)) + node.appendChild(text) + result.appendChild(node) + return result + attrs = metadata.get('attributes', {}).get(nodename, {}) + for k, v in data.items(): + if k in attrs: + result.setAttribute(k, str(v)) + else: + node = self._to_xml_node(doc, metadata, k, v) + result.appendChild(node) + else: + # Type is atom + node = doc.createTextNode(str(data)) + result.appendChild(node) + return result + + +class Resource(object): + """WSGI app that dispatched to methods. + + WSGI app that reads routing information supplied by RoutesMiddleware + and calls the requested action method upon itself. All action methods + must, in addition to their normal parameters, accept a 'req' argument + which is the incoming wsgi.Request. They raise a webob.exc exception, + or return a dict which will be serialized by requested content type. + + """ + def __init__(self, controller, serializers=None, deserializers=None): + self.serializers = { + 'application/xml': XMLSerializer(), + 'application/json': JSONSerializer(), + } + self.serializers.update(serializers or {}) + + self.deserializers = { + 'application/xml': XMLDeserializer(), + 'application/json': JSONDeserializer(), + } + self.deserializers.update(deserializers or {}) + + self.controller = controller + + @webob.dec.wsgify(RequestClass=Request) + def __call__(self, request): + """Call the method specified in req.environ by RoutesMiddleware.""" + LOG.debug("%s %s" % (request.method, request.url)) + + try: + action, action_args, accept = self.deserialize_request(request) + except exception.InvalidContentType: + return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) + + controller_method = getattr(self.controller, action) + result = controller_method(req=request, **action_args) + + response = self.serialize_response(accept, result) + + try: + msg_dict = dict(url=request.url, status=response.status_int) + msg = _("%(url)s returned with HTTP %(status)d") % msg_dict + except AttributeError: + msg_dict = dict(url=request.url) + msg = _("%(url)s returned a fault") + + LOG.debug(msg) + + return response + + def serialize_response(self, content_type, response_body): + """Serialize a dict into a string and wrap in a wsgi.Request object. + + :param content_type: expected mimetype of serialized response body + :param response_body: dict produced by the Controller + + """ + if not type(response_body) is dict: + return response_body + + response = webob.Response() + response.headers['Content-Type'] = content_type + + serializer = self.get_serializer(content_type) + response.body = serializer.serialize(response_body) + + return response + + def get_serializer(self, content_type): + try: + return self.serializers[content_type] + except Exception: + raise exception.InvalidContentType(content_type=content_type) + + def deserialize_request(self, request): + """Parse a wsgi request into a set of params we care about. + + :param request: wsgi.Request object + + """ + action_args = self.get_action_args(request.environ) + action = action_args.pop('action') + + if request.method.lower() in ('post', 'put'): + if len(request.body) == 0: + action_args['body'] = None + else: + content_type = request.get_content_type() + deserializer = self.get_deserializer(content_type) + + try: + action_args['body'] = deserializer.deserialize(request.body) + except exception.InvalidContentType: + action_args['body'] = None + + accept = self.get_expected_content_type(request) + + return (action, action_args, accept) + + def get_expected_content_type(self, request): + return request.best_match_content_type() + + def get_action_args(self, request_environment): + args = request_environment['wsgiorg.routing_args'][1].copy() + + del args['controller'] + + if 'format' in args: + del args['format'] + + return args + + def get_deserializer(self, content_type): + try: + return self.deserializers[content_type] + except Exception: + raise exception.InvalidContentType(content_type=content_type) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 227ffecdc..d17ab7a9b 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -17,6 +17,7 @@ from nova import db from nova import flags from nova import log as logging from nova.api.openstack import common +from nova.api.openstack import wsgi from nova.scheduler import api @@ -41,12 +42,7 @@ def _scrub_zone(zone): 'deleted', 'deleted_at', 'updated_at')) -class Controller(common.OpenstackController): - - _serialization_metadata = { - 'application/xml': { - "attributes": { - "zone": ["id", "api_url", "name", "capabilities"]}}} +class Controller(object): def index(self, req): """Return all zones in brief""" @@ -85,15 +81,28 @@ class Controller(common.OpenstackController): api.zone_delete(req.environ['nova.context'], zone_id) return {} - def create(self, req): + def create(self, req, body): context = req.environ['nova.context'] - env = self._deserialize(req.body, req.get_content_type()) - zone = api.zone_create(context, env["zone"]) + zone = api.zone_create(context, body["zone"]) return dict(zone=_scrub_zone(zone)) - def update(self, req, id): + def update(self, req, id, body): context = req.environ['nova.context'] - env = self._deserialize(req.body, req.get_content_type()) zone_id = int(id) - zone = api.zone_update(context, zone_id, env["zone"]) + zone = api.zone_update(context, zone_id, body["zone"]) return dict(zone=_scrub_zone(zone)) + + +def resource_factory(): + metadata = { + "attributes": { + "zone": ["id", "api_url", "name", "capabilities"], + }, + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V10, + metadata=metadata), + } + + return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/tests/api/openstack/test_limits.py b/nova/tests/api/openstack/test_limits.py index 45bd4d501..db859c2f8 100644 --- a/nova/tests/api/openstack/test_limits.py +++ b/nova/tests/api/openstack/test_limits.py @@ -65,7 +65,7 @@ class LimitsControllerV10Test(BaseLimitTestSuite): def setUp(self): """Run before each test.""" BaseLimitTestSuite.setUp(self) - self.controller = limits.LimitsControllerV10() + self.controller = limits.resource_factory('1.0') def _get_index_request(self, accept_header="application/json"): """Helper to set routing arguments.""" @@ -178,7 +178,7 @@ class LimitsControllerV11Test(BaseLimitTestSuite): def setUp(self): """Run before each test.""" BaseLimitTestSuite.setUp(self) - self.controller = limits.LimitsControllerV11() + self.controller = limits.resource_factory('1.1') def _get_index_request(self, accept_header="application/json"): """Helper to set routing arguments.""" diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index e8182b6a9..15f376f74 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -207,7 +207,6 @@ class ServersTest(test.TestCase): }, ] - print res_dict['server'] self.assertEqual(res_dict['server']['links'], expected_links) def test_get_server_by_id_with_addresses_xml(self): @@ -831,7 +830,6 @@ class ServersTest(test.TestCase): req = webob.Request.blank('/v1.0/servers/detail') req.headers['Accept'] = 'application/xml' res = req.get_response(fakes.wsgi_app()) - print res.body dom = minidom.parseString(res.body) for i, server in enumerate(dom.getElementsByTagName('server')): self.assertEqual(server.getAttribute('id'), str(i)) diff --git a/nova/tests/api/test_wsgi.py b/nova/tests/api/test_wsgi.py index 5820ecdc2..0be3aecf1 100644 --- a/nova/tests/api/test_wsgi.py +++ b/nova/tests/api/test_wsgi.py @@ -121,138 +121,3 @@ class ControllerTest(test.TestCase): result = request.get_response(self.TestRouter()) self.assertEqual(result.status_int, 200) self.assertEqual(result.headers["Content-Type"], "application/json") - - -class RequestTest(test.TestCase): - - def test_request_content_type_missing(self): - request = wsgi.Request.blank('/tests/123') - request.body = "" - self.assertRaises(webob.exc.HTTPBadRequest, request.get_content_type) - - def test_request_content_type_unsupported(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Content-Type"] = "text/html" - request.body = "asdf
" - self.assertRaises(webob.exc.HTTPBadRequest, request.get_content_type) - - def test_request_content_type_with_charset(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Content-Type"] = "application/json; charset=UTF-8" - result = request.get_content_type() - self.assertEqual(result, "application/json") - - def test_content_type_from_accept_xml(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/xml" - result = request.best_match_content_type() - self.assertEqual(result, "application/xml") - - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - self.assertEqual(result, "application/json") - - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/xml, application/json" - result = request.best_match_content_type() - self.assertEqual(result, "application/json") - - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = \ - "application/json; q=0.3, application/xml; q=0.9" - result = request.best_match_content_type() - self.assertEqual(result, "application/xml") - - def test_content_type_from_query_extension(self): - request = wsgi.Request.blank('/tests/123.xml') - result = request.best_match_content_type() - self.assertEqual(result, "application/xml") - - request = wsgi.Request.blank('/tests/123.json') - result = request.best_match_content_type() - self.assertEqual(result, "application/json") - - request = wsgi.Request.blank('/tests/123.invalid') - result = request.best_match_content_type() - self.assertEqual(result, "application/json") - - def test_content_type_accept_and_query_extension(self): - request = wsgi.Request.blank('/tests/123.xml') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - self.assertEqual(result, "application/xml") - - def test_content_type_accept_default(self): - request = wsgi.Request.blank('/tests/123.unsupported') - request.headers["Accept"] = "application/unsupported1" - result = request.best_match_content_type() - self.assertEqual(result, "application/json") - - -class SerializerTest(test.TestCase): - - def test_xml(self): - input_dict = dict(servers=dict(a=(2, 3))) - expected_xml = '(2,3)' - serializer = wsgi.Serializer() - result = serializer.serialize(input_dict, "application/xml") - result = result.replace('\n', '').replace(' ', '') - self.assertEqual(result, expected_xml) - - def test_json(self): - input_dict = dict(servers=dict(a=(2, 3))) - expected_json = '{"servers":{"a":[2,3]}}' - serializer = wsgi.Serializer() - result = serializer.serialize(input_dict, "application/json") - result = result.replace('\n', '').replace(' ', '') - self.assertEqual(result, expected_json) - - def test_unsupported_content_type(self): - serializer = wsgi.Serializer() - self.assertRaises(exception.InvalidContentType, serializer.serialize, - {}, "text/null") - - def test_deserialize_json(self): - data = """{"a": { - "a1": "1", - "a2": "2", - "bs": ["1", "2", "3", {"c": {"c1": "1"}}], - "d": {"e": "1"}, - "f": "1"}}""" - as_dict = dict(a={ - 'a1': '1', - 'a2': '2', - 'bs': ['1', '2', '3', {'c': dict(c1='1')}], - 'd': {'e': '1'}, - 'f': '1'}) - metadata = {} - serializer = wsgi.Serializer(metadata) - self.assertEqual(serializer.deserialize(data, "application/json"), - as_dict) - - def test_deserialize_xml(self): - xml = """ - - 123 - 1 - 1 - - """.strip() - as_dict = dict(a={ - 'a1': '1', - 'a2': '2', - 'bs': ['1', '2', '3', {'c': dict(c1='1')}], - 'd': {'e': '1'}, - 'f': '1'}) - metadata = {'application/xml': dict(plurals={'bs': 'b', 'ts': 't'})} - serializer = wsgi.Serializer(metadata) - self.assertEqual(serializer.deserialize(xml, "application/xml"), - as_dict) - - def test_deserialize_empty_xml(self): - xml = """""" - as_dict = {"a": {}} - serializer = wsgi.Serializer() - self.assertEqual(serializer.deserialize(xml, "application/xml"), - as_dict) diff --git a/nova/tests/integrated/test_xml.py b/nova/tests/integrated/test_xml.py index 8a9754777..fde32f797 100644 --- a/nova/tests/integrated/test_xml.py +++ b/nova/tests/integrated/test_xml.py @@ -32,7 +32,7 @@ class XmlTests(integrated_helpers._IntegratedTestBase): """"Some basic XML sanity checks.""" def test_namespace_limits(self): - """/limits should have v1.0 namespace (hasn't changed in 1.1).""" + """/limits should have v1.1 namespace (has changed in 1.1).""" headers = {} headers['Accept'] = 'application/xml' @@ -40,7 +40,7 @@ class XmlTests(integrated_helpers._IntegratedTestBase): data = response.read() LOG.debug("data: %s" % data) - prefix = ' Date: Wed, 18 May 2011 20:33:25 -0400 Subject: removing controller/serializer code from wsgi.py; updating other code to use new modules --- nova/api/direct.py | 12 +- nova/api/openstack/common.py | 7 - nova/api/openstack/consoles.py | 3 +- nova/api/openstack/contrib/volumes.py | 23 +- nova/api/openstack/extensions.py | 97 +++++---- nova/api/openstack/faults.py | 39 ++-- nova/api/openstack/image_metadata.py | 1 - nova/api/openstack/images.py | 11 +- nova/api/openstack/versions.py | 44 ++-- nova/api/openstack/wsgi.py | 23 +- nova/objectstore/s3server.py | 2 +- nova/tests/api/openstack/extensions/foxinsocks.py | 4 +- nova/tests/api/openstack/test_extensions.py | 4 +- nova/tests/api/test_wsgi.py | 54 ----- nova/wsgi.py | 250 +--------------------- 15 files changed, 147 insertions(+), 427 deletions(-) diff --git a/nova/api/direct.py b/nova/api/direct.py index 8ceae299c..5e6c7c882 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -42,6 +42,7 @@ from nova import exception from nova import flags from nova import utils from nova import wsgi +import nova.api.openstack.wsgi # Global storage for registering modules. @@ -251,7 +252,7 @@ class Reflection(object): return self._methods[method] -class ServiceWrapper(wsgi.Controller): +class ServiceWrapper(object): """Wrapper to dynamically povide a WSGI controller for arbitrary objects. With lightweight introspection allows public methods on the object to @@ -265,7 +266,7 @@ class ServiceWrapper(wsgi.Controller): def __init__(self, service_handle): self.service_handle = service_handle - @webob.dec.wsgify(RequestClass=wsgi.Request) + @webob.dec.wsgify(RequestClass=nova.api.openstack.wsgi.Request) def __call__(self, req): arg_dict = req.environ['wsgiorg.routing_args'][1] action = arg_dict['action'] @@ -289,8 +290,11 @@ class ServiceWrapper(wsgi.Controller): try: content_type = req.best_match_content_type() - default_xmlns = self.get_default_xmlns(req) - return self._serialize(result, content_type, default_xmlns) + serializer = { + 'application/xml': nova.api.openstack.wsgi.XMLSerializer(), + 'application/json': nova.api.openstack.wsgi.JSONSerializer(), + }[content_type] + return serializer.serialize(result) except: raise exception.Error("returned non-serializable type: %s" % result) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 32cd689ca..bb1a96812 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -23,7 +23,6 @@ import webob from nova import exception from nova import flags from nova import log as logging -from nova import wsgi LOG = logging.getLogger('nova.api.openstack.common') @@ -146,9 +145,3 @@ def get_id_from_href(href): except: LOG.debug(_("Error extracting id from href: %s") % href) raise webob.exc.HTTPBadRequest(_('could not parse id from href')) - - -class OpenstackController(wsgi.Controller): - def get_default_xmlns(self, req): - # Use V10 by default - return XML_NS_V10 diff --git a/nova/api/openstack/consoles.py b/nova/api/openstack/consoles.py index 36d570803..97304affe 100644 --- a/nova/api/openstack/consoles.py +++ b/nova/api/openstack/consoles.py @@ -44,11 +44,10 @@ def _translate_detail_keys(cons): class Controller(object): - """The Consoles Controller for the Openstack API""" + """The Consoles controller for the Openstack API""" def __init__(self): self.console_api = console.API() - super(Controller, self).__init__() def index(self, req, server_id): """Returns a list of consoles for this instance""" diff --git a/nova/api/openstack/contrib/volumes.py b/nova/api/openstack/contrib/volumes.py index 18de2ec71..b00790b7f 100644 --- a/nova/api/openstack/contrib/volumes.py +++ b/nova/api/openstack/contrib/volumes.py @@ -22,7 +22,6 @@ from nova import exception from nova import flags from nova import log as logging from nova import volume -from nova import wsgi from nova.api.openstack import common from nova.api.openstack import extensions from nova.api.openstack import faults @@ -64,7 +63,7 @@ def _translate_volume_summary_view(context, vol): return d -class VolumeController(wsgi.Controller): +class VolumeController(object): """The Volumes API controller for the OpenStack API.""" _serialization_metadata = { @@ -124,15 +123,14 @@ class VolumeController(wsgi.Controller): res = [entity_maker(context, vol) for vol in limited_list] return {'volumes': res} - def create(self, req): + def create(self, req, body): """Creates a new volume.""" context = req.environ['nova.context'] - env = self._deserialize(req.body, req.get_content_type()) - if not env: + if not body: return faults.Fault(exc.HTTPUnprocessableEntity()) - vol = env['volume'] + vol = body['volume'] size = vol['size'] LOG.audit(_("Create volume of %s GB"), size, context=context) new_volume = self.volume_api.create(context, size, @@ -175,7 +173,7 @@ def _translate_attachment_summary_view(_context, vol): return d -class VolumeAttachmentController(wsgi.Controller): +class VolumeAttachmentController(object): """The volume attachment API controller for the Openstack API. A child resource of the server. Note that we use the volume id @@ -219,17 +217,16 @@ class VolumeAttachmentController(wsgi.Controller): return {'volumeAttachment': _translate_attachment_detail_view(context, vol)} - def create(self, req, server_id): + def create(self, req, server_id, body): """Attach a volume to an instance.""" context = req.environ['nova.context'] - env = self._deserialize(req.body, req.get_content_type()) - if not env: + if not body: return faults.Fault(exc.HTTPUnprocessableEntity()) instance_id = server_id - volume_id = env['volumeAttachment']['volumeId'] - device = env['volumeAttachment']['device'] + volume_id = body['volumeAttachment']['volumeId'] + device = body['volumeAttachment']['device'] msg = _("Attach volume %(volume_id)s to instance %(server_id)s" " at %(device)s") % locals() @@ -259,7 +256,7 @@ class VolumeAttachmentController(wsgi.Controller): # TODO(justinsb): How do I return "accepted" here? return {'volumeAttachment': attachment} - def update(self, _req, _server_id, _id): + def update(self, req, server_id, id, body): """Update a volume attachment. We don't currently support this.""" return faults.Fault(exc.HTTPBadRequest()) diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index 7ea7afef6..73f174e07 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -27,9 +27,10 @@ import webob.exc from nova import exception from nova import flags from nova import log as logging -from nova import wsgi +from nova import wsgi as base_wsgi from nova.api.openstack import common from nova.api.openstack import faults +from nova.api.openstack import wsgi LOG = logging.getLogger('extensions') @@ -116,28 +117,34 @@ class ExtensionDescriptor(object): return response_exts -class ActionExtensionController(common.OpenstackController): - +class ActionExtensionController(object): def __init__(self, application): - self.application = application self.action_handlers = {} def add_action(self, action_name, handler): self.action_handlers[action_name] = handler - def action(self, req, id): - - input_dict = self._deserialize(req.body, req.get_content_type()) + def action(self, req, id, body): for action_name, handler in self.action_handlers.iteritems(): - if action_name in input_dict: - return handler(input_dict, req, id) + if action_name in body: + return handler(body, req, id) # no action handler found (bump to downstream application) res = self.application return res -class ResponseExtensionController(common.OpenstackController): +class ActionExtensionResource(wsgi.Resource): + + def __init__(self, application): + controller = ActionExtensionController(application) + super(ActionExtensionResource, self).__init__(controller) + + def add_action(self, action_name, handler): + self.controller.add_action(action_name, handler) + + +class ResponseExtensionController(object): def __init__(self, application): self.application = application @@ -157,7 +164,11 @@ class ResponseExtensionController(common.OpenstackController): headers = res.headers except AttributeError: default_xmlns = None - body = self._serialize(res, content_type, default_xmlns) + serializer = { + 'application/xml': wsgi.XMLSerializer(), + 'application/json': wsgi.JSONSerializer(), + }[content_type] + body = serializer.serialize(res) headers = {"Content-Type": content_type} res = webob.Response() res.body = body @@ -165,7 +176,17 @@ class ResponseExtensionController(common.OpenstackController): return res -class ExtensionController(common.OpenstackController): +class ResponseExtensionResource(wsgi.Resource): + + def __init__(self, application): + controller = ResponseExtensionController(application) + super(ResponseExtensionResource, self).__init__(controller) + + def add_handler(self, handler): + self.controller.add_handler(handler) + + +class ExtensionController(object): def __init__(self, extension_manager): self.extension_manager = extension_manager @@ -198,7 +219,7 @@ class ExtensionController(common.OpenstackController): raise faults.Fault(webob.exc.HTTPNotFound()) -class ExtensionMiddleware(wsgi.Middleware): +class ExtensionMiddleware(base_wsgi.Middleware): """Extensions middleware for WSGI.""" @classmethod def factory(cls, global_config, **local_config): @@ -207,43 +228,43 @@ class ExtensionMiddleware(wsgi.Middleware): return cls(app, **local_config) return _factory - def _action_ext_controllers(self, application, ext_mgr, mapper): - """Return a dict of ActionExtensionController-s by collection.""" - action_controllers = {} + def _action_ext_resources(self, application, ext_mgr, mapper): + """Return a dict of ActionExtensionResource objects by collection.""" + action_resources = {} for action in ext_mgr.get_actions(): - if not action.collection in action_controllers.keys(): - controller = ActionExtensionController(application) + if not action.collection in action_resources.keys(): + resource = ActionExtensionResource(application) mapper.connect("/%s/:(id)/action.:(format)" % action.collection, action='action', - controller=controller, + controller=resource, conditions=dict(method=['POST'])) mapper.connect("/%s/:(id)/action" % action.collection, action='action', - controller=controller, + controller=resource, conditions=dict(method=['POST'])) - action_controllers[action.collection] = controller + action_resources[action.collection] = resource - return action_controllers + return action_resources - def _response_ext_controllers(self, application, ext_mgr, mapper): - """Returns a dict of ResponseExtensionController-s by collection.""" - response_ext_controllers = {} + def _response_ext_resources(self, application, ext_mgr, mapper): + """Returns a dict of ResponseExtensionResource objects by collection.""" + response_ext_resources = {} for resp_ext in ext_mgr.get_response_extensions(): - if not resp_ext.key in response_ext_controllers.keys(): - controller = ResponseExtensionController(application) + if not resp_ext.key in response_ext_resources.keys(): + resource = ResponseExtensionResource(application) mapper.connect(resp_ext.url_route + '.:(format)', action='process', - controller=controller, + controller=resource, conditions=resp_ext.conditions) mapper.connect(resp_ext.url_route, action='process', - controller=controller, + controller=resource, conditions=resp_ext.conditions) - response_ext_controllers[resp_ext.key] = controller + response_ext_resources[resp_ext.key] = resource - return response_ext_controllers + return response_ext_resources def __init__(self, application, ext_mgr=None): @@ -258,21 +279,21 @@ class ExtensionMiddleware(wsgi.Middleware): LOG.debug(_('Extended resource: %s'), resource.collection) mapper.resource(resource.collection, resource.collection, - controller=resource.controller, + controller=wsgi.Resource(resource.controller), collection=resource.collection_actions, member=resource.member_actions, parent_resource=resource.parent) # extended actions - action_controllers = self._action_ext_controllers(application, ext_mgr, + action_resources = self._action_ext_resources(application, ext_mgr, mapper) for action in ext_mgr.get_actions(): LOG.debug(_('Extended action: %s'), action.action_name) - controller = action_controllers[action.collection] - controller.add_action(action.action_name, action.handler) + resource = action_resources[action.collection] + resource.add_action(action.action_name, action.handler) # extended responses - resp_controllers = self._response_ext_controllers(application, ext_mgr, + resp_controllers = self._response_ext_resources(application, ext_mgr, mapper) for response_ext in ext_mgr.get_response_extensions(): LOG.debug(_('Extended response: %s'), response_ext.key) @@ -422,7 +443,7 @@ class ExtensionManager(object): class ResponseExtension(object): - """Add data to responses from core nova OpenStack API controllers.""" + """Add data to responses from core nova OpenStack API resources.""" def __init__(self, method, url_route, handler): self.url_route = url_route @@ -432,7 +453,7 @@ class ResponseExtension(object): class ActionExtension(object): - """Add custom actions to core nova OpenStack API controllers.""" + """Add custom actions to core nova OpenStack API resources.""" def __init__(self, collection, action_name, handler): self.collection = collection diff --git a/nova/api/openstack/faults.py b/nova/api/openstack/faults.py index 87118ce19..fd36f8f17 100644 --- a/nova/api/openstack/faults.py +++ b/nova/api/openstack/faults.py @@ -19,8 +19,7 @@ import webob.dec import webob.exc -from nova import wsgi -from nova.api.openstack import common +from nova.api.openstack import wsgi class Fault(webob.exc.HTTPException): @@ -55,13 +54,21 @@ class Fault(webob.exc.HTTPException): if code == 413: retry = self.wrapped_exc.headers['Retry-After'] fault_data[fault_name]['retryAfter'] = retry + # 'code' is an attribute on the fault tag itself - metadata = {'application/xml': {'attributes': {fault_name: 'code'}}} - default_xmlns = common.XML_NS_V10 - serializer = wsgi.Serializer(metadata, default_xmlns) + metadata = {'attributes': {fault_name: 'code'}} + content_type = req.best_match_content_type() - self.wrapped_exc.body = serializer.serialize(fault_data, content_type) + + serializer = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata, + xmlns=wsgi.XMLNS_V10), + 'application/json': wsgi.JSONSerializer(), + }[content_type] + + self.wrapped_exc.body = serializer.serialize(fault_data) self.wrapped_exc.content_type = content_type + return self.wrapped_exc @@ -70,14 +77,6 @@ class OverLimitFault(webob.exc.HTTPException): Rate-limited request response. """ - _serialization_metadata = { - "application/xml": { - "attributes": { - "overLimitFault": "code", - }, - }, - } - def __init__(self, message, details, retry_time): """ Initialize new `OverLimitFault` with relevant information. @@ -97,8 +96,16 @@ class OverLimitFault(webob.exc.HTTPException): Return the wrapped exception with a serialized body conforming to our error format. """ - serializer = wsgi.Serializer(self._serialization_metadata) content_type = request.best_match_content_type() - content = serializer.serialize(self.content, content_type) + metadata = {"attributes": {"overLimitFault": "code"}} + + serializer = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata, + xmlns=wsgi.XMLNS_V10), + 'application/json': wsgi.JSONSerializer(), + }[content_type] + + content = serializer.serialize(self.content) self.wrapped_exc.body = content + return self.wrapped_exc diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index ce0140265..506b63acf 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -20,7 +20,6 @@ from webob import exc from nova import flags from nova import quota from nova import utils -from nova import wsgi from nova.api.openstack import faults from nova.api.openstack import wsgi diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index e22854ebf..5a03573d8 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -31,7 +31,7 @@ FLAGS = flags.FLAGS class Controller(object): - """Base `wsgi.Controller` for retrieving/displaying images.""" + """Base controller for retrieving/displaying images.""" def __init__(self, image_service=None, compute_service=None): """Initialize new `ImageController`. @@ -99,21 +99,20 @@ class Controller(object): self._image_service.delete(context, image_id) return webob.exc.HTTPNoContent() - def create(self, req): + def create(self, req, body): """Snapshot a server instance and save the image. :param req: `wsgi.Request` object """ context = req.environ['nova.context'] content_type = req.get_content_type() - image = self._deserialize(req.body, content_type) - if not image: + if not body: raise webob.exc.HTTPBadRequest() try: - server_id = image["image"]["serverId"] - image_name = image["image"]["name"] + server_id = body["image"]["serverId"] + image_name = body["image"]["name"] except KeyError: raise webob.exc.HTTPBadRequest() diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index 3f9d91934..a8d785b52 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -18,13 +18,27 @@ import webob import webob.dec -from nova import wsgi +from nova import wsgi as base_wsgi import nova.api.openstack.views.versions +from nova.api.openstack import wsgi -class Versions(wsgi.Application): - @webob.dec.wsgify(RequestClass=wsgi.Request) - def __call__(self, req): +class Versions(wsgi.Resource, base_wsgi.Application): + def __init__(self): + metadata = { + "attributes": { + "version": ["status", "id"], + "link": ["rel", "href"], + } + } + + serializers = { + 'application/xml': wsgi.XMLSerializer(metadata=metadata), + } + + super(Versions, self).__init__(None, serializers=serializers) + + def dispatch(self, request, *args): """Respond to a request for all OpenStack API versions.""" version_objs = [ { @@ -37,24 +51,6 @@ class Versions(wsgi.Application): }, ] - builder = nova.api.openstack.views.versions.get_view_builder(req) + builder = nova.api.openstack.views.versions.get_view_builder(request) versions = [builder.build(version) for version in version_objs] - response = dict(versions=versions) - - metadata = { - "application/xml": { - "attributes": { - "version": ["status", "id"], - "link": ["rel", "href"], - } - } - } - - content_type = req.best_match_content_type() - body = wsgi.Serializer(metadata).serialize(response, content_type) - - response = webob.Response() - response.content_type = content_type - response.body = body - - return response + return dict(versions=versions) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 9e0077932..97280c365 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -206,8 +206,7 @@ class Resource(object): except exception.InvalidContentType: return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) - controller_method = getattr(self.controller, action) - result = controller_method(req=request, **action_args) + result = self.dispatch(request, action, action_args) response = self.serialize_response(accept, result) @@ -222,6 +221,10 @@ class Resource(object): return response + def dispatch(self, request, action, action_args): + controller_method = getattr(self.controller, action) + return controller_method(req=request, **action_args) + def serialize_response(self, content_type, response_body): """Serialize a dict into a string and wrap in a wsgi.Request object. @@ -253,7 +256,7 @@ class Resource(object): """ action_args = self.get_action_args(request.environ) - action = action_args.pop('action') + action = action_args.pop('action', None) if request.method.lower() in ('post', 'put'): if len(request.body) == 0: @@ -275,14 +278,18 @@ class Resource(object): return request.best_match_content_type() def get_action_args(self, request_environment): - args = request_environment['wsgiorg.routing_args'][1].copy() + try: + args = request_environment['wsgiorg.routing_args'][1].copy() + + del args['controller'] - del args['controller'] + if 'format' in args: + del args['format'] - if 'format' in args: - del args['format'] + return args - return args + except KeyError: + return {} def get_deserializer(self, content_type): try: diff --git a/nova/objectstore/s3server.py b/nova/objectstore/s3server.py index dd6327c8f..76025a1e3 100644 --- a/nova/objectstore/s3server.py +++ b/nova/objectstore/s3server.py @@ -81,7 +81,7 @@ class S3Application(wsgi.Router): super(S3Application, self).__init__(mapper) -class BaseRequestHandler(wsgi.Controller): +class BaseRequestHandler(object): """Base class emulating Tornado's web framework pattern in WSGI. This is a direct port of Tornado's implementation, so some key decisions diff --git a/nova/tests/api/openstack/extensions/foxinsocks.py b/nova/tests/api/openstack/extensions/foxinsocks.py index 0860b51ac..a64552af1 100644 --- a/nova/tests/api/openstack/extensions/foxinsocks.py +++ b/nova/tests/api/openstack/extensions/foxinsocks.py @@ -17,12 +17,10 @@ import json -from nova import wsgi - from nova.api.openstack import extensions -class FoxInSocksController(wsgi.Controller): +class FoxInSocksController(object): def index(self, req): return "Try to say this Mr. Knox, sir..." diff --git a/nova/tests/api/openstack/test_extensions.py b/nova/tests/api/openstack/test_extensions.py index 481d34ed1..a8168f88a 100644 --- a/nova/tests/api/openstack/test_extensions.py +++ b/nova/tests/api/openstack/test_extensions.py @@ -26,15 +26,15 @@ from nova import flags from nova.api import openstack from nova.api.openstack import extensions from nova.api.openstack import flavors +from nova.api.openstack import wsgi from nova.tests.api.openstack import fakes -import nova.wsgi FLAGS = flags.FLAGS response_body = "Try to say this Mr. Knox, sir..." -class StubController(nova.wsgi.Controller): +class StubController(object): def __init__(self, body): self.body = body diff --git a/nova/tests/api/test_wsgi.py b/nova/tests/api/test_wsgi.py index 0be3aecf1..d33268296 100644 --- a/nova/tests/api/test_wsgi.py +++ b/nova/tests/api/test_wsgi.py @@ -67,57 +67,3 @@ class Test(test.TestCase): self.assertEqual(result.body, "Router result") result = webob.Request.blank('/bad').get_response(Router()) self.assertNotEqual(result.body, "Router result") - - -class ControllerTest(test.TestCase): - - class TestRouter(wsgi.Router): - - class TestController(wsgi.Controller): - - _serialization_metadata = { - 'application/xml': { - "attributes": { - "test": ["id"]}}} - - def show(self, req, id): # pylint: disable=W0622,C0103 - return {"test": {"id": id}} - - def __init__(self): - mapper = routes.Mapper() - mapper.resource("test", "tests", controller=self.TestController()) - wsgi.Router.__init__(self, mapper) - - def test_show(self): - request = wsgi.Request.blank('/tests/123') - result = request.get_response(self.TestRouter()) - self.assertEqual(json.loads(result.body), {"test": {"id": "123"}}) - - def test_response_content_type_from_accept_xml(self): - request = webob.Request.blank('/tests/123') - request.headers["Accept"] = "application/xml" - result = request.get_response(self.TestRouter()) - self.assertEqual(result.headers["Content-Type"], "application/xml") - - def test_response_content_type_from_accept_json(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/json" - result = request.get_response(self.TestRouter()) - self.assertEqual(result.headers["Content-Type"], "application/json") - - def test_response_content_type_from_query_extension_xml(self): - request = wsgi.Request.blank('/tests/123.xml') - result = request.get_response(self.TestRouter()) - self.assertEqual(result.headers["Content-Type"], "application/xml") - - def test_response_content_type_from_query_extension_json(self): - request = wsgi.Request.blank('/tests/123.json') - result = request.get_response(self.TestRouter()) - self.assertEqual(result.headers["Content-Type"], "application/json") - - def test_response_content_type_default_when_unsupported(self): - request = wsgi.Request.blank('/tests/123.unsupported') - request.headers["Accept"] = "application/unsupported1" - result = request.get_response(self.TestRouter()) - self.assertEqual(result.status_int, 200) - self.assertEqual(result.headers["Content-Type"], "application/json") diff --git a/nova/wsgi.py b/nova/wsgi.py index e60a8820d..3a292073b 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -82,36 +82,7 @@ class Server(object): class Request(webob.Request): - - def best_match_content_type(self): - """Determine the most acceptable content-type. - - Based on the query extension then the Accept header. - - """ - parts = self.path.rsplit('.', 1) - - if len(parts) > 1: - format = parts[1] - if format in ['json', 'xml']: - return 'application/{0}'.format(parts[1]) - - ctypes = ['application/json', 'application/xml'] - bm = self.accept.best_match(ctypes) - - return bm or 'application/json' - - def get_content_type(self): - allowed_types = ("application/xml", "application/json") - if not "Content-Type" in self.headers: - msg = _("Missing Content-Type") - LOG.debug(msg) - raise webob.exc.HTTPBadRequest(msg) - type = self.content_type - if type in allowed_types: - return type - LOG.debug(_("Wrong Content-Type: %s") % type) - raise webob.exc.HTTPBadRequest("Invalid content type") + pass class Application(object): @@ -286,7 +257,7 @@ class Router(object): Each route in `mapper` must specify a 'controller', which is a WSGI app to call. You'll probably want to specify an 'action' as - well and have your controller be a wsgi.Controller, who will route + well and have your controller be a controller, who will route the request to the action method. Examples: @@ -335,223 +306,6 @@ class Router(object): return app -class Controller(object): - """WSGI app that dispatched to methods. - - WSGI app that reads routing information supplied by RoutesMiddleware - and calls the requested action method upon itself. All action methods - must, in addition to their normal parameters, accept a 'req' argument - which is the incoming wsgi.Request. They raise a webob.exc exception, - or return a dict which will be serialized by requested content type. - - """ - - @webob.dec.wsgify(RequestClass=Request) - def __call__(self, req): - """Call the method specified in req.environ by RoutesMiddleware.""" - arg_dict = req.environ['wsgiorg.routing_args'][1] - action = arg_dict['action'] - method = getattr(self, action) - LOG.debug("%s %s" % (req.method, req.url)) - del arg_dict['controller'] - del arg_dict['action'] - if 'format' in arg_dict: - del arg_dict['format'] - arg_dict['req'] = req - result = method(**arg_dict) - - if type(result) is dict: - content_type = req.best_match_content_type() - default_xmlns = self.get_default_xmlns(req) - body = self._serialize(result, content_type, default_xmlns) - - response = webob.Response() - response.headers['Content-Type'] = content_type - response.body = body - msg_dict = dict(url=req.url, status=response.status_int) - msg = _("%(url)s returned with HTTP %(status)d") % msg_dict - LOG.debug(msg) - return response - else: - return result - - def _serialize(self, data, content_type, default_xmlns): - """Serialize the given dict to the provided content_type. - - Uses self._serialization_metadata if it exists, which is a dict mapping - MIME types to information needed to serialize to that type. - - """ - _metadata = getattr(type(self), '_serialization_metadata', {}) - - serializer = Serializer(_metadata, default_xmlns) - try: - return serializer.serialize(data, content_type) - except exception.InvalidContentType: - raise webob.exc.HTTPNotAcceptable() - - def _deserialize(self, data, content_type): - """Deserialize the request body to the specefied content type. - - Uses self._serialization_metadata if it exists, which is a dict mapping - MIME types to information needed to serialize to that type. - - """ - _metadata = getattr(type(self), '_serialization_metadata', {}) - serializer = Serializer(_metadata) - return serializer.deserialize(data, content_type) - - def get_default_xmlns(self, req): - """Provide the XML namespace to use if none is otherwise specified.""" - return None - - -class Serializer(object): - """Serializes and deserializes dictionaries to certain MIME types.""" - - def __init__(self, metadata=None, default_xmlns=None): - """Create a serializer based on the given WSGI environment. - - 'metadata' is an optional dict mapping MIME types to information - needed to serialize a dictionary to that type. - - """ - self.metadata = metadata or {} - self.default_xmlns = default_xmlns - - def _get_serialize_handler(self, content_type): - handlers = { - 'application/json': self._to_json, - 'application/xml': self._to_xml, - } - - try: - return handlers[content_type] - except Exception: - raise exception.InvalidContentType(content_type=content_type) - - def serialize(self, data, content_type): - """Serialize a dictionary into the specified content type.""" - return self._get_serialize_handler(content_type)(data) - - def deserialize(self, datastring, content_type): - """Deserialize a string to a dictionary. - - The string must be in the format of a supported MIME type. - - """ - return self.get_deserialize_handler(content_type)(datastring) - - def get_deserialize_handler(self, content_type): - handlers = { - 'application/json': self._from_json, - 'application/xml': self._from_xml, - } - - try: - return handlers[content_type] - except Exception: - raise exception.InvalidContentType(content_type=content_type) - - def _from_json(self, datastring): - return utils.loads(datastring) - - def _from_xml(self, datastring): - xmldata = self.metadata.get('application/xml', {}) - plurals = set(xmldata.get('plurals', {})) - node = minidom.parseString(datastring).childNodes[0] - return {node.nodeName: self._from_xml_node(node, plurals)} - - def _from_xml_node(self, node, listnames): - """Convert a minidom node to a simple Python type. - - listnames is a collection of names of XML nodes whose subnodes should - be considered list items. - - """ - if len(node.childNodes) == 1 and node.childNodes[0].nodeType == 3: - return node.childNodes[0].nodeValue - elif node.nodeName in listnames: - return [self._from_xml_node(n, listnames) for n in node.childNodes] - else: - result = dict() - for attr in node.attributes.keys(): - result[attr] = node.attributes[attr].nodeValue - for child in node.childNodes: - if child.nodeType != node.TEXT_NODE: - result[child.nodeName] = self._from_xml_node(child, - listnames) - return result - - def _to_json(self, data): - return utils.dumps(data) - - def _to_xml(self, data): - metadata = self.metadata.get('application/xml', {}) - # We expect data to contain a single key which is the XML root. - root_key = data.keys()[0] - doc = minidom.Document() - node = self._to_xml_node(doc, metadata, root_key, data[root_key]) - - xmlns = node.getAttribute('xmlns') - if not xmlns and self.default_xmlns: - node.setAttribute('xmlns', self.default_xmlns) - - return node.toprettyxml(indent=' ') - - def _to_xml_node(self, doc, metadata, nodename, data): - """Recursive method to convert data members to XML nodes.""" - result = doc.createElement(nodename) - - # Set the xml namespace if one is specified - # TODO(justinsb): We could also use prefixes on the keys - xmlns = metadata.get('xmlns', None) - if xmlns: - result.setAttribute('xmlns', xmlns) - - if type(data) is list: - collections = metadata.get('list_collections', {}) - if nodename in collections: - metadata = collections[nodename] - for item in data: - node = doc.createElement(metadata['item_name']) - node.setAttribute(metadata['item_key'], str(item)) - result.appendChild(node) - return result - singular = metadata.get('plurals', {}).get(nodename, None) - if singular is None: - if nodename.endswith('s'): - singular = nodename[:-1] - else: - singular = 'item' - for item in data: - node = self._to_xml_node(doc, metadata, singular, item) - result.appendChild(node) - elif type(data) is dict: - collections = metadata.get('dict_collections', {}) - if nodename in collections: - metadata = collections[nodename] - for k, v in data.items(): - node = doc.createElement(metadata['item_name']) - node.setAttribute(metadata['item_key'], str(k)) - text = doc.createTextNode(str(v)) - node.appendChild(text) - result.appendChild(node) - return result - attrs = metadata.get('attributes', {}).get(nodename, {}) - for k, v in data.items(): - if k in attrs: - result.setAttribute(k, str(v)) - else: - node = self._to_xml_node(doc, metadata, k, v) - result.appendChild(node) - else: - # Type is atom - node = doc.createTextNode(str(data)) - result.appendChild(node) - return result - - def paste_config_file(basename): """Find the best location in the system for a paste config file. -- cgit From 0aefdc6da92b8db8b15a3e8a0bef8fc5c4b46450 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 18 May 2011 20:33:52 -0400 Subject: missed the new wsgi test file --- nova/tests/api/openstack/test_wsgi.py | 248 ++++++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 nova/tests/api/openstack/test_wsgi.py diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py new file mode 100644 index 000000000..430dafe77 --- /dev/null +++ b/nova/tests/api/openstack/test_wsgi.py @@ -0,0 +1,248 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import json +import webob + +from nova import exception +from nova import test +from nova.api.openstack import wsgi + + +class RequestTest(test.TestCase): + def test_content_type_missing(self): + request = wsgi.Request.blank('/tests/123') + request.body = "" + self.assertRaises(exception.InvalidContentType, + request.get_content_type) + + def test_content_type_unsupported(self): + request = wsgi.Request.blank('/tests/123') + request.headers["Content-Type"] = "text/html" + request.body = "asdf
" + self.assertRaises(exception.InvalidContentType, + request.get_content_type) + + def test_content_type_with_charset(self): + request = wsgi.Request.blank('/tests/123') + request.headers["Content-Type"] = "application/json; charset=UTF-8" + result = request.get_content_type() + self.assertEqual(result, "application/json") + + def test_content_type_from_accept_xml(self): + request = wsgi.Request.blank('/tests/123') + request.headers["Accept"] = "application/xml" + result = request.best_match_content_type() + self.assertEqual(result, "application/xml") + + request = wsgi.Request.blank('/tests/123') + request.headers["Accept"] = "application/json" + result = request.best_match_content_type() + self.assertEqual(result, "application/json") + + request = wsgi.Request.blank('/tests/123') + request.headers["Accept"] = "application/xml, application/json" + result = request.best_match_content_type() + self.assertEqual(result, "application/json") + + request = wsgi.Request.blank('/tests/123') + request.headers["Accept"] = \ + "application/json; q=0.3, application/xml; q=0.9" + result = request.best_match_content_type() + self.assertEqual(result, "application/xml") + + def test_content_type_from_query_extension(self): + request = wsgi.Request.blank('/tests/123.xml') + result = request.best_match_content_type() + self.assertEqual(result, "application/xml") + + request = wsgi.Request.blank('/tests/123.json') + result = request.best_match_content_type() + self.assertEqual(result, "application/json") + + request = wsgi.Request.blank('/tests/123.invalid') + result = request.best_match_content_type() + self.assertEqual(result, "application/json") + + def test_content_type_accept_and_query_extension(self): + request = wsgi.Request.blank('/tests/123.xml') + request.headers["Accept"] = "application/json" + result = request.best_match_content_type() + self.assertEqual(result, "application/xml") + + def test_content_type_accept_default(self): + request = wsgi.Request.blank('/tests/123.unsupported') + request.headers["Accept"] = "application/unsupported1" + result = request.best_match_content_type() + self.assertEqual(result, "application/json") + + +class SerializationTest(test.TestCase): + def test_xml(self): + input_dict = dict(servers=dict(a=(2, 3))) + expected_xml = '(2,3)' + xmlns = "testing xmlns" + serializer = wsgi.XMLSerializer(xmlns="asdf") + result = serializer.serialize(input_dict) + result = result.replace('\n', '').replace(' ', '') + self.assertEqual(result, expected_xml) + + def test_json(self): + input_dict = dict(servers=dict(a=(2, 3))) + expected_json = '{"servers":{"a":[2,3]}}' + serializer = wsgi.JSONSerializer() + result = serializer.serialize(input_dict) + result = result.replace('\n', '').replace(' ', '') + self.assertEqual(result, expected_json) + + +class DeserializationTest(test.TestCase): + def test_json(self): + data = """{"a": { + "a1": "1", + "a2": "2", + "bs": ["1", "2", "3", {"c": {"c1": "1"}}], + "d": {"e": "1"}, + "f": "1"}}""" + as_dict = dict(a={ + 'a1': '1', + 'a2': '2', + 'bs': ['1', '2', '3', {'c': dict(c1='1')}], + 'd': {'e': '1'}, + 'f': '1'}) + deserializer = wsgi.JSONDeserializer() + self.assertEqual(deserializer.deserialize(data), as_dict) + + def test_xml(self): + xml = """ + + 123 + 1 + 1 + + """.strip() + as_dict = dict(a={ + 'a1': '1', + 'a2': '2', + 'bs': ['1', '2', '3', {'c': dict(c1='1')}], + 'd': {'e': '1'}, + 'f': '1'}) + metadata = {'plurals': {'bs': 'b', 'ts': 't'}} + deserializer = wsgi.XMLDeserializer(metadata=metadata) + self.assertEqual(deserializer.deserialize(xml), as_dict) + + def test_xml_empty(self): + xml = """""" + as_dict = {"a": {}} + deserializer = wsgi.XMLDeserializer() + self.assertEqual(deserializer.deserialize(xml), as_dict) + + +class ResourceSerializerTest(test.TestCase): + def setUp(self): + class JSONSerializer(object): + def serialize(self, data): + return 'pew_json' + + class XMLSerializer(object): + def serialize(self, data): + return 'pew_xml' + + self.serializers = { + 'application/json': JSONSerializer(), + 'application/XML': XMLSerializer(), + } + + self.resource = wsgi.Resource(None, serializers=self.serializers) + + def tearDown(self): + pass + + def test_get_serializer(self): + self.assertEqual(self.resource.get_serializer('application/json'), + self.serializers['application/json']) + + def test_get_serializer_unknown_content_type(self): + self.assertRaises(exception.InvalidContentType, + self.resource.get_serializer, + 'application/unknown') + + def test_serialize_response_dict(self): + response = self.resource.serialize_response('application/json', {}) + self.assertEqual(response.headers['Content-Type'], 'application/json') + self.assertEqual(response.body, 'pew_json') + + def test_serialize_response_non_dict(self): + response = self.resource.serialize_response('application/json', 'a') + self.assertEqual(response, 'a') + + def test_serialize_response_dict_to_unknown_content_type(self): + self.assertRaises(exception.InvalidContentType, + self.resource.serialize_response, + 'application/unknown', {}) + + def test_serialize_response_non_dict_to_unknown_content_type(self): + response = self.resource.serialize_response('application/unknown', 'a') + self.assertEqual(response, 'a') + + +class ResourceDeserializerTest(test.TestCase): + def setUp(self): + class JSONDeserializer(object): + def deserialize(self, data): + return 'pew_json' + + class XMLDeserializer(object): + def deserialize(self, data): + return 'pew_xml' + + self.deserializers = { + 'application/json': JSONDeserializer(), + 'application/XML': XMLDeserializer(), + } + + self.resource = wsgi.Resource(None, deserializers=self.deserializers) + + def tearDown(self): + pass + + def test_get_deserializer(self): + self.assertEqual(self.resource.get_deserializer('application/json'), + self.deserializers['application/json']) + + def test_get_deserializer_unknown_content_type(self): + self.assertRaises(exception.InvalidContentType, + self.resource.get_deserializer, + 'application/unknown') + + def test_get_expected_content_type(self): + request = wsgi.Request.blank('/') + request.headers['Accept'] = 'application/json' + self.assertEqual(self.resource.get_expected_content_type(request), + 'application/json') + + def test_get_action_args(self): + env = { + 'wsgiorg.routing_args': [None, { + 'controller': None, + 'format': None, + 'action': 'update', + 'id': 12, + }], + } + + expected = {'action': 'update', 'id': 12} + + self.assertEqual(self.resource.get_action_args(env), expected) + + def test_deserialize_request(self): + def fake_get_routing_args(request): + return {'action': 'create'} + self.resource.get_action_args = fake_get_routing_args + + request = wsgi.Request.blank('/') + request.headers['Accept'] = 'application/xml' + + deserialized = self.resource.deserialize_request(request) + expected = ('create', {}, 'application/xml') + + self.assertEqual(expected, deserialized) -- cgit From beea6545804dc17661eea83b373d74d14cf07c32 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Thu, 19 May 2011 10:52:23 -0400 Subject: Minor cleanup --- nova/api/openstack/images.py | 8 +++----- nova/virt/libvirt_conn.py | 12 +++--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index c2511b99f..ac02d63c5 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -50,8 +50,7 @@ class Controller(common.OpenstackController): """ self._compute_service = compute_service or compute.API() - self._image_service = image_service or \ - utils.get_default_image_service() + self._image_service = image_service or utils.get_default_image_service() def index(self, req): """Return an index listing of images available to the request. @@ -75,14 +74,13 @@ class Controller(common.OpenstackController): builder = self.get_builder(req).build return dict(images=[builder(image, detail=True) for image in images]) - def show(self, req, id): + def show(self, req, image_id): """Return detailed information about a specific image. :param req: `wsgi.Request` object - :param id: Image identifier (integer) + :param image_id: Image identifier (integer) """ context = req.environ['nova.context'] - image_id = id try: (image_service, service_image_id) = utils.get_image_service( diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index ab47493fd..e311184e7 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -844,9 +844,7 @@ class LibvirtConnection(driver.ComputeDriver): 'ramdisk_id': inst['ramdisk_id']} if disk_images['kernel_id']: - fname_hash = hashlib.sha1() - fname_hash.update(disk_images['kernel_id']) - fname = fname_hash.hexdigest() + fname = hashlib.sha1(disk_images['kernel_id']).hexdigest() self._cache_image(fn=self._fetch_image, target=basepath('kernel'), fname=fname, @@ -854,9 +852,7 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) if disk_images['ramdisk_id']: - fname_hash = hashlib.sha1() - fname_hash.update(disk_images['ramdisk_id']) - fname = fname_hash.hexdigest() + fname = hashlib.sha1(disk_images['ramdisk_id']).hexdigest() self._cache_image(fn=self._fetch_image, target=basepath('ramdisk'), fname=fname, @@ -864,9 +860,7 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) - fname_hash = hashlib.sha1() - fname_hash.update(disk_images['image_id']) - root_fname = fname_hash.hexdigest() + fname = hashlib.sha1(disk_images['image_id']).hexdigest() size = FLAGS.minimum_root_size -- cgit From d6fab80027e5fdb9a8d3e56044c399a7a80b2464 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Thu, 19 May 2011 11:29:23 -0400 Subject: fname should have been root_fname --- nova/virt/libvirt_conn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index e311184e7..9e66c3b48 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -860,7 +860,7 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) - fname = hashlib.sha1(disk_images['image_id']).hexdigest() + root_fname = hashlib.sha1(disk_images['image_id']).hexdigest() size = FLAGS.minimum_root_size -- cgit From ce37d88a91c016fdb7f29a9178fb0b08a6a8f1b2 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Thu, 19 May 2011 11:17:20 -0700 Subject: temp --- nova/api/openstack/servers.py | 2 +- nova/scheduler/zone_aware_scheduler.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 12008d44a..738910bc8 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -162,7 +162,7 @@ class Controller(common.OpenstackController): msg = _("Server name is not defined") return exc.HTTPBadRequest(msg) - zone_blob = env.get('blob', None) + zone_blob = env['server'].get('blob') name = env['server']['name'] self._validate_server_name(name) name = name.strip() diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 6600951fb..9572d1c9f 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -150,7 +150,8 @@ class ZoneAwareScheduler(driver.Scheduler): raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) - nova.servers.create(name, image, flavor, ipgroup, meta, files) + nova.servers.create(name, image, flavor, ipgroup, meta, files, + child_blob) def select(self, context, request_spec, *args, **kwargs): """Select returns a list of weights and zone/host information -- cgit From e0d43f39aeee0d62741ed40de9045bfde3fd20d8 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Thu, 19 May 2011 16:03:10 -0400 Subject: No reason to hash ramdisk_id and kernel_id. They are ints. --- nova/virt/libvirt_conn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 9e66c3b48..25ba0bc8d 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -844,7 +844,7 @@ class LibvirtConnection(driver.ComputeDriver): 'ramdisk_id': inst['ramdisk_id']} if disk_images['kernel_id']: - fname = hashlib.sha1(disk_images['kernel_id']).hexdigest() + fname = disk_images['kernel_id'] self._cache_image(fn=self._fetch_image, target=basepath('kernel'), fname=fname, @@ -852,7 +852,7 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) if disk_images['ramdisk_id']: - fname = hashlib.sha1(disk_images['ramdisk_id']).hexdigest() + fname = disk_images['ramdisk_id'] self._cache_image(fn=self._fetch_image, target=basepath('ramdisk'), fname=fname, -- cgit From 68426df2287c24efc3d327d12371911ac29d117e Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 19 May 2011 16:16:06 -0400 Subject: further refactoring of wsgi module; adding documentation and tests --- nova/api/direct.py | 4 +- nova/api/openstack/accounts.py | 2 +- nova/api/openstack/backup_schedules.py | 4 +- nova/api/openstack/consoles.py | 2 +- nova/api/openstack/extensions.py | 8 +- nova/api/openstack/faults.py | 12 +- nova/api/openstack/flavors.py | 2 +- nova/api/openstack/image_metadata.py | 2 +- nova/api/openstack/images.py | 4 +- nova/api/openstack/ips.py | 4 +- nova/api/openstack/limits.py | 4 +- nova/api/openstack/server_metadata.py | 2 +- nova/api/openstack/servers.py | 11 +- nova/api/openstack/users.py | 2 +- nova/api/openstack/versions.py | 5 +- nova/api/openstack/wsgi.py | 301 ++++++++++++++++++++----------- nova/api/openstack/zones.py | 4 +- nova/tests/api/openstack/test_servers.py | 50 ++--- nova/tests/api/openstack/test_wsgi.py | 104 ++++++++--- 19 files changed, 331 insertions(+), 196 deletions(-) diff --git a/nova/api/direct.py b/nova/api/direct.py index 5e6c7c882..ea20042a7 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -291,8 +291,8 @@ class ServiceWrapper(object): try: content_type = req.best_match_content_type() serializer = { - 'application/xml': nova.api.openstack.wsgi.XMLSerializer(), - 'application/json': nova.api.openstack.wsgi.JSONSerializer(), + 'application/xml': nova.api.openstack.wsgi.XMLDictSerializer(), + 'application/json': nova.api.openstack.wsgi.JSONDictSerializer(), }[content_type] return serializer.serialize(result) except: diff --git a/nova/api/openstack/accounts.py b/nova/api/openstack/accounts.py index d8a9d1909..faff8bb2c 100644 --- a/nova/api/openstack/accounts.py +++ b/nova/api/openstack/accounts.py @@ -88,7 +88,7 @@ def resource_factory(): } serializers = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/backup_schedules.py b/nova/api/openstack/backup_schedules.py index 4153c90c1..d08a4799c 100644 --- a/nova/api/openstack/backup_schedules.py +++ b/nova/api/openstack/backup_schedules.py @@ -60,8 +60,8 @@ def resource_factory(): } serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V10, - metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V10, + metadata=metadata), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/consoles.py b/nova/api/openstack/consoles.py index 97304affe..56f79db60 100644 --- a/nova/api/openstack/consoles.py +++ b/nova/api/openstack/consoles.py @@ -97,7 +97,7 @@ def resource_factory(): } serializers = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index 73f174e07..19147bbea 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -165,8 +165,8 @@ class ResponseExtensionController(object): except AttributeError: default_xmlns = None serializer = { - 'application/xml': wsgi.XMLSerializer(), - 'application/json': wsgi.JSONSerializer(), + 'application/xml': wsgi.XMLDictSerializer(), + 'application/json': wsgi.JSONDictSerializer(), }[content_type] body = serializer.serialize(res) headers = {"Content-Type": content_type} @@ -229,7 +229,7 @@ class ExtensionMiddleware(base_wsgi.Middleware): return _factory def _action_ext_resources(self, application, ext_mgr, mapper): - """Return a dict of ActionExtensionResource objects by collection.""" + """Return a dict of ActionExtensionResource-s by collection.""" action_resources = {} for action in ext_mgr.get_actions(): if not action.collection in action_resources.keys(): @@ -248,7 +248,7 @@ class ExtensionMiddleware(base_wsgi.Middleware): return action_resources def _response_ext_resources(self, application, ext_mgr, mapper): - """Returns a dict of ResponseExtensionResource objects by collection.""" + """Returns a dict of ResponseExtensionResource-s by collection.""" response_ext_resources = {} for resp_ext in ext_mgr.get_response_extensions(): if not resp_ext.key in response_ext_resources.keys(): diff --git a/nova/api/openstack/faults.py b/nova/api/openstack/faults.py index fd36f8f17..b9a23c126 100644 --- a/nova/api/openstack/faults.py +++ b/nova/api/openstack/faults.py @@ -61,9 +61,9 @@ class Fault(webob.exc.HTTPException): content_type = req.best_match_content_type() serializer = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata, - xmlns=wsgi.XMLNS_V10), - 'application/json': wsgi.JSONSerializer(), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata, + xmlns=wsgi.XMLNS_V10), + 'application/json': wsgi.JSONDictSerializer(), }[content_type] self.wrapped_exc.body = serializer.serialize(fault_data) @@ -100,9 +100,9 @@ class OverLimitFault(webob.exc.HTTPException): metadata = {"attributes": {"overLimitFault": "code"}} serializer = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata, - xmlns=wsgi.XMLNS_V10), - 'application/json': wsgi.JSONSerializer(), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata, + xmlns=wsgi.XMLNS_V10), + 'application/json': wsgi.JSONDictSerializer(), }[content_type] content = serializer.serialize(self.content) diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/flavors.py index 46056a27a..9e98e6c27 100644 --- a/nova/api/openstack/flavors.py +++ b/nova/api/openstack/flavors.py @@ -86,7 +86,7 @@ def resource_factory(version='1.0'): }[version] serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=xmlns), + 'application/xml': wsgi.XMLDictSerializer(xmlns=xmlns), } return wsgi.Resource(controller, serializers=serializers) diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index 506b63acf..8acde9fe8 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -104,7 +104,7 @@ class Controller(object): def resource_factory(): serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V11), + 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V11), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 5a03573d8..a9071ed8a 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -165,8 +165,8 @@ def resource_factory(version='1.0'): } serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=xmlns, - metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(xmlns=xmlns, + metadata=metadata), } return wsgi.Resource(controller, serializers=serializers) diff --git a/nova/api/openstack/ips.py b/nova/api/openstack/ips.py index 24612eafb..87c8c997a 100644 --- a/nova/api/openstack/ips.py +++ b/nova/api/openstack/ips.py @@ -72,8 +72,8 @@ def resource_factory(): } serializers = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata, - xmlns=wsgi.XMLNS_V10), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata, + xmlns=wsgi.XMLNS_V10), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/limits.py b/nova/api/openstack/limits.py index 306048d8f..b0e093702 100644 --- a/nova/api/openstack/limits.py +++ b/nova/api/openstack/limits.py @@ -95,8 +95,8 @@ def resource_factory(version='1.0'): } serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=xmlns, - metadata=metadata) + 'application/xml': wsgi.XMLDictSerializer(xmlns=xmlns, + metadata=metadata) } return wsgi.Resource(controller, serializers=serializers) diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/server_metadata.py index fb9449b4c..eff98c060 100644 --- a/nova/api/openstack/server_metadata.py +++ b/nova/api/openstack/server_metadata.py @@ -93,7 +93,7 @@ class Controller(object): def resource_factory(): serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V11), + 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V11), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 78f8bb1b7..8f39bd256 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -707,7 +707,7 @@ class ControllerV11(Controller): return common.XML_NS_V11 -class ServerCreateRequestXMLDeserializer(object): +class ServerXMLDeserializer(wsgi.XMLDeserializer): """ Deserializer to handle xml-formatted server create requests. @@ -715,7 +715,7 @@ class ServerCreateRequestXMLDeserializer(object): and personality attributes """ - def deserialize(self, string): + def create(self, string): """Deserialize an xml-formatted server create request""" dom = minidom.parseString(string) server = self._extract_server(dom) @@ -812,14 +812,13 @@ def resource_factory(version='1.0'): }[version] serializers = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata, - xmlns=xmlns), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata, + xmlns=xmlns), } deserializers = { - 'application/xml': ServerCreateRequestXMLDeserializer(), + 'application/xml': ServerXMLDeserializer(), } return wsgi.Resource(controller, serializers=serializers, deserializers=deserializers) - diff --git a/nova/api/openstack/users.py b/nova/api/openstack/users.py index 35b6a502e..e14616349 100644 --- a/nova/api/openstack/users.py +++ b/nova/api/openstack/users.py @@ -106,7 +106,7 @@ def resource_factory(): } serializers = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index a8d785b52..9db160102 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -18,12 +18,11 @@ import webob import webob.dec -from nova import wsgi as base_wsgi import nova.api.openstack.views.versions from nova.api.openstack import wsgi -class Versions(wsgi.Resource, base_wsgi.Application): +class Versions(wsgi.Resource): def __init__(self): metadata = { "attributes": { @@ -33,7 +32,7 @@ class Versions(wsgi.Resource, base_wsgi.Application): } serializers = { - 'application/xml': wsgi.XMLSerializer(metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(metadata=metadata), } super(Versions, self).__init__(None, serializers=serializers) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 97280c365..bd840a6f7 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -6,6 +6,7 @@ from xml.dom import minidom from nova import exception from nova import log as logging from nova import utils +from nova import wsgi XMLNS_V10 = 'http://docs.rackspacecloud.com/servers/api/v1.0' @@ -15,17 +16,17 @@ LOG = logging.getLogger('nova.api.openstack.wsgi') class Request(webob.Request): - def best_match_content_type(self, supported=None): - """Determine the requested content-type. + """Add some Openstack API-specific logic to the base webob.Request.""" - Based on the query extension then the Accept header. + def best_match_content_type(self): + """Determine the requested response content-type. - :param supported: list of content-types to override defaults + Based on the query extension then the Accept header. """ - supported = supported or ['application/json', 'application/xml'] - parts = self.path.rsplit('.', 1) + supported = ('application/json', 'application/xml') + parts = self.path.rsplit('.', 1) if len(parts) > 1: ctype = 'application/{0}'.format(parts[1]) if ctype in supported: @@ -33,32 +34,52 @@ class Request(webob.Request): bm = self.accept.best_match(supported) + # default to application/json if we don't find a preference return bm or 'application/json' def get_content_type(self): + """Determine content type of the request body. + + Does not do any body introspection, only checks header + + """ if not "Content-Type" in self.headers: raise exception.InvalidContentType(content_type=None) allowed_types = ("application/xml", "application/json") - type = self.content_type + content_type = self.content_type - if type not in allowed_types: - raise exception.InvalidContentType(content_type=type) + if content_type not in allowed_types: + raise exception.InvalidContentType(content_type=content_type) else: - return type + return content_type -class JSONDeserializer(object): - def deserialize(self, datastring): - return utils.loads(datastring) +class TextDeserializer(object): + """Custom request body deserialization based on controller action name.""" + def deserialize(self, datastring, action=None): + """Find local deserialization method and parse request body.""" + try: + action_method = getattr(self, action) + except Exception: + action_method = self.default -class JSONSerializer(object): - def serialize(self, data): - return utils.dumps(data) + return action_method(datastring) + def default(self, datastring): + """Default deserialization code should live here""" + raise NotImplementedError() + + +class JSONDeserializer(TextDeserializer): + + def default(self, datastring): + return utils.loads(datastring) + + +class XMLDeserializer(TextDeserializer): -class XMLDeserializer(object): def __init__(self, metadata=None): """ :param metadata: information needed to deserialize xml into @@ -67,8 +88,7 @@ class XMLDeserializer(object): super(XMLDeserializer, self).__init__() self.metadata = metadata or {} - def deserialize(self, datastring): - """XML deserialization entry point.""" + def default(self, datastring): plurals = set(self.metadata.get('plurals', {})) node = minidom.parseString(datastring).childNodes[0] return {node.nodeName: self._from_xml_node(node, plurals)} @@ -95,18 +115,111 @@ class XMLDeserializer(object): return result -class XMLSerializer(object): +class RequestDeserializer(object): + """Break up a Request object into more useful pieces.""" + + def __init__(self, deserializers=None): + """ + :param deserializers: dictionary of content-type-specific deserializers + + """ + self.deserializers = { + 'application/xml': XMLDeserializer(), + 'application/json': JSONDeserializer(), + } + + self.deserializers.update(deserializers or {}) + + def deserialize(self, request): + """Extract necessary pieces of the request. + + :param request: Request object + :returns tuple of expected controller action name, dictionary of + keyword arguments to pass to the controller, the expected + content type of the response + + """ + action_args = self.get_action_args(request.environ) + action = action_args.pop('action', None) + + if request.method.lower() in ('post', 'put'): + if len(request.body) == 0: + action_args['body'] = None + else: + content_type = request.get_content_type() + deserializer = self.get_deserializer(content_type) + + try: + body = deserializer.deserialize(request.body, action) + action_args['body'] = body + except exception.InvalidContentType: + action_args['body'] = None + + accept = self.get_expected_content_type(request) + + return (action, action_args, accept) + + def get_deserializer(self, content_type): + try: + return self.deserializers[content_type] + except Exception: + raise exception.InvalidContentType(content_type=content_type) + + def get_expected_content_type(self, request): + return request.best_match_content_type() + + def get_action_args(self, request_environment): + """Parse dictionary created by routes library.""" + try: + args = request_environment['wsgiorg.routing_args'][1].copy() + + del args['controller'] + + if 'format' in args: + del args['format'] + + return args + + except KeyError: + return {} + + +class DictSerializer(object): + """Custom response body serialization based on controller action name.""" + + def serialize(self, data, action=None): + """Find local serialization method and encode response body.""" + try: + action_method = getattr(self, action) + except Exception: + action_method = self.default + + return action_method(data) + + def default(self, data): + """Default serialization code should live here""" + raise NotImplementedError() + + +class JSONDictSerializer(DictSerializer): + + def default(self, data): + return utils.dumps(data) + + +class XMLDictSerializer(DictSerializer): + def __init__(self, metadata=None, xmlns=None): """ :param metadata: information needed to deserialize xml into a dictionary. :param xmlns: XML namespace to include with serialized xml """ - super(XMLSerializer, self).__init__() + super(XMLDictSerializer, self).__init__() self.metadata = metadata or {} self.xmlns = xmlns - def serialize(self, data): + def default(self, data): # We expect data to contain a single key which is the XML root. root_key = data.keys()[0] doc = minidom.Document() @@ -171,75 +284,32 @@ class XMLSerializer(object): return result -class Resource(object): - """WSGI app that dispatched to methods. +class ResponseSerializer(object): + """Encode the necessary pieces into a response object""" - WSGI app that reads routing information supplied by RoutesMiddleware - and calls the requested action method upon itself. All action methods - must, in addition to their normal parameters, accept a 'req' argument - which is the incoming wsgi.Request. They raise a webob.exc exception, - or return a dict which will be serialized by requested content type. + def __init__(self, serializers=None): + """ + :param serializers: dictionary of content-type-specific serializers - """ - def __init__(self, controller, serializers=None, deserializers=None): + """ self.serializers = { - 'application/xml': XMLSerializer(), - 'application/json': JSONSerializer(), + 'application/xml': XMLDictSerializer(), + 'application/json': JSONDictSerializer(), } self.serializers.update(serializers or {}) - self.deserializers = { - 'application/xml': XMLDeserializer(), - 'application/json': JSONDeserializer(), - } - self.deserializers.update(deserializers or {}) - - self.controller = controller - - @webob.dec.wsgify(RequestClass=Request) - def __call__(self, request): - """Call the method specified in req.environ by RoutesMiddleware.""" - LOG.debug("%s %s" % (request.method, request.url)) - - try: - action, action_args, accept = self.deserialize_request(request) - except exception.InvalidContentType: - return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) - - result = self.dispatch(request, action, action_args) - - response = self.serialize_response(accept, result) - - try: - msg_dict = dict(url=request.url, status=response.status_int) - msg = _("%(url)s returned with HTTP %(status)d") % msg_dict - except AttributeError: - msg_dict = dict(url=request.url) - msg = _("%(url)s returned a fault") - - LOG.debug(msg) - - return response - - def dispatch(self, request, action, action_args): - controller_method = getattr(self.controller, action) - return controller_method(req=request, **action_args) - - def serialize_response(self, content_type, response_body): + def serialize(self, response_data, content_type): """Serialize a dict into a string and wrap in a wsgi.Request object. + :param response_data: dict produced by the Controller :param content_type: expected mimetype of serialized response body - :param response_body: dict produced by the Controller """ - if not type(response_body) is dict: - return response_body - response = webob.Response() response.headers['Content-Type'] = content_type serializer = self.get_serializer(content_type) - response.body = serializer.serialize(response_body) + response.body = serializer.serialize(response_data) return response @@ -249,50 +319,63 @@ class Resource(object): except Exception: raise exception.InvalidContentType(content_type=content_type) - def deserialize_request(self, request): - """Parse a wsgi request into a set of params we care about. - :param request: wsgi.Request object +class Resource(wsgi.Application): + """WSGI app that handles (de)serialization and controller dispatch. + + WSGI app that reads routing information supplied by RoutesMiddleware + and calls the requested action method upon its controller. All + controller action methods must accept a 'req' argument, which is the + incoming wsgi.Request. If the operation is a PUT or POST, the controller + method must also accept a 'body' argument (the deserialized request body). + They may raise a webob.exc exception or return a dict, which will be + serialized by requested content type. + """ + def __init__(self, controller, serializers=None, deserializers=None): """ - action_args = self.get_action_args(request.environ) - action = action_args.pop('action', None) + :param controller: object that implement methods created by routes lib + :param serializers: dict of content-type specific text serializers + :param deserializers: dict of content-type specific text deserializers - if request.method.lower() in ('post', 'put'): - if len(request.body) == 0: - action_args['body'] = None - else: - content_type = request.get_content_type() - deserializer = self.get_deserializer(content_type) + """ + self.controller = controller + self.serializer = ResponseSerializer(serializers) + self.deserializer = RequestDeserializer(deserializers) - try: - action_args['body'] = deserializer.deserialize(request.body) - except exception.InvalidContentType: - action_args['body'] = None + @webob.dec.wsgify(RequestClass=Request) + def __call__(self, request): + """WSGI method that controls (de)serialization and method dispatch.""" - accept = self.get_expected_content_type(request) + LOG.debug("%s %s" % (request.method, request.url)) - return (action, action_args, accept) + try: + action, action_args, accept = self.deserializer.deserialize( + request) + except exception.InvalidContentType: + return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) - def get_expected_content_type(self, request): - return request.best_match_content_type() + action_result = self.dispatch(request, action, action_args) - def get_action_args(self, request_environment): - try: - args = request_environment['wsgiorg.routing_args'][1].copy() + #TODO(bcwaldon): find a more elegant way to pass through non-dict types + if type(action_result) is dict: + response = self.serializer.serialize(action_result, accept) + else: + response = action_result - del args['controller'] + try: + msg_dict = dict(url=request.url, status=response.status_int) + msg = _("%(url)s returned with HTTP %(status)d") % msg_dict + except AttributeError: + msg_dict = dict(url=request.url) + msg = _("%(url)s returned a fault") - if 'format' in args: - del args['format'] + LOG.debug(msg) - return args + return response - except KeyError: - return {} + def dispatch(self, request, action, action_args): + """Find action-spefic method on controller and call it.""" - def get_deserializer(self, content_type): - try: - return self.deserializers[content_type] - except Exception: - raise exception.InvalidContentType(content_type=content_type) + controller_method = getattr(self.controller, action) + return controller_method(req=request, **action_args) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index d17ab7a9b..e750fc230 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -101,8 +101,8 @@ def resource_factory(): } serializers = { - 'application/xml': wsgi.XMLSerializer(xmlns=wsgi.XMLNS_V10, - metadata=metadata), + 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V10, + metadata=metadata), } return wsgi.Resource(Controller(), serializers=serializers) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 15f376f74..31571fc46 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -993,6 +993,14 @@ class ServersTest(test.TestCase): res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 501) + def test_server_change_password_xml(self): + req = webob.Request.blank('/v1.0/servers/1/action') + req.method = 'POST' + req.content_type = 'application/xml' + req.body = '' +# res = req.get_response(fakes.wsgi_app()) +# self.assertEqual(res.status_int, 501) + def test_server_change_password_v1_1(self): class MockSetAdminPassword(object): @@ -1375,13 +1383,13 @@ class ServersTest(test.TestCase): class TestServerCreateRequestXMLDeserializer(unittest.TestCase): def setUp(self): - self.deserializer = servers.ServerCreateRequestXMLDeserializer() + self.deserializer = servers.ServerXMLDeserializer() def test_minimal_request(self): serial_request = """ """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"server": { "name": "new-server-test", "imageId": "1", @@ -1395,7 +1403,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): name="new-server-test" imageId="1" flavorId="1"> """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"server": { "name": "new-server-test", "imageId": "1", @@ -1410,7 +1418,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): name="new-server-test" imageId="1" flavorId="1"> """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"server": { "name": "new-server-test", "imageId": "1", @@ -1426,7 +1434,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"server": { "name": "new-server-test", "imageId": "1", @@ -1443,7 +1451,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"server": { "name": "new-server-test", "imageId": "1", @@ -1461,7 +1469,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): aabbccdd """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = [{"path": "/etc/conf", "contents": "aabbccdd"}] self.assertEquals(request["server"]["personality"], expected) @@ -1471,7 +1479,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): name="new-server-test" imageId="1" flavorId="1"> aabbccdd abcd""" - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = [{"path": "/etc/conf", "contents": "aabbccdd"}, {"path": "/etc/sudoers", "contents": "abcd"}] self.assertEquals(request["server"]["personality"], expected) @@ -1487,7 +1495,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): anything """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = [{"path": "/etc/conf", "contents": "aabbccdd"}] self.assertEquals(request["server"]["personality"], expected) @@ -1496,7 +1504,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): aabbccdd""" - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = [{"contents": "aabbccdd"}] self.assertEquals(request["server"]["personality"], expected) @@ -1505,7 +1513,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = [{"path": "/etc/conf", "contents": ""}] self.assertEquals(request["server"]["personality"], expected) @@ -1514,7 +1522,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = [{"path": "/etc/conf", "contents": ""}] self.assertEquals(request["server"]["personality"], expected) @@ -1526,7 +1534,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): beta """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"alpha": "beta"} self.assertEquals(request["server"]["metadata"], expected) @@ -1539,7 +1547,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): bar """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"alpha": "beta", "foo": "bar"} self.assertEquals(request["server"]["metadata"], expected) @@ -1551,7 +1559,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"alpha": ""} self.assertEquals(request["server"]["metadata"], expected) @@ -1564,7 +1572,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"alpha": "", "delta": ""} self.assertEquals(request["server"]["metadata"], expected) @@ -1576,7 +1584,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): beta """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"": "beta"} self.assertEquals(request["server"]["metadata"], expected) @@ -1589,7 +1597,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): gamma """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"": "gamma"} self.assertEquals(request["server"]["metadata"], expected) @@ -1602,7 +1610,7 @@ class TestServerCreateRequestXMLDeserializer(unittest.TestCase): baz """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') expected = {"foo": "baz"} self.assertEquals(request["server"]["metadata"], expected) @@ -1649,7 +1657,7 @@ b25zLiINCg0KLVJpY2hhcmQgQmFjaA==""", }, ], }} - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') self.assertEqual(request, expected) def test_request_xmlser_with_flavor_image_ref(self): @@ -1659,7 +1667,7 @@ b25zLiINCg0KLVJpY2hhcmQgQmFjaA==""", imageRef="http://localhost:8774/v1.1/images/1" flavorRef="http://localhost:8774/v1.1/flavors/1"> """ - request = self.deserializer.deserialize(serial_request) + request = self.deserializer.deserialize(serial_request, 'create') self.assertEquals(request["server"]["flavorRef"], "http://localhost:8774/v1.1/flavors/1") self.assertEquals(request["server"]["imageRef"], diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index 430dafe77..6c57d3e4f 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -76,26 +76,56 @@ class RequestTest(test.TestCase): self.assertEqual(result, "application/json") -class SerializationTest(test.TestCase): +class DictSerializerTest(test.TestCase): + def test_dispatch(self): + serializer = wsgi.DictSerializer() + serializer.create = lambda x: 'pants' + serializer.default = lambda x: 'trousers' + self.assertEqual(serializer.serialize({}, 'create'), 'pants') + + def test_dispatch_default(self): + serializer = wsgi.DictSerializer() + serializer.create = lambda x: 'pants' + serializer.default = lambda x: 'trousers' + self.assertEqual(serializer.serialize({}, 'update'), 'trousers') + + +class XMLDictSerializerTest(test.TestCase): def test_xml(self): input_dict = dict(servers=dict(a=(2, 3))) expected_xml = '(2,3)' xmlns = "testing xmlns" - serializer = wsgi.XMLSerializer(xmlns="asdf") + serializer = wsgi.XMLDictSerializer(xmlns="asdf") result = serializer.serialize(input_dict) result = result.replace('\n', '').replace(' ', '') self.assertEqual(result, expected_xml) + +class JSONDictSerializerTest(test.TestCase): def test_json(self): input_dict = dict(servers=dict(a=(2, 3))) expected_json = '{"servers":{"a":[2,3]}}' - serializer = wsgi.JSONSerializer() + serializer = wsgi.JSONDictSerializer() result = serializer.serialize(input_dict) result = result.replace('\n', '').replace(' ', '') self.assertEqual(result, expected_json) -class DeserializationTest(test.TestCase): +class TextDeserializerTest(test.TestCase): + def test_dispatch(self): + deserializer = wsgi.TextDeserializer() + deserializer.create = lambda x: 'pants' + deserializer.default = lambda x: 'trousers' + self.assertEqual(deserializer.deserialize({}, 'create'), 'pants') + + def test_dispatch_default(self): + deserializer = wsgi.TextDeserializer() + deserializer.create = lambda x: 'pants' + deserializer.default = lambda x: 'trousers' + self.assertEqual(deserializer.deserialize({}, 'update'), 'trousers') + + +class JSONDeserializerTest(test.TestCase): def test_json(self): data = """{"a": { "a1": "1", @@ -112,6 +142,8 @@ class DeserializationTest(test.TestCase): deserializer = wsgi.JSONDeserializer() self.assertEqual(deserializer.deserialize(data), as_dict) + +class XMLDeserializerTest(test.TestCase): def test_xml(self): xml = """ @@ -137,7 +169,7 @@ class DeserializationTest(test.TestCase): self.assertEqual(deserializer.deserialize(xml), as_dict) -class ResourceSerializerTest(test.TestCase): +class ResponseSerializerTest(test.TestCase): def setUp(self): class JSONSerializer(object): def serialize(self, data): @@ -152,40 +184,32 @@ class ResourceSerializerTest(test.TestCase): 'application/XML': XMLSerializer(), } - self.resource = wsgi.Resource(None, serializers=self.serializers) + self.serializer = wsgi.ResponseSerializer(serializers=self.serializers) def tearDown(self): pass def test_get_serializer(self): - self.assertEqual(self.resource.get_serializer('application/json'), + self.assertEqual(self.serializer.get_serializer('application/json'), self.serializers['application/json']) def test_get_serializer_unknown_content_type(self): self.assertRaises(exception.InvalidContentType, - self.resource.get_serializer, + self.serializer.get_serializer, 'application/unknown') - def test_serialize_response_dict(self): - response = self.resource.serialize_response('application/json', {}) + def test_serialize_response(self): + response = self.serializer.serialize({}, 'application/json') self.assertEqual(response.headers['Content-Type'], 'application/json') self.assertEqual(response.body, 'pew_json') - def test_serialize_response_non_dict(self): - response = self.resource.serialize_response('application/json', 'a') - self.assertEqual(response, 'a') - def test_serialize_response_dict_to_unknown_content_type(self): self.assertRaises(exception.InvalidContentType, - self.resource.serialize_response, + self.serializer.serialize, 'application/unknown', {}) - def test_serialize_response_non_dict_to_unknown_content_type(self): - response = self.resource.serialize_response('application/unknown', 'a') - self.assertEqual(response, 'a') - -class ResourceDeserializerTest(test.TestCase): +class RequestDeserializerTest(test.TestCase): def setUp(self): class JSONDeserializer(object): def deserialize(self, data): @@ -200,24 +224,25 @@ class ResourceDeserializerTest(test.TestCase): 'application/XML': XMLDeserializer(), } - self.resource = wsgi.Resource(None, deserializers=self.deserializers) + self.deserializer = wsgi.RequestDeserializer( + deserializers=self.deserializers) def tearDown(self): pass def test_get_deserializer(self): - self.assertEqual(self.resource.get_deserializer('application/json'), - self.deserializers['application/json']) + expected = self.deserializer.get_deserializer('application/json') + self.assertEqual(expected, self.deserializers['application/json']) def test_get_deserializer_unknown_content_type(self): self.assertRaises(exception.InvalidContentType, - self.resource.get_deserializer, + self.deserializer.get_deserializer, 'application/unknown') def test_get_expected_content_type(self): request = wsgi.Request.blank('/') request.headers['Accept'] = 'application/json' - self.assertEqual(self.resource.get_expected_content_type(request), + self.assertEqual(self.deserializer.get_expected_content_type(request), 'application/json') def test_get_action_args(self): @@ -232,17 +257,38 @@ class ResourceDeserializerTest(test.TestCase): expected = {'action': 'update', 'id': 12} - self.assertEqual(self.resource.get_action_args(env), expected) + self.assertEqual(self.deserializer.get_action_args(env), expected) - def test_deserialize_request(self): + def test_deserialize(self): def fake_get_routing_args(request): return {'action': 'create'} - self.resource.get_action_args = fake_get_routing_args + self.deserializer.get_action_args = fake_get_routing_args request = wsgi.Request.blank('/') request.headers['Accept'] = 'application/xml' - deserialized = self.resource.deserialize_request(request) + deserialized = self.deserializer.deserialize(request) expected = ('create', {}, 'application/xml') self.assertEqual(expected, deserialized) + + +class ResourceTest(test.TestCase): + def test_dispatch(self): + class Controller(object): + def index(self, req, pants=None): + return pants + + resource = wsgi.Resource(Controller()) + actual = resource.dispatch(None, 'index', {'pants': 'off'}) + expected = 'off' + self.assertEqual(actual, expected) + + def test_dispatch_unknown_controller_action(self): + class Controller(object): + def index(self, req, pants=None): + return pants + + resource = wsgi.Resource(Controller()) + self.assertRaises(AttributeError, resource.dispatch, + None, 'create', {}) -- cgit From 74bae1b1e2b298ef8425f7cb1aefd3826db40147 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 19 May 2011 13:50:11 -0700 Subject: Separate out tests for when unfilter is called from iptables vs. nwfilter driver. Re: lp783705 --- nova/tests/test_virt.py | 65 ++++++++++++++++++++++++++++++++++------------- nova/virt/libvirt_conn.py | 22 ++++++++-------- 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index babb5de9b..3b5a3867d 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -657,6 +657,21 @@ class LibvirtConnTestCase(test.TestCase): super(LibvirtConnTestCase, self).tearDown() +class FakeNWFilter: + def __init__(self): + self.undefine_call_count = 0 + + def undefine(self): + self.undefine_call_count += 1 + pass + + def _nwfilterLookupByName(self, ignore): + return self + + def _filterDefineXMLMock(self, xml): + return True + + class IptablesFirewallTestCase(test.TestCase): def setUp(self): super(IptablesFirewallTestCase, self).setUp() @@ -869,6 +884,35 @@ class IptablesFirewallTestCase(test.TestCase): self.assertEquals(ipv6_network_rules, ipv6_rules_per_network * networks_count) + def test_unfilter_instance_undefines_nwfilters(self): + admin_ctxt = context.get_admin_context() + + fakefilter = FakeNWFilter() + self.fw.nwfilter._conn.nwfilterDefineXML =\ + fakefilter._filterDefineXMLMock + self.fw.nwfilter._conn.nwfilterLookupByName =\ + fakefilter._nwfilterLookupByName + + instance_ref = self._create_instance_ref() + inst_id = instance_ref['id'] + instance = db.instance_get(self.context, inst_id) + + ip = '10.11.12.13' + network_ref = db.project_get_network(self.context, 'fake') + fixed_ip = {'address': ip, 'network_id': network_ref['id']} + db.fixed_ip_create(admin_ctxt, fixed_ip) + db.fixed_ip_update(admin_ctxt, ip, {'allocated': True, + 'instance_id': inst_id}) + self.fw.setup_basic_filtering(instance) + self.fw.prepare_instance_filter(instance) + self.fw.apply_instance_filter(instance) + self.fw.unfilter_instance(instance) + + # should attempt to undefine just the instance filter + self.assertEquals(fakefilter.undefine_call_count, 1) + + db.instance_destroy(admin_ctxt, instance_ref['id']) + class NWFilterTestCase(test.TestCase): def setUp(self): @@ -1047,26 +1091,11 @@ class NWFilterTestCase(test.TestCase): self.assertEquals(len(result), 3) def test_unfilter_instance_undefines_nwfilters(self): - class FakeNWFilter: - def __init__(self): - self.undefine_call_count = 0 - - def undefine(self): - self.undefine_call_count += 1 - pass - - fakefilter = FakeNWFilter() - - def _nwfilterLookupByName(ignore): - return fakefilter - - def _filterDefineXMLMock(xml): - return True - admin_ctxt = context.get_admin_context() - self.fw._conn.nwfilterDefineXML = _filterDefineXMLMock - self.fw._conn.nwfilterLookupByName = _nwfilterLookupByName + fakefilter = FakeNWFilter() + self.fw._conn.nwfilterDefineXML = fakefilter._filterDefineXMLMock + self.fw._conn.nwfilterLookupByName = fakefilter._nwfilterLookupByName instance_ref = self._create_instance() inst_id = instance_ref['id'] diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 706973176..f808a4b7b 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -1834,7 +1834,7 @@ class NWFilterFirewall(FirewallDriver): # execute in a native thread and block current greenthread until done tpool.execute(self._conn.nwfilterDefineXML, xml) - def unfilter_instance(self, instance): + def unfilter_instance(self, instance, remove_secgroup=True): """Clear out the nwfilter rules.""" network_info = _get_network_info(instance) instance_name = instance.name @@ -1846,19 +1846,19 @@ class NWFilterFirewall(FirewallDriver): self._conn.nwfilterLookupByName(instance_filter_name).\ undefine() except libvirt.libvirtError: - LOG.debug(_('The nwfilter(%(instance_filter_name)s) for ' - '%(instance_name)s is not found.') % locals()) + LOG.debug(_('The nwfilter(%(instance_filter_name)s) ' + 'for %(instance_name)s is not found.') % locals()) instance_secgroup_filter_name =\ '%s-secgroup' % (self._instance_filter_name(instance)) - try: - self._conn.nwfilterLookupByName(instance_secgroup_filter_name).\ - undefine() - except libvirt.libvirtError: - # This will happen if called by IptablesFirewallDriver - LOG.debug(_('The nwfilter(%(instance_secgroup_filter_name)s) for ' - '%(instance_name)s is not found.') % locals()) + if remove_secgroup: + try: + self._conn.nwfilterLookupByName(instance_secgroup_filter_name)\ + .undefine() + except libvirt.libvirtError: + LOG.debug(_('The nwfilter(%(instance_secgroup_filter_name)s) ' + 'for %(instance_name)s is not found.') % locals()) def prepare_instance_filter(self, instance, network_info=None): """ @@ -2022,7 +2022,7 @@ class IptablesFirewallDriver(FirewallDriver): if self.instances.pop(instance['id'], None): self.remove_filters_for_instance(instance) self.iptables.apply() - self.nwfilter.unfilter_instance(instance) + self.nwfilter.unfilter_instance(instance, False) else: LOG.info(_('Attempted to unfilter instance %s which is not ' 'filtered'), instance['id']) -- cgit From a1869741689817168c75046f2f81ee9761956cbc Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Thu, 19 May 2011 18:05:38 -0400 Subject: Fail early if requested imageRef does not exist when creating a server. --- nova/api/openstack/servers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index a4e679242..337c6ced8 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -144,10 +144,8 @@ class Controller(common.OpenstackController): (image_service, image_id) = utils.get_image_service(image_ref) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) - - #TODO: need to assert image exists a better way - #image_id = common.get_image_id_from_image_hash(image_service, - #context, image_ref) + image_set = set([x['id'] for x in image_service.index(context)]) + assert image_id in image_set except: msg = _("Can not find requested image") return faults.Fault(exc.HTTPBadRequest(msg)) -- cgit From e16b2d22dc4e6e24c3bf5150a0830661933aad29 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Fri, 20 May 2011 04:14:02 -0400 Subject: Fixed some tests. --- nova/api/openstack/common.py | 28 ---------------------------- nova/api/openstack/servers.py | 6 +++--- nova/exception.py | 4 ++++ nova/flags.py | 3 --- nova/image/fake.py | 12 ++++++++++++ nova/tests/api/openstack/test_servers.py | 14 +++++++++----- nova/tests/integrated/integrated_helpers.py | 7 ++++++- nova/tests/test_quota.py | 8 ++++---- nova/utils.py | 16 +++++++--------- 9 files changed, 45 insertions(+), 53 deletions(-) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 32cd689ca..a89594c13 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -100,34 +100,6 @@ def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit): return items[start_index:range_end] -def get_image_id_from_image_hash(image_service, context, image_hash): - """Given an Image ID Hash, return an objectstore Image ID. - - image_service - reference to objectstore compatible image service. - context - security context for image service requests. - image_hash - hash of the image ID. - """ - - # FIX(sandy): This is terribly inefficient. It pulls all images - # from objectstore in order to find the match. ObjectStore - # should have a numeric counterpart to the string ID. - try: - items = image_service.detail(context) - except NotImplementedError: - items = image_service.index(context) - for image in items: - image_id = image['id'] - try: - if abs(hash(image_id)) == int(image_hash): - return image_id - except ValueError: - msg = _("Requested image_id has wrong format: %s," - "should have numerical format") % image_id - LOG.error(msg) - raise Exception(msg) - raise exception.ImageNotFound(image_id=image_hash) - - def get_id_from_href(href): """Return the id portion of a url as an int. diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 337c6ced8..31c1e86c0 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -144,10 +144,10 @@ class Controller(common.OpenstackController): (image_service, image_id) = utils.get_image_service(image_ref) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) - image_set = set([x['id'] for x in image_service.index(context)]) - assert image_id in image_set + images = set([str(x['id']) for x in image_service.index(context)]) + assert str(image_id) in images except: - msg = _("Can not find requested image") + msg = _("Cannot find requested image %s") % image_ref return faults.Fault(exc.HTTPBadRequest(msg)) personality = env['server'].get('personality') diff --git a/nova/exception.py b/nova/exception.py index cf6069454..4c977aca0 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -279,6 +279,10 @@ class DiskNotFound(NotFound): message = _("No disk at %(location)s") +class InvalidImageRef(Invalid): + message = _("Invalid image ref %(image_ref)s.") + + class ImageNotFound(NotFound): message = _("Image %(image_id)s could not be found.") diff --git a/nova/flags.py b/nova/flags.py index ee5adae32..32cb6efa8 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -362,9 +362,6 @@ DEFINE_string('scheduler_manager', 'nova.scheduler.manager.SchedulerManager', # The service to use for image search and retrieval DEFINE_string('image_service', 'nova.image.local.LocalImageService', 'The service to use for retrieving and searching for images.') -DEFINE_string('glance_image_service', 'nova.image.glance.GlanceImageService', - 'The service to use for retrieving and searching for ' + - 'glance images.') DEFINE_string('host', socket.gethostname(), 'name of this node') diff --git a/nova/image/fake.py b/nova/image/fake.py index 2a60c7743..659c16557 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -79,10 +79,22 @@ class FakeImageService(service.BaseImageService): 'disk_format': 'raw', 'properties': {'kernel_id': FLAGS.null_kernel, 'ramdisk_id': FLAGS.null_kernel}} + + image5 = {'id': '3', + 'name': 'fakeimage123456', + 'created_at': timestamp, + 'updated_at': timestamp, + 'status': 'active', + 'container_format': 'ami', + 'disk_format': 'raw', + 'properties': {'kernel_id': FLAGS.null_kernel, + 'ramdisk_id': FLAGS.null_kernel}} + self.create(None, image1) self.create(None, image2) self.create(None, image3) self.create(None, image4) + self.create(None, image5) super(FakeImageService, self).__init__() def index(self, context): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index bced2b910..22beef05f 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -29,6 +29,7 @@ from nova import db from nova import exception from nova import flags from nova import test +from nova import utils import nova.api.openstack from nova.api.openstack import servers import nova.compute.api @@ -37,6 +38,7 @@ from nova.compute import power_state import nova.db.api from nova.db.sqlalchemy.models import Instance from nova.db.sqlalchemy.models import InstanceMetadata +import nova.image.fake import nova.rpc from nova.tests.api.openstack import common from nova.tests.api.openstack import fakes @@ -464,7 +466,12 @@ class ServersTest(test.TestCase): def image_id_from_hash(*args, **kwargs): return 2 - FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' + def fake_image_service(*args): + return nova.image.fake.FakeImageService() + + FLAGS.image_service = 'nova.image.fake.FakeImageService' + self.stubs.Set( + nova.image.glance, 'GlanceImageService', fake_image_service) self.stubs.Set(nova.db.api, 'project_get_network', project_get_network) self.stubs.Set(nova.db.api, 'instance_create', instance_create) self.stubs.Set(nova.rpc, 'cast', fake_method) @@ -476,8 +483,6 @@ class ServersTest(test.TestCase): fake_method) self.stubs.Set(nova.api.openstack.servers.Controller, "_get_kernel_ramdisk_from_image", kernel_ramdisk_mapping) - self.stubs.Set(nova.api.openstack.common, - "get_image_id_from_image_hash", image_id_from_hash) self.stubs.Set(nova.compute.api.API, "_find_host", find_host) def _test_create_instance_helper(self): @@ -1707,11 +1712,10 @@ class TestServerInstanceCreation(test.TestCase): return stub_method compute_api = MockComputeAPI() + FLAGS.image_service = 'nova.image.fake.FakeImageService' self.stubs.Set(nova.compute, 'API', make_stub_method(compute_api)) self.stubs.Set(nova.api.openstack.servers.Controller, '_get_kernel_ramdisk_from_image', make_stub_method((1, 1))) - self.stubs.Set(nova.api.openstack.common, - 'get_image_id_from_image_hash', make_stub_method(2)) return compute_api def _create_personality_request_dict(self, personality_files): diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index e6efc16c5..5871a498c 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -27,6 +27,7 @@ from nova import flags from nova import service from nova import test # For the flags from nova.auth import manager +import nova.image.glance from nova.log import logging from nova.tests.integrated.api import client @@ -151,6 +152,11 @@ class _IntegratedTestBase(test.TestCase): f = self._get_flags() self.flags(**f) + def fake_image_service(*args): + return nova.image.fake.FakeImageService() + self.stubs.Set( + nova.image.glance, 'GlanceImageService', fake_image_service) + # set up services self.start_service('compute') self.start_service('volume') @@ -185,7 +191,6 @@ class _IntegratedTestBase(test.TestCase): """An opportunity to setup flags, before the services are started.""" f = {} f['image_service'] = 'nova.image.fake.FakeImageService' - f['glance_image_service'] = 'nova.image.fake.FakeImageService' f['fake_network'] = True return f diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py index 9ede0786f..02b641a47 100644 --- a/nova/tests/test_quota.py +++ b/nova/tests/test_quota.py @@ -280,18 +280,18 @@ class QuotaTestCase(test.TestCase): FLAGS.quota_max_injected_files) def _create_with_injected_files(self, files): - FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' + FLAGS.image_service = 'nova.image.fake.FakeImageService' api = compute.API(image_service=self.StubImageService()) inst_type = instance_types.get_instance_type_by_name('m1.small') api.create(self.context, min_count=1, max_count=1, - instance_type=inst_type, image_id='fake', + instance_type=inst_type, image_id='3', injected_files=files) def test_no_injected_files(self): - FLAGS.glance_image_service = 'nova.image.fake.FakeImageService' + FLAGS.image_service = 'nova.image.fake.FakeImageService' api = compute.API(image_service=self.StubImageService()) inst_type = instance_types.get_instance_type_by_name('m1.small') - api.create(self.context, instance_type=inst_type, image_id='fake') + api.create(self.context, instance_type=inst_type, image_id='3') def test_max_injected_files(self): files = [] diff --git a/nova/utils.py b/nova/utils.py index 85934813e..3802f50c4 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -748,11 +748,7 @@ def parse_image_ref(image_ref): o = urlparse(image_ref) port = o.port or 80 host = o.netloc.split(':', 1)[0] - image_id = o.path.split('/')[-1] - - if is_int(image_id): - image_id = int(image_id) - + image_id = int(o.path.split('/')[-1]) return (image_id, host, port) @@ -776,8 +772,10 @@ def get_image_service(image_ref): if is_int(image_ref): return (get_default_image_service(), int(image_ref)) - (image_id, host, port) = parse_image_ref(image_ref) - glance_client = import_class('nova.image.glance.GlanceClient')(host, - port) - image_service = import_class(FLAGS.glance_image_service)(glance_client) + try: + (image_id, host, port) = parse_image_ref(image_ref) + except: + raise exception.InvalidImageRef(image_ref=image_ref) + glance_client = nova.image.glance.GlanceClient(host, port) + image_service = nova.image.glance.GlanceImageService(glance_client) return (image_service, image_id) -- cgit From 27a0d56d921caa700f4aa84fb177c471071f2ddd Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Fri, 20 May 2011 05:02:34 -0700 Subject: temp fixes --- nova/api/openstack/servers.py | 2 +- nova/scheduler/zone_aware_scheduler.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 12008d44a..738910bc8 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -162,7 +162,7 @@ class Controller(common.OpenstackController): msg = _("Server name is not defined") return exc.HTTPBadRequest(msg) - zone_blob = env.get('blob', None) + zone_blob = env['server'].get('blob') name = env['server']['name'] self._validate_server_name(name) name = name.strip() diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 6600951fb..9572d1c9f 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -150,7 +150,8 @@ class ZoneAwareScheduler(driver.Scheduler): raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) - nova.servers.create(name, image, flavor, ipgroup, meta, files) + nova.servers.create(name, image, flavor, ipgroup, meta, files, + child_blob) def select(self, context, request_spec, *args, **kwargs): """Select returns a list of weights and zone/host information -- cgit From c61ed0605d443551087c54406b39e00273a6750d Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Fri, 20 May 2011 06:03:43 -0700 Subject: syntax errors --- nova/scheduler/zone_aware_scheduler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 9572d1c9f..20f7694a1 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -75,7 +75,7 @@ class ZoneAwareScheduler(driver.Scheduler): if "hostname" in item: self._provision_resource_locally(context, item, instance_id, kwargs) - return + return self._provision_resource_in_child_zone(context, item, instance_id, request_spec, kwargs) @@ -131,7 +131,7 @@ class ZoneAwareScheduler(driver.Scheduler): instance_properties = request_spec['instance_properties'] name = instance_properties['display_name'] - image_id = instance_properties['image_id']) + image_id = instance_properties['image_id'] flavor_id = instance_type['flavor_id'] meta = instance_type['metadata'] -- cgit From 0f191404fee42b9225f364af12242812798ff08a Mon Sep 17 00:00:00 2001 From: William Wolf Date: Fri, 20 May 2011 11:42:38 -0400 Subject: fixed silly issue with variable needing to be named 'id' for the url mapper, also caught new exception type where needed --- nova/api/openstack/images.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index ac02d63c5..2a3f9e070 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -74,7 +74,7 @@ class Controller(common.OpenstackController): builder = self.get_builder(req).build return dict(images=[builder(image, detail=True) for image in images]) - def show(self, req, image_id): + def show(self, req, id): """Return detailed information about a specific image. :param req: `wsgi.Request` object @@ -84,11 +84,14 @@ class Controller(common.OpenstackController): try: (image_service, service_image_id) = utils.get_image_service( - image_id) + id) image = image_service.show(context, service_image_id) except exception.NotFound: explanation = _("Image not found.") raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) + except exception.InvalidImageRef: + explanation = _("Image not found.") + raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) return dict(image=self.get_builder(req).build(image, detail=True)) -- cgit From f1da26ec9af6f6adffb7b6bfdc64f9702db93b56 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Fri, 20 May 2011 11:50:00 -0400 Subject: fix pep8 issue --- nova/api/openstack/images.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 2a3f9e070..5508e7d50 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -50,7 +50,8 @@ class Controller(common.OpenstackController): """ self._compute_service = compute_service or compute.API() - self._image_service = image_service or utils.get_default_image_service() + self._image_service = image_service or \ + utils.get_default_image_service() def index(self, req): """Return an index listing of images available to the request. -- cgit From 0bb2d0085e1fb3ba22a408f405f4539aa07b226c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 20 May 2011 08:59:07 -0700 Subject: make nwfilter mock more 'realistic' by having it remember which filters have been defined --- nova/tests/test_virt.py | 56 +++++++++++++++++++++++++++++++++++++++-------- nova/virt/libvirt_conn.py | 17 +++++++------- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 4bc5fed16..5e85e3a2f 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -659,16 +659,26 @@ class LibvirtConnTestCase(test.TestCase): class FakeNWFilter: def __init__(self): - self.undefine_call_count = 0 + self.filters = {} - def undefine(self): - self.undefine_call_count += 1 - pass - - def _nwfilterLookupByName(self, ignore): - return self + def _nwfilterLookupByName(self, name): + if name in self.filters: + return self.filters[name] + raise libvirt.libvirtError('Filter Not Found') def _filterDefineXMLMock(self, xml): + class FakeNWFilterInternal: + def __init__(self, parent, name): + self.name = name + self.parent = parent + + def undefine(self): + del self.parent.filters[self.name] + pass + tree = xml_to_tree(xml) + name = tree.get('name') + if name not in self.filters: + self.filters[name] = FakeNWFilterInternal(self, name) return True @@ -689,6 +699,20 @@ class IptablesFirewallTestCase(test.TestCase): self.fw = libvirt_conn.IptablesFirewallDriver( get_connection=lambda: self.fake_libvirt_connection) + def lazy_load_library_exists(self): + """check if libvirt is available.""" + # try to connect libvirt. if fail, skip test. + try: + import libvirt + import libxml2 + except ImportError: + return False + global libvirt + libvirt = __import__('libvirt') + libvirt_conn.libvirt = __import__('libvirt') + libvirt_conn.libxml2 = __import__('libxml2') + return True + def tearDown(self): self.manager.delete_project(self.project) self.manager.delete_user(self.user) @@ -895,6 +919,10 @@ class IptablesFirewallTestCase(test.TestCase): self.fw.do_refresh_security_group_rules("fake") def test_unfilter_instance_undefines_nwfilter(self): + # Skip if non-libvirt environment + if not self.lazy_load_library_exists(): + return + admin_ctxt = context.get_admin_context() fakefilter = FakeNWFilter() @@ -916,10 +944,11 @@ class IptablesFirewallTestCase(test.TestCase): self.fw.setup_basic_filtering(instance) self.fw.prepare_instance_filter(instance) self.fw.apply_instance_filter(instance) + original_filter_count = len(fakefilter.filters) self.fw.unfilter_instance(instance) # should attempt to undefine just the instance filter - self.assertEquals(fakefilter.undefine_call_count, 1) + self.assertEqual(original_filter_count - len(fakefilter.filters), 1) db.instance_destroy(admin_ctxt, instance_ref['id']) @@ -1109,6 +1138,12 @@ class NWFilterTestCase(test.TestCase): instance_ref = self._create_instance() inst_id = instance_ref['id'] + + self.security_group = self.setup_and_return_security_group() + + db.instance_add_security_group(self.context, inst_id, + self.security_group.id) + instance = db.instance_get(self.context, inst_id) ip = '10.11.12.13' @@ -1120,9 +1155,12 @@ class NWFilterTestCase(test.TestCase): self.fw.setup_basic_filtering(instance) self.fw.prepare_instance_filter(instance) self.fw.apply_instance_filter(instance) + original_filter_count = len(fakefilter.filters) + print fakefilter.filters.keys() self.fw.unfilter_instance(instance) + print fakefilter.filters.keys() # should attempt to undefine 2 filters: instance and instance-secgroup - self.assertEquals(fakefilter.undefine_call_count, 2) + self.assertEqual(original_filter_count - len(fakefilter.filters), 2) db.instance_destroy(admin_ctxt, instance_ref['id']) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 9241c1d9e..f27398aa3 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -1838,7 +1838,7 @@ class NWFilterFirewall(FirewallDriver): # execute in a native thread and block current greenthread until done tpool.execute(self._conn.nwfilterDefineXML, xml) - def unfilter_instance(self, instance, remove_secgroup=True): + def unfilter_instance(self, instance): """Clear out the nwfilter rules.""" network_info = _get_network_info(instance) instance_name = instance.name @@ -1856,13 +1856,12 @@ class NWFilterFirewall(FirewallDriver): instance_secgroup_filter_name =\ '%s-secgroup' % (self._instance_filter_name(instance)) - if remove_secgroup: - try: - self._conn.nwfilterLookupByName(instance_secgroup_filter_name)\ - .undefine() - except libvirt.libvirtError: - LOG.debug(_('The nwfilter(%(instance_secgroup_filter_name)s) ' - 'for %(instance_name)s is not found.') % locals()) + try: + self._conn.nwfilterLookupByName(instance_secgroup_filter_name)\ + .undefine() + except libvirt.libvirtError: + LOG.debug(_('The nwfilter(%(instance_secgroup_filter_name)s) ' + 'for %(instance_name)s is not found.') % locals()) def prepare_instance_filter(self, instance, network_info=None): """ @@ -2028,7 +2027,7 @@ class IptablesFirewallDriver(FirewallDriver): if self.instances.pop(instance['id'], None): self.remove_filters_for_instance(instance) self.iptables.apply() - self.nwfilter.unfilter_instance(instance, False) + self.nwfilter.unfilter_instance(instance) else: LOG.info(_('Attempted to unfilter instance %s which is not ' 'filtered'), instance['id']) -- cgit From 5c205bb5ef1565db4e52af538cf0d6b73cbeda37 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 20 May 2011 09:09:03 -0700 Subject: fix comments --- nova/tests/test_virt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 5e85e3a2f..90c6de5a9 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -659,6 +659,7 @@ class LibvirtConnTestCase(test.TestCase): class FakeNWFilter: def __init__(self): + self.filters = {} def _nwfilterLookupByName(self, name): @@ -947,7 +948,7 @@ class IptablesFirewallTestCase(test.TestCase): original_filter_count = len(fakefilter.filters) self.fw.unfilter_instance(instance) - # should attempt to undefine just the instance filter + # should undefine just the instance filter self.assertEqual(original_filter_count - len(fakefilter.filters), 1) db.instance_destroy(admin_ctxt, instance_ref['id']) @@ -1160,7 +1161,7 @@ class NWFilterTestCase(test.TestCase): self.fw.unfilter_instance(instance) print fakefilter.filters.keys() - # should attempt to undefine 2 filters: instance and instance-secgroup + # should undefine 2 filters: instance and instance-secgroup self.assertEqual(original_filter_count - len(fakefilter.filters), 2) db.instance_destroy(admin_ctxt, instance_ref['id']) -- cgit From 7ed71092d513bc621be539e612e6b4e66849b888 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Fri, 20 May 2011 14:22:58 -0400 Subject: combined the exception catching to eliminate duplication --- nova/api/openstack/images.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 5508e7d50..523b3f431 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -87,10 +87,7 @@ class Controller(common.OpenstackController): (image_service, service_image_id) = utils.get_image_service( id) image = image_service.show(context, service_image_id) - except exception.NotFound: - explanation = _("Image not found.") - raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) - except exception.InvalidImageRef: + except (exception.NotFound, exception.InvalidImageRef): explanation = _("Image not found.") raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) -- cgit From 3fc3b7537cc1af2783829a2caaca272e83d6d3e8 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 20 May 2011 14:42:19 -0400 Subject: renaming resource_factory to create_resource --- nova/api/openstack/__init__.py | 34 ++++++++++++++++----------------- nova/api/openstack/accounts.py | 2 +- nova/api/openstack/backup_schedules.py | 2 +- nova/api/openstack/consoles.py | 2 +- nova/api/openstack/flavors.py | 2 +- nova/api/openstack/image_metadata.py | 2 +- nova/api/openstack/images.py | 2 +- nova/api/openstack/ips.py | 2 +- nova/api/openstack/limits.py | 2 +- nova/api/openstack/server_metadata.py | 2 +- nova/api/openstack/servers.py | 2 +- nova/api/openstack/shared_ip_groups.py | 2 +- nova/api/openstack/users.py | 2 +- nova/api/openstack/zones.py | 2 +- nova/tests/api/openstack/test_limits.py | 4 ++-- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index fbbd99cb9..4419d0748 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -99,19 +99,19 @@ class APIRouter(base_wsgi.Router): server_members['inject_network_info'] = 'POST' mapper.resource("zone", "zones", - controller=zones.resource_factory(), + controller=zones.create_resource(), collection={'detail': 'GET', 'info': 'GET'}), mapper.resource("user", "users", - controller=users.resource_factory(), + controller=users.create_resource(), collection={'detail': 'GET'}) mapper.resource("account", "accounts", - controller=accounts.resource_factory(), + controller=accounts.create_resource(), collection={'detail': 'GET'}) mapper.resource("console", "consoles", - controller=consoles.resource_factory(), + controller=consoles.create_resource(), parent_resource=dict(member_name='server', collection_name='servers')) @@ -124,31 +124,31 @@ class APIRouterV10(APIRouter): def _setup_routes(self, mapper): super(APIRouterV10, self)._setup_routes(mapper) mapper.resource("server", "servers", - controller=servers.resource_factory('1.0'), + controller=servers.create_resource('1.0'), collection={'detail': 'GET'}, member=self.server_members) mapper.resource("image", "images", - controller=images.resource_factory('1.0'), + controller=images.create_resource('1.0'), collection={'detail': 'GET'}) mapper.resource("flavor", "flavors", - controller=flavors.resource_factory('1.0'), + controller=flavors.create_resource('1.0'), collection={'detail': 'GET'}) mapper.resource("shared_ip_group", "shared_ip_groups", collection={'detail': 'GET'}, - controller=shared_ip_groups.resource_factory()) + controller=shared_ip_groups.create_resource()) mapper.resource("backup_schedule", "backup_schedule", - controller=backup_schedules.resource_factory(), + controller=backup_schedules.create_resource(), parent_resource=dict(member_name='server', collection_name='servers')) mapper.resource("limit", "limits", - controller=limits.resource_factory('1.0')) + controller=limits.create_resource('1.0')) - mapper.resource("ip", "ips", controller=ips.resource_factory(), + mapper.resource("ip", "ips", controller=ips.create_resource(), collection=dict(public='GET', private='GET'), parent_resource=dict(member_name='server', collection_name='servers')) @@ -160,27 +160,27 @@ class APIRouterV11(APIRouter): def _setup_routes(self, mapper): super(APIRouterV11, self)._setup_routes(mapper) mapper.resource("server", "servers", - controller=servers.resource_factory('1.1'), + controller=servers.create_resource('1.1'), collection={'detail': 'GET'}, member=self.server_members) mapper.resource("image", "images", - controller=images.resource_factory('1.1'), + controller=images.create_resource('1.1'), collection={'detail': 'GET'}) mapper.resource("image_meta", "meta", - controller=image_metadata.resource_factory(), + controller=image_metadata.create_resource(), parent_resource=dict(member_name='image', collection_name='images')) mapper.resource("server_meta", "meta", - controller=server_metadata.resource_factory(), + controller=server_metadata.create_resource(), parent_resource=dict(member_name='server', collection_name='servers')) mapper.resource("flavor", "flavors", - controller=flavors.resource_factory('1.1'), + controller=flavors.create_resource('1.1'), collection={'detail': 'GET'}) mapper.resource("limit", "limits", - controller=limits.resource_factory('1.1')) + controller=limits.create_resource('1.1')) diff --git a/nova/api/openstack/accounts.py b/nova/api/openstack/accounts.py index faff8bb2c..0dcd37217 100644 --- a/nova/api/openstack/accounts.py +++ b/nova/api/openstack/accounts.py @@ -80,7 +80,7 @@ class Controller(object): return dict(account=_translate_keys(account)) -def resource_factory(): +def create_resource(): metadata = { "attributes": { "account": ["id", "name", "description", "manager"], diff --git a/nova/api/openstack/backup_schedules.py b/nova/api/openstack/backup_schedules.py index d08a4799c..71a14d4ce 100644 --- a/nova/api/openstack/backup_schedules.py +++ b/nova/api/openstack/backup_schedules.py @@ -52,7 +52,7 @@ class Controller(object): return faults.Fault(exc.HTTPNotImplemented()) -def resource_factory(): +def create_resource(): metadata = { 'attributes': { 'backupSchedule': [], diff --git a/nova/api/openstack/consoles.py b/nova/api/openstack/consoles.py index 56f79db60..bccf04d8f 100644 --- a/nova/api/openstack/consoles.py +++ b/nova/api/openstack/consoles.py @@ -89,7 +89,7 @@ class Controller(object): return exc.HTTPAccepted() -def resource_factory(): +def create_resource(): metadata = { 'attributes': { 'console': [], diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/flavors.py index 9e98e6c27..a21ff6cb2 100644 --- a/nova/api/openstack/flavors.py +++ b/nova/api/openstack/flavors.py @@ -74,7 +74,7 @@ class ControllerV11(Controller): return views.flavors.ViewBuilderV11(base_url) -def resource_factory(version='1.0'): +def create_resource(version='1.0'): controller = { '1.0': ControllerV10, '1.1': ControllerV11, diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index 8acde9fe8..88e10168d 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -102,7 +102,7 @@ class Controller(object): self.image_service.update(context, image_id, img, None) -def resource_factory(): +def create_resource(): serializers = { 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V11), } diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index a9071ed8a..3376f358a 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -145,7 +145,7 @@ class ControllerV11(Controller): return common.XML_NS_V11 -def resource_factory(version='1.0'): +def create_resource(version='1.0'): controller = { '1.0': ControllerV10, '1.1': ControllerV11, diff --git a/nova/api/openstack/ips.py b/nova/api/openstack/ips.py index 87c8c997a..abea71830 100644 --- a/nova/api/openstack/ips.py +++ b/nova/api/openstack/ips.py @@ -63,7 +63,7 @@ class Controller(object): return faults.Fault(exc.HTTPNotImplemented()) -def resource_factory(): +def create_resource(): metadata = { 'list_collections': { 'public': {'item_name': 'ip', 'item_key': 'addr'}, diff --git a/nova/api/openstack/limits.py b/nova/api/openstack/limits.py index b0e093702..2d9fe356f 100644 --- a/nova/api/openstack/limits.py +++ b/nova/api/openstack/limits.py @@ -73,7 +73,7 @@ class LimitsControllerV11(LimitsController): return limits_views.ViewBuilderV11() -def resource_factory(version='1.0'): +def create_resource(version='1.0'): controller = { '1.0': LimitsControllerV10, '1.1': LimitsControllerV11, diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/server_metadata.py index eff98c060..b38b84a2a 100644 --- a/nova/api/openstack/server_metadata.py +++ b/nova/api/openstack/server_metadata.py @@ -91,7 +91,7 @@ class Controller(object): raise error -def resource_factory(): +def create_resource(): serializers = { 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V11), } diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 8f39bd256..bdd2960d9 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -784,7 +784,7 @@ class ServerXMLDeserializer(wsgi.XMLDeserializer): return "" -def resource_factory(version='1.0'): +def create_resource(version='1.0'): controller = { '1.0': ControllerV10, '1.1': ControllerV11, diff --git a/nova/api/openstack/shared_ip_groups.py b/nova/api/openstack/shared_ip_groups.py index db178f2a2..4f11f8dfb 100644 --- a/nova/api/openstack/shared_ip_groups.py +++ b/nova/api/openstack/shared_ip_groups.py @@ -49,5 +49,5 @@ class Controller(object): raise faults.Fault(exc.HTTPNotImplemented()) -def resource_factory(): +def create_resource(): return wsgi.Resource(Controller()) diff --git a/nova/api/openstack/users.py b/nova/api/openstack/users.py index e14616349..50975fc1f 100644 --- a/nova/api/openstack/users.py +++ b/nova/api/openstack/users.py @@ -98,7 +98,7 @@ class Controller(object): return dict(user=_translate_keys(self.manager.get_user(id))) -def resource_factory(): +def create_resource(): metadata = { "attributes": { "user": ["id", "name", "access", "secret", "admin"], diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index e750fc230..0475deb52 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -93,7 +93,7 @@ class Controller(object): return dict(zone=_scrub_zone(zone)) -def resource_factory(): +def create_resource(): metadata = { "attributes": { "zone": ["id", "api_url", "name", "capabilities"], diff --git a/nova/tests/api/openstack/test_limits.py b/nova/tests/api/openstack/test_limits.py index db859c2f8..4cf857507 100644 --- a/nova/tests/api/openstack/test_limits.py +++ b/nova/tests/api/openstack/test_limits.py @@ -65,7 +65,7 @@ class LimitsControllerV10Test(BaseLimitTestSuite): def setUp(self): """Run before each test.""" BaseLimitTestSuite.setUp(self) - self.controller = limits.resource_factory('1.0') + self.controller = limits.create_resource('1.0') def _get_index_request(self, accept_header="application/json"): """Helper to set routing arguments.""" @@ -178,7 +178,7 @@ class LimitsControllerV11Test(BaseLimitTestSuite): def setUp(self): """Run before each test.""" BaseLimitTestSuite.setUp(self) - self.controller = limits.resource_factory('1.1') + self.controller = limits.create_resource('1.1') def _get_index_request(self, accept_header="application/json"): """Helper to set routing arguments.""" -- cgit From 2c16eb37822b3ebdb14ac36df26362636d0f5078 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 20 May 2011 16:36:10 -0400 Subject: minor cleanup --- nova/api/openstack/images.py | 3 --- nova/api/openstack/servers.py | 3 --- nova/tests/api/openstack/test_wsgi.py | 1 - 3 files changed, 7 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 3376f358a..7f5551664 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -141,9 +141,6 @@ class ControllerV11(Controller): base_url = request.application_url return images_view.ViewBuilderV11(base_url) - def get_default_xmlns(self, req): - return common.XML_NS_V11 - def create_resource(version='1.0'): controller = { diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index bdd2960d9..313321d7d 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -703,9 +703,6 @@ class ControllerV11(Controller): raise exc.HTTPBadRequest(msg) return password - def get_default_xmlns(self, req): - return common.XML_NS_V11 - class ServerXMLDeserializer(wsgi.XMLDeserializer): """ diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index 6c57d3e4f..89603d82b 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -94,7 +94,6 @@ class XMLDictSerializerTest(test.TestCase): def test_xml(self): input_dict = dict(servers=dict(a=(2, 3))) expected_xml = '(2,3)' - xmlns = "testing xmlns" serializer = wsgi.XMLDictSerializer(xmlns="asdf") result = serializer.serialize(input_dict) result = result.replace('\n', '').replace(' ', '') -- cgit From 4a184103fef7b1209ecfe3a6aadeccb8fc08fa31 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 21 May 2011 02:04:29 -0400 Subject: No reason to modify the way file names are generated for kernel and ramdisk, since the kernel_id and ramdisk_id is still guaranteed to be ints. --- nova/virt/libvirt_conn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 25ba0bc8d..18f5e3aa9 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -844,7 +844,7 @@ class LibvirtConnection(driver.ComputeDriver): 'ramdisk_id': inst['ramdisk_id']} if disk_images['kernel_id']: - fname = disk_images['kernel_id'] + fname = '%08x' % int(disk_images['kernel_id']) self._cache_image(fn=self._fetch_image, target=basepath('kernel'), fname=fname, @@ -852,7 +852,7 @@ class LibvirtConnection(driver.ComputeDriver): user=user, project=project) if disk_images['ramdisk_id']: - fname = disk_images['ramdisk_id'] + fname = '%08x' % int(disk_images['ramdisk_id']) self._cache_image(fn=self._fetch_image, target=basepath('ramdisk'), fname=fname, -- cgit From f1983479ae8d2483bdb73a494c9043f82928f189 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 21 May 2011 02:34:27 -0400 Subject: Minor cleanup --- nova/api/openstack/images.py | 3 +-- nova/api/openstack/servers.py | 4 ++-- nova/image/fake.py | 2 +- nova/virt/libvirt_conn.py | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 523b3f431..bf9d3f49e 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -84,8 +84,7 @@ class Controller(common.OpenstackController): context = req.environ['nova.context'] try: - (image_service, service_image_id) = utils.get_image_service( - id) + (image_service, service_image_id) = utils.get_image_service(id) image = image_service.show(context, service_image_id) except (exception.NotFound, exception.InvalidImageRef): explanation = _("Image not found.") diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 31c1e86c0..d5dee61a5 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -141,7 +141,7 @@ class Controller(common.OpenstackController): image_ref = self._image_ref_from_req_data(env) try: - (image_service, image_id) = utils.get_image_service(image_ref) + image_service, image_id = utils.get_image_service(image_ref) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) images = set([str(x['id']) for x in image_service.index(context)]) @@ -559,7 +559,7 @@ class Controller(common.OpenstackController): associated kernel and ramdisk image IDs. """ context = req.environ['nova.context'] - (image_service, service_image_id) = utils.get_image_service(image_id) + image_service, service_image_id = utils.get_image_service(image_id) image_meta = image_service.show(context, service_image_id) # NOTE(sirp): extracted to a separate method to aid unit-testing, the # new method doesn't need a request obj or an ImageService stub diff --git a/nova/image/fake.py b/nova/image/fake.py index 659c16557..939f855ac 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -35,7 +35,7 @@ FLAGS = flags.FLAGS class FakeImageService(service.BaseImageService): """Mock (fake) image service for unit testing.""" - def __init__(self, client=None): + def __init__(self): self.images = {} # NOTE(justinsb): The OpenStack API can't upload an image? # So, make sure we've got one.. diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 18f5e3aa9..8ba5d09ba 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -861,7 +861,6 @@ class LibvirtConnection(driver.ComputeDriver): project=project) root_fname = hashlib.sha1(disk_images['image_id']).hexdigest() - size = FLAGS.minimum_root_size inst_type_id = inst['instance_type_id'] -- cgit From 58c18901ab27219248e64175f2745502499dc265 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sun, 22 May 2011 03:16:16 -0400 Subject: Removing utils.is_int() --- nova/api/openstack/views/servers.py | 2 +- nova/utils.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 70a942594..0fe9dbe4a 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -132,7 +132,7 @@ class ViewBuilderV11(ViewBuilder): def _build_image(self, response, inst): if 'image_id' in dict(inst): image_id = inst['image_id'] - if utils.is_int(image_id): + if str(image_id).isdigit(): image_id = int(image_id) response['imageRef'] = image_id diff --git a/nova/utils.py b/nova/utils.py index 3802f50c4..ecca5303a 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -728,10 +728,6 @@ def parse_server_string(server_str): return ('', '') -def is_int(x): - return re.match(r'\d+$', str(x)) - - def parse_image_ref(image_ref): """Parse an image href into composite parts. @@ -742,7 +738,7 @@ def parse_image_ref(image_ref): :param image_ref: href or id of an image """ - if is_int(image_ref): + if str(image_ref).isdigit(): return (int(image_ref), None, None) o = urlparse(image_ref) @@ -769,7 +765,7 @@ def get_image_service(image_ref): """ image_ref = image_ref or 0 - if is_int(image_ref): + if str(image_ref).isdigit(): return (get_default_image_service(), int(image_ref)) try: -- cgit From 1c315d233128f1013d1ec02c78acb36821f6c63d Mon Sep 17 00:00:00 2001 From: William Wolf Date: Mon, 23 May 2011 10:28:04 -0400 Subject: moved utils functions into nova/image/ --- bin/nova-manage | 3 +- nova/api/openstack/image_metadata.py | 3 +- nova/api/openstack/images.py | 9 ++-- nova/api/openstack/servers.py | 10 +++-- nova/compute/api.py | 7 ++- nova/image/__init__.py | 77 ++++++++++++++++++++++++++++++++ nova/image/s3.py | 3 +- nova/tests/api/openstack/test_servers.py | 1 + nova/utils.py | 49 -------------------- nova/virt/images.py | 3 +- nova/virt/libvirt_conn.py | 6 ++- 11 files changed, 107 insertions(+), 64 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 3f3fd72a6..8a9be5d8f 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -78,6 +78,7 @@ from nova import crypto from nova import db from nova import exception from nova import flags +from nova import image from nova import log as logging from nova import quota from nova import rpc @@ -905,7 +906,7 @@ class ImageCommands(object): """Methods for dealing with a cloud in an odd state""" def __init__(self, *args, **kwargs): - self.image_service = utils.get_default_image_service() + self.image_service = image.get_default_image_service() def _register(self, container_format, disk_format, path, owner, name=None, is_public='T', diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index f6913ffc6..c51d7acf2 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -18,6 +18,7 @@ from webob import exc from nova import flags +from nova import image from nova import quota from nova import utils from nova import wsgi @@ -32,7 +33,7 @@ class Controller(common.OpenstackController): """The image metadata API controller for the Openstack API""" def __init__(self): - self.image_service = utils.get_default_image_service() + self.image_service = image.get_default_image_service() super(Controller, self).__init__() def _get_metadata(self, context, image_id, image=None): diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index bf9d3f49e..c61b5c6a6 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -18,6 +18,7 @@ import webob.exc from nova import compute from nova import exception from nova import flags +import nova.image from nova import log from nova import utils from nova.api.openstack import common @@ -51,7 +52,7 @@ class Controller(common.OpenstackController): """ self._compute_service = compute_service or compute.API() self._image_service = image_service or \ - utils.get_default_image_service() + nova.image.get_default_image_service() def index(self, req): """Return an index listing of images available to the request. @@ -84,7 +85,8 @@ class Controller(common.OpenstackController): context = req.environ['nova.context'] try: - (image_service, service_image_id) = utils.get_image_service(id) + (image_service, service_image_id) = nova.image.get_image_service( + id) image = image_service.show(context, service_image_id) except (exception.NotFound, exception.InvalidImageRef): explanation = _("Image not found.") @@ -100,7 +102,8 @@ class Controller(common.OpenstackController): """ image_id = id context = req.environ['nova.context'] - (image_service, service_image_id) = utils.get_image_service(image_id) + (image_service, service_image_id) = nova.image.get_image_service( + image_id) image_service.delete(context, service_image_id) return webob.exc.HTTPNoContent() diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index d5dee61a5..181833a23 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -22,6 +22,7 @@ from xml.dom import minidom from nova import compute from nova import exception from nova import flags +import nova.image from nova import log as logging from nova import quota from nova import utils @@ -141,7 +142,7 @@ class Controller(common.OpenstackController): image_ref = self._image_ref_from_req_data(env) try: - image_service, image_id = utils.get_image_service(image_ref) + image_service, image_id = nova.image.get_image_service(image_ref) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) images = set([str(x['id']) for x in image_service.index(context)]) @@ -559,12 +560,13 @@ class Controller(common.OpenstackController): associated kernel and ramdisk image IDs. """ context = req.environ['nova.context'] - image_service, service_image_id = utils.get_image_service(image_id) - image_meta = image_service.show(context, service_image_id) + image_service, service_image_id = nova.image.get_image_service( + image_id) + image = image_service.show(context, service_image_id) # NOTE(sirp): extracted to a separate method to aid unit-testing, the # new method doesn't need a request obj or an ImageService stub kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( - image_meta) + image) return kernel_id, ramdisk_id @staticmethod diff --git a/nova/compute/api.py b/nova/compute/api.py index 61adda13a..a9075ff8a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -26,6 +26,7 @@ import time from nova import db from nova import exception from nova import flags +import nova.image from nova import log as logging from nova import network from nova import quota @@ -58,7 +59,9 @@ class API(base.Base): def __init__(self, image_service=None, network_api=None, volume_api=None, hostname_factory=generate_default_hostname, **kwargs): - self.image_service = image_service or utils.get_default_image_service() + self.image_service = image_service or \ + nova.image.get_default_image_service() + if not network_api: network_api = network.API() self.network_api = network_api @@ -154,7 +157,7 @@ class API(base.Base): self._check_metadata_properties_quota(context, metadata) self._check_injected_file_quota(context, injected_files) - (image_service, service_image_id) = utils.get_image_service( + (image_service, service_image_id) = nova.image.get_image_service( image_ref or image_id) image = image_service.show(context, service_image_id) diff --git a/nova/image/__init__.py b/nova/image/__init__.py index e69de29bb..be692680a 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -0,0 +1,77 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2010 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from urlparse import urlparse + + +from nova import exception +import nova.image.glance +from nova.utils import import_class +from nova import flags + + +FLAGS = flags.FLAGS + + +def parse_image_ref(image_ref): + """Parse an image href into composite parts. + + If the image_ref passed in is an integer, it will + return (image_ref, None, None), otherwise it will + return (image_id, host, port) + + :param image_ref: href or id of an image + + """ + if str(image_ref).isdigit(): + return (int(image_ref), None, None) + + o = urlparse(image_ref) + port = o.port or 80 + host = o.netloc.split(':', 1)[0] + image_id = int(o.path.split('/')[-1]) + return (image_id, host, port) + + +def get_default_image_service(): + ImageService = import_class(FLAGS.image_service) + return ImageService() + + +def get_image_service(image_ref): + """Get the proper image_service and id for the given image_ref. + + The image_ref param can be an href of the form + http://myglanceserver:9292/images/42, or just an int such as 42. If the + image_ref is an int, then the default image service is returned. + + :param image_ref: image ref/id for an image + :returns: a tuple of the form (image_service, image_id) + + """ + image_ref = image_ref or 0 + if str(image_ref).isdigit(): + return (get_default_image_service(), int(image_ref)) + + try: + (image_id, host, port) = parse_image_ref(image_ref) + except: + raise exception.InvalidImageRef(image_ref=image_ref) + glance_client = nova.image.glance.GlanceClient(host, port) + image_service = nova.image.glance.GlanceImageService(glance_client) + return (image_service, image_id) diff --git a/nova/image/s3.py b/nova/image/s3.py index ed685ea51..7051b522a 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -31,6 +31,7 @@ import eventlet from nova import crypto from nova import exception from nova import flags +from nova import image from nova import utils from nova.auth import manager from nova.image import service @@ -46,7 +47,7 @@ class S3ImageService(service.BaseImageService): """Wraps an existing image service to support s3 based register.""" def __init__(self, service=None, *args, **kwargs): - self.service = service or utils.get_default_image_service() + self.service = service or image.get_default_image_service() self.service.__init__(*args, **kwargs) def create(self, context, metadata, data=None): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 22beef05f..b2b0325c2 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -607,6 +607,7 @@ class ServersTest(test.TestCase): res = req.get_response(fakes.wsgi_app()) + print "RES BODY:", res.body server = json.loads(res.body)['server'] self.assertEqual(16, len(server['adminPass'])) self.assertEqual('server_test', server['name']) diff --git a/nova/utils.py b/nova/utils.py index ecca5303a..954947589 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -726,52 +726,3 @@ def parse_server_string(server_str): except: LOG.debug(_('Invalid server_string: %s' % server_str)) return ('', '') - - -def parse_image_ref(image_ref): - """Parse an image href into composite parts. - - If the image_ref passed in is an integer, it will - return (image_ref, None, None), otherwise it will - return (image_id, host, port) - - :param image_ref: href or id of an image - - """ - if str(image_ref).isdigit(): - return (int(image_ref), None, None) - - o = urlparse(image_ref) - port = o.port or 80 - host = o.netloc.split(':', 1)[0] - image_id = int(o.path.split('/')[-1]) - return (image_id, host, port) - - -def get_default_image_service(): - ImageService = import_class(FLAGS.image_service) - return ImageService() - - -def get_image_service(image_ref): - """Get the proper image_service and id for the given image_ref. - - The image_ref param can be an href of the form - http://myglanceserver:9292/images/42, or just an int such as 42. If the - image_ref is an int, then the default image service is returned. - - :param image_ref: image ref/id for an image - :returns: a tuple of the form (image_service, image_id) - - """ - image_ref = image_ref or 0 - if str(image_ref).isdigit(): - return (get_default_image_service(), int(image_ref)) - - try: - (image_id, host, port) = parse_image_ref(image_ref) - except: - raise exception.InvalidImageRef(image_ref=image_ref) - glance_client = nova.image.glance.GlanceClient(host, port) - image_service = nova.image.glance.GlanceImageService(glance_client) - return (image_service, image_id) diff --git a/nova/virt/images.py b/nova/virt/images.py index 45887f38d..f571a9949 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -23,6 +23,7 @@ Handling of VM disk images. from nova import context from nova import flags +from nova import image from nova import log as logging from nova import utils @@ -36,7 +37,7 @@ def fetch(image_id, path, _user, _project): # when it is added to glance. Right now there is no # auth checking in glance, so we assume that access was # checked before we got here. - (image_service, service_image_id) = utils.get_image_service(image_id) + (image_service, service_image_id) = image.get_image_service(image_id) with open(path, "wb") as image_file: elevated = context.get_admin_context() metadata = image_service.get(elevated, service_image_id, image_file) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 8ba5d09ba..8c31f9e27 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -58,6 +58,7 @@ from nova import context from nova import db from nova import exception from nova import flags +import nova.image from nova import ipv6 from nova import log as logging from nova import utils @@ -449,11 +450,12 @@ class LibvirtConnection(driver.ComputeDriver): to support this command. """ - image_service = utils.get_default_image_service() virt_dom = self._lookup_by_name(instance['name']) elevated = context.get_admin_context() - base = image_service.show(elevated, instance['image_id']) + (image_service, service_image_id) = nova.image.get_image_service( + instance['image_id']) + base = image_service.show(elevated, service_image_id) metadata = {'disk_format': base['disk_format'], 'container_format': base['container_format'], -- cgit From 4d1fe953bbfb810f56224b9faae4c10d0d8dfac0 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Mon, 23 May 2011 16:38:30 -0400 Subject: got rid of print statement --- nova/tests/api/openstack/test_servers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index b2b0325c2..22beef05f 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -607,7 +607,6 @@ class ServersTest(test.TestCase): res = req.get_response(fakes.wsgi_app()) - print "RES BODY:", res.body server = json.loads(res.body)['server'] self.assertEqual(16, len(server['adminPass'])) self.assertEqual('server_test', server['name']) -- cgit From b6a4f6aa5b2a97a6a7d79c40c1a3160abc1def39 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Mon, 23 May 2011 16:47:25 -0400 Subject: Renaming service_image_id vars to image_id to reduce confusion. Also some minor cleanup. --- nova/api/openstack/images.py | 11 ++++------- nova/api/openstack/servers.py | 5 ++--- nova/api/openstack/views/servers.py | 8 ++++---- nova/compute/api.py | 4 ++-- nova/tests/api/openstack/test_servers.py | 1 - nova/utils.py | 2 -- nova/virt/images.py | 8 ++++---- nova/virt/libvirt_conn.py | 10 +++++----- 8 files changed, 21 insertions(+), 28 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index c61b5c6a6..fc26b6c1b 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -85,9 +85,8 @@ class Controller(common.OpenstackController): context = req.environ['nova.context'] try: - (image_service, service_image_id) = nova.image.get_image_service( - id) - image = image_service.show(context, service_image_id) + (image_service, image_id) = nova.image.get_image_service(id) + image = image_service.show(context, image_id) except (exception.NotFound, exception.InvalidImageRef): explanation = _("Image not found.") raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) @@ -100,11 +99,9 @@ class Controller(common.OpenstackController): :param req: `wsgi.Request` object :param id: Image identifier (integer) """ - image_id = id context = req.environ['nova.context'] - (image_service, service_image_id) = nova.image.get_image_service( - image_id) - image_service.delete(context, service_image_id) + (image_service, image_id) = nova.image.get_image_service(id) + image_service.delete(context, image_id) return webob.exc.HTTPNoContent() def create(self, req): diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 181833a23..4a0b208e0 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -560,9 +560,8 @@ class Controller(common.OpenstackController): associated kernel and ramdisk image IDs. """ context = req.environ['nova.context'] - image_service, service_image_id = nova.image.get_image_service( - image_id) - image = image_service.show(context, service_image_id) + image_service, _ = nova.image.get_image_service(image_id) + image = image_service.show(context, image_id) # NOTE(sirp): extracted to a separate method to aid unit-testing, the # new method doesn't need a request obj or an ImageService stub kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 0fe9dbe4a..4d825ff53 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -131,10 +131,10 @@ class ViewBuilderV11(ViewBuilder): def _build_image(self, response, inst): if 'image_id' in dict(inst): - image_id = inst['image_id'] - if str(image_id).isdigit(): - image_id = int(image_id) - response['imageRef'] = image_id + image_ref = inst['image_id'] + if str(image_ref).isdigit(): + image_ref = int(image_ref) + response['imageRef'] = image_ref def _build_flavor(self, response, inst): if "instance_type" in dict(inst): diff --git a/nova/compute/api.py b/nova/compute/api.py index a9075ff8a..47f7a594f 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -157,9 +157,9 @@ class API(base.Base): self._check_metadata_properties_quota(context, metadata) self._check_injected_file_quota(context, injected_files) - (image_service, service_image_id) = nova.image.get_image_service( + (image_service, image_id) = nova.image.get_image_service( image_ref or image_id) - image = image_service.show(context, service_image_id) + image = image_service.show(context, image_id) os_type = None if 'properties' in image and 'os_type' in image['properties']: diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index b2b0325c2..f5cfd64e7 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -29,7 +29,6 @@ from nova import db from nova import exception from nova import flags from nova import test -from nova import utils import nova.api.openstack from nova.api.openstack import servers import nova.compute.api diff --git a/nova/utils.py b/nova/utils.py index 954947589..361fc9873 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -35,7 +35,6 @@ import struct import sys import time import types -from urlparse import urlparse from xml.sax import saxutils from eventlet import event @@ -43,7 +42,6 @@ from eventlet import greenthread from eventlet import semaphore from eventlet.green import subprocess -import nova from nova import exception from nova import flags from nova import log as logging diff --git a/nova/virt/images.py b/nova/virt/images.py index f571a9949..61ea77ab0 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -23,7 +23,7 @@ Handling of VM disk images. from nova import context from nova import flags -from nova import image +import nova.image from nova import log as logging from nova import utils @@ -32,15 +32,15 @@ FLAGS = flags.FLAGS LOG = logging.getLogger('nova.virt.images') -def fetch(image_id, path, _user, _project): +def fetch(image_ref, path, _user, _project): # 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 # checked before we got here. - (image_service, service_image_id) = image.get_image_service(image_id) + (image_service, image_id) = nova.image.get_image_service(image_ref) with open(path, "wb") as image_file: elevated = context.get_admin_context() - metadata = image_service.get(elevated, service_image_id, image_file) + metadata = image_service.get(elevated, image_id, image_file) return metadata diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 8c31f9e27..e67f08dbf 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -442,7 +442,7 @@ class LibvirtConnection(driver.ComputeDriver): virt_dom.detachDevice(xml) @exception.wrap_exception - def snapshot(self, instance, image_id): + def snapshot(self, instance, image_ref): """Create snapshot from a running VM instance. This command only works with qemu 0.14+, the qemu_img flag is @@ -453,14 +453,14 @@ class LibvirtConnection(driver.ComputeDriver): virt_dom = self._lookup_by_name(instance['name']) elevated = context.get_admin_context() - (image_service, service_image_id) = nova.image.get_image_service( + (image_service, image_id) = nova.image.get_image_service( instance['image_id']) - base = image_service.show(elevated, service_image_id) + base = image_service.show(elevated, image_id) metadata = {'disk_format': base['disk_format'], 'container_format': base['container_format'], 'is_public': False, - 'name': '%s.%s' % (base['name'], image_id), + 'name': '%s.%s' % (base['name'], image_ref), 'properties': {'architecture': base['architecture'], 'kernel_id': instance['kernel_id'], 'image_location': 'snapshot', @@ -503,7 +503,7 @@ class LibvirtConnection(driver.ComputeDriver): # Upload that image to the image service with open(out_path) as image_file: image_service.update(elevated, - image_id, + image_ref, metadata, image_file) -- cgit From bac28418b7b92aa2654fad39d0240a85aa637488 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Mon, 23 May 2011 17:25:59 -0400 Subject: Removing code duplication between parse_image_ref and get_image service. Made parse_image_ref private. --- nova/image/__init__.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/nova/image/__init__.py b/nova/image/__init__.py index be692680a..d957c38fe 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -28,19 +28,13 @@ from nova import flags FLAGS = flags.FLAGS -def parse_image_ref(image_ref): +def _parse_image_ref(image_ref): """Parse an image href into composite parts. - If the image_ref passed in is an integer, it will - return (image_ref, None, None), otherwise it will - return (image_id, host, port) - - :param image_ref: href or id of an image + :param image_ref: href of an image + :returns: a tuple of the form (image_id, host, port) """ - if str(image_ref).isdigit(): - return (int(image_ref), None, None) - o = urlparse(image_ref) port = o.port or 80 host = o.netloc.split(':', 1)[0] @@ -69,7 +63,7 @@ def get_image_service(image_ref): return (get_default_image_service(), int(image_ref)) try: - (image_id, host, port) = parse_image_ref(image_ref) + (image_id, host, port) = _parse_image_ref(image_ref) except: raise exception.InvalidImageRef(image_ref=image_ref) glance_client = nova.image.glance.GlanceClient(host, port) -- cgit From 7a521f49f6daf0a0a37a9ef98ff1ea8813f04a6f Mon Sep 17 00:00:00 2001 From: John Tran Date: Mon, 23 May 2011 14:54:11 -0700 Subject: merged from trunk --- nova/tests/test_cloud.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index ebfb5ee44..f3887b07b 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -37,7 +37,6 @@ from nova import rpc from nova import service from nova import test from nova import utils -from nova import exception from nova.auth import manager from nova.compute import power_state from nova.api.ec2 import cloud @@ -279,6 +278,26 @@ class CloudTestCase(test.TestCase): user_group=['all']) self.assertEqual(True, result['is_public']) + def test_deregister_image(self): + deregister_image = self.cloud.deregister_image + + def fake_delete(self, context, id): + return None + + self.stubs.Set(local.LocalImageService, 'delete', fake_delete) + # valid image + result = deregister_image(self.context, 'ami-00000001') + self.assertEqual(result['imageId'], 'ami-00000001') + # invalid image + self.stubs.UnsetAll() + + def fake_detail_empty(self, context): + return [] + + self.stubs.Set(local.LocalImageService, 'detail', fake_detail_empty) + self.assertRaises(exception.ImageNotFound, deregister_image, + self.context, 'ami-bad001') + def test_console_output(self): instance_type = FLAGS.default_instance_type max_count = 1 @@ -334,6 +353,36 @@ class CloudTestCase(test.TestCase): self.assertTrue(filter(lambda k: k['keyName'] == 'test1', keys)) self.assertTrue(filter(lambda k: k['keyName'] == 'test2', keys)) + def test_import_public_key(self): + # test when user provides all values + result1 = self.cloud.import_public_key(self.context, + 'testimportkey1', + 'mytestpubkey', + 'mytestfprint') + self.assertTrue(result1) + keydata = db.key_pair_get(self.context, + self.context.user.id, + 'testimportkey1') + self.assertEqual('mytestpubkey', keydata['public_key']) + self.assertEqual('mytestfprint', keydata['fingerprint']) + # test when user omits fingerprint + pubkey_path = os.path.join(os.path.dirname(__file__), 'public_key') + f = open(pubkey_path + '/dummy.pub', 'r') + dummypub = f.readline().rstrip() + f.close + f = open(pubkey_path + '/dummy.fingerprint', 'r') + dummyfprint = f.readline().rstrip() + f.close + result2 = self.cloud.import_public_key(self.context, + 'testimportkey2', + dummypub) + self.assertTrue(result2) + keydata = db.key_pair_get(self.context, + self.context.user.id, + 'testimportkey2') + self.assertEqual(dummypub, keydata['public_key']) + self.assertEqual(dummyfprint, keydata['fingerprint']) + def test_delete_key_pair(self): self._create_key('test') self.cloud.delete_key_pair(self.context, 'test') -- cgit From 0ed410621b3c2d621aa3fa52ca7ac46c6a5f0b70 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 23 May 2011 16:19:12 -0700 Subject: getting closer to working select call --- nova/api/openstack/servers.py | 3 +++ nova/api/openstack/zones.py | 6 +----- nova/compute/api.py | 18 ++++++++++-------- nova/flags.py | 2 ++ nova/scheduler/api.py | 5 +++++ nova/scheduler/manager.py | 4 +++- nova/scheduler/zone_aware_scheduler.py | 17 +++++++++++++++-- 7 files changed, 39 insertions(+), 16 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 738910bc8..474695d98 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -189,6 +189,9 @@ class Controller(common.OpenstackController): inst['instance_type'] = inst_type inst['image_id'] = requested_image_id + # TODO(sandy): REMOVE THIS + LOG.debug(_("***** INST = %(inst)s") % locals()) + builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) server['server']['adminPass'] = password diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 70653dc0e..b9662761d 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -18,6 +18,7 @@ import urlparse from nova import crypto from nova import db +from nova import exception from nova import flags from nova import log as logging from nova.api.openstack import common @@ -25,11 +26,6 @@ from nova.scheduler import api FLAGS = flags.FLAGS -flags.DEFINE_string('build_plan_encryption_key', - None, - '128bit (hex) encryption key for scheduler build plans.') - - LOG = logging.getLogger('nova.api.openstack.zones') diff --git a/nova/compute/api.py b/nova/compute/api.py index 785aff397..301c777bb 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -257,19 +257,21 @@ class API(base.Base): # we'll be ripping this whole for-loop out and deferring the # creation of the Instance record. At that point all this will # change. + filter_driver = 'nova.scheduler.host_filter.InstanceTypeFilter' + request_spec = { + 'instance_properties': base_options, + 'instance_type': instance_type, + 'filter_driver': filter_driver, + 'blob': zone_blob + } + LOG.debug(_("**** REQUEST SPEC: %(request_spec)s") % locals()) + rpc.cast(context, FLAGS.scheduler_topic, {"method": "run_instance", "args": {"topic": FLAGS.compute_topic, "instance_id": instance_id, - "request_spec": { - 'instance_properties': instance, - 'instance_type': instance_type, - 'filter_driver': - 'nova.scheduler.host_filter.' - 'InstanceTypeFilter', - 'blob': zone_blob - }, + "request_spec": request_spec, "availability_zone": availability_zone, "injected_files": injected_files}}) diff --git a/nova/flags.py b/nova/flags.py index 519793643..0b7cd478e 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -376,3 +376,5 @@ DEFINE_string('zone_name', 'nova', 'name of this zone') DEFINE_list('zone_capabilities', ['hypervisor=xenserver;kvm', 'os=linux;windows'], 'Key/Multi-value list representng capabilities of this zone') +DEFINE_string('build_plan_encryption_key', None, + '128bit (hex) encryption key for scheduler build plans.') diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 55f8e0a6d..f9a4f238b 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -18,6 +18,7 @@ Handles all requests relating to schedulers. """ import novaclient +import traceback #nuke from nova import db from nova import exception @@ -124,6 +125,7 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): nova = novaclient.OpenStack(zone.username, zone.password, zone.api_url) nova.authenticate() + LOG.warn(_("*** AUTHENTICATED") % locals())#asdads except novaclient.exceptions.BadRequest, e: url = zone.api_url LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s") @@ -135,10 +137,13 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): def _error_trap(*args, **kwargs): try: + LOG.warn(_("*** CALLING ZONE") % locals())#asdads return zone_method(*args, **kwargs) except Exception as e: if type(e) in errors_to_ignore: return None + ex = traceback.format_exc(e) + LOG.warn(_("*** CAUGHT EXCEPTION %(ex)s") % locals())#asdads # TODO (dabo) - want to be able to re-raise here. # Returning a string now; raising was causing issues. # raise e diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index bd40e73c0..96e69566d 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -80,7 +80,9 @@ class SchedulerManager(manager.Manager): try: host = getattr(self.driver, driver_method)(elevated, *args, **kwargs) - except AttributeError: + except AttributeError, e: + LOG.exception(_("Driver Method %(driver_method)s missing: %(e)s") + % locals()) host = self.driver.schedule(elevated, topic, *args, **kwargs) if not host: diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 20f7694a1..6c666d1a8 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -23,12 +23,16 @@ across zones. There are two expansion points to this class for: import operator import M2Crypto +from nova import crypto from nova import db -from nova import rpc +from nova import flags from nova import log as logging +from nova import rpc + from nova.scheduler import api from nova.scheduler import driver +FLAGS = flags.FLAGS LOG = logging.getLogger('nova.scheduler.zone_aware_scheduler') @@ -51,7 +55,8 @@ class ZoneAwareScheduler(driver.Scheduler): # TODO(sandy): We'll have to look for richer specs at some point. - if 'blob' in request_spec: + blob = request_spec['blob'] + if blob: self.provision_resource(context, request_spec, instance_id, request_spec, kwargs) return None @@ -99,6 +104,8 @@ class ZoneAwareScheduler(driver.Scheduler): # 1. valid, # 2. intended for this zone or a child zone. # if 2 ... forward call to child zone. + LOG.debug(_("****** PROVISION IN CHILD %(item)s") % locals()) + blob = item['blob'] decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key) host_info = None @@ -182,16 +189,21 @@ class ZoneAwareScheduler(driver.Scheduler): #TODO(sandy): how to infer this from OS API params? num_instances = 1 + LOG.debug(_("XXXXXXX - 1 - _SCHEDULE")) + # Filter local hosts based on requirements ... host_list = self.filter_hosts(num_instances, request_spec) + LOG.debug(_("XXXXXXX - 2 - _SCHEDULE")) # then weigh the selected hosts. # weighted = [{weight=weight, name=hostname}, ...] weighted = self.weigh_hosts(num_instances, request_spec, host_list) + LOG.debug(_("XXXXXXX - 3 - _SCHEDULE")) # Next, tack on the best weights from the child zones ... child_results = self._call_zone_method(context, "select", specs=request_spec) + LOG.debug(_("XXXXXXX - 4 - _SCHEDULE - CHILD RESULTS %(child_results)s") % locals()) for child_zone, result in child_results: for weighting in result: # Remember the child_zone so we can get back to @@ -203,6 +215,7 @@ class ZoneAwareScheduler(driver.Scheduler): "child_blob": weighting["blob"]} weighted.append(host_dict) + LOG.debug(_("XXXXXXX - 4 - _SCHEDULE")) weighted.sort(key=operator.itemgetter('weight')) return weighted -- cgit From a5efbca08a6b057290622ba5938f87d2e44be3eb Mon Sep 17 00:00:00 2001 From: William Wolf Date: Mon, 23 May 2011 21:55:15 -0400 Subject: take out irrelevant TODO --- nova/compute/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 47f7a594f..7ffe9c90c 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -525,8 +525,7 @@ class API(base.Base): 'user_id': str(context.user_id)} sent_meta = {'name': name, 'is_public': False, 'properties': properties} - # TODO(wwolf): not sure if we need to use - # utils.get_image_service() here ? + recv_meta = self.image_service.create(context, sent_meta) params = {'image_id': recv_meta['id']} self._cast_compute_message('snapshot_instance', context, instance_id, -- cgit From f49024c437f2680a18eb702f2975de2955b98889 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Mon, 23 May 2011 22:47:44 -0400 Subject: make image_ref and image_id usage more consistant, eliminate redundancy in compute_api.create() call --- nova/api/ec2/cloud.py | 2 +- nova/api/openstack/servers.py | 3 +-- nova/compute/api.py | 9 ++++----- nova/tests/test_cloud.py | 4 ++-- nova/tests/test_compute.py | 6 +++--- nova/tests/test_quota.py | 10 +++++----- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index cc2e140b0..72bd56ed7 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -849,7 +849,7 @@ class CloudController(object): instances = self.compute_api.create(context, instance_type=instance_types.get_instance_type_by_name( kwargs.get('instance_type', None)), - image_id=self._get_image(context, kwargs['image_id'])['id'], + image_ref=self._get_image(context, kwargs['image_ref'])['id'], min_count=int(kwargs.get('min_count', max_count)), max_count=max_count, kernel_id=kwargs.get('kernel_id'), diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 4a0b208e0..01509f771 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -172,8 +172,7 @@ class Controller(common.OpenstackController): (inst,) = self.compute_api.create( context, inst_type, - image_id, - image_ref=image_ref, + image_ref, kernel_id=kernel_id, ramdisk_id=ramdisk_id, display_name=name, diff --git a/nova/compute/api.py b/nova/compute/api.py index 7ffe9c90c..4c4bc592b 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -130,12 +130,12 @@ class API(base.Base): raise quota.QuotaError(msg, "MetadataLimitExceeded") def create(self, context, instance_type, - image_id, kernel_id=None, ramdisk_id=None, + image_ref, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, - injected_files=None, image_ref=None): + injected_files=None): """Create the number and type of instances requested. Verifies that quota and other arguments are valid. @@ -157,8 +157,7 @@ class API(base.Base): self._check_metadata_properties_quota(context, metadata) self._check_injected_file_quota(context, injected_files) - (image_service, image_id) = nova.image.get_image_service( - image_ref or image_id) + (image_service, image_id) = nova.image.get_image_service(image_ref) image = image_service.show(context, image_id) os_type = None @@ -202,7 +201,7 @@ class API(base.Base): base_options = { 'reservation_id': utils.generate_uid('r'), - 'image_id': image_ref or image_id, + 'image_id': image_ref, 'kernel_id': kernel_id or '', 'ramdisk_id': ramdisk_id or '', 'state': 0, diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 54c0454de..3aaca6831 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -302,7 +302,7 @@ class CloudTestCase(test.TestCase): def test_console_output(self): instance_type = FLAGS.default_instance_type max_count = 1 - kwargs = {'image_id': 'ami-1', + kwargs = {'image_ref': 'ami-1', 'instance_type': instance_type, 'max_count': max_count} rv = self.cloud.run_instances(self.context, **kwargs) @@ -318,7 +318,7 @@ class CloudTestCase(test.TestCase): greenthread.sleep(0.3) def test_ajax_console(self): - kwargs = {'image_id': 'ami-1'} + kwargs = {'image_ref': 'ami-1'} rv = self.cloud.run_instances(self.context, **kwargs) instance_id = rv['instancesSet'][0]['instanceId'] greenthread.sleep(0.3) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 9170837b6..b02b99f66 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -150,7 +150,7 @@ class ComputeTestCase(test.TestCase): ref = self.compute_api.create( self.context, instance_type=instance_types.get_default_instance_type(), - image_id=None, + image_ref=None, security_group=['testgroup']) try: self.assertEqual(len(db.security_group_get_by_instance( @@ -168,7 +168,7 @@ class ComputeTestCase(test.TestCase): ref = self.compute_api.create( self.context, instance_type=instance_types.get_default_instance_type(), - image_id=None, + image_ref=None, security_group=['testgroup']) try: db.instance_destroy(self.context, ref[0]['id']) @@ -184,7 +184,7 @@ class ComputeTestCase(test.TestCase): ref = self.compute_api.create( self.context, instance_type=instance_types.get_default_instance_type(), - image_id=None, + image_ref=None, security_group=['testgroup']) try: diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py index 02b641a47..c0499c7a9 100644 --- a/nova/tests/test_quota.py +++ b/nova/tests/test_quota.py @@ -201,7 +201,7 @@ class QuotaTestCase(test.TestCase): min_count=1, max_count=1, instance_type=inst_type, - image_id=1) + image_ref=1) for instance_id in instance_ids: db.instance_destroy(self.context, instance_id) @@ -215,7 +215,7 @@ class QuotaTestCase(test.TestCase): min_count=1, max_count=1, instance_type=inst_type, - image_id=1) + image_ref=1) for instance_id in instance_ids: db.instance_destroy(self.context, instance_id) @@ -271,7 +271,7 @@ class QuotaTestCase(test.TestCase): min_count=1, max_count=1, instance_type=inst_type, - image_id='fake', + image_ref='fake', metadata=metadata) def test_allowed_injected_files(self): @@ -284,14 +284,14 @@ class QuotaTestCase(test.TestCase): api = compute.API(image_service=self.StubImageService()) inst_type = instance_types.get_instance_type_by_name('m1.small') api.create(self.context, min_count=1, max_count=1, - instance_type=inst_type, image_id='3', + instance_type=inst_type, image_ref='3', injected_files=files) def test_no_injected_files(self): FLAGS.image_service = 'nova.image.fake.FakeImageService' api = compute.API(image_service=self.StubImageService()) inst_type = instance_types.get_instance_type_by_name('m1.small') - api.create(self.context, instance_type=inst_type, image_id='3') + api.create(self.context, instance_type=inst_type, image_ref='3') def test_max_injected_files(self): files = [] -- cgit From 9a2c944be8e7187a12bfd363a2a74325403e00d8 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 23 May 2011 22:30:01 -0700 Subject: select partially going through --- nova/scheduler/api.py | 4 ++-- nova/scheduler/manager.py | 4 ++++ nova/scheduler/zone_aware_scheduler.py | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index f9a4f238b..f5b570dbd 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -85,7 +85,7 @@ def get_zone_capabilities(context): def select(context, specs=None): """Returns a list of hosts.""" return _call_scheduler('select', context=context, - params={"specs": specs}) + params={"request_spec": specs}) def update_service_capabilities(context, service_name, host, capabilities): @@ -137,7 +137,7 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): def _error_trap(*args, **kwargs): try: - LOG.warn(_("*** CALLING ZONE") % locals())#asdads + LOG.warn(_("*** CALLING ZONE %(args)s ^^ %(kwargs)s") % locals())#asdads return zone_method(*args, **kwargs) except Exception as e: if type(e) in errors_to_ignore: diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index 96e69566d..db8c41e71 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -70,6 +70,10 @@ class SchedulerManager(manager.Manager): self.zone_manager.update_service_capabilities(service_name, host, capabilities) + def select(self, context=None, *args, **kwargs): + """Select a list of hosts best matching the provided specs.""" + return self.driver.select(context, *args, **kwargs) + def _schedule(self, method, context, topic, *args, **kwargs): """Tries to call schedule_* method on the driver to retrieve host. diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 6c666d1a8..c6f2935b7 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -21,6 +21,7 @@ across zones. There are two expansion points to this class for: """ import operator +import json import M2Crypto from nova import crypto @@ -199,10 +200,11 @@ class ZoneAwareScheduler(driver.Scheduler): # weighted = [{weight=weight, name=hostname}, ...] weighted = self.weigh_hosts(num_instances, request_spec, host_list) - LOG.debug(_("XXXXXXX - 3 - _SCHEDULE")) + LOG.debug(_("XXXXXXX - 3 - _SCHEDULE >> %s") % request_spec) # Next, tack on the best weights from the child zones ... + json_spec = json.dumps(request_spec) child_results = self._call_zone_method(context, "select", - specs=request_spec) + specs=json_spec) LOG.debug(_("XXXXXXX - 4 - _SCHEDULE - CHILD RESULTS %(child_results)s") % locals()) for child_zone, result in child_results: for weighting in result: -- cgit From 51b3d877c53d9c79dbbea21ed4d4abd0a1b91bf8 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Tue, 24 May 2011 04:08:10 -0400 Subject: Fixing year of copyright. --- nova/image/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/image/__init__.py b/nova/image/__init__.py index d957c38fe..088b7796e 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # -# Copyright 2010 OpenStack LLC. +# Copyright 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may -- cgit From 84209a3f02f35c16de0614fa81685b242784bf20 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Tue, 24 May 2011 05:26:04 -0400 Subject: Fixing _get_kernel_ramdisk_from_image to use the correct image service. --- nova/api/openstack/servers.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 01509f771..4f823ccf7 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -144,7 +144,7 @@ class Controller(common.OpenstackController): try: image_service, image_id = nova.image.get_image_service(image_ref) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( - req, image_id) + req, image_service, image_id) images = set([str(x['id']) for x in image_service.index(context)]) assert str(image_id) in images except: @@ -554,18 +554,15 @@ class Controller(common.OpenstackController): error=item.error)) return dict(actions=actions) - def _get_kernel_ramdisk_from_image(self, req, image_id): + def _get_kernel_ramdisk_from_image(self, req, image_service, image_id): """Fetch an image from the ImageService, then if present, return the associated kernel and ramdisk image IDs. """ context = req.environ['nova.context'] - image_service, _ = nova.image.get_image_service(image_id) - image = image_service.show(context, image_id) + image_meta = image_service.show(context, image_id) # NOTE(sirp): extracted to a separate method to aid unit-testing, the # new method doesn't need a request obj or an ImageService stub - kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( - image) - return kernel_id, ramdisk_id + return self._do_get_kernel_ramdisk_from_image(image_meta) @staticmethod def _do_get_kernel_ramdisk_from_image(image_meta): -- cgit From fe30e4f8d6f757b03b22b821878aee22a35e1161 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 24 May 2011 05:46:09 -0700 Subject: sending calls --- nova/scheduler/zone_aware_scheduler.py | 45 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index c6f2935b7..238a50d04 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -23,6 +23,7 @@ across zones. There are two expansion points to this class for: import operator import json import M2Crypto +import novaclient from nova import crypto from nova import db @@ -105,16 +106,24 @@ class ZoneAwareScheduler(driver.Scheduler): # 1. valid, # 2. intended for this zone or a child zone. # if 2 ... forward call to child zone. + # Note: If we have "blob" that means the request was passed + # into us. If we have "child_blob" that means we just asked + # the child zone for the weight info. LOG.debug(_("****** PROVISION IN CHILD %(item)s") % locals()) - blob = item['blob'] - decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key) - host_info = None - try: - json_entry = decryptor(blob) - host_info = json.dumps(entry) - except M2Crypto.EVP.EVPError: - pass + if "blob" in item: + # Request was passed in from above. Is it for us? + blob = item['blob'] + decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key) + host_info = None + try: + json_entry = decryptor(blob) + host_info = json.dumps(entry) + except M2Crypto.EVP.EVPError: + pass + elif "child_blob" in item: + # Our immediate child zone provided this info ... + host_info = item if not host_info: raise exception.Invalid(_("Ill-formed or incorrectly " @@ -129,26 +138,27 @@ class ZoneAwareScheduler(driver.Scheduler): self._provision_resource_locally(context, host_info, instance_id, kwargs) - def _ask_child_zone_to_create_instance(self, zone_info, request_spec, - kwargs): + def _ask_child_zone_to_create_instance(self, context, zone_info, + request_spec, kwargs): # Note: we have to reverse engineer from our args to get back the # image, flavor, ipgroup, etc. since the original call could have # come in from EC2 (which doesn't use these things). + LOG.debug(_("****** ASK CHILD %(zone_info)s ** %(request_spec)s") % locals()) instance_type = request_spec['instance_type'] instance_properties = request_spec['instance_properties'] name = instance_properties['display_name'] image_id = instance_properties['image_id'] - flavor_id = instance_type['flavor_id'] - meta = instance_type['metadata'] + meta = instance_properties['metadata'] + flavor_id = instance_type['flavorid'] files = kwargs['injected_files'] ipgroup = None # Not supported in OS API ... yet child_zone = zone_info['child_zone'] child_blob = zone_info['child_blob'] - zone = db.zone_get(child_zone) + zone = db.zone_get(context, child_zone) url = zone.api_url nova = None try: @@ -158,7 +168,7 @@ class ZoneAwareScheduler(driver.Scheduler): raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) - nova.servers.create(name, image, flavor, ipgroup, meta, files, + nova.servers.create(name, image_id, flavor_id, ipgroup, meta, files, child_blob) def select(self, context, request_spec, *args, **kwargs): @@ -211,10 +221,9 @@ class ZoneAwareScheduler(driver.Scheduler): # Remember the child_zone so we can get back to # it later if needed. This implicitly builds a zone # path structure. - host_dict = { - "weight": weighting["weight"], - "child_zone": child_zone, - "child_blob": weighting["blob"]} + host_dict = {"weight": weighting["weight"], + "child_zone": child_zone, + "child_blob": weighting["blob"]} weighted.append(host_dict) LOG.debug(_("XXXXXXX - 4 - _SCHEDULE")) -- cgit From 884b6d3ed74c5a5f766e405ac2178066314fb6d3 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 24 May 2011 09:51:21 -0400 Subject: make _make_fixture respect name passed in --- nova/tests/api/openstack/test_images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 2c329f920..82bf66e49 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -127,7 +127,7 @@ class _BaseImageServiceTests(test.TestCase): @staticmethod def _make_fixture(name): - fixture = {'name': 'test image', + fixture = {'name': name, 'updated': None, 'created': None, 'status': None, -- cgit From 6e271a42258b439e8fed55c922792b632e062b63 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Tue, 24 May 2011 10:27:26 -0400 Subject: Fixing docstring. --- nova/api/openstack/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index fc26b6c1b..171c4a036 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -80,7 +80,7 @@ class Controller(common.OpenstackController): """Return detailed information about a specific image. :param req: `wsgi.Request` object - :param image_id: Image identifier (integer) + :param id: Image identifier """ context = req.environ['nova.context'] -- cgit From b8fd215635b850bb9c0309fd7e8e723a78250c32 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 24 May 2011 07:36:32 -0700 Subject: removed most of debugging code --- nova/api/openstack/servers.py | 2 +- nova/rpc.py | 1 - nova/scheduler/manager.py | 3 +-- nova/scheduler/zone_aware_scheduler.py | 24 +++++++----------------- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index f726a3709..f3fa36028 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -190,7 +190,7 @@ class Controller(common.OpenstackController): inst['image_id'] = requested_image_id # TODO(sandy): REMOVE THIS - LOG.debug(_("***** INST = %(inst)s") % locals()) #pep8 + LOG.debug(_("***** API.OPENSTACK.SERVER.CREATE = %(inst)s") % locals()) #pep8 builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) diff --git a/nova/rpc.py b/nova/rpc.py index af3625eee..2116f22c3 100644 --- a/nova/rpc.py +++ b/nova/rpc.py @@ -194,7 +194,6 @@ class AdapterConsumer(Consumer): node_func = getattr(self.proxy, str(method)) node_args = dict((str(k), v) for k, v in args.iteritems()) # NOTE(vish): magic is fun! - logging.exception('CALLING %s on SCHEDULER with %s' % (node_func, node_args)) try: rval = node_func(context=ctxt, **node_args) if msg_id: diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index ba0d5b962..a6fc53be5 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -73,14 +73,13 @@ class SchedulerManager(manager.Manager): def select(self, context=None, *args, **kwargs): """Select a list of hosts best matching the provided specs.""" return self.driver.select(context, *args, **kwargs) - + def _schedule(self, method, context, topic, *args, **kwargs): """Tries to call schedule_* method on the driver to retrieve host. Falls back to schedule(context, topic) if method doesn't exist. """ driver_method = 'schedule_%s' % method - LOG.debug(_("CALLING %(driver_method)s handled in Scheduler") % locals()) # nuke elevated = context.elevated() try: host = getattr(self.driver, driver_method)(elevated, *args, diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index d387011eb..1a96c56c3 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -64,7 +64,6 @@ class ZoneAwareScheduler(driver.Scheduler): return None # Create build plan and provision ... - LOG.debug(_("****** SCHEDULE RUN INSTANCE") % locals()) build_plan = self.select(context, request_spec) if not build_plan: raise driver.NoValidHost(_('No hosts were available')) @@ -84,7 +83,7 @@ class ZoneAwareScheduler(driver.Scheduler): self._provision_resource_locally(context, item, instance_id, kwargs) return - + self._provision_resource_in_child_zone(context, item, instance_id, request_spec, kwargs) @@ -104,13 +103,12 @@ class ZoneAwareScheduler(driver.Scheduler): """Create the requested resource in a child zone.""" # Start by attempting to decrypt the blob to see if this # request is: - # 1. valid, + # 1. valid, # 2. intended for this zone or a child zone. # if 2 ... forward call to child zone. # Note: If we have "blob" that means the request was passed # into us. If we have "child_blob" that means we just asked # the child zone for the weight info. - LOG.debug(_("****** PROVISION IN CHILD %(item)s") % locals()) if "blob" in item: # Request was passed in from above. Is it for us? @@ -156,7 +154,7 @@ class ZoneAwareScheduler(driver.Scheduler): files = kwargs['injected_files'] ipgroup = None # Not supported in OS API ... yet - + child_zone = zone_info['child_zone'] child_blob = zone_info['child_blob'] zone = db.zone_get(context, child_zone) @@ -166,18 +164,17 @@ class ZoneAwareScheduler(driver.Scheduler): nova = novaclient.OpenStack(zone.username, zone.password, url) nova.authenticate() except novaclient.exceptions.BadRequest, e: - raise exception.NotAuthorized(_("Bad credentials attempting " + raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) - + nova.servers.create(name, image_id, flavor_id, ipgroup, meta, files, child_blob) - + def select(self, context, request_spec, *args, **kwargs): """Select returns a list of weights and zone/host information corresponding to the best hosts to service the request. Any child zone information has been encrypted so as not to reveal - anything about the children.""" - LOG.debug(_("XXXXXXX - SELECT %(request_spec)s") % locals()) # nuke this !!! + anything about the children.""" return self._schedule(context, "compute", request_spec, *args, **kwargs) @@ -188,7 +185,6 @@ class ZoneAwareScheduler(driver.Scheduler): """The schedule() contract requires we return the one best-suited host for this request. """ - LOG.debug(_("XXXXXXX - DEFAULT SCHEDULE %(request_spec)s") % locals()) # nuke this !!! raise driver.NoValidHost(_('No hosts were available')) def _schedule(self, context, topic, request_spec, *args, **kwargs): @@ -203,22 +199,17 @@ class ZoneAwareScheduler(driver.Scheduler): #TODO(sandy): how to infer this from OS API params? num_instances = 1 - LOG.debug(_("XXXXXXX - 1 - _SCHEDULE")) - # Filter local hosts based on requirements ... host_list = self.filter_hosts(num_instances, request_spec) - LOG.debug(_("XXXXXXX - 2 - _SCHEDULE")) # then weigh the selected hosts. # weighted = [{weight=weight, name=hostname}, ...] weighted = self.weigh_hosts(num_instances, request_spec, host_list) - LOG.debug(_("XXXXXXX - 3 - _SCHEDULE >> %s") % request_spec) # Next, tack on the best weights from the child zones ... json_spec = json.dumps(request_spec) child_results = self._call_zone_method(context, "select", specs=json_spec) - LOG.debug(_("XXXXXXX - 4 - _SCHEDULE - CHILD RESULTS %(child_results)s") % locals()) for child_zone, result in child_results: for weighting in result: # Remember the child_zone so we can get back to @@ -229,7 +220,6 @@ class ZoneAwareScheduler(driver.Scheduler): "child_blob": weighting["blob"]} weighted.append(host_dict) - LOG.debug(_("XXXXXXX - 4 - _SCHEDULE")) weighted.sort(key=operator.itemgetter('weight')) return weighted -- cgit From 8e7c3121fab4b5a87c2efe865f3c06b1bd267cbc Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 24 May 2011 08:59:02 -0700 Subject: added imageid string to exception, per peer review --- nova/tests/test_cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index f3887b07b..e37aca4d6 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -226,7 +226,7 @@ class CloudTestCase(test.TestCase): 'type': 'machine'}}] def fake_show_none(meh, context, id): - raise exception.ImageNotFound + raise exception.ImageNotFound('bad_image_id') self.stubs.Set(local.LocalImageService, 'detail', fake_detail) # list all -- cgit From a0cffc4de8ba4b15958e320308477d42287858e7 Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 24 May 2011 09:43:52 -0700 Subject: specified image_id keyword in exception arg --- nova/api/ec2/cloud.py | 2 +- nova/tests/test_cloud.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 59e00781e..80c61d62b 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -848,7 +848,7 @@ class CloudController(object): kwargs['ramdisk_id'] = ramdisk['id'] image = self._get_image(context, kwargs['image_id']) if not image: - raise exception.ImageNotFound(kwargs['image_id']) + raise exception.ImageNotFound(image_id=kwargs['image_id']) try: available = (image['properties']['image_state'] == 'available') except KeyError: diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index e37aca4d6..1e583377b 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -226,7 +226,7 @@ class CloudTestCase(test.TestCase): 'type': 'machine'}}] def fake_show_none(meh, context, id): - raise exception.ImageNotFound('bad_image_id') + raise exception.ImageNotFound(image_id='bad_image_id') self.stubs.Set(local.LocalImageService, 'detail', fake_detail) # list all -- cgit From 48a3ec6e55f029578d5dc8ef7fe2e9fbe0de1b81 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 24 May 2011 12:05:46 -0700 Subject: more fix up --- nova/api/openstack/servers.py | 1 - nova/api/openstack/zones.py | 2 +- nova/compute/api.py | 1 - nova/scheduler/api.py | 4 ---- nova/scheduler/zone_aware_scheduler.py | 41 +++++++++++++++++++++------------- nova/service.py | 2 -- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index f3fa36028..8d5e78d3a 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -189,7 +189,6 @@ class Controller(common.OpenstackController): inst['instance_type'] = inst_type inst['image_id'] = requested_image_id - # TODO(sandy): REMOVE THIS LOG.debug(_("***** API.OPENSTACK.SERVER.CREATE = %(inst)s") % locals()) #pep8 builder = self._get_view_builder(req) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 96a6552b3..f8867f5a4 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -119,7 +119,7 @@ class Controller(common.OpenstackController): ctx = req.environ['nova.context'] json_specs = json.loads(req.body) specs = json.loads(json_specs) - LOG.debug("INCOMING SELECT '%s'" % specs) + LOG.debug("NOVA.API.OPENSTACK.ZONES.SELECT '%s'" % specs)#pep8 build_plan = api.select(ctx, specs=specs) cooked = self._scrub_build_plan(build_plan) return {"weights": cooked} diff --git a/nova/compute/api.py b/nova/compute/api.py index 301c777bb..d66ee7920 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -264,7 +264,6 @@ class API(base.Base): 'filter_driver': filter_driver, 'blob': zone_blob } - LOG.debug(_("**** REQUEST SPEC: %(request_spec)s") % locals()) rpc.cast(context, FLAGS.scheduler_topic, diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index f5b570dbd..24d7ed0d6 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -18,7 +18,6 @@ Handles all requests relating to schedulers. """ import novaclient -import traceback #nuke from nova import db from nova import exception @@ -125,7 +124,6 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): nova = novaclient.OpenStack(zone.username, zone.password, zone.api_url) nova.authenticate() - LOG.warn(_("*** AUTHENTICATED") % locals())#asdads except novaclient.exceptions.BadRequest, e: url = zone.api_url LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s") @@ -137,13 +135,11 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): def _error_trap(*args, **kwargs): try: - LOG.warn(_("*** CALLING ZONE %(args)s ^^ %(kwargs)s") % locals())#asdads return zone_method(*args, **kwargs) except Exception as e: if type(e) in errors_to_ignore: return None ex = traceback.format_exc(e) - LOG.warn(_("*** CAUGHT EXCEPTION %(ex)s") % locals())#asdads # TODO (dabo) - want to be able to re-raise here. # Returning a string now; raising was causing issues. # raise e diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 1a96c56c3..3dd43443a 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -84,7 +84,7 @@ class ZoneAwareScheduler(driver.Scheduler): kwargs) return - self._provision_resource_in_child_zone(context, item, instance_id, + self._provision_resource_from_blob(context, item, instance_id, request_spec, kwargs) def _provision_resource_locally(self, context, item, instance_id, kwargs): @@ -95,20 +95,24 @@ class ZoneAwareScheduler(driver.Scheduler): db.queue_get_for(context, "compute", host), {"method": "run_instance", "args": kwargs}) - LOG.debug(_("Casted to compute %(host)s for run_instance") + LOG.debug(_("Provisioning locally via compute node %(host)s") % locals()) - def _provision_resource_in_child_zone(self, context, item, instance_id, + def _provision_resource_from_blob(self, context, item, instance_id, request_spec, kwargs): - """Create the requested resource in a child zone.""" - # Start by attempting to decrypt the blob to see if this - # request is: - # 1. valid, - # 2. intended for this zone or a child zone. - # if 2 ... forward call to child zone. - # Note: If we have "blob" that means the request was passed - # into us. If we have "child_blob" that means we just asked - # the child zone for the weight info. + """Create the requested resource locally or in a child zone + based on what is stored in the zone blob info. + + Attempt to decrypt the blob to see if this request is: + 1. valid, and + 2. intended for this zone or a child zone. + + Note: If we have "blob" that means the request was passed + into us from a parent zone. If we have "child_blob" that + means we gathered the info from one of our children. + It's possible that, when we decrypt the 'blob' field, it + contains "child_blob" data. In which case we forward the + request.""" if "blob" in item: # Request was passed in from above. Is it for us? @@ -139,11 +143,14 @@ class ZoneAwareScheduler(driver.Scheduler): def _ask_child_zone_to_create_instance(self, context, zone_info, request_spec, kwargs): + """Once we have determined that the request should go to one + of our children, we need to fabricate a new POST /servers/ + call with the same parameters that were passed into us. + + Note that we have to reverse engineer from our args to get back the + image, flavor, ipgroup, etc. since the original call could have + come in from EC2 (which doesn't use these things).""" - # Note: we have to reverse engineer from our args to get back the - # image, flavor, ipgroup, etc. since the original call could have - # come in from EC2 (which doesn't use these things). - LOG.debug(_("****** ASK CHILD %(zone_info)s ** %(request_spec)s") % locals()) instance_type = request_spec['instance_type'] instance_properties = request_spec['instance_properties'] @@ -159,6 +166,8 @@ class ZoneAwareScheduler(driver.Scheduler): child_blob = zone_info['child_blob'] zone = db.zone_get(context, child_zone) url = zone.api_url + LOG.debug(_("Forwarding instance create call to child zone %(url)s") + % locals()) nova = None try: nova = novaclient.OpenStack(zone.username, zone.password, url) diff --git a/nova/service.py b/nova/service.py index 93020d94f..2532b9df2 100644 --- a/nova/service.py +++ b/nova/service.py @@ -132,9 +132,7 @@ class Service(object): self.service_id = service_ref['id'] def __getattr__(self, key): - logging.warn(_('SERVICE __GETATTR__ %s') % (key, )) manager = self.__dict__.get('manager', None) - logging.warn(_('SERVICE MANAGER %s') % (manager, )) return getattr(manager, key) @classmethod -- cgit From f3d7ec3fd2b2b987ae1118a6ae96874e8bbfdac5 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 24 May 2011 15:16:07 -0400 Subject: initial use of limited_by_marker --- nova/api/openstack/images.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 34d4c27fc..b06429943 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -153,3 +153,25 @@ class ControllerV11(Controller): def get_default_xmlns(self, req): return common.XML_NS_V11 + + def index(self, req): + """Return an index listing of images available to the request. + + :param req: `wsgi.Request` object + """ + context = req.environ['nova.context'] + images = self._image_service.index(context) + images = common.limited_by_marker(images, req) + builder = self.get_builder(req).build + return dict(images=[builder(image, detail=False) for image in images]) + + def detail(self, req): + """Return a detailed index listing of images available to the request. + + :param req: `wsgi.Request` object. + """ + context = req.environ['nova.context'] + images = self._image_service.detail(context) + images = common.limited_by_marker(images, req) + builder = self.get_builder(req).build + return dict(images=[builder(image, detail=True) for image in images]) -- cgit From a33970f17abb0fed47cd03d48a25709d987b5c25 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 24 May 2011 18:09:25 -0700 Subject: tests working again --- nova/scheduler/zone_aware_scheduler.py | 2 +- nova/tests/api/openstack/test_zones.py | 4 ++++ nova/tests/test_zone_aware_scheduler.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 3dd43443a..00f5660f3 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -57,7 +57,7 @@ class ZoneAwareScheduler(driver.Scheduler): # TODO(sandy): We'll have to look for richer specs at some point. - blob = request_spec['blob'] + blob = request_spec.get('blob') if blob: self.provision_resource(context, request_spec, instance_id, request_spec, kwargs) diff --git a/nova/tests/api/openstack/test_zones.py b/nova/tests/api/openstack/test_zones.py index b42b3e7d8..e21b5ce86 100644 --- a/nova/tests/api/openstack/test_zones.py +++ b/nova/tests/api/openstack/test_zones.py @@ -209,6 +209,10 @@ class ZonesTest(test.TestCase): self.stubs.Set(api, 'select', zone_select) req = webob.Request.blank('/v1.0/zones/select') + req.method = 'POST' + # Select queries end up being JSON encoded twice. + # Once to a string and again as an HTTP POST Body + req.body = json.dumps(json.dumps({})) res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) diff --git a/nova/tests/test_zone_aware_scheduler.py b/nova/tests/test_zone_aware_scheduler.py index 37169fb97..493eb294f 100644 --- a/nova/tests/test_zone_aware_scheduler.py +++ b/nova/tests/test_zone_aware_scheduler.py @@ -118,4 +118,5 @@ class ZoneAwareSchedulerTestCase(test.TestCase): fake_context = {} self.assertRaises(driver.NoValidHost, sched.schedule_run_instance, fake_context, 1, - dict(host_filter=None, instance_type={})) + dict(host_filter=None, + request_spec={'instance_type': {}})) -- cgit From 46ddecc177830ea0ccef82e84d72c48261450b40 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Wed, 25 May 2011 03:29:16 -0400 Subject: Don't need to import json. --- nova/tests/test_notifier.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index 14bef79b8..523f38f24 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import json - import stubout import nova -- cgit From f4cc59f0d4344deecea59a7276a50d446f1ea2cd Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 25 May 2011 08:17:50 -0700 Subject: New tests added --- nova/api/openstack/servers.py | 2 - nova/api/openstack/zones.py | 1 - nova/exception.py | 2 +- nova/scheduler/zone_aware_scheduler.py | 177 +++++++++++++++++--------------- nova/tests/test_zone_aware_scheduler.py | 143 ++++++++++++++++++++++++++ 5 files changed, 237 insertions(+), 88 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 8d5e78d3a..738910bc8 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -189,8 +189,6 @@ class Controller(common.OpenstackController): inst['instance_type'] = inst_type inst['image_id'] = requested_image_id - LOG.debug(_("***** API.OPENSTACK.SERVER.CREATE = %(inst)s") % locals()) #pep8 - builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) server['server']['adminPass'] = password diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index f8867f5a4..411eb2b54 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -119,7 +119,6 @@ class Controller(common.OpenstackController): ctx = req.environ['nova.context'] json_specs = json.loads(req.body) specs = json.loads(json_specs) - LOG.debug("NOVA.API.OPENSTACK.ZONES.SELECT '%s'" % specs)#pep8 build_plan = api.select(ctx, specs=specs) cooked = self._scrub_build_plan(build_plan) return {"weights": cooked} diff --git a/nova/exception.py b/nova/exception.py index cf6069454..0927a42f8 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -122,7 +122,7 @@ class NotAuthorized(NovaException): message = _("Not authorized.") def __init__(self, *args, **kwargs): - super(NotFound, self).__init__(**kwargs) + super(NotAuthorized, self).__init__(**kwargs) class AdminRequired(NotAuthorized): diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 00f5660f3..58a9eca55 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -27,6 +27,7 @@ import novaclient from nova import crypto from nova import db +from nova import exception from nova import flags from nova import log as logging from nova import rpc @@ -38,6 +39,11 @@ FLAGS = flags.FLAGS LOG = logging.getLogger('nova.scheduler.zone_aware_scheduler') +class InvalidBlob(exception.NovaException): + message = _("Ill-formed or incorrectly routed 'blob' data sent " + "to instance create request.") + + class ZoneAwareScheduler(driver.Scheduler): """Base class for creating Zone Aware Schedulers.""" @@ -45,48 +51,6 @@ class ZoneAwareScheduler(driver.Scheduler): """Call novaclient zone method. Broken out for testing.""" return api.call_zone_method(context, method, specs=specs) - def schedule_run_instance(self, context, instance_id, request_spec, - *args, **kwargs): - """This method is called from nova.compute.api to provision - an instance. However we need to look at the parameters being - passed in to see if this is a request to: - 1. Create a Build Plan and then provision, or - 2. Use the Build Plan information in the request parameters - to simply create the instance (either in this zone or - a child zone).""" - - # TODO(sandy): We'll have to look for richer specs at some point. - - blob = request_spec.get('blob') - if blob: - self.provision_resource(context, request_spec, instance_id, - request_spec, kwargs) - return None - - # Create build plan and provision ... - build_plan = self.select(context, request_spec) - if not build_plan: - raise driver.NoValidHost(_('No hosts were available')) - - for item in build_plan: - self.provision_resource(context, item, instance_id, request_spec, - kwargs) - - # Returning None short-circuits the routing to Compute (since - # we've already done it here) - return None - - def provision_resource(self, context, item, instance_id, request_spec, - kwargs): - """Create the requested resource in this Zone or a child zone.""" - if "hostname" in item: - self._provision_resource_locally(context, item, instance_id, - kwargs) - return - - self._provision_resource_from_blob(context, item, instance_id, - request_spec, kwargs) - def _provision_resource_locally(self, context, item, instance_id, kwargs): """Create the requested resource in this Zone.""" host = item['hostname'] @@ -98,48 +62,16 @@ class ZoneAwareScheduler(driver.Scheduler): LOG.debug(_("Provisioning locally via compute node %(host)s") % locals()) - def _provision_resource_from_blob(self, context, item, instance_id, - request_spec, kwargs): - """Create the requested resource locally or in a child zone - based on what is stored in the zone blob info. - - Attempt to decrypt the blob to see if this request is: - 1. valid, and - 2. intended for this zone or a child zone. - - Note: If we have "blob" that means the request was passed - into us from a parent zone. If we have "child_blob" that - means we gathered the info from one of our children. - It's possible that, when we decrypt the 'blob' field, it - contains "child_blob" data. In which case we forward the - request.""" - - if "blob" in item: - # Request was passed in from above. Is it for us? - blob = item['blob'] - decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key) - host_info = None - try: - json_entry = decryptor(blob) - host_info = json.dumps(entry) - except M2Crypto.EVP.EVPError: - pass - elif "child_blob" in item: - # Our immediate child zone provided this info ... - host_info = item - - if not host_info: - raise exception.Invalid(_("Ill-formed or incorrectly " - "routed 'blob' data sent " - "to instance create request.") % locals()) - - # Valid data ... is it for us? - if 'child_zone' in host_info and 'child_blob' in host_info: - self._ask_child_zone_to_create_instance(context, host_info, - request_spec, kwargs) - else: - self._provision_resource_locally(context, host_info, - instance_id, kwargs) + def _decrypt_blob(self, blob): + """Returns the decrypted blob or None if invalid. Broken out + for testing.""" + decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key) + try: + json_entry = decryptor(blob) + return json.dumps(entry) + except M2Crypto.EVP.EVPError: + pass + return None def _ask_child_zone_to_create_instance(self, context, zone_info, request_spec, kwargs): @@ -179,6 +111,83 @@ class ZoneAwareScheduler(driver.Scheduler): nova.servers.create(name, image_id, flavor_id, ipgroup, meta, files, child_blob) + def _provision_resource_from_blob(self, context, item, instance_id, + request_spec, kwargs): + """Create the requested resource locally or in a child zone + based on what is stored in the zone blob info. + + Attempt to decrypt the blob to see if this request is: + 1. valid, and + 2. intended for this zone or a child zone. + + Note: If we have "blob" that means the request was passed + into us from a parent zone. If we have "child_blob" that + means we gathered the info from one of our children. + It's possible that, when we decrypt the 'blob' field, it + contains "child_blob" data. In which case we forward the + request.""" + + host_info = None + if "blob" in item: + # Request was passed in from above. Is it for us? + host_info = self._decrypt_blob(item['blob']) + elif "child_blob" in item: + # Our immediate child zone provided this info ... + host_info = item + + if not host_info: + raise InvalidBlob() + + # Valid data ... is it for us? + if 'child_zone' in host_info and 'child_blob' in host_info: + self._ask_child_zone_to_create_instance(context, host_info, + request_spec, kwargs) + else: + self._provision_resource_locally(context, host_info, + instance_id, kwargs) + + def _provision_resource(self, context, item, instance_id, request_spec, + kwargs): + """Create the requested resource in this Zone or a child zone.""" + if "hostname" in item: + self._provision_resource_locally(context, item, instance_id, + kwargs) + return + + self._provision_resource_from_blob(context, item, instance_id, + request_spec, kwargs) + + def schedule_run_instance(self, context, instance_id, request_spec, + *args, **kwargs): + """This method is called from nova.compute.api to provision + an instance. However we need to look at the parameters being + passed in to see if this is a request to: + 1. Create a Build Plan and then provision, or + 2. Use the Build Plan information in the request parameters + to simply create the instance (either in this zone or + a child zone).""" + + # TODO(sandy): We'll have to look for richer specs at some point. + + blob = request_spec.get('blob') + if blob: + self._provision_resource(context, request_spec, instance_id, + request_spec, kwargs) + return None + + # Create build plan and provision ... + build_plan = self.select(context, request_spec) + if not build_plan: + raise driver.NoValidHost(_('No hosts were available')) + + for item in build_plan: + self._provision_resource(context, item, instance_id, request_spec, + kwargs) + + # Returning None short-circuits the routing to Compute (since + # we've already done it here) + return None + def select(self, context, request_spec, *args, **kwargs): """Select returns a list of weights and zone/host information corresponding to the best hosts to service the request. Any diff --git a/nova/tests/test_zone_aware_scheduler.py b/nova/tests/test_zone_aware_scheduler.py index 493eb294f..2ec0f2199 100644 --- a/nova/tests/test_zone_aware_scheduler.py +++ b/nova/tests/test_zone_aware_scheduler.py @@ -16,6 +16,7 @@ Tests For Zone Aware Scheduler. """ +from nova import exception from nova import test from nova.scheduler import driver from nova.scheduler import zone_aware_scheduler @@ -59,6 +60,41 @@ def fake_empty_call_zone_method(context, method, specs): return [] +# Hmm, I should probably be using mox for this. +was_called = False + + +def fake_provision_resource(context, item, instance_id, request_spec, kwargs): + global was_called + was_called = True + + +def fake_ask_child_zone_to_create_instance(context, zone_info, + request_spec, kwargs): + global was_called + was_called = True + + +def fake_provision_resource_locally(context, item, instance_id, kwargs): + global was_called + was_called = True + + +def fake_provision_resource_from_blob(context, item, instance_id, + request_spec, kwargs): + global was_called + was_called = True + + +def fake_decrypt_blob_returns_local_info(blob): + return {'foo': True} # values aren't important. + + +def fake_decrypt_blob_returns_child_info(blob): + return {'child_zone': True, + 'child_blob': True} # values aren't important. Keys are. + + def fake_call_zone_method(context, method, specs): return [ ('zone1', [ @@ -120,3 +156,110 @@ class ZoneAwareSchedulerTestCase(test.TestCase): fake_context, 1, dict(host_filter=None, request_spec={'instance_type': {}})) + + def test_schedule_do_not_schedule_with_hint(self): + """ + Check the local/child zone routing in the run_instance() call. + If the zone_blob hint was passed in, don't re-schedule. + """ + global was_called + sched = FakeZoneAwareScheduler() + was_called = False + self.stubs.Set(sched, '_provision_resource', fake_provision_resource) + request_spec = { + 'instance_properties': {}, + 'instance_type': {}, + 'filter_driver': 'nova.scheduler.host_filter.AllHostsFilter', + 'blob': "Non-None blob data" + } + + result = sched.schedule_run_instance(None, 1, request_spec) + self.assertEquals(None, result) + self.assertTrue(was_called) + + def test_provision_resource_local(self): + """Provision a resource locally or remotely.""" + global was_called + sched = FakeZoneAwareScheduler() + was_called = False + self.stubs.Set(sched, '_provision_resource_locally', + fake_provision_resource_locally) + + request_spec = {'hostname': "foo"} + sched._provision_resource(None, request_spec, 1, request_spec, {}) + self.assertTrue(was_called) + + def test_provision_resource_remote(self): + """Provision a resource locally or remotely.""" + global was_called + sched = FakeZoneAwareScheduler() + was_called = False + self.stubs.Set(sched, '_provision_resource_from_blob', + fake_provision_resource_from_blob) + + request_spec = {} + sched._provision_resource(None, request_spec, 1, request_spec, {}) + self.assertTrue(was_called) + + def test_provision_resource_from_blob_empty(self): + """Provision a resource locally or remotely given no hints.""" + global was_called + sched = FakeZoneAwareScheduler() + request_spec = {} + self.assertRaises(zone_aware_scheduler.InvalidBlob, + sched._provision_resource_from_blob, + None, {}, 1, {}, {}) + + def test_provision_resource_from_blob_with_local_blob(self): + """ + Provision a resource locally or remotely when blob hint passed in. + """ + global was_called + sched = FakeZoneAwareScheduler() + was_called = False + self.stubs.Set(sched, '_decrypt_blob', + fake_decrypt_blob_returns_local_info) + self.stubs.Set(sched, '_provision_resource_locally', + fake_provision_resource_locally) + + request_spec = {'blob': "Non-None blob data"} + + sched._provision_resource_from_blob(None, request_spec, 1, + request_spec, {}) + self.assertTrue(was_called) + + def test_provision_resource_from_blob_with_child_blob(self): + """ + Provision a resource locally or remotely when child blob hint + passed in. + """ + global was_called + sched = FakeZoneAwareScheduler() + self.stubs.Set(sched, '_decrypt_blob', + fake_decrypt_blob_returns_child_info) + was_called = False + self.stubs.Set(sched, '_ask_child_zone_to_create_instance', + fake_ask_child_zone_to_create_instance) + + request_spec = {'blob': "Non-None blob data"} + + sched._provision_resource_from_blob(None, request_spec, 1, + request_spec, {}) + self.assertTrue(was_called) + + def test_provision_resource_from_blob_with_immediate_child_blob(self): + """ + Provision a resource locally or remotely when blob hint passed in + from an immediate child. + """ + global was_called + sched = FakeZoneAwareScheduler() + was_called = False + self.stubs.Set(sched, '_ask_child_zone_to_create_instance', + fake_ask_child_zone_to_create_instance) + + request_spec = {'child_blob': True, 'child_zone': True} + + sched._provision_resource_from_blob(None, request_spec, 1, + request_spec, {}) + self.assertTrue(was_called) -- cgit From 0b9ede226674b253f638b78cdce5fa40b2991701 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 25 May 2011 11:21:46 -0400 Subject: simplified the limiting differences for different versions of the API --- nova/api/openstack/images.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index b06429943..c96b1c3e3 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -53,6 +53,9 @@ class Controller(common.OpenstackController): self._compute_service = compute_service or compute.API() self._image_service = image_service or _default_service + def _limit_items(self, items, req): + return common.limited(items, req) + def index(self, req): """Return an index listing of images available to the request. @@ -60,7 +63,7 @@ class Controller(common.OpenstackController): """ context = req.environ['nova.context'] images = self._image_service.index(context) - images = common.limited(images, req) + images = self._limit_items(images, req) builder = self.get_builder(req).build return dict(images=[builder(image, detail=False) for image in images]) @@ -71,7 +74,7 @@ class Controller(common.OpenstackController): """ context = req.environ['nova.context'] images = self._image_service.detail(context) - images = common.limited(images, req) + images = self._limited_items(images, req) builder = self.get_builder(req).build return dict(images=[builder(image, detail=True) for image in images]) @@ -154,24 +157,5 @@ class ControllerV11(Controller): def get_default_xmlns(self, req): return common.XML_NS_V11 - def index(self, req): - """Return an index listing of images available to the request. - - :param req: `wsgi.Request` object - """ - context = req.environ['nova.context'] - images = self._image_service.index(context) - images = common.limited_by_marker(images, req) - builder = self.get_builder(req).build - return dict(images=[builder(image, detail=False) for image in images]) - - def detail(self, req): - """Return a detailed index listing of images available to the request. - - :param req: `wsgi.Request` object. - """ - context = req.environ['nova.context'] - images = self._image_service.detail(context) - images = common.limited_by_marker(images, req) - builder = self.get_builder(req).build - return dict(images=[builder(image, detail=True) for image in images]) + def _limit_items(self, items, req): + return common.limited_by_marker(items, req) -- cgit From f6f98f1fe905443eacbfb036f1b6ff6c6f5d5261 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 25 May 2011 09:00:13 -0700 Subject: dist-sched-2a merge --- nova/api/openstack/zones.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 78715f1cc..29b7b2279 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -26,9 +26,6 @@ from nova.scheduler import api FLAGS = flags.FLAGS -flags.DEFINE_string('build_plan_encryption_key', - None, - '128bit (hex) encryption key for scheduler build plans.') LOG = logging.getLogger('nova.api.openstack.zones') -- cgit From 660d1802a6c202465af585a059930113de5ae646 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 25 May 2011 13:20:34 -0700 Subject: starting breakdown of nova.compute.api.create() --- nova/compute/api.py | 67 +++++++++++++++++++++++++++++++++++++++++++++------ nova/scheduler/api.py | 7 ++++++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 57f8c421a..1d75dbc80 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -54,6 +54,7 @@ def generate_default_hostname(instance_id): class API(base.Base): """API for interacting with the compute manager.""" + scheduler_rules = None def __init__(self, image_service=None, network_api=None, volume_api=None, hostname_factory=generate_default_hostname, @@ -128,18 +129,15 @@ class API(base.Base): LOG.warn(msg) raise quota.QuotaError(msg, "MetadataLimitExceeded") - def create(self, context, instance_type, + def _check_create_parameters(self, context, instance_type, image_id, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, injected_files=None, zone_blob=None): - """Create the number and type of instances requested. - - Verifies that quota and other arguments are valid. - - """ + """Verify all the input parameters regardless of the provisioning + strategy being performed.""" if not instance_type: instance_type = instance_types.get_default_instance_type() @@ -220,7 +218,46 @@ class API(base.Base): 'metadata': metadata, 'availability_zone': availability_zone, 'os_type': os_type} - elevated = context.elevated() + + return (num_instances, base_options) + + def create_all_at_once(self, context, instance_type, + image_id, kernel_id=None, ramdisk_id=None, + min_count=1, max_count=1, + display_name='', display_description='', + key_name=None, key_data=None, security_group='default', + availability_zone=None, user_data=None, metadata={}, + injected_files=None, zone_blob=None): + """Provision the instances by passing the whole request to + the Scheduler for execution.""" + self._check_create_parameters(self, context, instance_type, + image_id, kernel_id, ramdisk_id, min_count=1, max_count=1, + display_name, display_description, + key_name, key_data, security_group, + availability_zone, user_data, metadata, + injected_files, zone_blob) + + def create(self, context, instance_type, + image_id, kernel_id=None, ramdisk_id=None, + min_count=1, max_count=1, + display_name='', display_description='', + key_name=None, key_data=None, security_group='default', + availability_zone=None, user_data=None, metadata={}, + injected_files=None, zone_blob=None): + """Provision the instances by sending off a series of single + instance requests to the Schedulers. This is fine for trival + Scheduler drivers, but may remove the effectiveness of the + more complicated drivers.""" + + num_instances, base_options = self._check_create_parameters( + context, instance_type, + image_id, kernel_id, ramdisk_id, + min_count=1, max_count=1, + display_name, display_description, + key_name, key_data, security_group, + availability_zone, user_data, metadata, + injected_files, zone_blob) + instances = [] LOG.debug(_("Going to run %s instances..."), num_instances) for num in range(num_instances): @@ -279,6 +316,22 @@ class API(base.Base): return [dict(x.iteritems()) for x in instances] + def smart_create(self, *args, **kwargs): + """Ask the scheduler if we should: 1. do single shot instance + requests or all-at-once, and 2. defer the DB work until + a suitable host has been selected (if at all). Cache this + information and act accordingly.""" + + if API.scheduler_rules == None: + API.scheduler_rules = scheduler_api.get_scheduler_rules(context) + + should_create_all_at_once, should_defer_database_create = \ + API.scheduler_rules + + if should_create_all_at_once: + return self.create_all_at_once(*args, **kwargs) + return self.create(*args, **kwargs) + def has_finished_migration(self, context, instance_id): """Returns true if an instance has a finished migration.""" try: diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 09e7c9140..8123082f9 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -87,6 +87,13 @@ def select(context, specs=None): params={"request_spec": specs}) +def get_scheduler_rules(context): + """Returns a tuple of rules for how instances should + be created given the current Scheduler driver being used.""" + return _call_scheduler('get_scheduler_rules', context=context, + params={}) + + def update_service_capabilities(context, service_name, host, capabilities): """Send an update to all the scheduler services informing them of the capabilities of this service.""" -- cgit From 781672793c5fb774c5d9d291798775db471233b2 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Wed, 25 May 2011 19:57:04 -0400 Subject: Renamed image_ref variables to image_href. Since the convention is that x_ref vars may imply that they are db objects. --- nova/api/ec2/cloud.py | 2 +- nova/api/openstack/servers.py | 14 +++++++------- nova/api/openstack/views/servers.py | 8 ++++---- nova/compute/api.py | 6 +++--- nova/exception.py | 2 +- nova/image/__init__.py | 26 +++++++++++++------------- nova/tests/api/openstack/test_servers.py | 26 +++++++++++++------------- nova/tests/integrated/integrated_helpers.py | 8 ++++---- nova/tests/test_cloud.py | 4 ++-- nova/tests/test_compute.py | 6 +++--- nova/tests/test_quota.py | 10 +++++----- nova/virt/images.py | 4 ++-- nova/virt/libvirt_conn.py | 6 +++--- 13 files changed, 61 insertions(+), 61 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 72bd56ed7..ed33e2d42 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -849,7 +849,7 @@ class CloudController(object): instances = self.compute_api.create(context, instance_type=instance_types.get_instance_type_by_name( kwargs.get('instance_type', None)), - image_ref=self._get_image(context, kwargs['image_ref'])['id'], + image_href=self._get_image(context, kwargs['image_href'])['id'], min_count=int(kwargs.get('min_count', max_count)), max_count=max_count, kernel_id=kwargs.get('kernel_id'), diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 4f823ccf7..cac433557 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -140,15 +140,15 @@ class Controller(common.OpenstackController): key_name = key_pair['name'] key_data = key_pair['public_key'] - image_ref = self._image_ref_from_req_data(env) + image_href = self._image_ref_from_req_data(env) try: - image_service, image_id = nova.image.get_image_service(image_ref) + image_service, image_id = nova.image.get_image_service(image_href) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_service, image_id) images = set([str(x['id']) for x in image_service.index(context)]) assert str(image_id) in images except: - msg = _("Cannot find requested image %s") % image_ref + msg = _("Cannot find requested image %s") % image_href return faults.Fault(exc.HTTPBadRequest(msg)) personality = env['server'].get('personality') @@ -172,7 +172,7 @@ class Controller(common.OpenstackController): (inst,) = self.compute_api.create( context, inst_type, - image_ref, + image_href, kernel_id=kernel_id, ramdisk_id=ramdisk_id, display_name=name, @@ -188,7 +188,7 @@ class Controller(common.OpenstackController): return faults.Fault(exc.HTTPBadRequest(msg)) inst['instance_type'] = inst_type - inst['image_id'] = image_ref + inst['image_id'] = image_href builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) @@ -701,13 +701,13 @@ class ControllerV11(Controller): instance_id = int(instance_id) try: - image_ref = info["rebuild"]["imageRef"] + image_href = info["rebuild"]["imageRef"] except (KeyError, TypeError): msg = _("Could not parse imageRef from request.") LOG.debug(msg) return faults.Fault(exc.HTTPBadRequest(explanation=msg)) - image_id = common.get_id_from_href(image_ref) + image_id = common.get_id_from_href(image_href) personalities = info["rebuild"].get("personality", []) metadata = info["rebuild"].get("metadata", {}) diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 4d825ff53..ddd17ab93 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -131,10 +131,10 @@ class ViewBuilderV11(ViewBuilder): def _build_image(self, response, inst): if 'image_id' in dict(inst): - image_ref = inst['image_id'] - if str(image_ref).isdigit(): - image_ref = int(image_ref) - response['imageRef'] = image_ref + image_href = inst['image_id'] + if str(image_href).isdigit(): + image_href = int(image_href) + response['imageRef'] = image_href def _build_flavor(self, response, inst): if "instance_type" in dict(inst): diff --git a/nova/compute/api.py b/nova/compute/api.py index 4c4bc592b..bb419520d 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -130,7 +130,7 @@ class API(base.Base): raise quota.QuotaError(msg, "MetadataLimitExceeded") def create(self, context, instance_type, - image_ref, kernel_id=None, ramdisk_id=None, + image_href, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, display_name='', display_description='', key_name=None, key_data=None, security_group='default', @@ -157,7 +157,7 @@ class API(base.Base): self._check_metadata_properties_quota(context, metadata) self._check_injected_file_quota(context, injected_files) - (image_service, image_id) = nova.image.get_image_service(image_ref) + (image_service, image_id) = nova.image.get_image_service(image_href) image = image_service.show(context, image_id) os_type = None @@ -201,7 +201,7 @@ class API(base.Base): base_options = { 'reservation_id': utils.generate_uid('r'), - 'image_id': image_ref, + 'image_id': image_href, 'kernel_id': kernel_id or '', 'ramdisk_id': ramdisk_id or '', 'state': 0, diff --git a/nova/exception.py b/nova/exception.py index 13f5bf95c..5b91e1cde 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -284,7 +284,7 @@ class DiskNotFound(NotFound): class InvalidImageRef(Invalid): - message = _("Invalid image ref %(image_ref)s.") + message = _("Invalid image ref %(image_href)s.") class ImageNotFound(NotFound): diff --git a/nova/image/__init__.py b/nova/image/__init__.py index 088b7796e..9b9108bd2 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -28,14 +28,14 @@ from nova import flags FLAGS = flags.FLAGS -def _parse_image_ref(image_ref): +def _parse_image_ref(image_href): """Parse an image href into composite parts. - :param image_ref: href of an image + :param image_href: href of an image :returns: a tuple of the form (image_id, host, port) """ - o = urlparse(image_ref) + o = urlparse(image_href) port = o.port or 80 host = o.netloc.split(':', 1)[0] image_id = int(o.path.split('/')[-1]) @@ -47,25 +47,25 @@ def get_default_image_service(): return ImageService() -def get_image_service(image_ref): - """Get the proper image_service and id for the given image_ref. +def get_image_service(image_href): + """Get the proper image_service and id for the given image_href. - The image_ref param can be an href of the form + The image_href param can be an href of the form http://myglanceserver:9292/images/42, or just an int such as 42. If the - image_ref is an int, then the default image service is returned. + image_href is an int, then the default image service is returned. - :param image_ref: image ref/id for an image + :param image_href: image ref/id for an image :returns: a tuple of the form (image_service, image_id) """ - image_ref = image_ref or 0 - if str(image_ref).isdigit(): - return (get_default_image_service(), int(image_ref)) + image_href = image_href or 0 + if str(image_href).isdigit(): + return (get_default_image_service(), int(image_href)) try: - (image_id, host, port) = _parse_image_ref(image_ref) + (image_id, host, port) = _parse_image_ref(image_href) except: - raise exception.InvalidImageRef(image_ref=image_ref) + raise exception.InvalidImageRef(image_href=image_href) glance_client = nova.image.glance.GlanceClient(host, port) image_service = nova.image.glance.GlanceImageService(glance_client) return (image_service, image_id) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 3910f9820..8f8c6b024 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -584,12 +584,12 @@ class ServersTest(test.TestCase): def test_create_instance_v1_1(self): self._setup_for_create_instance() - image_ref = 'http://localhost/v1.1/images/2' + image_href = 'http://localhost/v1.1/images/2' flavor_ref = 'http://localhost/v1.1/flavors/3' body = { 'server': { 'name': 'server_test', - 'imageRef': image_ref, + 'imageRef': image_href, 'flavorRef': flavor_ref, 'metadata': { 'hello': 'world', @@ -611,16 +611,16 @@ class ServersTest(test.TestCase): self.assertEqual('server_test', server['name']) self.assertEqual(1, server['id']) self.assertEqual(flavor_ref, server['flavorRef']) - self.assertEqual(image_ref, server['imageRef']) + self.assertEqual(image_href, server['imageRef']) self.assertEqual(res.status_int, 200) def test_create_instance_v1_1_bad_href(self): self._setup_for_create_instance() - image_ref = 'http://localhost/v1.1/images/asdf' + image_href = 'http://localhost/v1.1/images/asdf' flavor_ref = 'http://localhost/v1.1/flavors/3' body = dict(server=dict( - name='server_test', imageRef=image_ref, flavorRef=flavor_ref, + name='server_test', imageRef=image_href, flavorRef=flavor_ref, metadata={'hello': 'world', 'open': 'stack'}, personality={})) req = webob.Request.blank('/v1.1/servers') @@ -633,12 +633,12 @@ class ServersTest(test.TestCase): def test_create_instance_v1_1_local_href(self): self._setup_for_create_instance() - image_ref = 2 + image_id = 2 flavor_ref = 'http://localhost/v1.1/flavors/3' body = { 'server': { 'name': 'server_test', - 'imageRef': image_ref, + 'imageRef': image_id, 'flavorRef': flavor_ref, }, } @@ -653,7 +653,7 @@ class ServersTest(test.TestCase): server = json.loads(res.body)['server'] self.assertEqual(1, server['id']) self.assertEqual(flavor_ref, server['flavorRef']) - self.assertEqual(image_ref, server['imageRef']) + self.assertEqual(image_id, server['imageRef']) self.assertEqual(res.status_int, 200) def test_create_instance_with_admin_pass_v1_0(self): @@ -680,12 +680,12 @@ class ServersTest(test.TestCase): def test_create_instance_with_admin_pass_v1_1(self): self._setup_for_create_instance() - image_ref = 'http://localhost/v1.1/images/2' + image_href = 'http://localhost/v1.1/images/2' flavor_ref = 'http://localhost/v1.1/flavors/3' body = { 'server': { 'name': 'server_test', - 'imageRef': image_ref, + 'imageRef': image_href, 'flavorRef': flavor_ref, 'adminPass': 'testpass', }, @@ -702,12 +702,12 @@ class ServersTest(test.TestCase): def test_create_instance_with_empty_admin_pass_v1_1(self): self._setup_for_create_instance() - image_ref = 'http://localhost/v1.1/images/2' + image_href = 'http://localhost/v1.1/images/2' flavor_ref = 'http://localhost/v1.1/flavors/3' body = { 'server': { 'name': 'server_test', - 'imageRef': image_ref, + 'imageRef': image_href, 'flavorRef': flavor_ref, 'adminPass': '', }, @@ -1658,7 +1658,7 @@ b25zLiINCg0KLVJpY2hhcmQgQmFjaA==""", request = self.deserializer.deserialize(serial_request) self.assertEqual(request, expected) - def test_request_xmlser_with_flavor_image_ref(self): + def test_request_xmlser_with_flavor_image_href(self): serial_request = """ Date: Thu, 26 May 2011 09:16:02 -0400 Subject: Switching back to chown. I'm fine w/ setfacl too but nova already has 'chown' via sudoers so this seems reasonable for now. --- nova/virt/xenapi/vm_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 931f8e2d4..fdf51ff74 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -1013,8 +1013,7 @@ def _stream_disk(dev, image_type, virtual_size, image_file): offset = MBR_SIZE_BYTES _write_partition(virtual_size, dev) - utils.execute('sudo', 'setfacl', '-m', 'u:%s:rw' % os.getuid(), - '/dev/%s' % dev) + utils.execute('sudo', 'chown', os.getuid(), '/dev/%s' % dev) with open('/dev/%s' % dev, 'wb') as f: f.seek(offset) -- cgit From 131d5bcae4e5f0ab48369e2979f16468bd0900a4 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 26 May 2011 10:34:17 -0400 Subject: Switch the run_instances call in the EC2 back to 'image_id'. Incoming requests use 'imageId' so we shouldn't modify this for image HREF's. --- nova/api/ec2/cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index ed33e2d42..cc2e140b0 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -849,7 +849,7 @@ class CloudController(object): instances = self.compute_api.create(context, instance_type=instance_types.get_instance_type_by_name( kwargs.get('instance_type', None)), - image_href=self._get_image(context, kwargs['image_href'])['id'], + image_id=self._get_image(context, kwargs['image_id'])['id'], min_count=int(kwargs.get('min_count', max_count)), max_count=max_count, kernel_id=kwargs.get('kernel_id'), -- cgit From 995a65ac42b4e36679ad0708a227139cdd3bc06e Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 26 May 2011 11:21:28 -0400 Subject: Fix test_cloud tests. --- nova/api/ec2/cloud.py | 2 +- nova/tests/test_cloud.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index cc2e140b0..8580dc79e 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -849,7 +849,7 @@ class CloudController(object): instances = self.compute_api.create(context, instance_type=instance_types.get_instance_type_by_name( kwargs.get('instance_type', None)), - image_id=self._get_image(context, kwargs['image_id'])['id'], + image_href=self._get_image(context, kwargs['image_id'])['id'], min_count=int(kwargs.get('min_count', max_count)), max_count=max_count, kernel_id=kwargs.get('kernel_id'), diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 1219d600e..54c0454de 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -302,7 +302,7 @@ class CloudTestCase(test.TestCase): def test_console_output(self): instance_type = FLAGS.default_instance_type max_count = 1 - kwargs = {'image_href': 'ami-1', + kwargs = {'image_id': 'ami-1', 'instance_type': instance_type, 'max_count': max_count} rv = self.cloud.run_instances(self.context, **kwargs) @@ -318,7 +318,7 @@ class CloudTestCase(test.TestCase): greenthread.sleep(0.3) def test_ajax_console(self): - kwargs = {'image_href': 'ami-1'} + kwargs = {'image_id': 'ami-1'} rv = self.cloud.run_instances(self.context, **kwargs) instance_id = rv['instancesSet'][0]['instanceId'] greenthread.sleep(0.3) -- cgit From bc176751de7f55d22d1bb04552bbff9c496979ed Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Thu, 26 May 2011 08:28:57 -0700 Subject: refactoring compute.api.create() --- nova/compute/api.py | 193 ++++++++++++++++++++------------- nova/scheduler/driver.py | 7 ++ nova/scheduler/manager.py | 4 + nova/scheduler/zone_aware_scheduler.py | 6 + 4 files changed, 135 insertions(+), 75 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 1d75dbc80..cd4d7ca47 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -54,7 +54,11 @@ def generate_default_hostname(instance_id): class API(base.Base): """API for interacting with the compute manager.""" - scheduler_rules = None + + # Should we create instances all-at-once or as single-shot requests. + # Different schedulers use different approaches. + # This is cached across all API instances. + should_create_all_at_once = None # None implies uninitialized. def __init__(self, image_service=None, network_api=None, volume_api=None, hostname_factory=generate_default_hostname, @@ -219,8 +223,74 @@ class API(base.Base): 'availability_zone': availability_zone, 'os_type': os_type} - return (num_instances, base_options) + return (num_instances, base_options, security_groups) + + def create_db_entry_for_new_instance(self, context, base_options, + security_groups, num=1): + """Create an entry in the DB for this new instance, + including any related table updates (such as security + groups, MAC address, etc). This will called by create() + in the majority of situations, but all-at-once style + Schedulers may initiate the call.""" + instance = dict(mac_address=utils.generate_mac(), + launch_index=num, + **base_options) + instance = self.db.instance_create(context, instance) + instance_id = instance['id'] + + elevated = context.elevated() + if not security_groups: + security_groups = [] + for security_group_id in security_groups: + self.db.instance_add_security_group(elevated, + instance_id, + security_group_id) + + # Set sane defaults if not specified + updates = dict(hostname=self.hostname_factory(instance_id)) + if (not hasattr(instance, 'display_name') or + instance.display_name is None): + updates['display_name'] = "Server %s" % instance_id + + instance = self.update(context, instance_id, **updates) + + for group_id in security_groups: + self.trigger_security_group_members_refresh(elevated, group_id) + + return instance + def _ask_scheduler_to_create_instance(self, context, base_options, + instance_type, zone_blob, + availability_zone, injected_files, + instance_id=None, num_instances=1): + """Send the run_instance request to the schedulers for processing.""" + pid = context.project_id + uid = context.user_id + if instance_id: + LOG.debug(_("Casting to scheduler for %(pid)s/%(uid)s's" + " instance %(instance_id)s (single-shot)") % locals()) + else: + LOG.debug(_("Casting to scheduler for %(pid)s/%(uid)s's" + " (all-at-once)") % locals()) + + filter_class = 'nova.scheduler.host_filter.InstanceTypeFilter' + request_spec = { + 'instance_properties': base_options, + 'instance_type': instance_type, + 'filter': filter_class, + 'blob': zone_blob, + 'num_instances': num_instances + } + + rpc.cast(context, + FLAGS.scheduler_topic, + {"method": "run_instance", + "args": {"topic": FLAGS.compute_topic, + "instance_id": instance_id, + "request_spec": request_spec, + "availability_zone": availability_zone, + "injected_files": injected_files}}) + def create_all_at_once(self, context, instance_type, image_id, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, @@ -229,13 +299,24 @@ class API(base.Base): availability_zone=None, user_data=None, metadata={}, injected_files=None, zone_blob=None): """Provision the instances by passing the whole request to - the Scheduler for execution.""" - self._check_create_parameters(self, context, instance_type, - image_id, kernel_id, ramdisk_id, min_count=1, max_count=1, - display_name, display_description, - key_name, key_data, security_group, - availability_zone, user_data, metadata, - injected_files, zone_blob) + the Scheduler for execution. Returns a Reservation ID + related to the creation of all of these instances.""" + num_instances, base_options, security_groups = \ + self._check_create_parameters( + context, instance_type, + image_id, kernel_id, ramdisk_id, + min_count, max_count, + display_name, display_description, + key_name, key_data, security_group, + availability_zone, user_data, metadata, + injected_files, zone_blob) + + self._ask_scheduler_to_create_instance(context, base_options, + instance_type, zone_blob, + availability_zone, injected_files, + num_instances=num_instances) + + return base_options['reservation_id'] def create(self, context, instance_type, image_id, kernel_id=None, ramdisk_id=None, @@ -244,15 +325,20 @@ class API(base.Base): key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, injected_files=None, zone_blob=None): - """Provision the instances by sending off a series of single + """ + Provision the instances by sending off a series of single instance requests to the Schedulers. This is fine for trival Scheduler drivers, but may remove the effectiveness of the - more complicated drivers.""" + more complicated drivers. + + Returns a list of instance dicts. + """ - num_instances, base_options = self._check_create_parameters( + num_instances, base_options, security_groups = \ + self._check_create_parameters( context, instance_type, image_id, kernel_id, ramdisk_id, - min_count=1, max_count=1, + min_count, max_count, display_name, display_description, key_name, key_data, security_group, availability_zone, user_data, metadata, @@ -261,74 +347,31 @@ class API(base.Base): instances = [] LOG.debug(_("Going to run %s instances..."), num_instances) for num in range(num_instances): - instance = dict(mac_address=utils.generate_mac(), - launch_index=num, - **base_options) - instance = self.db.instance_create(context, instance) - instance_id = instance['id'] - - elevated = context.elevated() - if not security_groups: - security_groups = [] - for security_group_id in security_groups: - self.db.instance_add_security_group(elevated, - instance_id, - security_group_id) - - # Set sane defaults if not specified - updates = dict(hostname=self.hostname_factory(instance_id)) - if (not hasattr(instance, 'display_name') or - instance.display_name is None): - updates['display_name'] = "Server %s" % instance_id - - instance = self.update(context, instance_id, **updates) + instance = self.create_db_entry_for_new_instance(context, + base_options, security_groups, num=num) instances.append(instance) - - pid = context.project_id - uid = context.user_id - LOG.debug(_("Casting to scheduler for %(pid)s/%(uid)s's" - " instance %(instance_id)s") % locals()) - - # NOTE(sandy): For now we're just going to pass in the - # instance_type record to the scheduler. In a later phase - # we'll be ripping this whole for-loop out and deferring the - # creation of the Instance record. At that point all this will - # change. - filter_driver = 'nova.scheduler.host_filter.InstanceTypeFilter' - request_spec = { - 'instance_properties': base_options, - 'instance_type': instance_type, - 'filter_driver': filter_driver, - 'blob': zone_blob - } - - rpc.cast(context, - FLAGS.scheduler_topic, - {"method": "run_instance", - "args": {"topic": FLAGS.compute_topic, - "instance_id": instance_id, - "request_spec": request_spec, - "availability_zone": availability_zone, - "injected_files": injected_files}}) - - for group_id in security_groups: - self.trigger_security_group_members_refresh(elevated, group_id) - - return [dict(x.iteritems()) for x in instances] + instance_id = instance['id'] + + self._ask_scheduler_to_create_instance(context, base_options, + instance_type, zone_blob, + availability_zone, injected_files, + instance_id=instance_id) + + return [x.items() for x in instances] def smart_create(self, *args, **kwargs): - """Ask the scheduler if we should: 1. do single shot instance - requests or all-at-once, and 2. defer the DB work until - a suitable host has been selected (if at all). Cache this - information and act accordingly.""" + """ + Ask the scheduler if we should do single shot instance requests + or all-at-once. - if API.scheduler_rules == None: - API.scheduler_rules = scheduler_api.get_scheduler_rules(context) + Cache this information on first request and act accordingly. + """ - should_create_all_at_once, should_defer_database_create = \ - API.scheduler_rules + if API.should_create_all_at_once == None: + API.should_create_all_at_once = \ + scheduler_api.should_create_all_at_once(context) - if should_create_all_at_once: + if API.should_create_all_at_once: return self.create_all_at_once(*args, **kwargs) return self.create(*args, **kwargs) diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 2094e3565..237e31c04 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -72,6 +72,13 @@ class Scheduler(object): for service in services if self.service_is_up(service)] + def should_create_all_at_once(self, context=None, *args, **kwargs): + """ + Does this driver prefer single-shot requests or all-at-once? + By default, prefer single-shot. + """ + return False + def schedule(self, context, topic, *_args, **_kwargs): """Must override at least this method for scheduler to work.""" raise NotImplementedError(_("Must implement a fallback schedule")) diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index a6fc53be5..a29703aaf 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -74,6 +74,10 @@ class SchedulerManager(manager.Manager): """Select a list of hosts best matching the provided specs.""" return self.driver.select(context, *args, **kwargs) + def get_scheduler_rules(self, context=None, *args, **kwargs): + """Ask the driver how requests should be made of it.""" + return self.driver.get_scheduler_rules(context, *args, **kwargs) + def _schedule(self, method, context, topic, *args, **kwargs): """Tries to call schedule_* method on the driver to retrieve host. diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 58a9eca55..35ffdbde1 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -157,6 +157,12 @@ class ZoneAwareScheduler(driver.Scheduler): self._provision_resource_from_blob(context, item, instance_id, request_spec, kwargs) + def should_create_all_at_once(self, context=None, *args, **kwargs): + """ + This driver prefers all-at-once requests. + """ + return True + def schedule_run_instance(self, context, instance_id, request_spec, *args, **kwargs): """This method is called from nova.compute.api to provision -- cgit From 7c0564baf72cbb5c3693ab72c72684a5c6b333c5 Mon Sep 17 00:00:00 2001 From: John Tran Date: Thu, 26 May 2011 10:22:45 -0700 Subject: instance obj returned is not a hash, instead is sqlalchemy obj and hostname attr is what the logic is looking for --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index 26c0d776c..51373d282 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -536,7 +536,7 @@ class FloatingIpCommands(object): for floating_ip in floating_ips: instance = None if floating_ip['fixed_ip']: - instance = floating_ip['fixed_ip']['instance']['ec2_id'] + instance = floating_ip['fixed_ip']['instance'].hostname print "%s\t%s\t%s" % (floating_ip['host'], floating_ip['address'], instance) -- cgit From 2d834fa19078c645e3c36001b5dd34fb8e708f0a Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 26 May 2011 14:09:59 -0400 Subject: review fixups --- nova/api/openstack/wsgi.py | 27 ++++++++++++++++----------- nova/tests/api/openstack/test_wsgi.py | 2 +- nova/wsgi.py | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index bd840a6f7..5577d326f 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -62,7 +62,7 @@ class TextDeserializer(object): """Find local deserialization method and parse request body.""" try: action_method = getattr(self, action) - except Exception: + except (AttributeError, TypeError): action_method = self.default return action_method(datastring) @@ -162,7 +162,7 @@ class RequestDeserializer(object): def get_deserializer(self, content_type): try: return self.deserializers[content_type] - except Exception: + except (KeyError, TypeError): raise exception.InvalidContentType(content_type=content_type) def get_expected_content_type(self, request): @@ -172,16 +172,20 @@ class RequestDeserializer(object): """Parse dictionary created by routes library.""" try: args = request_environment['wsgiorg.routing_args'][1].copy() + except Exception: + return {} + try: del args['controller'] + except KeyError: + pass - if 'format' in args: - del args['format'] - - return args - + try: + del args['format'] except KeyError: - return {} + pass + + return args class DictSerializer(object): @@ -191,7 +195,7 @@ class DictSerializer(object): """Find local serialization method and encode response body.""" try: action_method = getattr(self, action) - except Exception: + except (AttributeError, TypeError): action_method = self.default return action_method(data) @@ -316,7 +320,7 @@ class ResponseSerializer(object): def get_serializer(self, content_type): try: return self.serializers[content_type] - except Exception: + except (KeyError, TypeError): raise exception.InvalidContentType(content_type=content_type) @@ -347,7 +351,8 @@ class Resource(wsgi.Application): def __call__(self, request): """WSGI method that controls (de)serialization and method dispatch.""" - LOG.debug("%s %s" % (request.method, request.url)) + LOG.debug("%(method)s %(url)s" % {"method": request.method, + "url": request.url}) try: action, action_args, accept = self.deserializer.deserialize( diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index 89603d82b..ebbdc9409 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -205,7 +205,7 @@ class ResponseSerializerTest(test.TestCase): def test_serialize_response_dict_to_unknown_content_type(self): self.assertRaises(exception.InvalidContentType, self.serializer.serialize, - 'application/unknown', {}) + {}, 'application/unknown') class RequestDeserializerTest(test.TestCase): diff --git a/nova/wsgi.py b/nova/wsgi.py index d59d2ee13..33ba852bc 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -260,8 +260,8 @@ class Router(object): Each route in `mapper` must specify a 'controller', which is a WSGI app to call. You'll probably want to specify an 'action' as - well and have your controller be a controller, who will route - the request to the action method. + well and have your controller be an object that can route + the request to the action-specific method. Examples: mapper = routes.Mapper() -- cgit From 9a9dc80bcb47db5864b0c35fe1dd1a636b0a933e Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Thu, 26 May 2011 11:34:53 -0700 Subject: tests pass and pep8'ed --- nova/compute/api.py | 30 +++++++++++++++--------------- nova/scheduler/api.py | 4 ++-- nova/scheduler/host_filter.py | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index cd4d7ca47..032ef7469 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -225,9 +225,9 @@ class API(base.Base): return (num_instances, base_options, security_groups) - def create_db_entry_for_new_instance(self, context, base_options, + def create_db_entry_for_new_instance(self, context, base_options, security_groups, num=1): - """Create an entry in the DB for this new instance, + """Create an entry in the DB for this new instance, including any related table updates (such as security groups, MAC address, etc). This will called by create() in the majority of situations, but all-at-once style @@ -272,7 +272,7 @@ class API(base.Base): else: LOG.debug(_("Casting to scheduler for %(pid)s/%(uid)s's" " (all-at-once)") % locals()) - + filter_class = 'nova.scheduler.host_filter.InstanceTypeFilter' request_spec = { 'instance_properties': base_options, @@ -290,7 +290,7 @@ class API(base.Base): "request_spec": request_spec, "availability_zone": availability_zone, "injected_files": injected_files}}) - + def create_all_at_once(self, context, instance_type, image_id, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, @@ -298,10 +298,10 @@ class API(base.Base): key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, injected_files=None, zone_blob=None): - """Provision the instances by passing the whole request to - the Scheduler for execution. Returns a Reservation ID - related to the creation of all of these instances.""" - num_instances, base_options, security_groups = \ + """Provision the instances by passing the whole request to + the Scheduler for execution. Returns a Reservation ID + related to the creation of all of these instances.""" + num_instances, base_options, security_groups = \ self._check_create_parameters( context, instance_type, image_id, kernel_id, ramdisk_id, @@ -311,12 +311,12 @@ class API(base.Base): availability_zone, user_data, metadata, injected_files, zone_blob) - self._ask_scheduler_to_create_instance(context, base_options, + self._ask_scheduler_to_create_instance(context, base_options, instance_type, zone_blob, availability_zone, injected_files, num_instances=num_instances) - return base_options['reservation_id'] + return base_options['reservation_id'] def create(self, context, instance_type, image_id, kernel_id=None, ramdisk_id=None, @@ -330,7 +330,7 @@ class API(base.Base): instance requests to the Schedulers. This is fine for trival Scheduler drivers, but may remove the effectiveness of the more complicated drivers. - + Returns a list of instance dicts. """ @@ -343,7 +343,7 @@ class API(base.Base): key_name, key_data, security_group, availability_zone, user_data, metadata, injected_files, zone_blob) - + instances = [] LOG.debug(_("Going to run %s instances..."), num_instances) for num in range(num_instances): @@ -351,13 +351,13 @@ class API(base.Base): base_options, security_groups, num=num) instances.append(instance) instance_id = instance['id'] - + self._ask_scheduler_to_create_instance(context, base_options, instance_type, zone_blob, availability_zone, injected_files, instance_id=instance_id) - - return [x.items() for x in instances] + + return [dict(x.iteritems()) for x in instances] def smart_create(self, *args, **kwargs): """ diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 8123082f9..de0660713 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -87,10 +87,10 @@ def select(context, specs=None): params={"request_spec": specs}) -def get_scheduler_rules(context): +def should_create_all_at_once(context): """Returns a tuple of rules for how instances should be created given the current Scheduler driver being used.""" - return _call_scheduler('get_scheduler_rules', context=context, + return _call_scheduler('should_create_all_at_once', context=context, params={}) diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index d9771754a..ed76c90bf 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -296,13 +296,13 @@ class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): hosts for weighing. The particular filter used may be passed in as an argument or the default will be used. - request_spec = {'filter_name': , + request_spec = {'filter': , 'instance_type': } """ def filter_hosts(self, num, request_spec): """Filter the full host list (from the ZoneManager)""" - filter_name = request_spec.get('filter_name', None) + filter_name = request_spec.get('filter', None) host_filter = choose_host_filter(filter_name) # TODO(sandy): We're only using InstanceType-based specs -- cgit From 3264c18fffa26b1288fc253f2526d9a78fdc9dd4 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 26 May 2011 15:01:24 -0400 Subject: cleaning up getattr calls with default param --- nova/api/openstack/wsgi.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 5577d326f..7a747842e 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -58,13 +58,9 @@ class Request(webob.Request): class TextDeserializer(object): """Custom request body deserialization based on controller action name.""" - def deserialize(self, datastring, action=None): + def deserialize(self, datastring, action='default'): """Find local deserialization method and parse request body.""" - try: - action_method = getattr(self, action) - except (AttributeError, TypeError): - action_method = self.default - + action_method = getattr(self, action, self.default) return action_method(datastring) def default(self, datastring): @@ -191,13 +187,9 @@ class RequestDeserializer(object): class DictSerializer(object): """Custom response body serialization based on controller action name.""" - def serialize(self, data, action=None): + def serialize(self, data, action='default'): """Find local serialization method and encode response body.""" - try: - action_method = getattr(self, action) - except (AttributeError, TypeError): - action_method = self.default - + action_method = getattr(self, action, self.default) return action_method(data) def default(self, data): -- cgit From a79f01fcea81bb6be233a65670c6a79af8534a10 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 26 May 2011 17:27:48 -0400 Subject: adding TODOs per dabo's review --- nova/api/openstack/wsgi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 7a747842e..ddf4e6fa9 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -237,6 +237,7 @@ class XMLDictSerializer(DictSerializer): if xmlns: result.setAttribute('xmlns', xmlns) + #TODO(bcwaldon): accomplish this without a type-check if type(data) is list: collections = metadata.get('list_collections', {}) if nodename in collections: @@ -255,6 +256,7 @@ class XMLDictSerializer(DictSerializer): for item in data: node = self._to_xml_node(doc, metadata, singular, item) result.appendChild(node) + #TODO(bcwaldon): accomplish this without a type-check elif type(data) is dict: collections = metadata.get('dict_collections', {}) if nodename in collections: -- cgit From 2819681b762fe8a23f3af68f1c1cbed0a113c08e Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 26 May 2011 18:14:38 -0400 Subject: Rename instances.image_id to instances.image_ref. --- nova/api/ec2/cloud.py | 6 +++--- nova/compute/api.py | 2 +- nova/compute/manager.py | 2 +- nova/db/sqlalchemy/api.py | 2 +- nova/db/sqlalchemy/models.py | 4 ++-- nova/tests/test_cloud.py | 6 +++--- nova/tests/test_compute.py | 2 +- nova/virt/libvirt/firewall.py | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 8580dc79e..5bbee1afd 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -159,7 +159,7 @@ class CloudController(object): floating_ip = db.instance_get_floating_address(ctxt, instance_ref['id']) ec2_id = ec2utils.id_to_ec2_id(instance_ref['id']) - image_ec2_id = self.image_ec2_id(instance_ref['image_id']) + image_ec2_id = self.image_ec2_id(instance_ref['image_ref']) data = { 'user-data': base64.b64decode(instance_ref['user_data']), 'meta-data': { @@ -724,13 +724,13 @@ class CloudController(object): instances = self.compute_api.get_all(context, **kwargs) for instance in instances: if not context.is_admin: - if instance['image_id'] == str(FLAGS.vpn_image_id): + if instance['image_ref'] == str(FLAGS.vpn_image_id): continue i = {} instance_id = instance['id'] ec2_id = ec2utils.id_to_ec2_id(instance_id) i['instanceId'] = ec2_id - i['imageId'] = self.image_ec2_id(instance['image_id']) + i['imageId'] = self.image_ec2_id(instance['image_ref']) i['instanceState'] = { 'code': instance['state'], 'name': instance['state_description']} diff --git a/nova/compute/api.py b/nova/compute/api.py index 432ea1fad..61b45843d 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -207,7 +207,7 @@ class API(base.Base): base_options = { 'reservation_id': utils.generate_uid('r'), - 'image_id': image_href, + 'image_ref': image_href, 'kernel_id': kernel_id or '', 'ramdisk_id': ramdisk_id or '', 'state': 0, diff --git a/nova/compute/manager.py b/nova/compute/manager.py index d1e01f275..7c88236ba 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -235,7 +235,7 @@ class ComputeManager(manager.SchedulerDependentManager): power_state.NOSTATE, 'networking') - is_vpn = instance_ref['image_id'] == str(FLAGS.vpn_image_id) + is_vpn = instance_ref['image_ref'] == str(FLAGS.vpn_image_id) # NOTE(vish): This could be a cast because we don't do anything # with the address currently, but I'm leaving it as # a call to ensure that network setup completes. We diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index e4dda5c12..4403cd7d9 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -955,7 +955,7 @@ def instance_get_project_vpn(context, project_id): options(joinedload('security_groups')).\ options(joinedload('instance_type')).\ filter_by(project_id=project_id).\ - filter_by(image_id=str(FLAGS.vpn_image_id)).\ + filter_by(image_ref=str(FLAGS.vpn_image_id)).\ filter_by(deleted=can_read_deleted(context)).\ first() diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 1215448f8..6d4be8767 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -184,11 +184,11 @@ class Instance(BASE, NovaBase): def project(self): return auth.manager.AuthManager().get_project(self.project_id) - image_id = Column(String(255)) + image_ref = Column(String(255)) kernel_id = Column(String(255)) ramdisk_id = Column(String(255)) -# image_id = Column(Integer, ForeignKey('images.id'), nullable=True) +# image_ref = Column(Integer, ForeignKey('images.id'), nullable=True) # kernel_id = Column(Integer, ForeignKey('images.id'), nullable=True) # ramdisk_id = Column(Integer, ForeignKey('images.id'), nullable=True) # ramdisk = relationship(Ramdisk, backref=backref('instances', order_by=id)) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 54c0454de..eefab58d0 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -191,10 +191,10 @@ class CloudTestCase(test.TestCase): def test_describe_instances(self): """Makes sure describe_instances works and filters results.""" inst1 = db.instance_create(self.context, {'reservation_id': 'a', - 'image_id': 1, + 'image_ref': 1, 'host': 'host1'}) inst2 = db.instance_create(self.context, {'reservation_id': 'a', - 'image_id': 1, + 'image_ref': 1, 'host': 'host2'}) comp1 = db.service_create(self.context, {'host': 'host1', 'availability_zone': 'zone1', @@ -390,7 +390,7 @@ class CloudTestCase(test.TestCase): def test_terminate_instances(self): inst1 = db.instance_create(self.context, {'reservation_id': 'a', - 'image_id': 1, + 'image_ref': 1, 'host': 'host1'}) terminate_instances = self.cloud.terminate_instances # valid instance_id diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b4097660f..25454087d 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -84,7 +84,7 @@ class ComputeTestCase(test.TestCase): def _create_instance(self, params={}): """Create a test instance""" inst = {} - inst['image_id'] = 1 + inst['image_ref'] = 1 inst['reservation_id'] = 'r-fakeres' inst['launch_time'] = '10' inst['user_id'] = self.user.id diff --git a/nova/virt/libvirt/firewall.py b/nova/virt/libvirt/firewall.py index 7e00662cd..12727f2b1 100644 --- a/nova/virt/libvirt/firewall.py +++ b/nova/virt/libvirt/firewall.py @@ -195,7 +195,7 @@ class NWFilterFirewall(FirewallDriver): logging.info('ensuring static filters') self._ensure_static_filters() - if instance['image_id'] == str(FLAGS.vpn_image_id): + if instance['image_ref'] == str(FLAGS.vpn_image_id): base_filter = 'nova-vpn' else: base_filter = 'nova-base' @@ -336,7 +336,7 @@ class NWFilterFirewall(FirewallDriver): def _create_network_filters(self, instance, network_info, instance_secgroup_filter_name): - if instance['image_id'] == str(FLAGS.vpn_image_id): + if instance['image_ref'] == str(FLAGS.vpn_image_id): base_filter = 'nova-vpn' else: base_filter = 'nova-base' -- cgit From 299cadb9ce2e2600b18e2befbed967ca2941256d Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 27 May 2011 08:15:56 -0400 Subject: Commit the migration script. --- .../migrate_repo/versions/019_rename_image_ids.py | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py b/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py new file mode 100644 index 000000000..6838f1ea6 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py @@ -0,0 +1,39 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import Column, Integer, MetaData, String, Table +#from nova import log as logging + +meta = MetaData() + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True, + autoload_with=migrate_engine) + + image_id_column = instances.c.image_id + image_id_column.alter(name='image_ref') + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True, + autoload_with=migrate_engine) + + image_ref_column = instances.c.image_ref + image_ref_column.alter(name='image_id') -- cgit From e5d89198b188b9ae62ff0ac2bd72fd321f541713 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 27 May 2011 09:43:10 -0400 Subject: Libvirt updates for image_ref. --- nova/virt/libvirt/connection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 1cedd1fe3..62c40a022 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -392,7 +392,7 @@ class LibvirtConnection(driver.ComputeDriver): elevated = context.get_admin_context() (image_service, image_id) = nova.image.get_image_service( - instance['image_id']) + instance['image_ref']) base = image_service.show(elevated, image_id) metadata = {'disk_format': base['disk_format'], @@ -779,7 +779,7 @@ class LibvirtConnection(driver.ComputeDriver): project = manager.AuthManager().get_project(inst['project_id']) if not disk_images: - disk_images = {'image_id': inst['image_id'], + disk_images = {'image_id': inst['image_ref'], 'kernel_id': inst['kernel_id'], 'ramdisk_id': inst['ramdisk_id']} @@ -875,7 +875,7 @@ class LibvirtConnection(driver.ComputeDriver): if key or net: inst_name = inst['name'] - img_id = inst.image_id + img_id = inst.image_ref if key: LOG.info(_('instance %(inst_name)s: injecting key into' ' image %(img_id)s') % locals()) -- cgit From c26be56d63a9d263ea8632514be03607713c754d Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 27 May 2011 15:48:40 -0400 Subject: Glance client updates for xenapi and vmware API to work with image refs. --- nova/image/__init__.py | 42 +++++++++++++++++++++++++++--------- nova/tests/glance/stubs.py | 12 +++++++---- nova/tests/test_vmwareapi.py | 5 ++--- nova/tests/test_xenapi.py | 29 +++++++++++-------------- nova/tests/vmwareapi/db_fakes.py | 2 +- nova/virt/vmwareapi/vmops.py | 12 +++++------ nova/virt/vmwareapi/vmware_images.py | 16 ++++++-------- nova/virt/xenapi/vm_utils.py | 14 ++++++------ nova/virt/xenapi/vmops.py | 2 +- 9 files changed, 78 insertions(+), 56 deletions(-) diff --git a/nova/image/__init__.py b/nova/image/__init__.py index 9b9108bd2..011d79d61 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -18,16 +18,16 @@ from urlparse import urlparse - from nova import exception -import nova.image.glance -from nova.utils import import_class +from nova import utils from nova import flags - FLAGS = flags.FLAGS +GlanceClient = utils.import_class('glance.client.Client') + + def _parse_image_ref(image_href): """Parse an image href into composite parts. @@ -43,10 +43,36 @@ def _parse_image_ref(image_href): def get_default_image_service(): - ImageService = import_class(FLAGS.image_service) + ImageService = utils.import_class(FLAGS.image_service) return ImageService() +def get_glance_client(image_href): + """Get the correct glance client and id for the given image_href. + + The image_href param can be an href of the form + http://myglanceserver:9292/images/42, or just an int such as 42. If the + image_href is an int, then flags are used to create the default + glance client. + + :param image_href: image ref/id for an image + :returns: a tuple of the form (glance_client, image_id) + + """ + image_href = image_href or 0 + if str(image_href).isdigit(): + glance_client = GlanceClient(FLAGS.glance_host, FLAGS.glance_port) + return (glance_client, int(image_href)) + + try: + (image_id, host, port) = _parse_image_ref(image_href) + except: + raise exception.InvalidImageRef(image_href=image_href) + glance_client = GlanceClient(host, port) + #glance_client = client.Client(host, port) + return (glance_client, image_id) + + def get_image_service(image_href): """Get the proper image_service and id for the given image_href. @@ -62,10 +88,6 @@ def get_image_service(image_href): if str(image_href).isdigit(): return (get_default_image_service(), int(image_href)) - try: - (image_id, host, port) = _parse_image_ref(image_href) - except: - raise exception.InvalidImageRef(image_href=image_href) - glance_client = nova.image.glance.GlanceClient(host, port) + (glance_client, image_id) = get_glance_client(image_href) image_service = nova.image.glance.GlanceImageService(glance_client) return (image_service, image_id) diff --git a/nova/tests/glance/stubs.py b/nova/tests/glance/stubs.py index 5872552ec..8611fef29 100644 --- a/nova/tests/glance/stubs.py +++ b/nova/tests/glance/stubs.py @@ -16,13 +16,17 @@ import StringIO -import glance.client +from nova import images -def stubout_glance_client(stubs, cls): + +def get_mock_glance_client(): + return FakeGlance() + + +def stubout_glance_client(stubs): """Stubs out glance.client.Client""" - stubs.Set(glance.client, 'Client', - lambda *args, **kwargs: cls(*args, **kwargs)) + stubs.Set(images, 'get_glance_client', get_mock_glance_client) class FakeGlance(object): diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py index 22b66010a..e5ebd1600 100644 --- a/nova/tests/test_vmwareapi.py +++ b/nova/tests/test_vmwareapi.py @@ -55,8 +55,7 @@ class VMWareAPIVMTestCase(test.TestCase): vmwareapi_fake.reset() db_fakes.stub_out_db_instance_api(self.stubs) stubs.set_stubs(self.stubs) - glance_stubs.stubout_glance_client(self.stubs, - glance_stubs.FakeGlance) + glance_stubs.stubout_glance_client(self.stubs) self.conn = vmwareapi_conn.get_connection(False) def _create_instance_in_the_db(self): @@ -64,7 +63,7 @@ class VMWareAPIVMTestCase(test.TestCase): 'id': 1, 'project_id': self.project.id, 'user_id': self.user.id, - 'image_id': "1", + 'image_ref': "1", 'kernel_id': "1", 'ramdisk_id': "1", 'instance_type': 'm1.large', diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 18a267896..56e1e47af 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -79,7 +79,7 @@ class XenAPIVolumeTestCase(test.TestCase): self.values = {'id': 1, 'project_id': 'fake', 'user_id': 'fake', - 'image_id': 1, + 'image_ref': 1, 'kernel_id': 2, 'ramdisk_id': 3, 'instance_type_id': '3', # m1.large @@ -193,8 +193,7 @@ class XenAPIVMTestCase(test.TestCase): stubs.stubout_is_vdi_pv(self.stubs) self.stubs.Set(VMOps, 'reset_network', reset_network) stubs.stub_out_vm_methods(self.stubs) - glance_stubs.stubout_glance_client(self.stubs, - glance_stubs.FakeGlance) + glance_stubs.stubout_glance_client(self.stubs) fake_utils.stub_out_utils_execute(self.stubs) self.context = context.RequestContext('fake', 'fake', False) self.conn = xenapi_conn.get_connection(False) @@ -207,7 +206,7 @@ class XenAPIVMTestCase(test.TestCase): 'id': id, 'project_id': proj, 'user_id': user, - 'image_id': 1, + 'image_ref': 1, 'kernel_id': 2, 'ramdisk_id': 3, 'instance_type_id': '3', # m1.large @@ -351,14 +350,14 @@ class XenAPIVMTestCase(test.TestCase): self.assertEquals(self.vm['HVM_boot_params'], {}) self.assertEquals(self.vm['HVM_boot_policy'], '') - def _test_spawn(self, image_id, kernel_id, ramdisk_id, + def _test_spawn(self, image_ref, kernel_id, ramdisk_id, instance_type_id="3", os_type="linux", instance_id=1, check_injection=False): stubs.stubout_loopingcall_start(self.stubs) values = {'id': instance_id, 'project_id': self.project.id, 'user_id': self.user.id, - 'image_id': image_id, + 'image_ref': image_ref, 'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id, 'instance_type_id': instance_type_id, @@ -567,7 +566,7 @@ class XenAPIVMTestCase(test.TestCase): 'id': 1, 'project_id': self.project.id, 'user_id': self.user.id, - 'image_id': 1, + 'image_ref': 1, 'kernel_id': 2, 'ramdisk_id': 3, 'instance_type_id': '3', # m1.large @@ -623,7 +622,7 @@ class XenAPIMigrateInstance(test.TestCase): self.values = {'id': 1, 'project_id': self.project.id, 'user_id': self.user.id, - 'image_id': 1, + 'image_ref': 1, 'kernel_id': None, 'ramdisk_id': None, 'local_gb': 5, @@ -634,8 +633,7 @@ class XenAPIMigrateInstance(test.TestCase): fake_utils.stub_out_utils_execute(self.stubs) stubs.stub_out_migration_methods(self.stubs) stubs.stubout_get_this_vm_uuid(self.stubs) - glance_stubs.stubout_glance_client(self.stubs, - glance_stubs.FakeGlance) + glance_stubs.stubout_glance_client(self.stubs) def tearDown(self): super(XenAPIMigrateInstance, self).tearDown() @@ -661,8 +659,7 @@ class XenAPIDetermineDiskImageTestCase(test.TestCase): """Unit tests for code that detects the ImageType.""" def setUp(self): super(XenAPIDetermineDiskImageTestCase, self).setUp() - glance_stubs.stubout_glance_client(self.stubs, - glance_stubs.FakeGlance) + glance_stubs.stubout_glance_client(self.stubs) class FakeInstance(object): pass @@ -679,7 +676,7 @@ class XenAPIDetermineDiskImageTestCase(test.TestCase): def test_instance_disk(self): """If a kernel is specified, the image type is DISK (aka machine).""" FLAGS.xenapi_image_service = 'objectstore' - self.fake_instance.image_id = glance_stubs.FakeGlance.IMAGE_MACHINE + self.fake_instance.image_ref = glance_stubs.FakeGlance.IMAGE_MACHINE self.fake_instance.kernel_id = glance_stubs.FakeGlance.IMAGE_KERNEL self.assert_disk_type(vm_utils.ImageType.DISK) @@ -689,7 +686,7 @@ class XenAPIDetermineDiskImageTestCase(test.TestCase): DISK_RAW is assumed. """ FLAGS.xenapi_image_service = 'objectstore' - self.fake_instance.image_id = glance_stubs.FakeGlance.IMAGE_RAW + self.fake_instance.image_ref = glance_stubs.FakeGlance.IMAGE_RAW self.fake_instance.kernel_id = None self.assert_disk_type(vm_utils.ImageType.DISK_RAW) @@ -699,7 +696,7 @@ class XenAPIDetermineDiskImageTestCase(test.TestCase): this case will be 'raw'. """ FLAGS.xenapi_image_service = 'glance' - self.fake_instance.image_id = glance_stubs.FakeGlance.IMAGE_RAW + self.fake_instance.image_ref = glance_stubs.FakeGlance.IMAGE_RAW self.fake_instance.kernel_id = None self.assert_disk_type(vm_utils.ImageType.DISK_RAW) @@ -709,7 +706,7 @@ class XenAPIDetermineDiskImageTestCase(test.TestCase): this case will be 'vhd'. """ FLAGS.xenapi_image_service = 'glance' - self.fake_instance.image_id = glance_stubs.FakeGlance.IMAGE_VHD + self.fake_instance.image_ref = glance_stubs.FakeGlance.IMAGE_VHD self.fake_instance.kernel_id = None self.assert_disk_type(vm_utils.ImageType.DISK_VHD) diff --git a/nova/tests/vmwareapi/db_fakes.py b/nova/tests/vmwareapi/db_fakes.py index 0addd5573..764de42d8 100644 --- a/nova/tests/vmwareapi/db_fakes.py +++ b/nova/tests/vmwareapi/db_fakes.py @@ -61,7 +61,7 @@ def stub_out_db_instance_api(stubs): 'name': values['name'], 'id': values['id'], 'reservation_id': utils.generate_uid('r'), - 'image_id': values['image_id'], + 'image_ref': values['image_ref'], 'kernel_id': values['kernel_id'], 'ramdisk_id': values['ramdisk_id'], 'state_description': 'scheduling', diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py index c3e79a92f..d1bf2de2c 100644 --- a/nova/virt/vmwareapi/vmops.py +++ b/nova/virt/vmwareapi/vmops.py @@ -150,7 +150,7 @@ class VMWareVMOps(object): """ image_size, image_properties = \ vmware_images.get_vmdk_size_and_properties( - instance.image_id, instance) + instance.image_ref, instance) vmdk_file_size_in_kb = int(image_size) / 1024 os_type = image_properties.get("vmware_ostype", "otherGuest") adapter_type = image_properties.get("vmware_adaptertype", @@ -265,23 +265,23 @@ class VMWareVMOps(object): def _fetch_image_on_esx_datastore(): """Fetch image from Glance to ESX datastore.""" - LOG.debug(_("Downloading image file data %(image_id)s to the ESX " + LOG.debug(_("Downloading image file data %(image_ref)s to the ESX " "data store %(data_store_name)s") % - ({'image_id': instance.image_id, + ({'image_ref': instance.image_ref, 'data_store_name': data_store_name})) # Upload the -flat.vmdk file whose meta-data file we just created # above vmware_images.fetch_image( - instance.image_id, + instance.image_ref, instance, host=self._session._host_ip, data_center_name=self._get_datacenter_name_and_ref()[1], datastore_name=data_store_name, cookies=cookies, file_path=flat_uploaded_vmdk_name) - LOG.debug(_("Downloaded image file data %(image_id)s to the ESX " + LOG.debug(_("Downloaded image file data %(image_ref)s to the ESX " "data store %(data_store_name)s") % - ({'image_id': instance.image_id, + ({'image_ref': instance.image_ref, 'data_store_name': data_store_name})) _fetch_image_on_esx_datastore() diff --git a/nova/virt/vmwareapi/vmware_images.py b/nova/virt/vmwareapi/vmware_images.py index 50c6baedf..11f4fe06a 100644 --- a/nova/virt/vmwareapi/vmware_images.py +++ b/nova/virt/vmwareapi/vmware_images.py @@ -18,10 +18,9 @@ Utility functions for Image transfer. """ -from glance import client - from nova import exception from nova import flags +import nova.image from nova import log as logging from nova.virt.vmwareapi import io_util from nova.virt.vmwareapi import read_write_util @@ -117,8 +116,8 @@ def upload_image(image, instance, **kwargs): def _get_glance_image(image, instance, **kwargs): """Download image from the glance image server.""" LOG.debug(_("Downloading image %s from glance image server") % image) - glance_client = client.Client(FLAGS.glance_host, FLAGS.glance_port) - metadata, read_iter = glance_client.get_image(image) + glance_client, image_id = nova.image.get_glance_client(image) + metadata, read_iter = glance_client.get_image(image_id) read_file_handle = read_write_util.GlanceFileRead(read_iter) file_size = int(metadata['size']) write_file_handle = read_write_util.VMWareHTTPWriteFile( @@ -153,7 +152,7 @@ def _put_glance_image(image, instance, **kwargs): kwargs.get("cookies"), kwargs.get("file_path")) file_size = read_file_handle.get_size() - glance_client = client.Client(FLAGS.glance_host, FLAGS.glance_port) + glance_client, image_id = nova.image.get_glance_client(image) # The properties and other fields that we need to set for the image. image_metadata = {"is_public": True, "disk_format": "vmdk", @@ -165,7 +164,7 @@ def _put_glance_image(image, instance, **kwargs): "vmware_image_version": kwargs.get("image_version")}} start_transfer(read_file_handle, file_size, glance_client=glance_client, - image_id=image, image_meta=image_metadata) + image_id=image_id, image_meta=image_metadata) LOG.debug(_("Uploaded image %s to the Glance image server") % image) @@ -188,9 +187,8 @@ def get_vmdk_size_and_properties(image, instance): LOG.debug(_("Getting image size for the image %s") % image) if FLAGS.image_service == "nova.image.glance.GlanceImageService": - glance_client = client.Client(FLAGS.glance_host, - FLAGS.glance_port) - meta_data = glance_client.get_image_meta(image) + glance_client, image_id = nova.image.get_glance_client(image) + meta_data = glance_client.get_image_meta(image_id) size, properties = meta_data["size"], meta_data["properties"] elif FLAGS.image_service == "nova.image.s3.S3ImageService": raise NotImplementedError diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 06ee8ee9b..3b1209da8 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -32,6 +32,7 @@ from xml.dom import minidom import glance.client from nova import exception from nova import flags +import nova.image from nova import log as logging from nova import utils from nova.auth.manager import AuthManager @@ -455,8 +456,8 @@ class VMHelper(HelperBase): # DISK restores sr_ref = safe_find_sr(session) - client = glance.client.Client(FLAGS.glance_host, FLAGS.glance_port) - meta, image_file = client.get_image(image) + glance_client, image_id = nova.image.get_glance_client(image) + meta, image_file = glance_client.get_image(image_id) virtual_size = int(meta['size']) vdi_size = virtual_size LOG.debug(_("Size for image %(image)s:%(virtual_size)d") % locals()) @@ -515,10 +516,10 @@ class VMHelper(HelperBase): ImageType.DISK_RAW: 'DISK_RAW', ImageType.DISK_VHD: 'DISK_VHD'} disk_format = pretty_format[image_type] - image_id = instance.image_id + image_ref = instance.image_ref instance_id = instance.id LOG.debug(_("Detected %(disk_format)s format for image " - "%(image_id)s, instance %(instance_id)s") % locals()) + "%(image_ref)s, instance %(instance_id)s") % locals()) def determine_from_glance(): glance_disk_format2nova_type = { @@ -527,8 +528,9 @@ class VMHelper(HelperBase): 'ari': ImageType.KERNEL_RAMDISK, 'raw': ImageType.DISK_RAW, 'vhd': ImageType.DISK_VHD} - client = glance.client.Client(FLAGS.glance_host, FLAGS.glance_port) - meta = client.get_image_meta(instance.image_id) + image_ref = instance.image_ref + glance_client, image_id = nova.image.get_glance_client(image_ref) + meta = glance_client.get_image_meta(image_id) disk_format = meta['disk_format'] try: return glance_disk_format2nova_type[disk_format] diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 6d516ddbc..183d29470 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -111,7 +111,7 @@ class VMOps(object): project = AuthManager().get_project(instance.project_id) disk_image_type = VMHelper.determine_disk_image_type(instance) vdis = VMHelper.fetch_image(self._session, - instance.id, instance.image_id, user, project, + instance.id, instance.image_ref, user, project, disk_image_type) return vdis -- cgit From e75bbc348c713775af11293fc6e5e05667279234 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 28 May 2011 02:18:48 -0400 Subject: More image_id to image_ref stuff. Also fixed tests in test_servers. --- nova/api/openstack/servers.py | 2 +- nova/api/openstack/views/servers.py | 8 ++++---- nova/tests/api/openstack/test_servers.py | 16 +++++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 76800795c..7593694bd 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -189,7 +189,7 @@ class Controller(common.OpenstackController): return faults.Fault(exc.HTTPBadRequest(msg)) inst['instance_type'] = inst_type - inst['image_id'] = image_href + inst['image_ref'] = image_href builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index ddd17ab93..dd1d68ff0 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -112,8 +112,8 @@ class ViewBuilderV10(ViewBuilder): """Model an Openstack API V1.0 server response.""" def _build_image(self, response, inst): - if 'image_id' in dict(inst): - response['imageId'] = int(inst['image_id']) + if 'image_ref' in dict(inst): + response['imageId'] = int(inst['image_ref']) def _build_flavor(self, response, inst): if 'instance_type' in dict(inst): @@ -130,8 +130,8 @@ class ViewBuilderV11(ViewBuilder): self.base_url = base_url def _build_image(self, response, inst): - if 'image_id' in dict(inst): - image_href = inst['image_id'] + if 'image_ref' in dict(inst): + image_href = inst['image_ref'] if str(image_href).isdigit(): image_href = int(image_href) response['imageRef'] = image_href diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index a6ab9c0c8..1ce0e8e84 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -98,7 +98,7 @@ def stub_instance(id, user_id=1, private_address=None, public_addresses=None, "admin_pass": "", "user_id": user_id, "project_id": "", - "image_id": "10", + "image_ref": "10", "kernel_id": "", "ramdisk_id": "", "launch_index": 0, @@ -475,12 +475,13 @@ class ServersTest(test.TestCase): def image_id_from_hash(*args, **kwargs): return 2 - def fake_image_service(*args): - return nova.image.fake.FakeImageService() + def fake_get_image_service(image_href): + image_id = int(str(image_href).split('/')[-1]) + return (nova.image.fake.FakeImageService(), image_id) - FLAGS.image_service = 'nova.image.fake.FakeImageService' - self.stubs.Set( - nova.image.glance, 'GlanceImageService', fake_image_service) + self.stubs.Set(nova.image, 'get_default_image_service', + lambda: nova.image.fake.FakeImageService()) + self.stubs.Set(nova.image, 'get_image_service', fake_get_image_service) self.stubs.Set(nova.db.api, 'project_get_network', project_get_network) self.stubs.Set(nova.db.api, 'instance_create', instance_create) self.stubs.Set(nova.rpc, 'cast', fake_method) @@ -1685,6 +1686,8 @@ class TestServerInstanceCreation(test.TestCase): fakes.stub_out_auth(self.stubs) fakes.stub_out_key_pair_funcs(self.stubs) self.allow_admin = FLAGS.allow_admin_api + self.stubs.Set(nova.image, 'get_default_image_service', + lambda: nova.image.fake.FakeImageService()) def tearDown(self): self.stubs.UnsetAll() @@ -1714,7 +1717,6 @@ class TestServerInstanceCreation(test.TestCase): return stub_method compute_api = MockComputeAPI() - FLAGS.image_service = 'nova.image.fake.FakeImageService' self.stubs.Set(nova.compute, 'API', make_stub_method(compute_api)) self.stubs.Set(nova.api.openstack.servers.Controller, '_get_kernel_ramdisk_from_image', make_stub_method((1, 1))) -- cgit From 1fced8f7a527f25abde457cfcf056a9a082a79c3 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 28 May 2011 04:29:35 -0400 Subject: Fixing integration tests by correctly stubbing image service. --- nova/tests/integrated/integrated_helpers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index 3b4c49c93..5eacc829d 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -152,10 +152,10 @@ class _IntegratedTestBase(test.TestCase): f = self._get_flags() self.flags(**f) - def fake_image_service(*args): - return nova.image.fake.FakeImageService() - self.stubs.Set( - nova.image.glance, 'GlanceImageService', fake_image_service) + def fake_get_image_service(image_href): + image_id = int(str(image_href).split('/')[-1]) + return (nova.image.fake.FakeImageService(), image_id) + self.stubs.Set(nova.image, 'get_image_service', fake_get_image_service) # set up services self.start_service('compute') -- cgit From bceac9e68021959c8711a0be4ed7ac13352a4623 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 28 May 2011 06:04:19 -0400 Subject: Fixing xen and vmware tests by correctly mocking glance client. --- nova/tests/glance/stubs.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nova/tests/glance/stubs.py b/nova/tests/glance/stubs.py index 8611fef29..fdd9ad4da 100644 --- a/nova/tests/glance/stubs.py +++ b/nova/tests/glance/stubs.py @@ -16,19 +16,16 @@ import StringIO - -from nova import images - - -def get_mock_glance_client(): - return FakeGlance() +import nova.image def stubout_glance_client(stubs): - """Stubs out glance.client.Client""" - stubs.Set(images, 'get_glance_client', get_mock_glance_client) - + def fake_get_glance_client(image_href): + image_id = int(str(image_href).split('/')[-1]) + return (FakeGlance('foo'), image_id) + stubs.Set(nova.image, 'get_glance_client', fake_get_glance_client) + class FakeGlance(object): IMAGE_MACHINE = 1 IMAGE_KERNEL = 2 -- cgit From 9ce5728a0d800374a76cacf935daf2c032f1c33d Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 28 May 2011 06:25:04 -0400 Subject: Fixing nova.tests.api.openstack.fakes.stub_out_image_service. It now stubs out the get_image_service and get_default_image_service functions. Also some pep8 whitespace fixes. --- .../sqlalchemy/migrate_repo/versions/019_rename_image_ids.py | 3 ++- nova/tests/api/openstack/fakes.py | 11 +++++++---- nova/tests/api/openstack/test_servers.py | 10 +--------- nova/tests/glance/stubs.py | 2 +- nova/virt/vmwareapi/vmware_images.py | 6 +++--- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py b/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py index 6838f1ea6..73a5e8477 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py @@ -15,10 +15,11 @@ # under the License. from sqlalchemy import Column, Integer, MetaData, String, Table -#from nova import log as logging + meta = MetaData() + def upgrade(migrate_engine): # Upgrade operations go here. Don't create your own engine; # bind migrate_engine to your metadata diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index bf51239e6..01b42d00c 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -38,6 +38,7 @@ from nova.api.openstack import auth from nova.api.openstack import versions from nova.api.openstack import limits from nova.auth.manager import User, Project +import nova.image.fake from nova.image import glance from nova.image import local from nova.image import service @@ -104,10 +105,12 @@ def stub_out_key_pair_funcs(stubs, have_key_pair=True): def stub_out_image_service(stubs): - def fake_image_show(meh, context, id): - return dict(kernelId=1, ramdiskId=1) - - stubs.Set(local.LocalImageService, 'show', fake_image_show) + def fake_get_image_service(image_href): + image_id = int(str(image_href).split('/')[-1]) + return (nova.image.fake.FakeImageService(), image_id) + stubs.Set(nova.image, 'get_image_service', fake_get_image_service) + stubs.Set(nova.image, 'get_default_image_service', + lambda: nova.image.fake.FakeImageService()) def stub_out_auth(stubs): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 1ce0e8e84..9f3b53cdf 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -475,13 +475,6 @@ class ServersTest(test.TestCase): def image_id_from_hash(*args, **kwargs): return 2 - def fake_get_image_service(image_href): - image_id = int(str(image_href).split('/')[-1]) - return (nova.image.fake.FakeImageService(), image_id) - - self.stubs.Set(nova.image, 'get_default_image_service', - lambda: nova.image.fake.FakeImageService()) - self.stubs.Set(nova.image, 'get_image_service', fake_get_image_service) self.stubs.Set(nova.db.api, 'project_get_network', project_get_network) self.stubs.Set(nova.db.api, 'instance_create', instance_create) self.stubs.Set(nova.rpc, 'cast', fake_method) @@ -1684,10 +1677,9 @@ class TestServerInstanceCreation(test.TestCase): fakes.FakeAuthManager.auth_data = {} fakes.FakeAuthDatabase.data = {} fakes.stub_out_auth(self.stubs) + fakes.stub_out_image_service(self.stubs) fakes.stub_out_key_pair_funcs(self.stubs) self.allow_admin = FLAGS.allow_admin_api - self.stubs.Set(nova.image, 'get_default_image_service', - lambda: nova.image.fake.FakeImageService()) def tearDown(self): self.stubs.UnsetAll() diff --git a/nova/tests/glance/stubs.py b/nova/tests/glance/stubs.py index fdd9ad4da..1e0b90d82 100644 --- a/nova/tests/glance/stubs.py +++ b/nova/tests/glance/stubs.py @@ -25,7 +25,7 @@ def stubout_glance_client(stubs): return (FakeGlance('foo'), image_id) stubs.Set(nova.image, 'get_glance_client', fake_get_glance_client) - + class FakeGlance(object): IMAGE_MACHINE = 1 IMAGE_KERNEL = 2 diff --git a/nova/virt/vmwareapi/vmware_images.py b/nova/virt/vmwareapi/vmware_images.py index 11f4fe06a..48edc5384 100644 --- a/nova/virt/vmwareapi/vmware_images.py +++ b/nova/virt/vmwareapi/vmware_images.py @@ -116,7 +116,7 @@ def upload_image(image, instance, **kwargs): def _get_glance_image(image, instance, **kwargs): """Download image from the glance image server.""" LOG.debug(_("Downloading image %s from glance image server") % image) - glance_client, image_id = nova.image.get_glance_client(image) + (glance_client, image_id) = nova.image.get_glance_client(image) metadata, read_iter = glance_client.get_image(image_id) read_file_handle = read_write_util.GlanceFileRead(read_iter) file_size = int(metadata['size']) @@ -152,7 +152,7 @@ def _put_glance_image(image, instance, **kwargs): kwargs.get("cookies"), kwargs.get("file_path")) file_size = read_file_handle.get_size() - glance_client, image_id = nova.image.get_glance_client(image) + (glance_client, image_id) = nova.image.get_glance_client(image) # The properties and other fields that we need to set for the image. image_metadata = {"is_public": True, "disk_format": "vmdk", @@ -187,7 +187,7 @@ def get_vmdk_size_and_properties(image, instance): LOG.debug(_("Getting image size for the image %s") % image) if FLAGS.image_service == "nova.image.glance.GlanceImageService": - glance_client, image_id = nova.image.get_glance_client(image) + (glance_client, image_id) = nova.image.get_glance_client(image) meta_data = glance_client.get_image_meta(image_id) size, properties = meta_data["size"], meta_data["properties"] elif FLAGS.image_service == "nova.image.s3.S3ImageService": -- cgit From b0636780291fc6531d89a69e164e82203414a875 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sat, 28 May 2011 07:49:31 -0400 Subject: Another image_id location in hyperv. --- nova/virt/hyperv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/virt/hyperv.py b/nova/virt/hyperv.py index 1142e97a4..05b4775c1 100644 --- a/nova/virt/hyperv.py +++ b/nova/virt/hyperv.py @@ -151,7 +151,7 @@ class HyperVConnection(driver.ComputeDriver): base_vhd_filename = os.path.join(FLAGS.instances_path, instance.name) vhdfile = "%s.vhd" % (base_vhd_filename) - images.fetch(instance['image_id'], vhdfile, user, project) + images.fetch(instance['image_ref'], vhdfile, user, project) try: self._create_vm(instance) -- cgit From 29387999d6befc29dddfb7dfd5d543607676e106 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sat, 28 May 2011 14:18:25 -0400 Subject: Added missing nova import to image/__init__.py. --- nova/image/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/image/__init__.py b/nova/image/__init__.py index 011d79d61..f42332a29 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -18,6 +18,7 @@ from urlparse import urlparse +import nova from nova import exception from nova import utils from nova import flags -- cgit From 394b37f8c944fbd3ca683d7752cd751bc69cce51 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sun, 29 May 2011 00:00:02 -0400 Subject: Implement the v1.1 style resize action with support for flavorRef. --- nova/api/openstack/servers.py | 32 ++++++++++++++++++++++++++++++++ nova/tests/api/openstack/test_servers.py | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 5c10fc916..a3066e578 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -332,6 +332,7 @@ class Controller(common.OpenstackController): return exc.HTTPAccepted() def _action_resize(self, input_dict, req, id): + return exc.HTTPNotImplemented() """ Resizes a given instance to the flavor size requested """ try: if 'resize' in input_dict and 'flavorId' in input_dict['resize']: @@ -610,6 +611,21 @@ class ControllerV10(Controller): self.compute_api.set_admin_password(context, server_id, inst_dict['server']['adminPass']) + def _action_resize(self, input_dict, req, id): + """ Resizes a given instance to the flavor size requested """ + try: + if 'resize' in input_dict and 'flavorId' in input_dict['resize']: + flavor_id = input_dict['resize']['flavorId'] + self.compute_api.resize(req.environ['nova.context'], id, + flavor_id) + else: + LOG.exception(_("Missing arguments for resize")) + return faults.Fault(exc.HTTPUnprocessableEntity()) + except Exception, e: + LOG.exception(_("Error in resize %s"), e) + return faults.Fault(exc.HTTPBadRequest()) + return exc.HTTPAccepted() + def _action_rebuild(self, info, request, instance_id): context = request.environ['nova.context'] instance_id = int(instance_id) @@ -695,6 +711,22 @@ class ControllerV11(Controller): LOG.info(msg) raise faults.Fault(exc.HTTPBadRequest(explanation=msg)) + def _action_resize(self, input_dict, req, id): + """ Resizes a given instance to the flavor size requested """ + try: + if 'resize' in input_dict and 'flavorRef' in input_dict['resize']: + flavor_ref = input_dict['resize']['flavorRef'] + flavor_id = common.get_id_from_href(flavor_ref) + self.compute_api.resize(req.environ['nova.context'], id, + flavor_id) + else: + LOG.exception(_("Missing arguments for resize")) + return faults.Fault(exc.HTTPUnprocessableEntity()) + except Exception, e: + LOG.exception(_("Error in resize %s"), e) + return faults.Fault(exc.HTTPBadRequest()) + return exc.HTTPAccepted() + def _action_rebuild(self, info, request, instance_id): context = request.environ['nova.context'] instance_id = int(instance_id) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index fbde5c9ce..e0910fed6 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -1267,6 +1267,25 @@ class ServersTest(test.TestCase): self.assertEqual(res.status_int, 202) self.assertEqual(self.resize_called, True) + def test_resize_server_v11(self): + + req = webob.Request.blank('/v1.1/servers/1/action') + req.content_type = 'application/json' + req.method = 'POST' + body_dict = dict(resize=dict(flavorRef="http://localhost/3")) + req.body = json.dumps(body_dict) + + self.resize_called = False + + def resize_mock(*args): + self.resize_called = True + + self.stubs.Set(nova.compute.api.API, 'resize', resize_mock) + + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 202) + self.assertEqual(self.resize_called, True) + def test_resize_bad_flavor_fails(self): req = self.webreq('/1/action', 'POST', dict(resize=dict(derp=3))) -- cgit From c9926b12f4c554d9a21c6e77fc657e54a2dd4888 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Sun, 29 May 2011 18:01:46 -0700 Subject: starting --- doc/source/devref/distributed_scheduler.rst | 164 ++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 doc/source/devref/distributed_scheduler.rst diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst new file mode 100644 index 000000000..75a4d57ce --- /dev/null +++ b/doc/source/devref/distributed_scheduler.rst @@ -0,0 +1,164 @@ +.. + Copyright 2011 OpenStack LLC + All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); you may + not use this file except in compliance with the License. You may obtain + a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. + +Distributed Scheduler +===== + +The Scheduler is akin to a Dating Service. Requests for the creation of new instances come in and Compute nodes are selected for where the work should be performed. In a small deployment we may be happy with the currently available Change Scheduler which randomly selects a Host from the available pool. Or if you need something a little more fancy you may want to use the Availability Zone Scheduler, which selects Compute hosts from a logical partitioning of available hosts (within a single Zone). + +But for larger deployments a more complex scheduling algorithm is required. Additionally, if you are using Zones in your Nova setup, you'll need a scheduler that understand how to pass instance requests from Zone to Zone. + +This is the purpose of the Distributed Scheduler (DS). The DS utilizes the Capabilities of a Zone and its component services to make informed decisions on where a new instance should be created. When making this decision it consults not only all the Compute nodes in the current Zone, but the Compute nodes in each Child Zone. This continues recursively until the ideal host is found. + +So, how does this all work? + +This document will explain the strategy employed by the ZoneAwareScheduler and its derivations. + +Costs & Weights +---------- +When deciding where to place an Instance, we compare a Weighted Cost for each Host. The Weighting, currently, is just the sum of each Cost. Costs are nothing more than integers from `0 - max_int`. Costs are computed by looking at the various Capabilities of the Host relative to the specs of the Instance being asked for. Trying to put an Instance with 8G of RAM on a Host that only has 4G remaining would have a very high cost. But putting a 512m RAM instance on an empty Host should have a low cost. + +Some Costs are more esoteric. Consider a rule that says we should prefer Hosts that don't already have an instance on it that is owned by the user requesting it (to mitigate against machine failures). Here we have to look at all the other Instances on the host to compute our cost. + +An example of some other costs might include selecting: +* a GPU-based host over a standard CPU +* a host with fast ethernet over a 10mbps line +* a host than can run Windows instances +* a host in the EU vs North America +* etc + +This Weight is computed for each Instance requested. If the customer asked for 1000 instances, the consumed resources on each Host are "virtually" depleted so the Cost can change accordingly. + +nova.scheduler.zone_aware_scheduler.ZoneAwareScheduler +----------- +As we explained in the Zones documentation, each Scheduler has a `ZoneManager` object that collects "Capabilities" about Child Zones and each of the Services running in the current Zone. The `ZoneAwareScheduler` uses this information to make its decisions. + +Here is how it works: + +1. The Compute nodes are Filtered and the remaining set are Weighted. +1a. Filtering the hosts is a simple matter of ensuring the Compute node has ample resources (CPU, RAM, DISK, etc) to fulfil the request. +1b. Weighing of the remaining Compute nodes is performed +2. The same request is sent to each Child Zone and step #1 is done there too. The resulting Weighted List is returned to the parent. +3. The Parent Zone sorts and aggregates all the Weights and a final Build Plan is constructed. +4. The Build Plan is executed upon. Concurrently, Instance Create requests are sent to each of the selected Hosts, be they local or in a child zone. Child Zones may forward the requests to their Child Zones as needed. + +Filtering and Weighing +------------ +Filtering (excluding Compute nodes incapable of fulfilling the request) and Weighing (computing the relative "fitness" of a Compute node to fulfill the request) are very subjective operations. + + + + + + +- +Routing between Zones is based on the Capabilities of that Zone. Capabilities are nothing more than key/value pairs. Values are multi-value, with each value separated with a semicolon (`;`). When expressed as a string they take the form: + +:: + + key=value;value;value, key=value;value;value + +Zones have Capabilities which are general to the Zone and are set via `--zone_capabilities` flag. Zones also have dynamic per-service Capabilities. Services derived from `nova.manager.SchedulerDependentManager` (such as Compute, Volume and Network) can set these capabilities by calling the `update_service_capabilities()` method on their `Manager` base class. These capabilities will be periodically sent to the Scheduler service automatically. The rate at which these updates are sent is controlled by the `--periodic_interval` flag. + +Flow within a Zone +------------------ +The brunt of the work within a Zone is done in the Scheduler Service. The Scheduler is responsible for: +- collecting capability messages from the Compute, Volume and Network nodes, +- polling the child Zones for their status and +- providing data to the Distributed Scheduler for performing load balancing calculations + +Inter-service communication within a Zone is done with RabbitMQ. Each class of Service (Compute, Volume and Network) has both a named message exchange (particular to that host) and a general message exchange (particular to that class of service). Messages sent to these exchanges are picked off in round-robin fashion. Zones introduce a new fan-out exchange per service. Messages sent to the fan-out exchange are picked up by all services of a particular class. This fan-out exchange is used by the Scheduler services to receive capability messages from the Compute, Volume and Network nodes. + +These capability messages are received by the Scheduler services and stored in the `ZoneManager` object. The SchedulerManager object has a reference to the `ZoneManager` it can use for load balancing. + +The `ZoneManager` also polls the child Zones periodically to gather their capabilities to aid in decision making. This is done via the OpenStack API `/v1.0/zones/info` REST call. This also captures the name of each child Zone. The Zone name is set via the `--zone_name` flag (and defaults to "nova"). + +Zone administrative functions +----------------------------- +Zone administrative operations are usually done using python-novaclient_ + +.. _python-novaclient: https://github.com/rackspace/python-novaclient + +In order to use the Zone operations, be sure to enable administrator operations in OpenStack API by setting the `--allow_admin_api=true` flag. + +Finally you need to enable Zone Forwarding. This will be used by the Distributed Scheduler initiative currently underway. Set `--enable_zone_routing=true` to enable this feature. + +Find out about this Zone +------------------------ +In any Zone you can find the Zone's name and capabilities with the ``nova zone-info`` command. + +:: + + alice@novadev:~$ nova zone-info + +-----------------+---------------+ + | Property | Value | + +-----------------+---------------+ + | compute_cpu | 0.7,0.7 | + | compute_disk | 123000,123000 | + | compute_network | 800,800 | + | hypervisor | xenserver | + | name | nova | + | network_cpu | 0.7,0.7 | + | network_disk | 123000,123000 | + | network_network | 800,800 | + | os | linux | + +-----------------+---------------+ + +This equates to a GET operation on `.../zones/info`. If you have no child Zones defined you'll usually only get back the default `name`, `hypervisor` and `os` capabilities. Otherwise you'll get back a tuple of min, max values for each capabilities of all the hosts of all the services running in the child zone. These take the `_ = ,` format. + +Adding a child Zone +------------------- +Any Zone can be a parent Zone. Children are associated to a Zone. The Zone where this command originates from is known as the Parent Zone. Routing is only ever conducted from a Zone to its children, never the other direction. From a parent zone you can add a child zone with the following command: + +:: + + nova zone-add + +You can get the `child zone api url`, `nova api key` and `username` from the `novarc` file in the child zone. For example: + +:: + + export NOVA_API_KEY="3bd1af06-6435-4e23-a827-413b2eb86934" + export NOVA_USERNAME="alice" + export NOVA_URL="http://192.168.2.120:8774/v1.0/" + + +This equates to a POST operation to `.../zones/` to add a new zone. No connection attempt to the child zone is done when this command. It only puts an entry in the db at this point. After about 30 seconds the `ZoneManager` in the Scheduler services will attempt to talk to the child zone and get its information. + +Getting a list of child Zones +----------------------------- + +:: + + nova zone-list + + alice@novadev:~$ nova zone-list + +----+-------+-----------+--------------------------------------------+---------------------------------+ + | ID | Name | Is Active | Capabilities | API URL | + +----+-------+-----------+--------------------------------------------+---------------------------------+ + | 2 | zone1 | True | hypervisor=xenserver;kvm, os=linux;windows | http://192.168.2.108:8774/v1.0/ | + | 3 | zone2 | True | hypervisor=xenserver;kvm, os=linux;windows | http://192.168.2.115:8774/v1.0/ | + +----+-------+-----------+--------------------------------------------+---------------------------------+ + +This equates to a GET operation to `.../zones`. + +Removing a child Zone +--------------------- +:: + + nova zone-delete + +This equates to a DELETE call to `.../zones/N`. The Zone with ID=N will be removed. This will only remove the zone entry from the current (parent) Zone, no child Zones are affected. Removing a Child Zone doesn't affect any other part of the hierarchy. -- cgit From 5aa54545486ffe9d9988761576f497de9a957d47 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Sun, 29 May 2011 23:42:46 -0300 Subject: lots more --- doc/source/devref/distributed_scheduler.rst | 44 +++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index 75a4d57ce..7599f2cc5 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -25,7 +25,7 @@ This is the purpose of the Distributed Scheduler (DS). The DS utilizes the Capab So, how does this all work? -This document will explain the strategy employed by the ZoneAwareScheduler and its derivations. +This document will explain the strategy employed by the `ZoneAwareScheduler` and its derivations. You should read the Zones documentation before reading this. Costs & Weights ---------- @@ -48,19 +48,51 @@ As we explained in the Zones documentation, each Scheduler has a `ZoneManager` o Here is how it works: -1. The Compute nodes are Filtered and the remaining set are Weighted. +1. The Compute nodes are Filtered and the nodes remaining are Weighed. 1a. Filtering the hosts is a simple matter of ensuring the Compute node has ample resources (CPU, RAM, DISK, etc) to fulfil the request. -1b. Weighing of the remaining Compute nodes is performed +1b. Weighing of the remaining Compute nodes assigns a number based on their suitability for the request. 2. The same request is sent to each Child Zone and step #1 is done there too. The resulting Weighted List is returned to the parent. 3. The Parent Zone sorts and aggregates all the Weights and a final Build Plan is constructed. 4. The Build Plan is executed upon. Concurrently, Instance Create requests are sent to each of the selected Hosts, be they local or in a child zone. Child Zones may forward the requests to their Child Zones as needed. Filtering and Weighing ------------ -Filtering (excluding Compute nodes incapable of fulfilling the request) and Weighing (computing the relative "fitness" of a Compute node to fulfill the request) are very subjective operations. - - +Filtering (excluding Compute nodes incapable of fulfilling the request) and Weighing (computing the relative "fitness" of a Compute node to fulfill the request) are very subjective operations. Service Providers will probably have a very different set of filtering and weighing rules than private cloud administrators. The filtering and weighing aspects of the `ZoneAwareScheduler` are flexible and extensible. We will explain how to do this later in this document. +Requesting a new instance +------------ +To request a new instance, a call is made to `nova.compute.api.create()`. The type of instance created depends on the value of the `InstanceType` record being passed in. The `InstanceType` determines the amount of disk, cpu, ram and network required for the instance. Administrators can add new `InstanceType` records to suit their needs. For more complicated instance requests we need to go beyond the default fields in the `InstanceType` table, but we'll discuss that later. + +`nova.compute.api.create()` performs the following actions: +1. it validates all the fields passed into it. +2. it creates an entry in the `Instance` table for each instance requested +3. it puts one `run_instance` message in the scheduler queue for each instance requested +4. the schedulers pick off the messages and decide which Compute node should handle the request. +5. the `run_instance` message is forwarded to the Compute node for processing and the instance is created. +6. it returns a list of dicts representing each of the `Instance` records (even if the instance has not been activated yet). At least the `instance_id`'s are valid. + +Generally, the standard schedulers (like `ChangeScheduler` and `AvailabilityZoneScheduler`) only operate in the current Zone. They have no concept of Child Zones. + +The problem with this approach is that each request is scattered amongst each of the schedulers. If we are asking for 1000 instances, each scheduler gets the requests one-at-a-time. There is no possability of optimizing the requests to take into account all 1000 instances as a group. We call this Single-Shot vs. All-at-Once. + +For the `ZoneAwareScheduler` we need to use the All-at-Once approach. We need to consider all the hosts across all the Zones before deciding where they should reside. In order to handle this we have a new method `nova.compute.api.create_all_at_once()`. This method does things a little differently: +1. it validates all the fields passed into it. +2. it creates a single `request_id` for all of instances created. This is a UUID. +3. it creates a single `run_instance` request in the scheduler queue +4. a scheduler picks the message off the queue and works on it. +5. the scheduler sends off an OS API `POST /zones/select` command to each Child Zone. The `BODY` payload of the call contains the `request_spec`. +6. the Child Zones use the `request_spec` to compute a weighted list for each instance requested. No attempt to actually create an instance is done at this point. We're only estimating the suitability of the Zones. +7. if the Child Zone has its own Child Zone's, the `/zones/select` call will be sent down to them as well. +8. Finally, when all the estimates have bubbled back to the Zone that initiated the call, all the results are merged, sorted and processed. +9. Now the instances can be created. The initiating Zone either forwards the `run_instance` message to the local Compute node to do the work, or it issues a `POST /servers` call to the relevant Child Zone. The parameters to the Child Zone call are the same as what was passed in by the user. + +The Catch +------------- +This all seems pretty straightforward but, like most things, there's a catch. Zones are expected to operate in complete isolation from each other. Each Zone has its own AMQP service, Database and set of Nova Services. But, for security reasons Zones should never leak information about the architectural layout internally. That means Zones cannot leak information about hostnames or service IP addresses outside of its world. + +When `POST /zones/select` is called to estimate which Compute node to use, time passes until the `POST /servers` call is issued. If we only passed the Weight back from the `select` we would have to re-compute the appropriate Compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to Child Zones asking for estimates. + +Instead, we take a rather innovative approach to the problem. We encrypt all the child zone internal details and pass them back the to parent Zone. If the parent zone decides to use a child Zone for the instance it simply passes the encrypted data back to the child during the `POST /servers` call as an extra parameter. The child Zone can then decrypt the hint and go directly to the Compute node previously selected. -- cgit From c3c2c1a63c126f046457d0d61306ebe9c46af700 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 00:00:28 -0300 Subject: basic flow done --- doc/source/devref/distributed_scheduler.rst | 105 ++++------------------------ 1 file changed, 13 insertions(+), 92 deletions(-) diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index 7599f2cc5..c9aaf8c01 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -55,6 +55,8 @@ Here is how it works: 3. The Parent Zone sorts and aggregates all the Weights and a final Build Plan is constructed. 4. The Build Plan is executed upon. Concurrently, Instance Create requests are sent to each of the selected Hosts, be they local or in a child zone. Child Zones may forward the requests to their Child Zones as needed. +`ZoneAwareScheduler` by itself is not capable of handling all the provisioning itself. Derived classes are used to select which Host filtering and Weighing strategy will be used. We'll go into more detail on that later. + Filtering and Weighing ------------ Filtering (excluding Compute nodes incapable of fulfilling the request) and Weighing (computing the relative "fitness" of a Compute node to fulfill the request) are very subjective operations. Service Providers will probably have a very different set of filtering and weighing rules than private cloud administrators. The filtering and weighing aspects of the `ZoneAwareScheduler` are flexible and extensible. We will explain how to do this later in this document. @@ -77,7 +79,7 @@ The problem with this approach is that each request is scattered amongst each of For the `ZoneAwareScheduler` we need to use the All-at-Once approach. We need to consider all the hosts across all the Zones before deciding where they should reside. In order to handle this we have a new method `nova.compute.api.create_all_at_once()`. This method does things a little differently: 1. it validates all the fields passed into it. -2. it creates a single `request_id` for all of instances created. This is a UUID. +2. it creates a single `reservation_id` for all of instances created. This is a UUID. 3. it creates a single `run_instance` request in the scheduler queue 4. a scheduler picks the message off the queue and works on it. 5. the scheduler sends off an OS API `POST /zones/select` command to each Child Zone. The `BODY` payload of the call contains the `request_spec`. @@ -85,6 +87,7 @@ For the `ZoneAwareScheduler` we need to use the All-at-Once approach. We need to 7. if the Child Zone has its own Child Zone's, the `/zones/select` call will be sent down to them as well. 8. Finally, when all the estimates have bubbled back to the Zone that initiated the call, all the results are merged, sorted and processed. 9. Now the instances can be created. The initiating Zone either forwards the `run_instance` message to the local Compute node to do the work, or it issues a `POST /servers` call to the relevant Child Zone. The parameters to the Child Zone call are the same as what was passed in by the user. +10. The `reservation_id` is passed back to the caller. Later we explain how the user can check on the status of the command with this `reservation_id`. The Catch ------------- @@ -92,105 +95,23 @@ This all seems pretty straightforward but, like most things, there's a catch. Zo When `POST /zones/select` is called to estimate which Compute node to use, time passes until the `POST /servers` call is issued. If we only passed the Weight back from the `select` we would have to re-compute the appropriate Compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to Child Zones asking for estimates. -Instead, we take a rather innovative approach to the problem. We encrypt all the child zone internal details and pass them back the to parent Zone. If the parent zone decides to use a child Zone for the instance it simply passes the encrypted data back to the child during the `POST /servers` call as an extra parameter. The child Zone can then decrypt the hint and go directly to the Compute node previously selected. - - - -- -Routing between Zones is based on the Capabilities of that Zone. Capabilities are nothing more than key/value pairs. Values are multi-value, with each value separated with a semicolon (`;`). When expressed as a string they take the form: - -:: - - key=value;value;value, key=value;value;value - -Zones have Capabilities which are general to the Zone and are set via `--zone_capabilities` flag. Zones also have dynamic per-service Capabilities. Services derived from `nova.manager.SchedulerDependentManager` (such as Compute, Volume and Network) can set these capabilities by calling the `update_service_capabilities()` method on their `Manager` base class. These capabilities will be periodically sent to the Scheduler service automatically. The rate at which these updates are sent is controlled by the `--periodic_interval` flag. - -Flow within a Zone ------------------- -The brunt of the work within a Zone is done in the Scheduler Service. The Scheduler is responsible for: -- collecting capability messages from the Compute, Volume and Network nodes, -- polling the child Zones for their status and -- providing data to the Distributed Scheduler for performing load balancing calculations - -Inter-service communication within a Zone is done with RabbitMQ. Each class of Service (Compute, Volume and Network) has both a named message exchange (particular to that host) and a general message exchange (particular to that class of service). Messages sent to these exchanges are picked off in round-robin fashion. Zones introduce a new fan-out exchange per service. Messages sent to the fan-out exchange are picked up by all services of a particular class. This fan-out exchange is used by the Scheduler services to receive capability messages from the Compute, Volume and Network nodes. - -These capability messages are received by the Scheduler services and stored in the `ZoneManager` object. The SchedulerManager object has a reference to the `ZoneManager` it can use for load balancing. - -The `ZoneManager` also polls the child Zones periodically to gather their capabilities to aid in decision making. This is done via the OpenStack API `/v1.0/zones/info` REST call. This also captures the name of each child Zone. The Zone name is set via the `--zone_name` flag (and defaults to "nova"). - -Zone administrative functions ------------------------------ -Zone administrative operations are usually done using python-novaclient_ - -.. _python-novaclient: https://github.com/rackspace/python-novaclient - -In order to use the Zone operations, be sure to enable administrator operations in OpenStack API by setting the `--allow_admin_api=true` flag. - -Finally you need to enable Zone Forwarding. This will be used by the Distributed Scheduler initiative currently underway. Set `--enable_zone_routing=true` to enable this feature. - -Find out about this Zone ------------------------- -In any Zone you can find the Zone's name and capabilities with the ``nova zone-info`` command. - -:: - - alice@novadev:~$ nova zone-info - +-----------------+---------------+ - | Property | Value | - +-----------------+---------------+ - | compute_cpu | 0.7,0.7 | - | compute_disk | 123000,123000 | - | compute_network | 800,800 | - | hypervisor | xenserver | - | name | nova | - | network_cpu | 0.7,0.7 | - | network_disk | 123000,123000 | - | network_network | 800,800 | - | os | linux | - +-----------------+---------------+ - -This equates to a GET operation on `.../zones/info`. If you have no child Zones defined you'll usually only get back the default `name`, `hypervisor` and `os` capabilities. Otherwise you'll get back a tuple of min, max values for each capabilities of all the hosts of all the services running in the child zone. These take the `_ = ,` format. - -Adding a child Zone -------------------- -Any Zone can be a parent Zone. Children are associated to a Zone. The Zone where this command originates from is known as the Parent Zone. Routing is only ever conducted from a Zone to its children, never the other direction. From a parent zone you can add a child zone with the following command: - -:: - - nova zone-add - -You can get the `child zone api url`, `nova api key` and `username` from the `novarc` file in the child zone. For example: - -:: +Instead, we take a rather innovative approach to the problem. We encrypt all the child zone internal details and pass them back the to parent Zone. If the parent zone decides to use a child Zone for the instance it simply passes the encrypted data back to the child during the `POST /servers` call as an extra parameter. The child Zone can then decrypt the hint and go directly to the Compute node previously selected. If the estimate isn't used, it is simply discarded by the parent. - export NOVA_API_KEY="3bd1af06-6435-4e23-a827-413b2eb86934" - export NOVA_USERNAME="alice" - export NOVA_URL="http://192.168.2.120:8774/v1.0/" +In the case of nested child Zones, each Zone re-encrypts the weighted list results and passes those values to the parent. +Throughout the `nova.api.openstack.servers`, `nova.api.openstack.zones`, `nova.compute.api.create*` and `nova.scheduler.zone_aware_scheduler` code you'll see references to `blob` and `child_blob`. These are the encrypted hints about which Compute node to use. -This equates to a POST operation to `.../zones/` to add a new zone. No connection attempt to the child zone is done when this command. It only puts an entry in the db at this point. After about 30 seconds the `ZoneManager` in the Scheduler services will attempt to talk to the child zone and get its information. +Reservation ID's +--------------- -Getting a list of child Zones ------------------------------ -:: - nova zone-list - alice@novadev:~$ nova zone-list - +----+-------+-----------+--------------------------------------------+---------------------------------+ - | ID | Name | Is Active | Capabilities | API URL | - +----+-------+-----------+--------------------------------------------+---------------------------------+ - | 2 | zone1 | True | hypervisor=xenserver;kvm, os=linux;windows | http://192.168.2.108:8774/v1.0/ | - | 3 | zone2 | True | hypervisor=xenserver;kvm, os=linux;windows | http://192.168.2.115:8774/v1.0/ | - +----+-------+-----------+--------------------------------------------+---------------------------------+ +Host Filter +-------------- -This equates to a GET operation to `.../zones`. -Removing a child Zone ---------------------- -:: +Cost Scheduler Weighing +-------------- - nova zone-delete -This equates to a DELETE call to `.../zones/N`. The Zone with ID=N will be removed. This will only remove the zone entry from the current (parent) Zone, no child Zones are affected. Removing a Child Zone doesn't affect any other part of the hierarchy. -- cgit From 5101aa300b087bf57f22cb128649679e8b11051d Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 00:45:15 -0300 Subject: reservation_id's done --- doc/source/devref/distributed_scheduler.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index c9aaf8c01..402f50bee 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -104,8 +104,17 @@ Throughout the `nova.api.openstack.servers`, `nova.api.openstack.zones`, `nova.c Reservation ID's --------------- +NOTE: The features described in this section are related to the up-coming 'merge-4' branch. +The OpenStack API allows a user to list all the instances they own via the `GET /servers/` command or the details on a particular instance via `GET /servers/###`. This mechanism is usually sufficient since OS API only allows for creating one instance at a time, unlike the EC2 API which allows you to specify a quantity of instances to be created. +NOTE: currently the `GET /servers` command is not Zone-aware since all operations done in child Zones are done via a single administrative account. Therefore, asking a child Zone to `GET /servers` would return all the active instances ... and that would be bad. Later, when the Keystone Auth system is integrated with Nova, this functionality will be enabled. + +We could use the OS API 1.1 Extensions mechanism to accept a `num_instances` parameter, but this would result in a different return code. Instead of getting back an `Instance` record, we would be getting back a `reservation_id`. So, instead, we've implemented a new command `POST /zones/servers` command which is nearly identical to `POST /servers` except that it takes a `num_instances` parameter and returns a `reservation_id`. Perhaps in OS API 2.x we can unify these approaches. + +Finally, we need to give the user a way to get information on each of the instances created under this `reservation_id`. Fortunately, this is still possible with the existing `GET /servers` command, so long as we add a new optional `reservation_id` parameter. + +`python-novaclient` will be extended to support both of these changes. Host Filter -------------- -- cgit From 0cf5316131aecbac5e843282e2e2eb2acd3fc9e3 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 05:03:45 -0700 Subject: first cut complete --- doc/source/devref/distributed_scheduler.rst | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index 402f50bee..a45505640 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -119,8 +119,49 @@ Finally, we need to give the user a way to get information on each of the instan Host Filter -------------- +As we mentioned earlier, filtering hosts is a very deployment specific process. Service Providers may have a different set of criteria for filtering Compute nodes than a University. To faciliate this the `nova.scheduler.host_filter` module supports a variety of filtering strategies as well as an easy means for plugging in your own algorithms. +The filter used is determined by the `--default_host_filter` flag, which points to a Python Class. By default this flag is set to `nova.scheduler.host_filter.AllHostsFilter` which simply returns all available hosts. But there are others. + +`nova.scheduler.host_filter.InstanceTypeFilter` provides host filtering based on the memory and disk size specified in the `InstanceType` record passed into `run_instance`. +`nova.scheduler.host_filter.JSONFilter` filters hosts based on simple JSON expression grammar. Using a LISP-like JSON structure the caller can request instances based on criteria well beyond what `InstanceType` specifies. See `nova.tests.test_host_filter` for examples. + +To create your own `HostFilter` the user simply has to derive from `nova.scheduler.host_filter.HostFilter` and implement two methods: `instance_type_to_filter` and `filter_hosts`. Since Nova is currently dependent on the `InstanceType` structure, the `instance_type_to_filter` method should take an `InstanceType` and turn it into an internal data structure usable by your filter. This is for backward compatibility with existing OpenStack and EC2 API calls. If you decide the create your own call for creating instances not based on `Flavors` or `InstanceTypes` you can ignore this method. The real work is done in `filter_hosts` which must return a list of weight tuples for each appropriate host. The set of all available hosts is in the `ZoneManager` object passed into the call as well as the filter query. The weight tuple contains (``, ``) where `` is whatever you want it to be. + Cost Scheduler Weighing -------------- +Every `ZoneAwareScheduler` derivation must also override the `weigh_hosts` method. This takes the list of filtered hosts (generated by the `filter_hosts` method) and returns a list of weight dicts. The weight dicts must contain two keys: `weight` and `hostname` where `weight` is simply an integer (lower is better) and `hostname` is the name of the host. The list does not need to be sorted, this will be done by the `ZoneAwareScheduler` base class when all the results have been assembled. + +Simple Zone Aware Scheduling +-------------- +The easiest way to get started with the Zone Aware Scheduler is to use the `nova.scheduler.host_filter.HostFilterScheduler`. This scheduler uses the default Host Filter as and the `weight_hosts` method simply returns a weight of 1 for all hosts. But, from this, you can see calls being routed from Zone to Zone and follow the flow of things. + +The `--scheduler_driver` flag is how you specify the Scheduler class name. + +Flags +-------------- + +All this Zone and Distributed Scheduler stuff can seem a little daunting to configure, but it's actually not too bad. Here are some of the main flags you should set in your `nova.conf` file: + +:: + --allow_admin_api=true + --enable_zone_routing=true + --zone_name=zone1 + --build_plan_encryption_key=c286696d887c9aa0611bbb3e2025a45b + --scheduler_driver=nova.scheduler.host_filter.HostFilterScheduler + --default_host_filter=nova.scheduler.host_filter.AllHostsFilter + +`--allow_admin_api` must be set for OS API to enable the new `/zones/*` commands. +`--enable_zone_routing` must be set for OS API commands such as `create()`, `pause()` and `delete()` to get routed from Zone to Zone when looking for instances. +`--zone_name` is only required in Child Zones. The default Zone name is `nova`, but you may want to name your child Zones something useful. Duplicate Zone names are not an issue. +`build_plan_encryption_key` is the SHA-256 key for encrypting/decrypting the Host information when it leaves a Zone. Be sure to change this key for each Zone you create. Do not duplicate keys. +`scheduler_driver` is the real work horse of the operation. For Distributed Scheduler, you need to specify a class derived from `nova.scheduler.zone_aware_scheduler.ZoneAwareScheduler` +`default_host_filter` is the host filter to be used for filtering candidate Compute nodes. + +Some optional flags which are handy for debugging are: +:: + --connection_type=fake + --verbose +Using the `Fake` virtualization driver is handy when you're setting this stuff up so you're not dealing with a million possible issues at once. When things seem to working correctly, switch back to whatever hypervisor your deployment uses. -- cgit From c9b4bf8f3eb3bdb51b51b98b6f283415229c2e0e Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 11:02:55 -0700 Subject: first pass at reservation id support --- nova/api/openstack/zones.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 29b7b2279..7b495cecf 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -114,6 +114,13 @@ class Controller(common.OpenstackController): zone = api.zone_update(context, zone_id, env["zone"]) return dict(zone=_scrub_zone(zone)) + def boot(self, req): + """Creates a new server for a given user while being Zone aware.""" + reservation_id = \ + common.create(req, self.compute_api.create_all_at_once) + + return {'reservation': {'reservation_id': reservation_id}} + @check_encryption_key def select(self, req): """Returns a weighted list of costs to create instances -- cgit From d428a8e4f9dc5291cae105e13a02e993cca19350 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 15:38:29 -0700 Subject: regular boot working again --- nova/api/openstack/__init__.py | 7 +- nova/api/openstack/common.py | 3 +- nova/api/openstack/servers.py | 233 ++--------------------------------------- nova/api/openstack/zones.py | 22 +++- nova/compute/api.py | 20 ++-- 5 files changed, 47 insertions(+), 238 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index ce9e0b7ed..6862abd39 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -98,8 +98,11 @@ class APIRouter(wsgi.Router): server_members['inject_network_info'] = 'POST' mapper.resource("zone", "zones", controller=zones.Controller(), - collection={'detail': 'GET', 'info': 'GET', - 'select': 'POST'}) + collection={'detail': 'GET', + 'info': 'GET', + 'select': 'POST', + 'boot': 'POST' + }) mapper.resource("user", "users", controller=users.Controller(), collection={'detail': 'GET'}) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 32cd689ca..32a948f2d 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -23,12 +23,11 @@ import webob from nova import exception from nova import flags from nova import log as logging +from nova import utils from nova import wsgi LOG = logging.getLogger('nova.api.openstack.common') - - FLAGS = flags.FLAGS diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 0ffb66763..cbf284d60 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -23,16 +23,15 @@ from nova import compute from nova import exception from nova import flags from nova import log as logging -from nova import quota from nova import utils from nova.api.openstack import common +from nova.api.openstack import create_instance_controller as controller from nova.api.openstack import faults import nova.api.openstack.views.addresses import nova.api.openstack.views.flavors import nova.api.openstack.views.images import nova.api.openstack.views.servers from nova.auth import manager as auth_manager -from nova.compute import instance_types import nova.api.openstack from nova.scheduler import api as scheduler_api @@ -41,7 +40,7 @@ LOG = logging.getLogger('nova.api.openstack.servers') FLAGS = flags.FLAGS -class Controller(common.OpenstackController): +class Controller(controller.OpenstackCreateInstanceController): """ The Server API controller for the OpenStack API """ _serialization_metadata = { @@ -64,7 +63,6 @@ class Controller(common.OpenstackController): def __init__(self): self.compute_api = compute.API() - self._image_service = utils.import_object(FLAGS.image_service) super(Controller, self).__init__() def index(self, req): @@ -124,89 +122,18 @@ class Controller(common.OpenstackController): def create(self, req): """ Creates a new server for a given user """ - env = self._deserialize_create(req) - if not env: - return faults.Fault(exc.HTTPUnprocessableEntity()) - - context = req.environ['nova.context'] - - password = self._get_server_admin_password(env['server']) - - key_name = None - key_data = None - key_pairs = auth_manager.AuthManager.get_key_pairs(context) - if key_pairs: - key_pair = key_pairs[0] - key_name = key_pair['name'] - key_data = key_pair['public_key'] - - requested_image_id = self._image_id_from_req_data(env) - try: - image_id = common.get_image_id_from_image_hash(self._image_service, - context, requested_image_id) - except: - msg = _("Can not find requested image") - return faults.Fault(exc.HTTPBadRequest(msg)) - - kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( - req, image_id) - - personality = env['server'].get('personality') - injected_files = [] - if personality: - injected_files = self._get_injected_files(personality) - - flavor_id = self._flavor_id_from_req_data(env) - - if not 'name' in env['server']: - msg = _("Server name is not defined") - return exc.HTTPBadRequest(msg) - - zone_blob = env['server'].get('blob') - name = env['server']['name'] - self._validate_server_name(name) - name = name.strip() - - try: - inst_type = \ - instance_types.get_instance_type_by_flavor_id(flavor_id) - (inst,) = self.compute_api.create( - context, - inst_type, - image_id, - kernel_id=kernel_id, - ramdisk_id=ramdisk_id, - display_name=name, - display_description=name, - key_name=key_name, - key_data=key_data, - metadata=env['server'].get('metadata', {}), - injected_files=injected_files, - admin_password=password, - zone_blob=zone_blob) - except quota.QuotaError as error: - self._handle_quota_error(error) - - inst['instance_type'] = inst_type - inst['image_id'] = requested_image_id + extra_values, instances = \ + self.create_instance(req, self.compute_api.create) + (inst, ) = instances + for key in ['instance_type', 'image_id']: + inst[key] = extra_values[key] + builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) - server['server']['adminPass'] = password + server['server']['adminPass'] = extra_values['password'] return server - def _deserialize_create(self, request): - """ - Deserialize a create request - - Overrides normal behavior in the case of xml content - """ - if request.content_type == "application/xml": - deserializer = ServerCreateRequestXMLDeserializer() - return deserializer.deserialize(request.body) - else: - return self._deserialize(request.body, request.get_content_type()) - def _get_injected_files(self, personality): """ Create a list of injected files from the personality attribute @@ -235,22 +162,6 @@ class Controller(common.OpenstackController): injected_files.append((path, contents)) return injected_files - def _handle_quota_error(self, error): - """ - Reraise quota errors as api-specific http exceptions - """ - if error.code == "OnsetFileLimitExceeded": - expl = _("Personality file limit exceeded") - raise exc.HTTPBadRequest(explanation=expl) - if error.code == "OnsetFilePathLimitExceeded": - expl = _("Personality file path too long") - raise exc.HTTPBadRequest(explanation=expl) - if error.code == "OnsetFileContentLimitExceeded": - expl = _("Personality file content too long") - raise exc.HTTPBadRequest(explanation=expl) - # if the original error is okay, just reraise it - raise error - def _get_server_admin_password(self, server): """ Determine the admin password for a server on creation """ return utils.generate_password(16) @@ -552,45 +463,6 @@ class Controller(common.OpenstackController): error=item.error)) return dict(actions=actions) - def _get_kernel_ramdisk_from_image(self, req, image_id): - """Fetch an image from the ImageService, then if present, return the - associated kernel and ramdisk image IDs. - """ - context = req.environ['nova.context'] - image_meta = self._image_service.show(context, image_id) - # NOTE(sirp): extracted to a separate method to aid unit-testing, the - # new method doesn't need a request obj or an ImageService stub - kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( - image_meta) - return kernel_id, ramdisk_id - - @staticmethod - def _do_get_kernel_ramdisk_from_image(image_meta): - """Given an ImageService image_meta, return kernel and ramdisk image - ids if present. - - This is only valid for `ami` style images. - """ - image_id = image_meta['id'] - if image_meta['status'] != 'active': - raise exception.ImageUnacceptable(image_id=image_id, - reason=_("status is not active")) - - if image_meta.get('container_format') != 'ami': - return None, None - - try: - kernel_id = image_meta['properties']['kernel_id'] - except KeyError: - raise exception.KernelNotFoundForImage(image_id=image_id) - - try: - ramdisk_id = image_meta['properties']['ramdisk_id'] - except KeyError: - raise exception.RamdiskNotFoundForImage(image_id=image_id) - - return kernel_id, ramdisk_id - class ControllerV10(Controller): def _image_id_from_req_data(self, data): @@ -727,92 +599,5 @@ class ControllerV11(Controller): response.empty_body = True return response - def _get_server_admin_password(self, server): - """ Determine the admin password for a server on creation """ - password = server.get('adminPass') - if password is None: - return utils.generate_password(16) - if not isinstance(password, basestring) or password == '': - msg = _("Invalid adminPass") - raise exc.HTTPBadRequest(msg) - return password - def get_default_xmlns(self, req): return common.XML_NS_V11 - - -class ServerCreateRequestXMLDeserializer(object): - """ - Deserializer to handle xml-formatted server create requests. - - Handles standard server attributes as well as optional metadata - and personality attributes - """ - - def deserialize(self, string): - """Deserialize an xml-formatted server create request""" - dom = minidom.parseString(string) - server = self._extract_server(dom) - return {'server': server} - - def _extract_server(self, node): - """Marshal the server attribute of a parsed request""" - server = {} - server_node = self._find_first_child_named(node, 'server') - for attr in ["name", "imageId", "flavorId", "imageRef", "flavorRef"]: - if server_node.getAttribute(attr): - server[attr] = server_node.getAttribute(attr) - metadata = self._extract_metadata(server_node) - if metadata is not None: - server["metadata"] = metadata - personality = self._extract_personality(server_node) - if personality is not None: - server["personality"] = personality - return server - - def _extract_metadata(self, server_node): - """Marshal the metadata attribute of a parsed request""" - metadata_node = self._find_first_child_named(server_node, "metadata") - if metadata_node is None: - return None - metadata = {} - for meta_node in self._find_children_named(metadata_node, "meta"): - key = meta_node.getAttribute("key") - metadata[key] = self._extract_text(meta_node) - return metadata - - def _extract_personality(self, server_node): - """Marshal the personality attribute of a parsed request""" - personality_node = \ - self._find_first_child_named(server_node, "personality") - if personality_node is None: - return None - personality = [] - for file_node in self._find_children_named(personality_node, "file"): - item = {} - if file_node.hasAttribute("path"): - item["path"] = file_node.getAttribute("path") - item["contents"] = self._extract_text(file_node) - personality.append(item) - return personality - - def _find_first_child_named(self, parent, name): - """Search a nodes children for the first child with a given name""" - for node in parent.childNodes: - if node.nodeName == name: - return node - return None - - def _find_children_named(self, parent, name): - """Return all of a nodes children who have the given name""" - for node in parent.childNodes: - if node.nodeName == name: - yield node - - def _extract_text(self, node): - """Get the text field contained by the given node""" - if len(node.childNodes) == 1: - child = node.childNodes[0] - if child.nodeType == child.TEXT_NODE: - return child.nodeValue - return "" diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 7b495cecf..51ce315dc 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -21,7 +21,7 @@ from nova import db from nova import exception from nova import flags from nova import log as logging -from nova.api.openstack import common +from nova.api.openstack import create_instance_controller as controller from nova.scheduler import api @@ -57,7 +57,7 @@ def check_encryption_key(func): return wrapped -class Controller(common.OpenstackController): +class Controller(controller.OpenstackCreateInstanceController): _serialization_metadata = { 'application/xml': { @@ -97,17 +97,20 @@ class Controller(common.OpenstackController): return dict(zone=_scrub_zone(zone)) def delete(self, req, id): + """Delete a child zone entry.""" zone_id = int(id) api.zone_delete(req.environ['nova.context'], zone_id) return {} def create(self, req): + """Create a child zone entry.""" context = req.environ['nova.context'] env = self._deserialize(req.body, req.get_content_type()) zone = api.zone_create(context, env["zone"]) return dict(zone=_scrub_zone(zone)) def update(self, req, id): + """Update a child zone entry.""" context = req.environ['nova.context'] env = self._deserialize(req.body, req.get_content_type()) zone_id = int(id) @@ -115,11 +118,14 @@ class Controller(common.OpenstackController): return dict(zone=_scrub_zone(zone)) def boot(self, req): - """Creates a new server for a given user while being Zone aware.""" + """Creates a new server for a given user while being Zone aware. + + Returns a reservation ID (a UUID). + """ reservation_id = \ common.create(req, self.compute_api.create_all_at_once) - return {'reservation': {'reservation_id': reservation_id}} + return {'reservation_id': reservation_id} @check_encryption_key def select(self, req): @@ -144,3 +150,11 @@ class Controller(common.OpenstackController): cooked.append(dict(weight=entry['weight'], blob=cipher_text)) return cooked + + # Assume OS 1.0 functionality for these overrides. + + def _image_id_from_req_data(self, data): + return data['server']['imageId'] + + def _flavor_id_from_req_data(self, data): + return data['server']['flavorId'] diff --git a/nova/compute/api.py b/nova/compute/api.py index 52cff3d56..fc369ccd2 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -140,7 +140,8 @@ class API(base.Base): display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, - injected_files=None, admin_password=None, zone_blob=None): + injected_files=None, admin_password=None, zone_blob=None, + reservation_id=None): """Verify all the input parameters regardless of the provisioning strategy being performed.""" @@ -205,8 +206,11 @@ class API(base.Base): key_pair = db.key_pair_get(context, context.user_id, key_name) key_data = key_pair['public_key'] + if reservation_id is None: + reservation_id = utils.generate_uid('r') + base_options = { - 'reservation_id': utils.generate_uid('r'), + 'reservation_id': reservation_id, 'image_id': image_id, 'kernel_id': kernel_id or '', 'ramdisk_id': ramdisk_id or '', @@ -305,7 +309,8 @@ class API(base.Base): display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, - injected_files=None, admin_password=None, zone_blob=None): + injected_files=None, admin_password=None, zone_blob=None, + reservation_id=None): """Provision the instances by passing the whole request to the Scheduler for execution. Returns a Reservation ID related to the creation of all of these instances.""" @@ -317,7 +322,8 @@ class API(base.Base): display_name, display_description, key_name, key_data, security_group, availability_zone, user_data, metadata, - injected_files, admin_password, zone_blob) + injected_files, admin_password, zone_blob, + reservation_id) self._ask_scheduler_to_create_instance(context, base_options, instance_type, zone_blob, @@ -333,7 +339,8 @@ class API(base.Base): display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata={}, - injected_files=None, admin_password=None, zone_blob=None): + injected_files=None, admin_password=None, zone_blob=None, + reservation_id=None): """ Provision the instances by sending off a series of single instance requests to the Schedulers. This is fine for trival @@ -351,7 +358,8 @@ class API(base.Base): display_name, display_description, key_name, key_data, security_group, availability_zone, user_data, metadata, - injected_files, admin_password, zone_blob) + injected_files, admin_password, zone_blob, + reservation_id) instances = [] LOG.debug(_("Going to run %s instances..."), num_instances) -- cgit From 318e307c268bb554d24ba441b2484790f2a08798 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 15:38:45 -0700 Subject: regular boot working again --- nova/api/openstack/create_instance_controller.py | 291 +++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 nova/api/openstack/create_instance_controller.py diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py new file mode 100644 index 000000000..52c1e444e --- /dev/null +++ b/nova/api/openstack/create_instance_controller.py @@ -0,0 +1,291 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import re +from urlparse import urlparse +from webob import exc +from xml.dom import minidom + +import webob + +from nova import exception +from nova import flags +from nova import log as logging +from nova import quota +from nova import utils +from nova import wsgi + +from nova.compute import instance_types +from nova.api.openstack import common +from nova.api.openstack import faults +from nova.auth import manager as auth_manager + + +LOG = logging.getLogger('nova.api.openstack.create_instance_controller') +FLAGS = flags.FLAGS + + +class OpenstackCreateInstanceController(common.OpenstackController): + """This is the base class for OS API Controllers that + are capable of creating instances (currently Servers and Zones). + + Once we stabilize the Zones portion of the API we may be able + to move this code back into servers.py + """ + + def __init__(self): + """We need the image service to create an instance.""" + self._image_service = utils.import_object(FLAGS.image_service) + super(OpenstackCreateInstanceController, self).__init__() + + def create_instance(self, req, create_method): + """Creates a new server for the given user. The approach + used depends on the create_method. For example, the standard + POST /server call uses compute.api.create(), while + POST /zones/server uses compute.api.create_all_at_once(). + + The problem is, both approaches return different values (i.e. + [instance dicts] vs. reservation_id). So the handling of the + return type from this method is left to the caller. + """ + env = self._deserialize_create(req) + if not env: + return faults.Fault(exc.HTTPUnprocessableEntity()) + + context = req.environ['nova.context'] + + password = self._get_server_admin_password(env['server']) + + key_name = None + key_data = None + key_pairs = auth_manager.AuthManager.get_key_pairs(context) + if key_pairs: + key_pair = key_pairs[0] + key_name = key_pair['name'] + key_data = key_pair['public_key'] + + requested_image_id = self._image_id_from_req_data(env) + try: + image_id = common.get_image_id_from_image_hash(self._image_service, + context, requested_image_id) + except: + msg = _("Can not find requested image") + return faults.Fault(exc.HTTPBadRequest(msg)) + + kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( + req, image_id) + + personality = env['server'].get('personality') + injected_files = [] + if personality: + injected_files = self._get_injected_files(personality) + + flavor_id = self._flavor_id_from_req_data(env) + + if not 'name' in env['server']: + msg = _("Server name is not defined") + return exc.HTTPBadRequest(msg) + + zone_blob = env['server'].get('blob') + reservation_id = env['server'].get('reservation_id') + name = env['server']['name'] + self._validate_server_name(name) + name = name.strip() + + inst_type = instance_types.get_instance_type_by_flavor_id(flavor_id) + extra_values = { + 'instance_type': inst_type, + 'image_id': requested_image_id, + 'password': password + } + + try: + return (extra_values, + create_method(context, + inst_type, + image_id, + kernel_id=kernel_id, + ramdisk_id=ramdisk_id, + display_name=name, + display_description=name, + key_name=key_name, + key_data=key_data, + metadata=env['server'].get('metadata', {}), + injected_files=injected_files, + admin_password=password, + zone_blob=zone_blob, + reservation_id=reservation_id + ) + ) + except quota.QuotaError as error: + self._handle_quota_error(error) + + # Let the caller deal with unhandled exceptions. + + def _handle_quota_error(self, error): + """ + Reraise quota errors as api-specific http exceptions + """ + if error.code == "OnsetFileLimitExceeded": + expl = _("Personality file limit exceeded") + raise exc.HTTPBadRequest(explanation=expl) + if error.code == "OnsetFilePathLimitExceeded": + expl = _("Personality file path too long") + raise exc.HTTPBadRequest(explanation=expl) + if error.code == "OnsetFileContentLimitExceeded": + expl = _("Personality file content too long") + raise exc.HTTPBadRequest(explanation=expl) + # if the original error is okay, just reraise it + raise error + + def _deserialize_create(self, request): + """ + Deserialize a create request + + Overrides normal behavior in the case of xml content + """ + if request.content_type == "application/xml": + deserializer = ServerCreateRequestXMLDeserializer() + return deserializer.deserialize(request.body) + else: + return self._deserialize(request.body, request.get_content_type()) + + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + password = server.get('adminPass') + if password is None: + return utils.generate_password(16) + if not isinstance(password, basestring) or password == '': + msg = _("Invalid adminPass") + raise exc.HTTPBadRequest(msg) + return password + + def _get_kernel_ramdisk_from_image(self, req, image_id): + """Fetch an image from the ImageService, then if present, return the + associated kernel and ramdisk image IDs. + """ + context = req.environ['nova.context'] + image_meta = self._image_service.show(context, image_id) + # NOTE(sirp): extracted to a separate method to aid unit-testing, the + # new method doesn't need a request obj or an ImageService stub + kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( + image_meta) + return kernel_id, ramdisk_id + + @staticmethod + def _do_get_kernel_ramdisk_from_image(image_meta): + """Given an ImageService image_meta, return kernel and ramdisk image + ids if present. + + This is only valid for `ami` style images. + """ + image_id = image_meta['id'] + if image_meta['status'] != 'active': + raise exception.ImageUnacceptable(image_id=image_id, + reason=_("status is not active")) + + if image_meta.get('container_format') != 'ami': + return None, None + + try: + kernel_id = image_meta['properties']['kernel_id'] + except KeyError: + raise exception.KernelNotFoundForImage(image_id=image_id) + + try: + ramdisk_id = image_meta['properties']['ramdisk_id'] + except KeyError: + raise exception.RamdiskNotFoundForImage(image_id=image_id) + + return kernel_id, ramdisk_id + + +class ServerCreateRequestXMLDeserializer(object): + """ + Deserializer to handle xml-formatted server create requests. + + Handles standard server attributes as well as optional metadata + and personality attributes + """ + + def deserialize(self, string): + """Deserialize an xml-formatted server create request""" + dom = minidom.parseString(string) + server = self._extract_server(dom) + return {'server': server} + + def _extract_server(self, node): + """Marshal the server attribute of a parsed request""" + server = {} + server_node = self._find_first_child_named(node, 'server') + for attr in ["name", "imageId", "flavorId", "imageRef", "flavorRef"]: + if server_node.getAttribute(attr): + server[attr] = server_node.getAttribute(attr) + metadata = self._extract_metadata(server_node) + if metadata is not None: + server["metadata"] = metadata + personality = self._extract_personality(server_node) + if personality is not None: + server["personality"] = personality + return server + + def _extract_metadata(self, server_node): + """Marshal the metadata attribute of a parsed request""" + metadata_node = self._find_first_child_named(server_node, "metadata") + if metadata_node is None: + return None + metadata = {} + for meta_node in self._find_children_named(metadata_node, "meta"): + key = meta_node.getAttribute("key") + metadata[key] = self._extract_text(meta_node) + return metadata + + def _extract_personality(self, server_node): + """Marshal the personality attribute of a parsed request""" + personality_node = \ + self._find_first_child_named(server_node, "personality") + if personality_node is None: + return None + personality = [] + for file_node in self._find_children_named(personality_node, "file"): + item = {} + if file_node.hasAttribute("path"): + item["path"] = file_node.getAttribute("path") + item["contents"] = self._extract_text(file_node) + personality.append(item) + return personality + + def _find_first_child_named(self, parent, name): + """Search a nodes children for the first child with a given name""" + for node in parent.childNodes: + if node.nodeName == name: + return node + return None + + def _find_children_named(self, parent, name): + """Return all of a nodes children who have the given name""" + for node in parent.childNodes: + if node.nodeName == name: + yield node + + def _extract_text(self, node): + """Get the text field contained by the given node""" + if len(node.childNodes) == 1: + child = node.childNodes[0] + if child.nodeType == child.TEXT_NODE: + return child.nodeValue + return "" -- cgit From 544ec189a7fddc4b4491774b62071a4884e8e895 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 30 May 2011 16:18:11 -0700 Subject: zone-boot working --- nova/api/openstack/create_instance_controller.py | 15 +++++++++++++++ nova/api/openstack/servers.py | 15 --------------- nova/api/openstack/zones.py | 12 +++++++++--- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index 52c1e444e..1c4098a08 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -52,6 +52,12 @@ class OpenstackCreateInstanceController(common.OpenstackController): self._image_service = utils.import_object(FLAGS.image_service) super(OpenstackCreateInstanceController, self).__init__() + def _image_id_from_req_data(self, data): + raise NotImplementedError() + + def _flavor_id_from_req_data(self, data): + raise NotImplementedError() + def create_instance(self, req, create_method): """Creates a new server for the given user. The approach used depends on the create_method. For example, the standard @@ -164,6 +170,15 @@ class OpenstackCreateInstanceController(common.OpenstackController): else: return self._deserialize(request.body, request.get_content_type()) + def _validate_server_name(self, value): + if not isinstance(value, basestring): + msg = _("Server name is not a string or unicode") + raise exc.HTTPBadRequest(msg) + + if value.strip() == '': + msg = _("Server name is an empty string") + raise exc.HTTPBadRequest(msg) + def _get_server_admin_password(self, server): """ Determine the admin password for a server on creation """ password = server.get('adminPass') diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index cbf284d60..6e86c2956 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -73,12 +73,6 @@ class Controller(controller.OpenstackCreateInstanceController): """ Returns a list of server details for a given user """ return self._items(req, is_detail=True) - def _image_id_from_req_data(self, data): - raise NotImplementedError() - - def _flavor_id_from_req_data(self, data): - raise NotImplementedError() - def _get_view_builder(self, req): raise NotImplementedError() @@ -193,15 +187,6 @@ class Controller(controller.OpenstackCreateInstanceController): return exc.HTTPNoContent() - def _validate_server_name(self, value): - if not isinstance(value, basestring): - msg = _("Server name is not a string or unicode") - raise exc.HTTPBadRequest(msg) - - if value.strip() == '': - msg = _("Server name is an empty string") - raise exc.HTTPBadRequest(msg) - def _parse_update(self, context, id, inst_dict, update_dict): pass diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 51ce315dc..91531aa97 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -21,9 +21,11 @@ from nova import db from nova import exception from nova import flags from nova import log as logging -from nova.api.openstack import create_instance_controller as controller + +from nova.compute import api as compute from nova.scheduler import api +from nova.api.openstack import create_instance_controller as controller FLAGS = flags.FLAGS @@ -64,6 +66,10 @@ class Controller(controller.OpenstackCreateInstanceController): "attributes": { "zone": ["id", "api_url", "name", "capabilities"]}}} + def __init__(self): + self.compute_api = compute.API() + super(Controller, self).__init__() + def index(self, req): """Return all zones in brief""" # Ask the ZoneManager in the Scheduler for most recent data, @@ -122,8 +128,8 @@ class Controller(controller.OpenstackCreateInstanceController): Returns a reservation ID (a UUID). """ - reservation_id = \ - common.create(req, self.compute_api.create_all_at_once) + extra_values, reservation_id = \ + self.create_instance(req, self.compute_api.create_all_at_once) return {'reservation_id': reservation_id} -- cgit From 4f8c995bbeca903319bcc1f314b25be0150eea2f Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 30 May 2011 22:47:10 -0400 Subject: Updated compute api and manager to support image_refs in rebuild. --- nova/compute/api.py | 4 ++-- nova/compute/manager.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 61b45843d..e0f9ec8f3 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -533,7 +533,7 @@ class API(base.Base): """Reboot the given instance.""" self._cast_compute_message('reboot_instance', context, instance_id) - def rebuild(self, context, instance_id, image_id, metadata=None, + def rebuild(self, context, instance_id, image_ref, metadata=None, files_to_inject=None): """Rebuild the given instance with the provided metadata.""" instance = db.api.instance_get(context, instance_id) @@ -551,7 +551,7 @@ class API(base.Base): self.db.instance_update(context, instance_id, {"metadata": metadata}) rebuild_params = { - "image_id": image_id, + "image_ref": image_ref, "injected_files": files_to_inject, } diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 7c88236ba..055d15c43 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -162,9 +162,9 @@ class ComputeManager(manager.SchedulerDependentManager): data = {'launched_at': launched_at or datetime.datetime.utcnow()} self.db.instance_update(context, instance_id, data) - def _update_image_id(self, context, instance_id, image_id): + def _update_image_ref(self, context, instance_id, image_ref): """Update the image_id for the given instance.""" - data = {'image_id': image_id} + data = {'image_ref': image_ref} self.db.instance_update(context, instance_id, data) def get_console_topic(self, context, **kwargs): @@ -331,7 +331,7 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception @checks_instance_lock - def rebuild_instance(self, context, instance_id, image_id): + def rebuild_instance(self, context, instance_id, image_ref): """Destroy and re-make this instance. A 'rebuild' effectively purges all existing data from the system and @@ -339,7 +339,7 @@ class ComputeManager(manager.SchedulerDependentManager): :param context: `nova.RequestContext` object :param instance_id: Instance identifier (integer) - :param image_id: Image identifier (integer) + :param image_ref: Image identifier (href or integer) """ context = context.elevated() @@ -349,10 +349,10 @@ class ComputeManager(manager.SchedulerDependentManager): self._update_state(context, instance_id, power_state.BUILDING) self.driver.destroy(instance_ref) - instance_ref.image_id = image_id + instance_ref.image_ref = image_ref self.driver.spawn(instance_ref) - self._update_image_id(context, instance_id, image_id) + self._update_image_ref(context, instance_id, image_ref) self._update_launched_at(context, instance_id) self._update_state(context, instance_id) -- cgit From d6cd02a07ab3b66a53689fb8edbf55db03b4bff2 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 31 May 2011 08:20:40 -0400 Subject: Actually remove the _action_resize code from the base Servers controller. The V11 and V10 controllers implement these now. --- nova/api/openstack/servers.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index a3066e578..4bd7ddb14 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -333,19 +333,6 @@ class Controller(common.OpenstackController): def _action_resize(self, input_dict, req, id): return exc.HTTPNotImplemented() - """ Resizes a given instance to the flavor size requested """ - try: - if 'resize' in input_dict and 'flavorId' in input_dict['resize']: - flavor_id = input_dict['resize']['flavorId'] - self.compute_api.resize(req.environ['nova.context'], id, - flavor_id) - else: - LOG.exception(_("Missing arguments for resize")) - return faults.Fault(exc.HTTPUnprocessableEntity()) - except Exception, e: - LOG.exception(_("Error in resize %s"), e) - return faults.Fault(exc.HTTPBadRequest()) - return exc.HTTPAccepted() def _action_reboot(self, input_dict, req, id): if 'reboot' in input_dict and 'type' in input_dict['reboot']: -- cgit From fccc653376ec03e2f8d4e91449a18d62cd87902f Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 31 May 2011 06:29:38 -0700 Subject: tests passing again --- nova/api/openstack/create_instance_controller.py | 31 +++++++++--------------- nova/api/openstack/servers.py | 27 ++++++++++++++++----- nova/api/openstack/zones.py | 12 ++++++--- nova/tests/api/openstack/test_servers.py | 4 ++- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index 1c4098a08..ca076a218 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -46,7 +46,7 @@ class OpenstackCreateInstanceController(common.OpenstackController): Once we stabilize the Zones portion of the API we may be able to move this code back into servers.py """ - + def __init__(self): """We need the image service to create an instance.""" self._image_service = utils.import_object(FLAGS.image_service) @@ -58,19 +58,22 @@ class OpenstackCreateInstanceController(common.OpenstackController): def _flavor_id_from_req_data(self, data): raise NotImplementedError() + def _get_server_admin_password(self, server): + raise NotImplementedError() + def create_instance(self, req, create_method): """Creates a new server for the given user. The approach used depends on the create_method. For example, the standard - POST /server call uses compute.api.create(), while + POST /server call uses compute.api.create(), while POST /zones/server uses compute.api.create_all_at_once(). The problem is, both approaches return different values (i.e. [instance dicts] vs. reservation_id). So the handling of the - return type from this method is left to the caller. + return type from this method is left to the caller. """ env = self._deserialize_create(req) if not env: - return faults.Fault(exc.HTTPUnprocessableEntity()) + return (None, faults.Fault(exc.HTTPUnprocessableEntity())) context = req.environ['nova.context'] @@ -90,7 +93,7 @@ class OpenstackCreateInstanceController(common.OpenstackController): context, requested_image_id) except: msg = _("Can not find requested image") - return faults.Fault(exc.HTTPBadRequest(msg)) + return (None, faults.Fault(exc.HTTPBadRequest(msg))) kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) @@ -104,14 +107,14 @@ class OpenstackCreateInstanceController(common.OpenstackController): if not 'name' in env['server']: msg = _("Server name is not defined") - return exc.HTTPBadRequest(msg) - - zone_blob = env['server'].get('blob') - reservation_id = env['server'].get('reservation_id') + return (None, exc.HTTPBadRequest(msg)) name = env['server']['name'] self._validate_server_name(name) name = name.strip() + zone_blob = env['server'].get('blob') + reservation_id = env['server'].get('reservation_id') + inst_type = instance_types.get_instance_type_by_flavor_id(flavor_id) extra_values = { 'instance_type': inst_type, @@ -179,16 +182,6 @@ class OpenstackCreateInstanceController(common.OpenstackController): msg = _("Server name is an empty string") raise exc.HTTPBadRequest(msg) - def _get_server_admin_password(self, server): - """ Determine the admin password for a server on creation """ - password = server.get('adminPass') - if password is None: - return utils.generate_password(16) - if not isinstance(password, basestring) or password == '': - msg = _("Invalid adminPass") - raise exc.HTTPBadRequest(msg) - return password - def _get_kernel_ramdisk_from_image(self, req, image_id): """Fetch an image from the ImageService, then if present, return the associated kernel and ramdisk image IDs. diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 6e86c2956..223e1a191 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -116,13 +116,17 @@ class Controller(controller.OpenstackCreateInstanceController): def create(self, req): """ Creates a new server for a given user """ - extra_values, instances = \ + extra_values, result = \ self.create_instance(req, self.compute_api.create) + if extra_values is None: + return result # a Fault. + + instances = result (inst, ) = instances for key in ['instance_type', 'image_id']: inst[key] = extra_values[key] - + builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) server['server']['adminPass'] = extra_values['password'] @@ -156,10 +160,6 @@ class Controller(controller.OpenstackCreateInstanceController): injected_files.append((path, contents)) return injected_files - def _get_server_admin_password(self, server): - """ Determine the admin password for a server on creation """ - return utils.generate_password(16) - @scheduler_api.redirect_handler def update(self, req, id): """ Updates the server name or password """ @@ -491,6 +491,10 @@ class ControllerV10(Controller): response.empty_body = True return response + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + return utils.generate_password(16) + class ControllerV11(Controller): def _image_id_from_req_data(self, data): @@ -586,3 +590,14 @@ class ControllerV11(Controller): def get_default_xmlns(self, req): return common.XML_NS_V11 + + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + password = server.get('adminPass') + + if password is None: + return utils.generate_password(16) + if not isinstance(password, basestring) or password == '': + msg = _("Invalid adminPass") + raise exc.HTTPBadRequest(msg) + return password diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 91531aa97..acd01a1ff 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -26,6 +26,7 @@ from nova.compute import api as compute from nova.scheduler import api from nova.api.openstack import create_instance_controller as controller +from nova.api.openstack import common FLAGS = flags.FLAGS @@ -125,12 +126,15 @@ class Controller(controller.OpenstackCreateInstanceController): def boot(self, req): """Creates a new server for a given user while being Zone aware. - + Returns a reservation ID (a UUID). """ - extra_values, reservation_id = \ + extra_values, result = \ self.create_instance(req, self.compute_api.create_all_at_once) + if extra_values is None: + return result # a Fault. + reservation_id = result return {'reservation_id': reservation_id} @check_encryption_key @@ -156,8 +160,8 @@ class Controller(controller.OpenstackCreateInstanceController): cooked.append(dict(weight=entry['weight'], blob=cipher_text)) return cooked - - # Assume OS 1.0 functionality for these overrides. + + # Assume OS 1.0 functionality for these overrides. def _image_id_from_req_data(self, data): return data['server']['imageId'] diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index fbde5c9ce..7bad28ca8 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -31,6 +31,7 @@ from nova import flags from nova import test import nova.api.openstack from nova.api.openstack import servers +from nova.api.openstack import create_instance_controller import nova.compute.api from nova.compute import instance_types from nova.compute import power_state @@ -1380,7 +1381,8 @@ class ServersTest(test.TestCase): class TestServerCreateRequestXMLDeserializer(unittest.TestCase): def setUp(self): - self.deserializer = servers.ServerCreateRequestXMLDeserializer() + self.deserializer = \ + create_instance_controller.ServerCreateRequestXMLDeserializer() def test_minimal_request(self): serial_request = """ -- cgit From 95f103f276f6eb7decd6ebd17ff4ac106bc7222f Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 31 May 2011 11:17:35 -0400 Subject: More specific error messages for resize requests. --- nova/api/openstack/servers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 4bd7ddb14..1ec74bc2e 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -606,7 +606,7 @@ class ControllerV10(Controller): self.compute_api.resize(req.environ['nova.context'], id, flavor_id) else: - LOG.exception(_("Missing arguments for resize")) + LOG.exception(_("Missing 'flavorId' argument for resize")) return faults.Fault(exc.HTTPUnprocessableEntity()) except Exception, e: LOG.exception(_("Error in resize %s"), e) @@ -707,7 +707,7 @@ class ControllerV11(Controller): self.compute_api.resize(req.environ['nova.context'], id, flavor_id) else: - LOG.exception(_("Missing arguments for resize")) + LOG.exception(_("Missing 'flavorRef' argument for resize")) return faults.Fault(exc.HTTPUnprocessableEntity()) except Exception, e: LOG.exception(_("Error in resize %s"), e) -- cgit From 1adb96550640a65a723635f2dc98e4595f95fd52 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 31 May 2011 08:26:11 -0700 Subject: edits based on ed's feedback --- doc/source/devref/distributed_scheduler.rst | 85 +++++++++++++++-------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index a45505640..28ba20af7 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -1,3 +1,7 @@ + + + + .. Copyright 2011 OpenStack LLC All Rights Reserved. @@ -17,7 +21,7 @@ Distributed Scheduler ===== -The Scheduler is akin to a Dating Service. Requests for the creation of new instances come in and Compute nodes are selected for where the work should be performed. In a small deployment we may be happy with the currently available Change Scheduler which randomly selects a Host from the available pool. Or if you need something a little more fancy you may want to use the Availability Zone Scheduler, which selects Compute hosts from a logical partitioning of available hosts (within a single Zone). +The Scheduler is akin to a Dating Service. Requests for the creation of new instances come in and the most applicable Compute nodes are selected from a large pool of potential candidates. In a small deployment we may be happy with the currently available Change Scheduler which randomly selects a Host from the available pool. Or if you need something a little more fancy you may want to use the Availability Zone Scheduler, which selects Compute hosts from a logical partitioning of available hosts (within a single Zone). But for larger deployments a more complex scheduling algorithm is required. Additionally, if you are using Zones in your Nova setup, you'll need a scheduler that understand how to pass instance requests from Zone to Zone. @@ -29,7 +33,7 @@ This document will explain the strategy employed by the `ZoneAwareScheduler` and Costs & Weights ---------- -When deciding where to place an Instance, we compare a Weighted Cost for each Host. The Weighting, currently, is just the sum of each Cost. Costs are nothing more than integers from `0 - max_int`. Costs are computed by looking at the various Capabilities of the Host relative to the specs of the Instance being asked for. Trying to put an Instance with 8G of RAM on a Host that only has 4G remaining would have a very high cost. But putting a 512m RAM instance on an empty Host should have a low cost. +When deciding where to place an Instance, we compare a Weighted Cost for each Host. The Weighting, currently, is just the sum of each Cost. Costs are nothing more than integers from `0 - max_int`. Costs are computed by looking at the various Capabilities of the Host relative to the specs of the Instance being asked for. Trying to putting a plain vanilla instance on a high performance host should have a very high cost. But putting a vanilla instance on a vanilla Host should have a low cost. Some Costs are more esoteric. Consider a rule that says we should prefer Hosts that don't already have an instance on it that is owned by the user requesting it (to mitigate against machine failures). Here we have to look at all the other Instances on the host to compute our cost. @@ -44,73 +48,73 @@ This Weight is computed for each Instance requested. If the customer asked for 1 nova.scheduler.zone_aware_scheduler.ZoneAwareScheduler ----------- -As we explained in the Zones documentation, each Scheduler has a `ZoneManager` object that collects "Capabilities" about Child Zones and each of the Services running in the current Zone. The `ZoneAwareScheduler` uses this information to make its decisions. +As we explained in the Zones documentation, each Scheduler has a `ZoneManager` object that collects "Capabilities" about child Zones and each of the services running in the current Zone. The `ZoneAwareScheduler` uses this information to make its decisions. Here is how it works: -1. The Compute nodes are Filtered and the nodes remaining are Weighed. -1a. Filtering the hosts is a simple matter of ensuring the Compute node has ample resources (CPU, RAM, DISK, etc) to fulfil the request. -1b. Weighing of the remaining Compute nodes assigns a number based on their suitability for the request. -2. The same request is sent to each Child Zone and step #1 is done there too. The resulting Weighted List is returned to the parent. -3. The Parent Zone sorts and aggregates all the Weights and a final Build Plan is constructed. -4. The Build Plan is executed upon. Concurrently, Instance Create requests are sent to each of the selected Hosts, be they local or in a child zone. Child Zones may forward the requests to their Child Zones as needed. +1. The compute nodes are filtered and the nodes remaining are weighed. +1a. Filtering the hosts is a simple matter of ensuring the compute node has ample resources (CPU, RAM, Disk, etc) to fulfil the request. +1b. Weighing of the remaining compute nodes assigns a number based on their suitability for the request. +2. The same request is sent to each child Zone and step #1 is done there too. The resulting weighted list is returned to the parent. +3. The parent Zone sorts and aggregates all the weights and a final build plan is constructed. +4. The build plan is executed upon. Concurrently, instance create requests are sent to each of the selected hosts, be they local or in a child zone. Child Zones may forward the requests to their child Zones as needed. -`ZoneAwareScheduler` by itself is not capable of handling all the provisioning itself. Derived classes are used to select which Host filtering and Weighing strategy will be used. We'll go into more detail on that later. +`ZoneAwareScheduler` by itself is not capable of handling all the provisioning itself. Derived classes are used to select which host filtering and weighing strategy will be used. Filtering and Weighing ------------ -Filtering (excluding Compute nodes incapable of fulfilling the request) and Weighing (computing the relative "fitness" of a Compute node to fulfill the request) are very subjective operations. Service Providers will probably have a very different set of filtering and weighing rules than private cloud administrators. The filtering and weighing aspects of the `ZoneAwareScheduler` are flexible and extensible. We will explain how to do this later in this document. +The filtering (excluding compute nodes incapable of fulfilling the request) and weighing (computing the relative "fitness" of a compute node to fulfill the request) rules used are very subjective operations ... Service Providers will probably have a very different set of filtering and weighing rules than private cloud administrators. The filtering and weighing aspects of the `ZoneAwareScheduler` are flexible and extensible. Requesting a new instance ------------ -To request a new instance, a call is made to `nova.compute.api.create()`. The type of instance created depends on the value of the `InstanceType` record being passed in. The `InstanceType` determines the amount of disk, cpu, ram and network required for the instance. Administrators can add new `InstanceType` records to suit their needs. For more complicated instance requests we need to go beyond the default fields in the `InstanceType` table, but we'll discuss that later. +Prior to the `ZoneAwareScheduler`, to request a new instance, a call was made to `nova.compute.api.create()`. The type of instance created depended on the value of the `InstanceType` record being passed in. The `InstanceType` determined the amount of disk, CPU, RAM and network required for the instance. Administrators can add new `InstanceType` records to suit their needs. For more complicated instance requests we need to go beyond the default fields in the `InstanceType` table. -`nova.compute.api.create()` performs the following actions: -1. it validates all the fields passed into it. -2. it creates an entry in the `Instance` table for each instance requested -3. it puts one `run_instance` message in the scheduler queue for each instance requested -4. the schedulers pick off the messages and decide which Compute node should handle the request. -5. the `run_instance` message is forwarded to the Compute node for processing and the instance is created. -6. it returns a list of dicts representing each of the `Instance` records (even if the instance has not been activated yet). At least the `instance_id`'s are valid. +`nova.compute.api.create()` performed the following actions: +1. it validated all the fields passed into it. +2. it created an entry in the `Instance` table for each instance requested +3. it put one `run_instance` message in the scheduler queue for each instance requested +4. the schedulers picked off the messages and decided which compute node should handle the request. +5. the `run_instance` message was forwarded to the compute node for processing and the instance is created. +6. it returned a list of dicts representing each of the `Instance` records (even if the instance has not been activated yet). At least the `instance_id`s are valid. -Generally, the standard schedulers (like `ChangeScheduler` and `AvailabilityZoneScheduler`) only operate in the current Zone. They have no concept of Child Zones. +Generally, the standard schedulers (like `ChanceScheduler` and `AvailabilityZoneScheduler`) only operate in the current Zone. They have no concept of child Zones. -The problem with this approach is that each request is scattered amongst each of the schedulers. If we are asking for 1000 instances, each scheduler gets the requests one-at-a-time. There is no possability of optimizing the requests to take into account all 1000 instances as a group. We call this Single-Shot vs. All-at-Once. +The problem with this approach is each request is scattered amongst each of the schedulers. If we are asking for 1000 instances, each scheduler gets the requests one-at-a-time. There is no possability of optimizing the requests to take into account all 1000 instances as a group. We call this Single-Shot vs. All-at-Once. For the `ZoneAwareScheduler` we need to use the All-at-Once approach. We need to consider all the hosts across all the Zones before deciding where they should reside. In order to handle this we have a new method `nova.compute.api.create_all_at_once()`. This method does things a little differently: 1. it validates all the fields passed into it. 2. it creates a single `reservation_id` for all of instances created. This is a UUID. 3. it creates a single `run_instance` request in the scheduler queue 4. a scheduler picks the message off the queue and works on it. -5. the scheduler sends off an OS API `POST /zones/select` command to each Child Zone. The `BODY` payload of the call contains the `request_spec`. -6. the Child Zones use the `request_spec` to compute a weighted list for each instance requested. No attempt to actually create an instance is done at this point. We're only estimating the suitability of the Zones. -7. if the Child Zone has its own Child Zone's, the `/zones/select` call will be sent down to them as well. +5. the scheduler sends off an OS API `POST /zones/select` command to each child Zone. The `BODY` payload of the call contains the `request_spec`. +6. the child Zones use the `request_spec` to compute a weighted list for each instance requested. No attempt to actually create an instance is done at this point. We're only estimating the suitability of the Zones. +7. if the child Zone has its own child Zones, the `/zones/select` call will be sent down to them as well. 8. Finally, when all the estimates have bubbled back to the Zone that initiated the call, all the results are merged, sorted and processed. -9. Now the instances can be created. The initiating Zone either forwards the `run_instance` message to the local Compute node to do the work, or it issues a `POST /servers` call to the relevant Child Zone. The parameters to the Child Zone call are the same as what was passed in by the user. +9. Now the instances can be created. The initiating Zone either forwards the `run_instance` message to the local Compute node to do the work, or it issues a `POST /servers` call to the relevant child Zone. The parameters to the child Zone call are the same as what was passed in by the user. 10. The `reservation_id` is passed back to the caller. Later we explain how the user can check on the status of the command with this `reservation_id`. The Catch ------------- -This all seems pretty straightforward but, like most things, there's a catch. Zones are expected to operate in complete isolation from each other. Each Zone has its own AMQP service, Database and set of Nova Services. But, for security reasons Zones should never leak information about the architectural layout internally. That means Zones cannot leak information about hostnames or service IP addresses outside of its world. +This all seems pretty straightforward but, like most things, there's a catch. Zones are expected to operate in complete isolation from each other. Each Zone has its own AMQP service, database and set of Nova services. But, for security reasons Zones should never leak information about the architectural layout internally. That means Zones cannot leak information about hostnames or service IP addresses outside of its world. -When `POST /zones/select` is called to estimate which Compute node to use, time passes until the `POST /servers` call is issued. If we only passed the Weight back from the `select` we would have to re-compute the appropriate Compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to Child Zones asking for estimates. +When `POST /zones/select` is called to estimate which compute node to use, time passes until the `POST /servers` call is issued. If we only passed the weight back from the `select` we would have to re-compute the appropriate compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to child Zones asking for estimates. -Instead, we take a rather innovative approach to the problem. We encrypt all the child zone internal details and pass them back the to parent Zone. If the parent zone decides to use a child Zone for the instance it simply passes the encrypted data back to the child during the `POST /servers` call as an extra parameter. The child Zone can then decrypt the hint and go directly to the Compute node previously selected. If the estimate isn't used, it is simply discarded by the parent. +Instead, we take a rather innovative approach to the problem. We encrypt all the child zone internal details and pass them back the to parent Zone. If the parent zone decides to use a child Zone for the instance it simply passes the encrypted data back to the child during the `POST /servers` call as an extra parameter. The child Zone can then decrypt the hint and go directly to the Compute node previously selected. If the estimate isn't used, it is simply discarded by the parent. It's for this reason that it is so important that each Zone defines a unique encryption key via `--build_plan_encryption_key` In the case of nested child Zones, each Zone re-encrypts the weighted list results and passes those values to the parent. Throughout the `nova.api.openstack.servers`, `nova.api.openstack.zones`, `nova.compute.api.create*` and `nova.scheduler.zone_aware_scheduler` code you'll see references to `blob` and `child_blob`. These are the encrypted hints about which Compute node to use. -Reservation ID's +Reservation IDs --------------- NOTE: The features described in this section are related to the up-coming 'merge-4' branch. The OpenStack API allows a user to list all the instances they own via the `GET /servers/` command or the details on a particular instance via `GET /servers/###`. This mechanism is usually sufficient since OS API only allows for creating one instance at a time, unlike the EC2 API which allows you to specify a quantity of instances to be created. -NOTE: currently the `GET /servers` command is not Zone-aware since all operations done in child Zones are done via a single administrative account. Therefore, asking a child Zone to `GET /servers` would return all the active instances ... and that would be bad. Later, when the Keystone Auth system is integrated with Nova, this functionality will be enabled. +NOTE: currently the `GET /servers` command is not Zone-aware since all operations done in child Zones are done via a single administrative account. Therefore, asking a child Zone to `GET /servers` would return all the active instances ... and that would be what the user intended. Later, when the Keystone Auth system is integrated with Nova, this functionality will be enabled. -We could use the OS API 1.1 Extensions mechanism to accept a `num_instances` parameter, but this would result in a different return code. Instead of getting back an `Instance` record, we would be getting back a `reservation_id`. So, instead, we've implemented a new command `POST /zones/servers` command which is nearly identical to `POST /servers` except that it takes a `num_instances` parameter and returns a `reservation_id`. Perhaps in OS API 2.x we can unify these approaches. +We could use the OS API 1.1 Extensions mechanism to accept a `num_instances` parameter, but this would result in a different return code. Instead of getting back an `Instance` record, we would be getting back a `reservation_id`. So, instead, we've implemented a new command `POST /zones/boot` command which is nearly identical to `POST /servers` except that it takes a `num_instances` parameter and returns a `reservation_id`. Perhaps in OS API 2.x we can unify these approaches. Finally, we need to give the user a way to get information on each of the instances created under this `reservation_id`. Fortunately, this is still possible with the existing `GET /servers` command, so long as we add a new optional `reservation_id` parameter. @@ -119,14 +123,15 @@ Finally, we need to give the user a way to get information on each of the instan Host Filter -------------- -As we mentioned earlier, filtering hosts is a very deployment specific process. Service Providers may have a different set of criteria for filtering Compute nodes than a University. To faciliate this the `nova.scheduler.host_filter` module supports a variety of filtering strategies as well as an easy means for plugging in your own algorithms. +As we mentioned earlier, filtering hosts is a very deployment-specific process. Service Providers may have a different set of criteria for filtering Compute nodes than a University. To faciliate this the `nova.scheduler.host_filter` module supports a variety of filtering strategies as well as an easy means for plugging in your own algorithms. + +The filter used is determined by the `--default_host_filter` flag, which points to a Python Class. By default this flag is set to `nova.scheduler.host_filter.AllHostsFilter` which simply returns all available hosts. But there are others: -The filter used is determined by the `--default_host_filter` flag, which points to a Python Class. By default this flag is set to `nova.scheduler.host_filter.AllHostsFilter` which simply returns all available hosts. But there are others. + * `nova.scheduler.host_filter.InstanceTypeFilter` provides host filtering based on the memory and disk size specified in the `InstanceType` record passed into `run_instance`. -`nova.scheduler.host_filter.InstanceTypeFilter` provides host filtering based on the memory and disk size specified in the `InstanceType` record passed into `run_instance`. -`nova.scheduler.host_filter.JSONFilter` filters hosts based on simple JSON expression grammar. Using a LISP-like JSON structure the caller can request instances based on criteria well beyond what `InstanceType` specifies. See `nova.tests.test_host_filter` for examples. + * `nova.scheduler.host_filter.JSONFilter` filters hosts based on simple JSON expression grammar. Using a LISP-like JSON structure the caller can request instances based on criteria well beyond what `InstanceType` specifies. See `nova.tests.test_host_filter` for examples. -To create your own `HostFilter` the user simply has to derive from `nova.scheduler.host_filter.HostFilter` and implement two methods: `instance_type_to_filter` and `filter_hosts`. Since Nova is currently dependent on the `InstanceType` structure, the `instance_type_to_filter` method should take an `InstanceType` and turn it into an internal data structure usable by your filter. This is for backward compatibility with existing OpenStack and EC2 API calls. If you decide the create your own call for creating instances not based on `Flavors` or `InstanceTypes` you can ignore this method. The real work is done in `filter_hosts` which must return a list of weight tuples for each appropriate host. The set of all available hosts is in the `ZoneManager` object passed into the call as well as the filter query. The weight tuple contains (``, ``) where `` is whatever you want it to be. +To create your own `HostFilter` the user simply has to derive from `nova.scheduler.host_filter.HostFilter` and implement two methods: `instance_type_to_filter` and `filter_hosts`. Since Nova is currently dependent on the `InstanceType` structure, the `instance_type_to_filter` method should take an `InstanceType` and turn it into an internal data structure usable by your filter. This is for backward compatibility with existing OpenStack and EC2 API calls. If you decide to create your own call for creating instances not based on `Flavors` or `InstanceTypes` you can ignore this method. The real work is done in `filter_hosts` which must return a list of host tuples for each appropriate host. The set of all available hosts is in the `ZoneManager` object passed into the call as well as the filter query. The host tuple contains (``, ``) where `` is whatever you want it to be. Cost Scheduler Weighing -------------- @@ -134,9 +139,9 @@ Every `ZoneAwareScheduler` derivation must also override the `weigh_hosts` metho Simple Zone Aware Scheduling -------------- -The easiest way to get started with the Zone Aware Scheduler is to use the `nova.scheduler.host_filter.HostFilterScheduler`. This scheduler uses the default Host Filter as and the `weight_hosts` method simply returns a weight of 1 for all hosts. But, from this, you can see calls being routed from Zone to Zone and follow the flow of things. +The easiest way to get started with the `ZoneAwareScheduler` is to use the `nova.scheduler.host_filter.HostFilterScheduler`. This scheduler uses the default Host Filter as and the `weight_hosts` method simply returns a weight of 1 for all hosts. But, from this, you can see calls being routed from Zone to Zone and follow the flow of things. -The `--scheduler_driver` flag is how you specify the Scheduler class name. +The `--scheduler_driver` flag is how you specify the scheduler class name. Flags -------------- @@ -153,9 +158,9 @@ All this Zone and Distributed Scheduler stuff can seem a little daunting to conf `--allow_admin_api` must be set for OS API to enable the new `/zones/*` commands. `--enable_zone_routing` must be set for OS API commands such as `create()`, `pause()` and `delete()` to get routed from Zone to Zone when looking for instances. -`--zone_name` is only required in Child Zones. The default Zone name is `nova`, but you may want to name your child Zones something useful. Duplicate Zone names are not an issue. +`--zone_name` is only required in child Zones. The default Zone name is `nova`, but you may want to name your child Zones something useful. Duplicate Zone names are not an issue. `build_plan_encryption_key` is the SHA-256 key for encrypting/decrypting the Host information when it leaves a Zone. Be sure to change this key for each Zone you create. Do not duplicate keys. -`scheduler_driver` is the real work horse of the operation. For Distributed Scheduler, you need to specify a class derived from `nova.scheduler.zone_aware_scheduler.ZoneAwareScheduler` +`scheduler_driver` is the real workhorse of the operation. For Distributed Scheduler, you need to specify a class derived from `nova.scheduler.zone_aware_scheduler.ZoneAwareScheduler`. `default_host_filter` is the host filter to be used for filtering candidate Compute nodes. Some optional flags which are handy for debugging are: -- cgit From 099c29549a70cb88a6266a5e4145f855e1862d99 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Tue, 31 May 2011 11:58:15 -0400 Subject: Handle the case when a v1.0 api tries to list servers that contain image hrefs. --- nova/api/openstack/servers.py | 12 ++++++++++-- nova/api/openstack/views/servers.py | 6 +++++- nova/exception.py | 7 ++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 7593694bd..33b677ffd 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -69,11 +69,19 @@ class Controller(common.OpenstackController): def index(self, req): """ Returns a list of server names and ids for a given user """ - return self._items(req, is_detail=False) + try: + servers = self._items(req, is_detail=False) + except exception.Invalid as err: + return exc.HTTPBadRequest(str(err)) + return servers def detail(self, req): """ Returns a list of server details for a given user """ - return self._items(req, is_detail=True) + try: + servers = self._items(req, is_detail=True) + except exception.Invalid as err: + return exc.HTTPBadRequest(str(err)) + return servers def _image_ref_from_req_data(self, data): raise NotImplementedError() diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index dd1d68ff0..595a54790 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -18,6 +18,7 @@ import hashlib import os +from nova import exception from nova.compute import power_state import nova.compute import nova.context @@ -113,7 +114,10 @@ class ViewBuilderV10(ViewBuilder): def _build_image(self, response, inst): if 'image_ref' in dict(inst): - response['imageId'] = int(inst['image_ref']) + image_ref = inst['image_ref'] + if str(image_ref).startswith('http'): + raise exception.ListingImageRefsNotSupported(); + response['imageId'] = int(image_ref) def _build_flavor(self, response, inst): if 'instance_type' in dict(inst): diff --git a/nova/exception.py b/nova/exception.py index 5b91e1cde..6ea6c3620 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -284,7 +284,12 @@ class DiskNotFound(NotFound): class InvalidImageRef(Invalid): - message = _("Invalid image ref %(image_href)s.") + message = _("Invalid image href %(image_href)s.") + + +class ListingImageRefsNotSupported(Invalid): + message = _("Some images have been stored via hrefs." + + " This version of the api does not support displaying image hrefs.") class ImageNotFound(NotFound): -- cgit From 0f7ac8903dd05d3477bad014c269470d395c879a Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 11:20:40 -0500 Subject: MySQL database tables are currently using the MyISAM engine. Created migration script nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py to change all current tables to InnoDB. --- .../versions/019_set_engine_mysql_innodb.py | 57 ---------------------- .../versions/020_set_engine_mysql_innodb.py | 57 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py deleted file mode 100644 index be7ff5abd..000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/019_set_engine_mysql_innodb.py +++ /dev/null @@ -1,57 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2011 OpenStack LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from sqlalchemy import MetaData, Table - -meta = MetaData() - -def upgrade(migrate_engine): - # Upgrade operations go here. Don't create your own engine; - # bind migrate_engine to your metadata - meta.bind = migrate_engine - if migrate_engine.name == "mysql": - migrate_engine.execute("ALTER TABLE auth_tokens Engine=InnoDB") - migrate_engine.execute("ALTER TABLE certificates Engine=InnoDB") - migrate_engine.execute("ALTER TABLE compute_nodes Engine=InnoDB") - migrate_engine.execute("ALTER TABLE console_pools Engine=InnoDB") - migrate_engine.execute("ALTER TABLE consoles Engine=InnoDB") - migrate_engine.execute("ALTER TABLE export_devices Engine=InnoDB") - migrate_engine.execute("ALTER TABLE fixed_ips Engine=InnoDB") - migrate_engine.execute("ALTER TABLE floating_ips Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instance_actions Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instance_metadata Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instance_types Engine=InnoDB") - migrate_engine.execute("ALTER TABLE instances Engine=InnoDB") - migrate_engine.execute("ALTER TABLE iscsi_targets Engine=InnoDB") - migrate_engine.execute("ALTER TABLE key_pairs Engine=InnoDB") - migrate_engine.execute("ALTER TABLE migrate_version Engine=InnoDB") - migrate_engine.execute("ALTER TABLE migrations Engine=InnoDB") - migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") - migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") - migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") - migrate_engine.execute("ALTER TABLE services Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE users Engine=InnoDB") - migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") - migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") - -def downgrade(migrate_engine): - meta.bind = migrate_engine diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py new file mode 100644 index 000000000..be7ff5abd --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py @@ -0,0 +1,57 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import MetaData, Table + +meta = MetaData() + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + if migrate_engine.name == "mysql": + migrate_engine.execute("ALTER TABLE auth_tokens Engine=InnoDB") + migrate_engine.execute("ALTER TABLE certificates Engine=InnoDB") + migrate_engine.execute("ALTER TABLE compute_nodes Engine=InnoDB") + migrate_engine.execute("ALTER TABLE console_pools Engine=InnoDB") + migrate_engine.execute("ALTER TABLE consoles Engine=InnoDB") + migrate_engine.execute("ALTER TABLE export_devices Engine=InnoDB") + migrate_engine.execute("ALTER TABLE fixed_ips Engine=InnoDB") + migrate_engine.execute("ALTER TABLE floating_ips Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_actions Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_metadata Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instance_types Engine=InnoDB") + migrate_engine.execute("ALTER TABLE instances Engine=InnoDB") + migrate_engine.execute("ALTER TABLE iscsi_targets Engine=InnoDB") + migrate_engine.execute("ALTER TABLE key_pairs Engine=InnoDB") + migrate_engine.execute("ALTER TABLE migrate_version Engine=InnoDB") + migrate_engine.execute("ALTER TABLE migrations Engine=InnoDB") + migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") + migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") + migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") + migrate_engine.execute("ALTER TABLE services Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE users Engine=InnoDB") + migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") + migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") + +def downgrade(migrate_engine): + meta.bind = migrate_engine -- cgit From 6bf9bd5f785ed4fc1ca576e5b729e75fc0a3aa27 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 11:25:38 -0500 Subject: MySQL database tables are currently using the MyISAM engine. Created migration script nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py to change all current tables to InnoDB. --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index b17c4f63e..0ce729261 100644 --- a/Authors +++ b/Authors @@ -28,6 +28,7 @@ Gabe Westmaas Hisaharu Ishii Hisaki Ohara Ilya Alekseyev +Isaku Yamahata Jason Cannavale Jason Koelker Jay Pipes -- cgit From b6e9072a89396aaf1ab616671fd427ec059a2daa Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 11:31:35 -0500 Subject: Cleaned up pep8 errors. --- Authors | 1 - .../versions/020_set_engine_mysql_innodb.py | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Authors b/Authors index 0ce729261..b17c4f63e 100644 --- a/Authors +++ b/Authors @@ -28,7 +28,6 @@ Gabe Westmaas Hisaharu Ishii Hisaki Ohara Ilya Alekseyev -Isaku Yamahata Jason Cannavale Jason Koelker Jay Pipes diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py index be7ff5abd..32126a453 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py @@ -18,6 +18,7 @@ from sqlalchemy import MetaData, Table meta = MetaData() + def upgrade(migrate_engine): # Upgrade operations go here. Don't create your own engine; # bind migrate_engine to your metadata @@ -42,16 +43,22 @@ def upgrade(migrate_engine): migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") + migrate_engine.execute("ALTER TABLE + security_group_instance_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE + security_group_rules Engine=InnoDB") migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") migrate_engine.execute("ALTER TABLE services Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE + user_project_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE + user_project_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE + user_role_association Engine=InnoDB") migrate_engine.execute("ALTER TABLE users Engine=InnoDB") migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") + def downgrade(migrate_engine): meta.bind = migrate_engine -- cgit From 51247c01f8ec3b89657c130935d039ae9fa776b0 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 11:35:13 -0500 Subject: Cleaned up text conflict. --- .../migrate_repo/versions/020_set_engine_mysql_innodb.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py index 32126a453..9b565598f 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py @@ -43,18 +43,25 @@ def upgrade(migrate_engine): migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_instance_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_group_rules Engine=InnoDB") + migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") migrate_engine.execute("ALTER TABLE services Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_project_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE user_role_association Engine=InnoDB") + migrate_engine.execute("ALTER TABLE users Engine=InnoDB") migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") -- cgit From 770c0a5ecd2e19318e5b581de1f23e4e1d3f5f9d Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Tue, 31 May 2011 12:37:36 -0400 Subject: removing semicolon --- nova/api/openstack/views/servers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 595a54790..b2352e3fd 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -116,7 +116,7 @@ class ViewBuilderV10(ViewBuilder): if 'image_ref' in dict(inst): image_ref = inst['image_ref'] if str(image_ref).startswith('http'): - raise exception.ListingImageRefsNotSupported(); + raise exception.ListingImageRefsNotSupported() response['imageId'] = int(image_ref) def _build_flavor(self, response, inst): -- cgit From e16ac0dbe6d1ca73ef6bb8f906c2dfdf2269ab6d Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 11:43:38 -0500 Subject: Cleaned up text conflict. --- Authors | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Authors b/Authors index b17c4f63e..53b336ce1 100644 --- a/Authors +++ b/Authors @@ -1,4 +1,5 @@ Alex Meade +Andrey Brindeyev Andy Smith Andy Southgate Anne Gentle @@ -16,6 +17,7 @@ Christian Berendt Chuck Short Cory Wright Dan Prince +Dave Walker David Pravec Dean Troyer Devin Carlen @@ -28,6 +30,7 @@ Gabe Westmaas Hisaharu Ishii Hisaki Ohara Ilya Alekseyev +Isaku Yamahata Jason Cannavale Jason Koelker Jay Pipes @@ -65,6 +68,7 @@ Nachi Ueno Naveed Massjouni Nirmal Ranganathan Paul Voccio +Renuka Apte Ricardo Carrillo Cruz Rick Clark Rick Harris @@ -81,6 +85,7 @@ Trey Morris Tushar Patil Vasiliy Shlykov Vishvananda Ishaya +Vivek Y S William Wolf Yoshiaki Tamura Youcef Laribi -- cgit From 1eee07811f9fb5fd29192b17610a6b2d2e6c3578 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 31 May 2011 13:34:33 -0400 Subject: added get_pagination_params function in common with tests, allow fake and local image services to accept filters, markers, and limits (but ignore them for now) --- nova/api/openstack/common.py | 31 ++++++++++++++++++++++ nova/api/openstack/images.py | 25 +++++++++++++++--- nova/image/fake.py | 4 +-- nova/image/glance.py | 10 ++++--- nova/image/local.py | 4 +-- nova/tests/api/openstack/fakes.py | 5 ++-- nova/tests/api/openstack/test_common.py | 46 +++++++++++++++++++++++++++++++++ nova/tests/image/test_glance.py | 2 +- 8 files changed, 113 insertions(+), 14 deletions(-) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 32cd689ca..69877cbce 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -36,6 +36,37 @@ XML_NS_V10 = 'http://docs.rackspacecloud.com/servers/api/v1.0' XML_NS_V11 = 'http://docs.openstack.org/compute/api/v1.1' +def get_pagination_params(request): + """ + Return marker, limit tuple from request + + @param request: `wsgi.Request` possibly containing 'marker' and 'limit' + GET variables. 'marker' is the id of the last element + the client has seen, and 'limit' is the maximum number + of items to return. If 'limit' is not specified, 0, or + > max_limit, we default to max_limit. Negative values + for either marker or limit will cause + exc.HTTPBadRequest() exceptions to be raised. + """ + try: + marker = int(request.GET.get('marker', 0)) + except ValueError: + raise webob.exc.HTTPBadRequest(_('offset param must be an integer')) + + try: + limit = int(request.GET.get('limit', 0)) + except ValueError: + raise webob.exc.HTTPBadRequest(_('limit param must be an integer')) + + if limit < 0: + raise webob.exc.HTTPBadRequest(_('limit param must be positive')) + + if marker < 0: + raise webob.exc.HTTPBadRequest(_('marker param must be positive')) + + return(marker, limit) + + def limited(items, request, max_limit=FLAGS.osapi_max_limit): """ Return a slice of items according to requested offset and limit. diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index c96b1c3e3..afe0f79de 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -74,7 +74,7 @@ class Controller(common.OpenstackController): """ context = req.environ['nova.context'] images = self._image_service.detail(context) - images = self._limited_items(images, req) + images = self._limit_items(images, req) builder = self.get_builder(req).build return dict(images=[builder(image, detail=True) for image in images]) @@ -157,5 +157,24 @@ class ControllerV11(Controller): def get_default_xmlns(self, req): return common.XML_NS_V11 - def _limit_items(self, items, req): - return common.limited_by_marker(items, req) + def index(self, req): + """Return an index listing of images available to the request. + + :param req: `wsgi.Request` object + """ + context = req.environ['nova.context'] + (marker, limit) = common.get_pagination_params(req) + images = self._image_service.index(context, marker, limit) + builder = self.get_builder(req).build + return dict(images=[builder(image, detail=False) for image in images]) + + def detail(self, req): + """Return a detailed index listing of images available to the request. + + :param req: `wsgi.Request` object. + """ + context = req.environ['nova.context'] + (marker, limit) = common.get_pagination_params(req) + images = self._image_service.detail(context, marker, limit) + builder = self.get_builder(req).build + return dict(images=[builder(image, detail=True) for image in images]) diff --git a/nova/image/fake.py b/nova/image/fake.py index b400b2adb..4aa4219fe 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -52,11 +52,11 @@ class FakeImageService(service.BaseImageService): self.create(None, image) super(FakeImageService, self).__init__() - def index(self, context): + def index(self, context, filters=None, marker=None, limit=None): """Returns list of images.""" return copy.deepcopy(self.images.values()) - def detail(self, context): + def detail(self, context, filters=None, marker=None, limit=None): """Return list of detailed image information.""" return copy.deepcopy(self.images.values()) diff --git a/nova/image/glance.py b/nova/image/glance.py index 193e37273..e084ed8ae 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -58,23 +58,25 @@ class GlanceImageService(service.BaseImageService): else: self.client = client - def index(self, context): + def index(self, context, marker=None, limit=None): """Calls out to Glance for a list of images available.""" # NOTE(sirp): We need to use `get_images_detailed` and not # `get_images` here because we need `is_public` and `properties` # included so we can filter by user filtered = [] - image_metas = self.client.get_images_detailed() + image_metas = self.client.get_images_detailed( + marker=marker, limit=limit) for image_meta in image_metas: if self._is_image_available(context, image_meta): meta_subset = utils.subset_dict(image_meta, ('id', 'name')) filtered.append(meta_subset) return filtered - def detail(self, context): + def detail(self, context, marker=None, limit=None): """Calls out to Glance for a list of detailed image information.""" filtered = [] - image_metas = self.client.get_images_detailed() + image_metas = self.client.get_images_detailed( + marker=marker, limit=limit) for image_meta in image_metas: if self._is_image_available(context, image_meta): base_image_meta = self._translate_to_base(image_meta) diff --git a/nova/image/local.py b/nova/image/local.py index 918180bae..f320cc60c 100644 --- a/nova/image/local.py +++ b/nova/image/local.py @@ -63,7 +63,7 @@ class LocalImageService(service.BaseImageService): images.append(unhexed_image_id) return images - def index(self, context): + def index(self, context, filters=None, marker=None, limit=None): filtered = [] image_metas = self.detail(context) for image_meta in image_metas: @@ -71,7 +71,7 @@ class LocalImageService(service.BaseImageService): filtered.append(meta) return filtered - def detail(self, context): + def detail(self, context, filters=None, marker=None, limit=None): images = [] for image_id in self._ids(): try: diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index bf51239e6..2e28e421c 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -166,11 +166,12 @@ def stub_out_glance(stubs, initial_fixtures=None): def __init__(self, initial_fixtures): self.fixtures = initial_fixtures or [] - def fake_get_images(self): + def fake_get_images(self, filters=None, marker=None, limit=None): return [dict(id=f['id'], name=f['name']) for f in self.fixtures] - def fake_get_images_detailed(self): + def fake_get_images_detailed(self, filters=None, + marker=None, limit=None): return copy.deepcopy(self.fixtures) def fake_get_image_meta(self, image_id): diff --git a/nova/tests/api/openstack/test_common.py b/nova/tests/api/openstack/test_common.py index 8f57c5b67..34597c7ac 100644 --- a/nova/tests/api/openstack/test_common.py +++ b/nova/tests/api/openstack/test_common.py @@ -25,6 +25,7 @@ from webob import Request from nova import test from nova.api.openstack.common import limited +from nova.api.openstack.common import get_pagination_params class LimiterTest(test.TestCase): @@ -169,3 +170,48 @@ class LimiterTest(test.TestCase): """ req = Request.blank('/?offset=-30') self.assertRaises(webob.exc.HTTPBadRequest, limited, self.tiny, req) + + +class PaginationParamsTest(test.TestCase): + """ + Unit tests for the `nova.api.openstack.common.get_pagination_params` + method which takes in a request object and returns 'marker' and 'limit' + GET params. + """ + + def test_no_params(self): + """ + Test no params. + """ + req = Request.blank('/') + self.assertEqual(get_pagination_params(req), (0, 0)) + + def test_valid_marker(self): + """ + Test valid marker param. + """ + req = Request.blank('/?marker=1') + self.assertEqual(get_pagination_params(req), (1, 0)) + + def test_invalid_marker(self): + """ + Test invalid marker param. + """ + req = Request.blank('/?marker=-2') + self.assertRaises(webob.exc.HTTPBadRequest, + get_pagination_params, req) + + def test_valid_limit(self): + """ + Test valid limit param. + """ + req = Request.blank('/?limit=10') + self.assertEqual(get_pagination_params(req), (0, 10)) + + def test_invalid_limit(self): + """ + Test invalid limit param. + """ + req = Request.blank('/?limit=-2') + self.assertRaises(webob.exc.HTTPBadRequest, + get_pagination_params, req) diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index 109905ded..041da1e13 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -34,7 +34,7 @@ class StubGlanceClient(object): def get_image_meta(self, image_id): return self.images[image_id] - def get_images_detailed(self): + def get_images_detailed(self, filters=None, marker=None, limit=None): return self.images.itervalues() def get_image(self, image_id): -- cgit From f668339effa089360c1989082c83afc35489f71e Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 31 May 2011 14:21:15 -0400 Subject: added tests for GlanceImageService --- nova/tests/api/openstack/fakes.py | 38 ++++++++++++++++-- nova/tests/api/openstack/test_images.py | 68 +++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 2e28e421c..e7006debe 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -167,12 +167,44 @@ def stub_out_glance(stubs, initial_fixtures=None): self.fixtures = initial_fixtures or [] def fake_get_images(self, filters=None, marker=None, limit=None): - return [dict(id=f['id'], name=f['name']) - for f in self.fixtures] + found = True + if marker: found = False + if limit == 0: limit = None + + fixtures = [] + count = 0 + for f in self.fixtures: + if limit and count >= limit: + break + if found: + fixtures.append(f) + count = count + 1 + if f['id'] == marker: + found = True + + return [dict(id=f['id'], name=f['name']) + for f in fixtures] def fake_get_images_detailed(self, filters=None, marker=None, limit=None): - return copy.deepcopy(self.fixtures) + found = True + if marker: found = False + if limit == 0: limit = None + + fixtures = [] + count = 0 + for f in self.fixtures: + if limit and count >= limit: + break + if found: + fixtures.append(f) + count = count + 1 + if f['id'] == marker: + found = True + + + return fixtures + def fake_get_image_meta(self, image_id): image = self._find_image(image_id) diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 82bf66e49..310fbd5b4 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -226,6 +226,74 @@ class GlanceImageServiceTest(_BaseImageServiceTests): expected = {'name': 'test image', 'properties': {}} self.assertDictMatch(self.sent_to_glance['metadata'], expected) + def test_index_default_limit(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.index(self.context) + i = 0 + for meta in image_metas: + expected = {'id': 'DONTCARE', + 'name': 'TestImage %d' % (i)} + self.assertDictMatch(meta, expected) + i = i + 1 + + def test_index_marker(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.index(self.context, marker=ids[1]) + self.assertEquals(len(image_metas), 8) + i = 2 + for meta in image_metas: + expected = {'id': 'DONTCARE', + 'name': 'TestImage %d' % (i)} + self.assertDictMatch(meta, expected) + i = i + 1 + + def test_index_limit(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.index(self.context, limit=3) + self.assertEquals(len(image_metas), 3) + + def test_index_marker_and_limit(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.index(self.context, marker=ids[3], limit=1) + self.assertEquals(len(image_metas), 1) + i = 4 + for meta in image_metas: + expected = {'id': 'DONTCARE', + 'name': 'TestImage %d' % (i)} + self.assertDictMatch(meta, expected) + i = i + 1 + + def test_detail(self): + fixture = self._make_fixture('test image') + image_id = self.service.create(self.context, fixture)['id'] + image_metas = self.service.index(self.context) + expected = [{'id': 'DONTCARE', 'name': 'test image'}] + self.assertDictListMatch(image_metas, expected) + class ImageControllerWithGlanceServiceTest(test.TestCase): """ -- cgit From f2da479b8988cd55d39e89935b10e0b348df43c9 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Tue, 31 May 2011 23:36:49 +0400 Subject: Moved everything from thread-local storage to class attributes --- nova/auth/ldapdriver.py | 38 +++++++++++--------------------------- nova/auth/manager.py | 14 +++----------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 9fe0165a1..91f412baa 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -26,7 +26,6 @@ public methods. import functools import sys -import threading from nova import exception from nova import flags @@ -106,7 +105,8 @@ class LdapDriver(object): isadmin_attribute = 'isNovaAdmin' project_attribute = 'owner' project_objectclass = 'groupOfNames' - __local = threading.local() + conn = None + mc = None def __init__(self): """Imports the LDAP module""" @@ -117,15 +117,22 @@ class LdapDriver(object): LdapDriver.project_attribute = 'projectManager' LdapDriver.project_objectclass = 'novaProject' self.__cache = None + if LdapDriver.conn is None: + LdapDriver.conn = self.ldap.initialize(FLAGS.ldap_url) + LdapDriver.conn.simple_bind_s(FLAGS.ldap_user_dn, FLAGS.ldap_password) + if LdapDriver.mc is None: + if FLAGS.memcached_servers: + import memcache + else: + from nova import fakememcache as memcache + LdapDriver.mc = memcache.Client(FLAGS.memcached_servers, debug=0) def __enter__(self): - """Creates the connection to LDAP""" # TODO(yorik-sar): Should be per-request cache, not per-driver-request self.__cache = {} return self def __exit__(self, exc_type, exc_value, traceback): - """Destroys the connection to LDAP""" self.__cache = None return False @@ -149,29 +156,6 @@ class LdapDriver(object): return inner return do_wrap - @property - def conn(self): - try: - return self.__local.conn - except AttributeError: - conn = self.ldap.initialize(FLAGS.ldap_url) - conn.simple_bind_s(FLAGS.ldap_user_dn, FLAGS.ldap_password) - self.__local.conn = conn - return conn - - @property - def mc(self): - try: - return self.__local.mc - except AttributeError: - if FLAGS.memcached_servers: - import memcache - else: - from nova import fakememcache as memcache - mc = memcache.Client(FLAGS.memcached_servers, debug=0) - self.__local.mc = mc - return mc - @sanitize @__local_cache('uid_user-%s') def get_user(self, uid): diff --git a/nova/auth/manager.py b/nova/auth/manager.py index c71f0f161..c887297f3 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -23,7 +23,6 @@ Nova authentication management import os import shutil import string # pylint: disable=W0402 -import threading import tempfile import uuid import zipfile @@ -207,7 +206,7 @@ class AuthManager(object): """ _instance = None - __local = threading.local() + mc = None def __new__(cls, *args, **kwargs): """Returns the AuthManager singleton""" @@ -224,19 +223,12 @@ class AuthManager(object): self.network_manager = utils.import_object(FLAGS.network_manager) if driver or not getattr(self, 'driver', None): self.driver = utils.import_class(driver or FLAGS.auth_driver) - - @property - def mc(self): - try: - return self.__local.mc - except AttributeError: + if AuthManager.mc is None: if FLAGS.memcached_servers: import memcache else: from nova import fakememcache as memcache - mc = memcache.Client(FLAGS.memcached_servers, debug=0) - self.__local.mc = mc - return mc + AuthManager.mc = memcache.Client(FLAGS.memcached_servers, debug=0) def authenticate(self, access, signature, params, verb='GET', server_string='127.0.0.1:8773', path='/', -- cgit From f16f55a08038c78200a490055183104fc6a9348d Mon Sep 17 00:00:00 2001 From: William Wolf Date: Tue, 31 May 2011 16:43:25 -0400 Subject: added tests for image detail requests --- nova/tests/api/openstack/test_images.py | 56 +++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 310fbd5b4..e8657683a 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -287,12 +287,56 @@ class GlanceImageServiceTest(_BaseImageServiceTests): self.assertDictMatch(meta, expected) i = i + 1 - def test_detail(self): - fixture = self._make_fixture('test image') - image_id = self.service.create(self.context, fixture)['id'] - image_metas = self.service.index(self.context) - expected = [{'id': 'DONTCARE', 'name': 'test image'}] - self.assertDictListMatch(image_metas, expected) + def test_detail_marker(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.detail(self.context, marker=ids[1]) + self.assertEquals(len(image_metas), 8) + i = 2 + for meta in image_metas: + expected = {'id': 'DONTCARE', 'status': None, + 'is_public': True, 'properties':{ + 'updated': None, 'created': None + }, + 'name': 'TestImage %d' % (i)} + self.assertDictMatch(meta, expected) + i = i + 1 + + def test_detail_limit(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.detail(self.context, limit=3) + self.assertEquals(len(image_metas), 3) + + def test_detail_marker_and_limit(self): + fixtures = [] + ids = [] + for i in range(10): + fixture = self._make_fixture('TestImage %d' % (i)) + fixtures.append(fixture) + ids.append(self.service.create(self.context, fixture)['id']) + + image_metas = self.service.detail(self.context, marker=ids[3], limit=3) + self.assertEquals(len(image_metas), 3) + i = 4 + for meta in image_metas: + expected = {'id': 'DONTCARE', 'status': None, + 'is_public': True, 'properties':{ + 'updated': None, 'created': None + }, + 'name': 'TestImage %d' % (i)} + self.assertDictMatch(meta, expected) + i = i + 1 class ImageControllerWithGlanceServiceTest(test.TestCase): -- cgit From 2010bd7f8c200a95496cc47e395a21fc9f4e278e Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 16:23:17 -0500 Subject: Cleaned up bug introduced after fixing ^Cp8 errors. --- .../versions/020_set_engine_mysql_innodb.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py index 9b565598f..960b04037 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py @@ -44,23 +44,23 @@ def upgrade(migrate_engine): migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") - migrate_engine.execute("ALTER TABLE - security_group_instance_association Engine=InnoDB") + migrate_engine.execute( + "ALTER TABLE security_group_instance_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE - security_group_rules Engine=InnoDB") + migrate_engine.execute( + "ALTER TABLE security_group_rules Engine=InnoDB") migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") migrate_engine.execute("ALTER TABLE services Engine=InnoDB") - migrate_engine.execute("ALTER TABLE - user_project_association Engine=InnoDB") + migrate_engine.execute( + "ALTER TABLE user_project_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE - user_project_role_association Engine=InnoDB") + migrate_engine.execute( + "ALTER TABLE user_project_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE - user_role_association Engine=InnoDB") + migrate_engine.execute( + "ALTER TABLE user_role_association Engine=InnoDB") migrate_engine.execute("ALTER TABLE users Engine=InnoDB") migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") -- cgit From 5922b5dc166476adf550abbbacc21e4585e53a37 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 31 May 2011 21:23:36 +0000 Subject: Fixing Scheduler Tests --- nova/tests/scheduler/test_scheduler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 54b3f80fb..b0f0e882a 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -61,7 +61,8 @@ class SchedulerTestCase(test.TestCase): """Test case for scheduler""" def setUp(self): super(SchedulerTestCase, self).setUp() - self.flags(scheduler_driver='nova.tests.test_scheduler.TestDriver') + driver = 'nova.tests.scheduler.test_scheduler.TestDriver' + self.flags(scheduler_driver=driver) def _create_compute_service(self): """Create compute-manager(ComputeNode and Service record).""" -- cgit From 75cf63108befbc4dbc7f61c36862a43defb90654 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 16:28:43 -0500 Subject: Cleaned up bug introduced after fixing pep8 errors. --- .../migrate_repo/versions/020_set_engine_mysql_innodb.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py index 960b04037..c49e37733 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py @@ -43,25 +43,18 @@ def upgrade(migrate_engine): migrate_engine.execute("ALTER TABLE networks Engine=InnoDB") migrate_engine.execute("ALTER TABLE projects Engine=InnoDB") migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB") - migrate_engine.execute( "ALTER TABLE security_group_instance_association Engine=InnoDB") - migrate_engine.execute( "ALTER TABLE security_group_rules Engine=InnoDB") - migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB") migrate_engine.execute("ALTER TABLE services Engine=InnoDB") - migrate_engine.execute( "ALTER TABLE user_project_association Engine=InnoDB") - migrate_engine.execute( "ALTER TABLE user_project_role_association Engine=InnoDB") - migrate_engine.execute( "ALTER TABLE user_role_association Engine=InnoDB") - migrate_engine.execute("ALTER TABLE users Engine=InnoDB") migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") -- cgit From abeef6b6942b05469daceac4f95ac75f5b23fda5 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 16:41:32 -0500 Subject: Added new snapshots table to InnoDB migrations. --- nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py index c49e37733..6e590479f 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/020_set_engine_mysql_innodb.py @@ -58,6 +58,7 @@ def upgrade(migrate_engine): migrate_engine.execute("ALTER TABLE users Engine=InnoDB") migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB") migrate_engine.execute("ALTER TABLE zones Engine=InnoDB") + migrate_engine.execute("ALTER TABLE snapshots Engine=InnoDB") def downgrade(migrate_engine): -- cgit From 2ff20fdde84ea80d910b6a16e83135fca1aabafa Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 16:53:30 -0500 Subject: Incremented version of migration script to reflect changes in trunk. --- dist/nova-2011.3-py2.6.egg | Bin 1563180 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 dist/nova-2011.3-py2.6.egg diff --git a/dist/nova-2011.3-py2.6.egg b/dist/nova-2011.3-py2.6.egg deleted file mode 100644 index 8a8808d31..000000000 Binary files a/dist/nova-2011.3-py2.6.egg and /dev/null differ -- cgit From beb6bf93d0bab5b50c6f0af90758e21cc68187ab Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 31 May 2011 14:56:04 -0700 Subject: basic zone-boot test in place --- nova/api/openstack/create_instance_controller.py | 3 ++- nova/api/openstack/servers.py | 4 ---- nova/api/openstack/zones.py | 1 + nova/tests/api/openstack/test_servers.py | 27 ++++++++++++++++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index ca076a218..c79638bd9 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -59,7 +59,8 @@ class OpenstackCreateInstanceController(common.OpenstackController): raise NotImplementedError() def _get_server_admin_password(self, server): - raise NotImplementedError() + """ Determine the admin password for a server on creation """ + return utils.generate_password(16) def create_instance(self, req, create_method): """Creates a new server for the given user. The approach diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 223e1a191..67b3fd23f 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -491,10 +491,6 @@ class ControllerV10(Controller): response.empty_body = True return response - def _get_server_admin_password(self, server): - """ Determine the admin password for a server on creation """ - return utils.generate_password(16) - class ControllerV11(Controller): def _image_id_from_req_data(self, data): diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index acd01a1ff..687978b08 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -129,6 +129,7 @@ class Controller(controller.OpenstackCreateInstanceController): Returns a reservation ID (a UUID). """ + print "************** IN ZONE BOOT" extra_values, result = \ self.create_instance(req, self.compute_api.create_all_at_once) if extra_values is None: diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 7bad28ca8..9d12097c8 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -218,7 +218,6 @@ class ServersTest(test.TestCase): }, ] - print res_dict['server'] self.assertEqual(res_dict['server']['links'], expected_links) def test_get_server_by_id_with_addresses_xml(self): @@ -484,7 +483,9 @@ class ServersTest(test.TestCase): self.stubs.Set(nova.db.api, 'queue_get_for', queue_get_for) self.stubs.Set(nova.network.manager.VlanManager, 'allocate_fixed_ip', fake_method) - self.stubs.Set(nova.api.openstack.servers.Controller, + self.stubs.Set( + nova.api.openstack.create_instance_controller.\ + OpenstackCreateInstanceController, "_get_kernel_ramdisk_from_image", kernel_ramdisk_mapping) self.stubs.Set(nova.api.openstack.common, "get_image_id_from_image_hash", image_id_from_hash) @@ -515,6 +516,28 @@ class ServersTest(test.TestCase): def test_create_instance(self): self._test_create_instance_helper() + def test_create_instance_via_zones(self): + """Server generated ReservationID""" + self._setup_for_create_instance() + FLAGS.allow_admin_api = True + + body = dict(server=dict( + name='server_test', imageId=3, flavorId=2, + metadata={'hello': 'world', 'open': 'stack'}, + personality={})) + req = webob.Request.blank('/v1.0/zones/boot') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + + res = req.get_response(fakes.wsgi_app()) + + reservation_id = json.loads(res.body)['reservation_id'] + self.assertEqual(res.status_int, 200) + self.assertNotEqual(reservation_id, "") + self.assertNotEqual(reservation_id, None) + self.assertTrue(len(reservation_id) > 1) + def test_create_instance_no_key_pair(self): fakes.stub_out_key_pair_funcs(self.stubs, have_key_pair=False) self._test_create_instance_helper() -- cgit From de7ae78561641bab3ba2d5783ec64acf67e96fb3 Mon Sep 17 00:00:00 2001 From: Jason Cannavale Date: Tue, 31 May 2011 16:59:30 -0500 Subject: Incremented version of migration script to reflect changes in trunk. --- nova.egg-info/PKG-INFO | 10 - nova.egg-info/SOURCES.txt | 641 ------------------------------------- nova.egg-info/dependency_links.txt | 1 - nova.egg-info/top_level.txt | 1 - 4 files changed, 653 deletions(-) delete mode 100644 nova.egg-info/PKG-INFO delete mode 100644 nova.egg-info/SOURCES.txt delete mode 100644 nova.egg-info/dependency_links.txt delete mode 100644 nova.egg-info/top_level.txt diff --git a/nova.egg-info/PKG-INFO b/nova.egg-info/PKG-INFO deleted file mode 100644 index 66fe27559..000000000 --- a/nova.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: nova -Version: 2011.3 -Summary: cloud computing fabric controller -Home-page: http://www.openstack.org/ -Author: OpenStack -Author-email: nova@lists.launchpad.net -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/nova.egg-info/SOURCES.txt b/nova.egg-info/SOURCES.txt deleted file mode 100644 index f45cd523a..000000000 --- a/nova.egg-info/SOURCES.txt +++ /dev/null @@ -1,641 +0,0 @@ -Authors -HACKING -LICENSE -MANIFEST.in -README -builddeb.sh -pylintrc -run_tests.py -run_tests.sh -setup.cfg -setup.py -bin/nova-ajax-console-proxy -bin/nova-api -bin/nova-compute -bin/nova-console -bin/nova-dhcpbridge -bin/nova-direct-api -bin/nova-import-canonical-imagestore -bin/nova-instancemonitor -bin/nova-logspool -bin/nova-manage -bin/nova-network -bin/nova-objectstore -bin/nova-scheduler -bin/nova-spoolsentry -bin/nova-vncproxy -bin/nova-volume -bin/stack -bzrplugins/novalog/__init__.py -contrib/nova.sh -contrib/boto_v6/__init__.py -contrib/boto_v6/ec2/__init__.py -contrib/boto_v6/ec2/connection.py -contrib/boto_v6/ec2/instance.py -doc/.autogenerated -doc/Makefile -doc/README.rst -doc/find_autodoc_modules.sh -doc/generate_autodoc_index.sh -doc/build/.placeholder -doc/build/html/.buildinfo -doc/ext/__init__.py -doc/ext/nova_autodoc.py -doc/ext/nova_todo.py -doc/source/cloud101.rst -doc/source/code.rst -doc/source/community.rst -doc/source/conf.py -doc/source/conf_back.py -doc/source/index.rst -doc/source/installer.rst -doc/source/livecd.rst -doc/source/nova.concepts.rst -doc/source/object.model.rst -doc/source/quickstart.rst -doc/source/service.architecture.rst -doc/source/vmwareapi_readme.rst -doc/source/_ga/layout.html -doc/source/_static/.placeholder -doc/source/_static/jquery.tweet.js -doc/source/_static/tweaks.css -doc/source/_templates/.placeholder -doc/source/_theme/layout.html -doc/source/_theme/theme.conf -doc/source/api/autoindex.rst -doc/source/api/nova..adminclient.rst -doc/source/api/nova..api.direct.rst -doc/source/api/nova..api.ec2.admin.rst -doc/source/api/nova..api.ec2.apirequest.rst -doc/source/api/nova..api.ec2.cloud.rst -doc/source/api/nova..api.ec2.metadatarequesthandler.rst -doc/source/api/nova..api.openstack.auth.rst -doc/source/api/nova..api.openstack.backup_schedules.rst -doc/source/api/nova..api.openstack.common.rst -doc/source/api/nova..api.openstack.consoles.rst -doc/source/api/nova..api.openstack.faults.rst -doc/source/api/nova..api.openstack.flavors.rst -doc/source/api/nova..api.openstack.images.rst -doc/source/api/nova..api.openstack.servers.rst -doc/source/api/nova..api.openstack.shared_ip_groups.rst -doc/source/api/nova..api.openstack.zones.rst -doc/source/api/nova..auth.dbdriver.rst -doc/source/api/nova..auth.fakeldap.rst -doc/source/api/nova..auth.ldapdriver.rst -doc/source/api/nova..auth.manager.rst -doc/source/api/nova..auth.signer.rst -doc/source/api/nova..cloudpipe.pipelib.rst -doc/source/api/nova..compute.api.rst -doc/source/api/nova..compute.instance_types.rst -doc/source/api/nova..compute.manager.rst -doc/source/api/nova..compute.monitor.rst -doc/source/api/nova..compute.power_state.rst -doc/source/api/nova..console.api.rst -doc/source/api/nova..console.fake.rst -doc/source/api/nova..console.manager.rst -doc/source/api/nova..console.xvp.rst -doc/source/api/nova..context.rst -doc/source/api/nova..crypto.rst -doc/source/api/nova..db.api.rst -doc/source/api/nova..db.base.rst -doc/source/api/nova..db.migration.rst -doc/source/api/nova..db.sqlalchemy.api.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.manage.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.001_austin.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.002_bexar.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -doc/source/api/nova..db.sqlalchemy.migrate_repo.versions.007_add_instance_types.rst -doc/source/api/nova..db.sqlalchemy.migration.rst -doc/source/api/nova..db.sqlalchemy.models.rst -doc/source/api/nova..db.sqlalchemy.session.rst -doc/source/api/nova..exception.rst -doc/source/api/nova..fakememcache.rst -doc/source/api/nova..fakerabbit.rst -doc/source/api/nova..flags.rst -doc/source/api/nova..image.glance.rst -doc/source/api/nova..image.local.rst -doc/source/api/nova..image.s3.rst -doc/source/api/nova..image.service.rst -doc/source/api/nova..log.rst -doc/source/api/nova..manager.rst -doc/source/api/nova..network.api.rst -doc/source/api/nova..network.linux_net.rst -doc/source/api/nova..network.manager.rst -doc/source/api/nova..objectstore.bucket.rst -doc/source/api/nova..objectstore.handler.rst -doc/source/api/nova..objectstore.image.rst -doc/source/api/nova..objectstore.stored.rst -doc/source/api/nova..quota.rst -doc/source/api/nova..rpc.rst -doc/source/api/nova..scheduler.chance.rst -doc/source/api/nova..scheduler.driver.rst -doc/source/api/nova..scheduler.manager.rst -doc/source/api/nova..scheduler.simple.rst -doc/source/api/nova..scheduler.zone.rst -doc/source/api/nova..service.rst -doc/source/api/nova..test.rst -doc/source/api/nova..tests.api.openstack.fakes.rst -doc/source/api/nova..tests.api.openstack.test_adminapi.rst -doc/source/api/nova..tests.api.openstack.test_api.rst -doc/source/api/nova..tests.api.openstack.test_auth.rst -doc/source/api/nova..tests.api.openstack.test_common.rst -doc/source/api/nova..tests.api.openstack.test_faults.rst -doc/source/api/nova..tests.api.openstack.test_flavors.rst -doc/source/api/nova..tests.api.openstack.test_images.rst -doc/source/api/nova..tests.api.openstack.test_ratelimiting.rst -doc/source/api/nova..tests.api.openstack.test_servers.rst -doc/source/api/nova..tests.api.openstack.test_shared_ip_groups.rst -doc/source/api/nova..tests.api.openstack.test_zones.rst -doc/source/api/nova..tests.api.test_wsgi.rst -doc/source/api/nova..tests.db.fakes.rst -doc/source/api/nova..tests.declare_flags.rst -doc/source/api/nova..tests.fake_flags.rst -doc/source/api/nova..tests.glance.stubs.rst -doc/source/api/nova..tests.hyperv_unittest.rst -doc/source/api/nova..tests.objectstore_unittest.rst -doc/source/api/nova..tests.real_flags.rst -doc/source/api/nova..tests.runtime_flags.rst -doc/source/api/nova..tests.test_access.rst -doc/source/api/nova..tests.test_api.rst -doc/source/api/nova..tests.test_auth.rst -doc/source/api/nova..tests.test_cloud.rst -doc/source/api/nova..tests.test_compute.rst -doc/source/api/nova..tests.test_console.rst -doc/source/api/nova..tests.test_direct.rst -doc/source/api/nova..tests.test_flags.rst -doc/source/api/nova..tests.test_instance_types.rst -doc/source/api/nova..tests.test_localization.rst -doc/source/api/nova..tests.test_log.rst -doc/source/api/nova..tests.test_middleware.rst -doc/source/api/nova..tests.test_misc.rst -doc/source/api/nova..tests.test_network.rst -doc/source/api/nova..tests.test_quota.rst -doc/source/api/nova..tests.test_rpc.rst -doc/source/api/nova..tests.test_scheduler.rst -doc/source/api/nova..tests.test_service.rst -doc/source/api/nova..tests.test_test.rst -doc/source/api/nova..tests.test_twistd.rst -doc/source/api/nova..tests.test_utils.rst -doc/source/api/nova..tests.test_virt.rst -doc/source/api/nova..tests.test_volume.rst -doc/source/api/nova..tests.test_xenapi.rst -doc/source/api/nova..tests.xenapi.stubs.rst -doc/source/api/nova..twistd.rst -doc/source/api/nova..utils.rst -doc/source/api/nova..version.rst -doc/source/api/nova..virt.connection.rst -doc/source/api/nova..virt.disk.rst -doc/source/api/nova..virt.fake.rst -doc/source/api/nova..virt.hyperv.rst -doc/source/api/nova..virt.images.rst -doc/source/api/nova..virt.libvirt_conn.rst -doc/source/api/nova..virt.xenapi.fake.rst -doc/source/api/nova..virt.xenapi.network_utils.rst -doc/source/api/nova..virt.xenapi.vm_utils.rst -doc/source/api/nova..virt.xenapi.vmops.rst -doc/source/api/nova..virt.xenapi.volume_utils.rst -doc/source/api/nova..virt.xenapi.volumeops.rst -doc/source/api/nova..virt.xenapi_conn.rst -doc/source/api/nova..volume.api.rst -doc/source/api/nova..volume.driver.rst -doc/source/api/nova..volume.manager.rst -doc/source/api/nova..volume.san.rst -doc/source/api/nova..wsgi.rst -doc/source/devref/addmethod.openstackapi.rst -doc/source/devref/api.rst -doc/source/devref/architecture.rst -doc/source/devref/auth.rst -doc/source/devref/cloudpipe.rst -doc/source/devref/compute.rst -doc/source/devref/database.rst -doc/source/devref/development.environment.rst -doc/source/devref/down.sh -doc/source/devref/fakes.rst -doc/source/devref/glance.rst -doc/source/devref/index.rst -doc/source/devref/interfaces -doc/source/devref/modules.rst -doc/source/devref/network.rst -doc/source/devref/nova.rst -doc/source/devref/objectstore.rst -doc/source/devref/rabbit.rst -doc/source/devref/rc.local -doc/source/devref/scheduler.rst -doc/source/devref/server.conf.template -doc/source/devref/services.rst -doc/source/devref/up.sh -doc/source/devref/volume.rst -doc/source/devref/zone.rst -doc/source/images/NOVA_ARCH.png -doc/source/images/NOVA_ARCH.svg -doc/source/images/NOVA_ARCH_200dpi.png -doc/source/images/NOVA_ARCH_66dpi.png -doc/source/images/NOVA_clouds_A_B.png -doc/source/images/NOVA_clouds_A_B.svg -doc/source/images/NOVA_clouds_C1_C2.svg -doc/source/images/NOVA_clouds_C1_C2.svg.png -doc/source/images/Novadiagram.png -doc/source/images/cloudpipe.png -doc/source/images/fabric.png -doc/source/images/novascreens.png -doc/source/images/novashvirtually.png -doc/source/images/vmwareapi_blockdiagram.jpg -doc/source/images/rabbit/arch.png -doc/source/images/rabbit/arch.svg -doc/source/images/rabbit/flow1.png -doc/source/images/rabbit/flow1.svg -doc/source/images/rabbit/flow2.png -doc/source/images/rabbit/flow2.svg -doc/source/images/rabbit/rabt.png -doc/source/images/rabbit/rabt.svg -doc/source/images/rabbit/state.png -doc/source/man/novamanage.rst -doc/source/runnova/binaries.rst -doc/source/runnova/euca2ools.rst -doc/source/runnova/flags.rst -doc/source/runnova/getting.started.rst -doc/source/runnova/index.rst -doc/source/runnova/managing.images.rst -doc/source/runnova/managing.instance.types.rst -doc/source/runnova/managing.instances.rst -doc/source/runnova/managing.networks.rst -doc/source/runnova/managing.projects.rst -doc/source/runnova/managing.users.rst -doc/source/runnova/managingsecurity.rst -doc/source/runnova/monitoring.rst -doc/source/runnova/network.flat.rst -doc/source/runnova/network.vlan.rst -doc/source/runnova/nova.manage.rst -doc/source/runnova/vncconsole.rst -etc/nova/api-paste.ini -nova/__init__.py -nova/context.py -nova/crypto.py -nova/exception.py -nova/fakememcache.py -nova/fakerabbit.py -nova/flags.py -nova/log.py -nova/manager.py -nova/quota.py -nova/rpc.py -nova/service.py -nova/test.py -nova/twistd.py -nova/utils.py -nova/vcsversion.py -nova/version.py -nova/wsgi.py -nova.egg-info/PKG-INFO -nova.egg-info/SOURCES.txt -nova.egg-info/dependency_links.txt -nova.egg-info/top_level.txt -nova/CA/.gitignore -nova/CA/geninter.sh -nova/CA/genrootca.sh -nova/CA/genvpn.sh -nova/CA/openssl.cnf.tmpl -nova/CA/newcerts/.placeholder -nova/CA/private/.placeholder -nova/CA/projects/.gitignore -nova/CA/projects/.placeholder -nova/CA/reqs/.gitignore -nova/CA/reqs/.placeholder -nova/api/__init__.py -nova/api/direct.py -nova/api/ec2/__init__.py -nova/api/ec2/admin.py -nova/api/ec2/apirequest.py -nova/api/ec2/cloud.py -nova/api/ec2/ec2utils.py -nova/api/ec2/metadatarequesthandler.py -nova/api/openstack/__init__.py -nova/api/openstack/accounts.py -nova/api/openstack/auth.py -nova/api/openstack/backup_schedules.py -nova/api/openstack/common.py -nova/api/openstack/consoles.py -nova/api/openstack/extensions.py -nova/api/openstack/faults.py -nova/api/openstack/flavors.py -nova/api/openstack/image_metadata.py -nova/api/openstack/images.py -nova/api/openstack/ips.py -nova/api/openstack/limits.py -nova/api/openstack/notes.txt -nova/api/openstack/server_metadata.py -nova/api/openstack/servers.py -nova/api/openstack/shared_ip_groups.py -nova/api/openstack/users.py -nova/api/openstack/versions.py -nova/api/openstack/zones.py -nova/api/openstack/contrib/__init__.py -nova/api/openstack/contrib/volumes.py -nova/api/openstack/ratelimiting/__init__.py -nova/api/openstack/views/__init__.py -nova/api/openstack/views/addresses.py -nova/api/openstack/views/flavors.py -nova/api/openstack/views/images.py -nova/api/openstack/views/limits.py -nova/api/openstack/views/servers.py -nova/api/openstack/views/versions.py -nova/auth/__init__.py -nova/auth/dbdriver.py -nova/auth/fakeldap.py -nova/auth/ldapdriver.py -nova/auth/manager.py -nova/auth/nova_openldap.schema -nova/auth/nova_sun.schema -nova/auth/novarc.template -nova/auth/opendj.sh -nova/auth/openssh-lpk_openldap.schema -nova/auth/openssh-lpk_sun.schema -nova/auth/signer.py -nova/auth/slap.sh -nova/cloudpipe/__init__.py -nova/cloudpipe/bootscript.template -nova/cloudpipe/client.ovpn.template -nova/cloudpipe/pipelib.py -nova/compute/__init__.py -nova/compute/api.py -nova/compute/fakevirtinstance.xml -nova/compute/instance_types.py -nova/compute/manager.py -nova/compute/monitor.py -nova/compute/power_state.py -nova/console/__init__.py -nova/console/api.py -nova/console/fake.py -nova/console/manager.py -nova/console/vmrc.py -nova/console/vmrc_manager.py -nova/console/xvp.conf.template -nova/console/xvp.py -nova/db/__init__.py -nova/db/api.py -nova/db/base.py -nova/db/migration.py -nova/db/sqlalchemy/__init__.py -nova/db/sqlalchemy/api.py -nova/db/sqlalchemy/migration.py -nova/db/sqlalchemy/models.py -nova/db/sqlalchemy/session.py -nova/db/sqlalchemy/migrate_repo/README -nova/db/sqlalchemy/migrate_repo/__init__.py -nova/db/sqlalchemy/migrate_repo/manage.py -nova/db/sqlalchemy/migrate_repo/migrate.cfg -nova/db/sqlalchemy/migrate_repo/versions/001_austin.py -nova/db/sqlalchemy/migrate_repo/versions/002_bexar.py -nova/db/sqlalchemy/migrate_repo/versions/003_add_label_to_networks.py -nova/db/sqlalchemy/migrate_repo/versions/004_add_zone_tables.py -nova/db/sqlalchemy/migrate_repo/versions/005_add_instance_metadata.py -nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py -nova/db/sqlalchemy/migrate_repo/versions/007_add_ipv6_to_fixed_ips.py -nova/db/sqlalchemy/migrate_repo/versions/008_add_instance_types.py -nova/db/sqlalchemy/migrate_repo/versions/009_add_instance_migrations.py -nova/db/sqlalchemy/migrate_repo/versions/010_add_os_type_to_instances.py -nova/db/sqlalchemy/migrate_repo/versions/011_live_migration.py -nova/db/sqlalchemy/migrate_repo/versions/012_add_ipv6_flatmanager.py -nova/db/sqlalchemy/migrate_repo/versions/013_add_flavors_to_migrations.py -nova/db/sqlalchemy/migrate_repo/versions/014_add_instance_type_id_to_instances.py -nova/db/sqlalchemy/migrate_repo/versions/015_add_auto_assign_to_floating_ips.py -nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py -nova/db/sqlalchemy/migrate_repo/versions/017_make_instance_type_id_an_integer.py -nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py -nova/db/sqlalchemy/migrate_repo/versions/019_add_volume_snapshot_support.py -nova/db/sqlalchemy/migrate_repo/versions/020_add_snapshot_id_to_volumes.py -nova/db/sqlalchemy/migrate_repo/versions/021_set_engine_mysql_innodb.py -nova/db/sqlalchemy/migrate_repo/versions/__init__.py -nova/image/__init__.py -nova/image/fake.py -nova/image/glance.py -nova/image/local.py -nova/image/s3.py -nova/image/service.py -nova/ipv6/__init__.py -nova/ipv6/account_identifier.py -nova/ipv6/api.py -nova/ipv6/rfc2462.py -nova/network/__init__.py -nova/network/api.py -nova/network/linux_net.py -nova/network/manager.py -nova/network/vmwareapi_net.py -nova/network/xenapi_net.py -nova/notifier/__init__.py -nova/notifier/api.py -nova/notifier/log_notifier.py -nova/notifier/no_op_notifier.py -nova/notifier/rabbit_notifier.py -nova/objectstore/__init__.py -nova/objectstore/s3server.py -nova/scheduler/__init__.py -nova/scheduler/api.py -nova/scheduler/chance.py -nova/scheduler/driver.py -nova/scheduler/host_filter.py -nova/scheduler/manager.py -nova/scheduler/simple.py -nova/scheduler/zone.py -nova/scheduler/zone_aware_scheduler.py -nova/scheduler/zone_manager.py -nova/tests/__init__.py -nova/tests/declare_flags.py -nova/tests/fake_flags.py -nova/tests/fake_utils.py -nova/tests/hyperv_unittest.py -nova/tests/runtime_flags.py -nova/tests/test_access.py -nova/tests/test_api.py -nova/tests/test_auth.py -nova/tests/test_cloud.py -nova/tests/test_compute.py -nova/tests/test_console.py -nova/tests/test_crypto.py -nova/tests/test_direct.py -nova/tests/test_exception.py -nova/tests/test_flags.py -nova/tests/test_flat_network.py -nova/tests/test_host_filter.py -nova/tests/test_instance_types.py -nova/tests/test_ipv6.py -nova/tests/test_libvirt.py -nova/tests/test_localization.py -nova/tests/test_log.py -nova/tests/test_middleware.py -nova/tests/test_misc.py -nova/tests/test_network.py -nova/tests/test_notifier.py -nova/tests/test_objectstore.py -nova/tests/test_quota.py -nova/tests/test_rpc.py -nova/tests/test_scheduler.py -nova/tests/test_service.py -nova/tests/test_test.py -nova/tests/test_twistd.py -nova/tests/test_utils.py -nova/tests/test_vlan_network.py -nova/tests/test_vmwareapi.py -nova/tests/test_volume.py -nova/tests/test_xenapi.py -nova/tests/test_zone_aware_scheduler.py -nova/tests/test_zones.py -nova/tests/CA/cacert.pem -nova/tests/CA/private/cakey.pem -nova/tests/api/__init__.py -nova/tests/api/test_wsgi.py -nova/tests/api/openstack/__init__.py -nova/tests/api/openstack/common.py -nova/tests/api/openstack/fakes.py -nova/tests/api/openstack/test_accounts.py -nova/tests/api/openstack/test_adminapi.py -nova/tests/api/openstack/test_api.py -nova/tests/api/openstack/test_auth.py -nova/tests/api/openstack/test_common.py -nova/tests/api/openstack/test_extensions.py -nova/tests/api/openstack/test_faults.py -nova/tests/api/openstack/test_flavors.py -nova/tests/api/openstack/test_image_metadata.py -nova/tests/api/openstack/test_images.py -nova/tests/api/openstack/test_limits.py -nova/tests/api/openstack/test_server_metadata.py -nova/tests/api/openstack/test_servers.py -nova/tests/api/openstack/test_shared_ip_groups.py -nova/tests/api/openstack/test_users.py -nova/tests/api/openstack/test_versions.py -nova/tests/api/openstack/test_zones.py -nova/tests/api/openstack/extensions/__init__.py -nova/tests/api/openstack/extensions/foxinsocks.py -nova/tests/bundle/1mb.manifest.xml -nova/tests/bundle/1mb.no_kernel_or_ramdisk.manifest.xml -nova/tests/bundle/1mb.part.0 -nova/tests/bundle/1mb.part.1 -nova/tests/db/__init__.py -nova/tests/db/fakes.py -nova/tests/db/nova.austin.sqlite -nova/tests/glance/__init__.py -nova/tests/glance/stubs.py -nova/tests/image/__init__.py -nova/tests/image/test_glance.py -nova/tests/integrated/__init__.py -nova/tests/integrated/integrated_helpers.py -nova/tests/integrated/test_extensions.py -nova/tests/integrated/test_login.py -nova/tests/integrated/test_servers.py -nova/tests/integrated/test_volumes.py -nova/tests/integrated/test_xml.py -nova/tests/integrated/api/__init__.py -nova/tests/integrated/api/client.py -nova/tests/network/__init__.py -nova/tests/network/base.py -nova/tests/public_key/dummy.fingerprint -nova/tests/public_key/dummy.pub -nova/tests/vmwareapi/__init__.py -nova/tests/vmwareapi/db_fakes.py -nova/tests/vmwareapi/stubs.py -nova/tests/xenapi/__init__.py -nova/tests/xenapi/stubs.py -nova/virt/__init__.py -nova/virt/connection.py -nova/virt/cpuinfo.xml.template -nova/virt/disk.py -nova/virt/driver.py -nova/virt/fake.py -nova/virt/hyperv.py -nova/virt/images.py -nova/virt/interfaces.template -nova/virt/libvirt.xml.template -nova/virt/vmwareapi_conn.py -nova/virt/xenapi_conn.py -nova/virt/libvirt/__init__.py -nova/virt/libvirt/connection.py -nova/virt/libvirt/firewall.py -nova/virt/libvirt/netutils.py -nova/virt/vmwareapi/__init__.py -nova/virt/vmwareapi/error_util.py -nova/virt/vmwareapi/fake.py -nova/virt/vmwareapi/io_util.py -nova/virt/vmwareapi/network_utils.py -nova/virt/vmwareapi/read_write_util.py -nova/virt/vmwareapi/vim.py -nova/virt/vmwareapi/vim_util.py -nova/virt/vmwareapi/vm_util.py -nova/virt/vmwareapi/vmops.py -nova/virt/vmwareapi/vmware_images.py -nova/virt/xenapi/__init__.py -nova/virt/xenapi/fake.py -nova/virt/xenapi/network_utils.py -nova/virt/xenapi/vm_utils.py -nova/virt/xenapi/vmops.py -nova/virt/xenapi/volume_utils.py -nova/virt/xenapi/volumeops.py -nova/vnc/__init__.py -nova/vnc/auth.py -nova/vnc/proxy.py -nova/volume/__init__.py -nova/volume/api.py -nova/volume/driver.py -nova/volume/manager.py -nova/volume/san.py -plugins/xenserver/doc/networking.rst -plugins/xenserver/networking/etc/init.d/host-rules -plugins/xenserver/networking/etc/xensource/scripts/vif_5.6-fp1.patch -plugins/xenserver/networking/etc/xensource/scripts/vif_rules.py -plugins/xenserver/xenapi/README -plugins/xenserver/xenapi/etc/xapi.d/plugins/agent -plugins/xenserver/xenapi/etc/xapi.d/plugins/glance -plugins/xenserver/xenapi/etc/xapi.d/plugins/migration -plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore -plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py -plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost -plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py -po/ast.po -po/cs.po -po/da.po -po/de.po -po/es.po -po/it.po -po/ja.po -po/nova.pot -po/pt_BR.po -po/ru.po -po/uk.po -po/zh_CN.po -smoketests/__init__.py -smoketests/base.py -smoketests/flags.py -smoketests/openwrt-x86-ext2.image -smoketests/openwrt-x86-vmlinuz -smoketests/proxy.sh -smoketests/public_network_smoketests.py -smoketests/run_tests.py -smoketests/test_admin.py -smoketests/test_netadmin.py -smoketests/test_sysadmin.py -tools/clean-vlans -tools/euca-get-ajax-console -tools/eventlet-patch -tools/install_venv.py -tools/nova-debug -tools/pip-requires -tools/setup_iptables.sh -tools/with_venv.sh -tools/ajaxterm/README.txt -tools/ajaxterm/ajaxterm.1 -tools/ajaxterm/ajaxterm.css -tools/ajaxterm/ajaxterm.html -tools/ajaxterm/ajaxterm.js -tools/ajaxterm/ajaxterm.py -tools/ajaxterm/configure -tools/ajaxterm/configure.ajaxterm.bin -tools/ajaxterm/configure.initd.debian -tools/ajaxterm/configure.initd.gentoo -tools/ajaxterm/configure.initd.redhat -tools/ajaxterm/configure.makefile -tools/ajaxterm/qweb.py -tools/ajaxterm/sarissa.js -tools/ajaxterm/sarissa_dhtml.js -tools/esx/guest_tool.py \ No newline at end of file diff --git a/nova.egg-info/dependency_links.txt b/nova.egg-info/dependency_links.txt deleted file mode 100644 index 8b1378917..000000000 --- a/nova.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/nova.egg-info/top_level.txt b/nova.egg-info/top_level.txt deleted file mode 100644 index 31c787fdd..000000000 --- a/nova.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -nova -- cgit From db68508e1468e9d2d3469f2ea6a9ec577d1190bc Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 05:36:41 -0700 Subject: added /zones/boot reservation id tests --- nova/tests/api/openstack/test_servers.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 9d12097c8..3d5f92dea 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -538,6 +538,26 @@ class ServersTest(test.TestCase): self.assertNotEqual(reservation_id, None) self.assertTrue(len(reservation_id) > 1) + def test_create_instance_via_zones_with_resid(self): + """User supplied ReservationID""" + self._setup_for_create_instance() + FLAGS.allow_admin_api = True + + body = dict(server=dict( + name='server_test', imageId=3, flavorId=2, + metadata={'hello': 'world', 'open': 'stack'}, + personality={}, reservation_id='myresid')) + req = webob.Request.blank('/v1.0/zones/boot') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + + res = req.get_response(fakes.wsgi_app()) + + reservation_id = json.loads(res.body)['reservation_id'] + self.assertEqual(res.status_int, 200) + self.assertEqual(reservation_id, "myresid") + def test_create_instance_no_key_pair(self): fakes.stub_out_key_pair_funcs(self.stubs, have_key_pair=False) self._test_create_instance_helper() -- cgit From 5b45d5477cfff946ada581676db54fb254be6522 Mon Sep 17 00:00:00 2001 From: Lvov Maxim Date: Wed, 1 Jun 2011 16:40:19 +0400 Subject: osapi: added support for header X-Auth-Project-Id --- nova/api/openstack/auth.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index 6c6ee22a2..e220ffcc2 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -50,19 +50,21 @@ class AuthMiddleware(wsgi.Middleware): if not self.has_authentication(req): return self.authenticate(req) user = self.get_user_by_authentication(req) - accounts = self.auth.get_projects(user=user) if not user: token = req.headers["X-Auth-Token"] msg = _("%(user)s could not be found with token '%(token)s'") LOG.warn(msg % locals()) return faults.Fault(webob.exc.HTTPUnauthorized()) - if accounts: - #we are punting on this til auth is settled, - #and possibly til api v1.1 (mdragon) - account = accounts[0] - else: - return faults.Fault(webob.exc.HTTPUnauthorized()) + try: + account = req.headers["X-Auth-Project-Id"] + except KeyError: + # FIXME: It needed only for compatibility + accounts = self.auth.get_projects(user=user) + if accounts: + account = accounts[0] + else: + return faults.Fault(webob.exc.HTTPUnauthorized()) if not self.auth.is_admin(user) and \ not self.auth.is_project_member(user, account): -- cgit From 16bd0ff62dccda5eba800b2762437d5e86faaafd Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 1 Jun 2011 09:20:15 -0400 Subject: Renamed migration to 020. --- .../migrate_repo/versions/019_rename_image_ids.py | 40 ---------------------- .../migrate_repo/versions/021_rename_image_ids.py | 40 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 40 deletions(-) delete mode 100644 nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py b/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py deleted file mode 100644 index 73a5e8477..000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/019_rename_image_ids.py +++ /dev/null @@ -1,40 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2011 OpenStack LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from sqlalchemy import Column, Integer, MetaData, String, Table - - -meta = MetaData() - - -def upgrade(migrate_engine): - # Upgrade operations go here. Don't create your own engine; - # bind migrate_engine to your metadata - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True, - autoload_with=migrate_engine) - - image_id_column = instances.c.image_id - image_id_column.alter(name='image_ref') - - -def downgrade(migrate_engine): - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True, - autoload_with=migrate_engine) - - image_ref_column = instances.c.image_ref - image_ref_column.alter(name='image_id') diff --git a/nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py b/nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py new file mode 100644 index 000000000..73a5e8477 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py @@ -0,0 +1,40 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import Column, Integer, MetaData, String, Table + + +meta = MetaData() + + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True, + autoload_with=migrate_engine) + + image_id_column = instances.c.image_id + image_id_column.alter(name='image_ref') + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True, + autoload_with=migrate_engine) + + image_ref_column = instances.c.image_ref + image_ref_column.alter(name='image_id') -- cgit From b8f2f8d63608d76af41fd218dddb955bdc656354 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 10:00:15 -0400 Subject: fix filtering tests --- nova/api/openstack/images.py | 8 ++++++-- nova/image/glance.py | 4 ++-- nova/tests/api/openstack/test_images.py | 30 ++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 20e6f38ce..8afd38a4f 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -181,8 +181,10 @@ class ControllerV11(Controller): :param req: `wsgi.Request` object """ context = req.environ['nova.context'] + filters = self._get_filters(req) (marker, limit) = common.get_pagination_params(req) - images = self._image_service.index(context, marker, limit) + images = self._image_service.index( + context, filters=filters, marker=marker, limit=limit) builder = self.get_builder(req).build return dict(images=[builder(image, detail=False) for image in images]) @@ -192,7 +194,9 @@ class ControllerV11(Controller): :param req: `wsgi.Request` object. """ context = req.environ['nova.context'] + filters = self._get_filters(req) (marker, limit) = common.get_pagination_params(req) - images = self._image_service.detail(context, marker, limit) + images = self._image_service.detail( + context, filters=filters, marker=marker, limit=limit) builder = self.get_builder(req).build return dict(images=[builder(image, detail=True) for image in images]) diff --git a/nova/image/glance.py b/nova/image/glance.py index 09b2240ab..06f546027 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -58,7 +58,7 @@ class GlanceImageService(service.BaseImageService): else: self.client = client - def index(self, context, marker=None, limit=None, filters=None): + def index(self, context, filters=None, marker=None, limit=None): """Calls out to Glance for a list of images available.""" # NOTE(sirp): We need to use `get_images_detailed` and not # `get_images` here because we need `is_public` and `properties` @@ -73,7 +73,7 @@ class GlanceImageService(service.BaseImageService): filtered.append(meta_subset) return filtered - def detail(self, context, marker=None, limit=None, filters=None): + def detail(self, context, filters=None, marker=None, limit=None): """Calls out to Glance for a list of detailed image information.""" filtered = [] image_metas = self.client.get_images_detailed(marker=marker, diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index d6b01400e..c859a31de 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -826,7 +826,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'name': 'testname'} - image_service.index(context, filters).AndReturn([]) + image_service.index( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images?name=testname') @@ -840,7 +841,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'status': 'ACTIVE'} - image_service.index(context, filters).AndReturn([]) + image_service.index( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images?status=ACTIVE') @@ -854,7 +856,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'property-test': '3'} - image_service.index(context, filters).AndReturn([]) + image_service.index( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images?property-test=3') @@ -868,7 +871,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'status': 'ACTIVE'} - image_service.index(context, filters).AndReturn([]) + image_service.index( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images?status=ACTIVE&UNSUPPORTEDFILTER=testname') @@ -882,7 +886,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {} - image_service.index(context, filters).AndReturn([]) + image_service.index( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images') @@ -896,7 +901,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'name': 'testname'} - image_service.detail(context, filters).AndReturn([]) + image_service.detail( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images/detail?name=testname') @@ -910,7 +916,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'status': 'ACTIVE'} - image_service.detail(context, filters).AndReturn([]) + image_service.detail( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images/detail?status=ACTIVE') @@ -924,7 +931,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'property-test': '3'} - image_service.detail(context, filters).AndReturn([]) + image_service.detail( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images/detail?property-test=3') @@ -938,7 +946,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {'status': 'ACTIVE'} - image_service.detail(context, filters).AndReturn([]) + image_service.detail( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images/detail?status=ACTIVE&UNSUPPORTEDFILTER=testname') @@ -952,7 +961,8 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): image_service = mocker.CreateMockAnything() context = object() filters = {} - image_service.detail(context, filters).AndReturn([]) + image_service.detail( + context, filters=filters, marker=0, limit=0).AndReturn([]) mocker.ReplayAll() request = webob.Request.blank( '/v1.1/images/detail') -- cgit From 9fc8e71f1b201adc0a5e49ac3a94e22bf47596fb Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Wed, 1 Jun 2011 10:17:00 -0400 Subject: pep8 fixes --- nova/log.py | 2 +- nova/tests/test_notifier.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nova/log.py b/nova/log.py index 960598b14..6909916a1 100644 --- a/nova/log.py +++ b/nova/log.py @@ -272,7 +272,7 @@ class PublishErrorsHandler(logging.Handler): def emit(self, record): nova.notifier.api.notify('nova.error.publisher', 'error_notification', nova.notifier.api.ERROR, dict(error=record.msg)) - + def handle_exception(type, value, tb): extra = {} diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index 523f38f24..64b799a2c 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -122,12 +122,13 @@ class NotifierTestCase(test.TestCase): self.stubs.Set(nova.flags.FLAGS, 'publish_errors', True) LOG = log.getLogger('nova') LOG.setup_from_flags() - msgs = [] + def mock_cast(context, topic, data): msgs.append(data) - self.stubs.Set(nova.rpc, 'cast', mock_cast) - LOG.error('foo'); + + self.stubs.Set(nova.rpc, 'cast', mock_cast) + LOG.error('foo') self.assertEqual(1, len(msgs)) msg = msgs[0] self.assertEqual(msg['event_type'], 'error_notification') -- cgit From 3fa4ece45eea12f0923c55d87130c668bafd2751 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 10:31:53 -0400 Subject: fix pep8 issues --- nova/api/openstack/common.py | 4 ++-- nova/tests/api/openstack/fakes.py | 13 ++++++++----- nova/tests/api/openstack/test_common.py | 6 +++--- nova/tests/api/openstack/test_images.py | 16 +++++++--------- nova/tests/api/openstack/test_servers.py | 3 +-- nova/tests/integrated/test_servers.py | 9 +++------ 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 69877cbce..b0d368dfa 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -39,13 +39,13 @@ XML_NS_V11 = 'http://docs.openstack.org/compute/api/v1.1' def get_pagination_params(request): """ Return marker, limit tuple from request - + @param request: `wsgi.Request` possibly containing 'marker' and 'limit' GET variables. 'marker' is the id of the last element the client has seen, and 'limit' is the maximum number of items to return. If 'limit' is not specified, 0, or > max_limit, we default to max_limit. Negative values - for either marker or limit will cause + for either marker or limit will cause exc.HTTPBadRequest() exceptions to be raised. """ try: diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 6395280fd..bc21d66b4 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -168,8 +168,10 @@ def stub_out_glance(stubs, initial_fixtures=None): def fake_get_images(self, filters=None, marker=None, limit=None): found = True - if marker: found = False - if limit == 0: limit = None + if marker: + found = False + if limit == 0: + limit = None fixtures = [] count = 0 @@ -188,8 +190,10 @@ def stub_out_glance(stubs, initial_fixtures=None): def fake_get_images_detailed(self, filters=None, marker=None, limit=None): found = True - if marker: found = False - if limit == 0: limit = None + if marker: + found = False + if limit == 0: + limit = None fixtures = [] count = 0 @@ -202,7 +206,6 @@ def stub_out_glance(stubs, initial_fixtures=None): if f['id'] == marker: found = True - return fixtures def fake_get_image_meta(self, image_id): diff --git a/nova/tests/api/openstack/test_common.py b/nova/tests/api/openstack/test_common.py index 34597c7ac..55142ffe1 100644 --- a/nova/tests/api/openstack/test_common.py +++ b/nova/tests/api/openstack/test_common.py @@ -174,8 +174,8 @@ class LimiterTest(test.TestCase): class PaginationParamsTest(test.TestCase): """ - Unit tests for the `nova.api.openstack.common.get_pagination_params` - method which takes in a request object and returns 'marker' and 'limit' + Unit tests for the `nova.api.openstack.common.get_pagination_params` + method which takes in a request object and returns 'marker' and 'limit' GET params. """ @@ -185,7 +185,7 @@ class PaginationParamsTest(test.TestCase): """ req = Request.blank('/') self.assertEqual(get_pagination_params(req), (0, 0)) - + def test_valid_marker(self): """ Test valid marker param. diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index c859a31de..667f2866b 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -238,7 +238,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): image_metas = self.service.index(self.context) i = 0 for meta in image_metas: - expected = {'id': 'DONTCARE', + expected = {'id': 'DONTCARE', 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -255,7 +255,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): self.assertEquals(len(image_metas), 8) i = 2 for meta in image_metas: - expected = {'id': 'DONTCARE', + expected = {'id': 'DONTCARE', 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -283,7 +283,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): self.assertEquals(len(image_metas), 1) i = 4 for meta in image_metas: - expected = {'id': 'DONTCARE', + expected = {'id': 'DONTCARE', 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -301,9 +301,8 @@ class GlanceImageServiceTest(_BaseImageServiceTests): i = 2 for meta in image_metas: expected = {'id': 'DONTCARE', 'status': None, - 'is_public': True, 'properties':{ - 'updated': None, 'created': None - }, + 'is_public': True, 'properties': { + 'updated': None, 'created': None}, 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -332,9 +331,8 @@ class GlanceImageServiceTest(_BaseImageServiceTests): i = 4 for meta in image_metas: expected = {'id': 'DONTCARE', 'status': None, - 'is_public': True, 'properties':{ - 'updated': None, 'created': None - }, + 'is_public': True, 'properties': { + 'updated': None, 'created': None}, 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index fbde5c9ce..20379e2bd 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -774,8 +774,7 @@ class ServersTest(test.TestCase): def server_update(context, id, params): filtered_dict = dict( - display_name='server_test' - ) + display_name='server_test') self.assertEqual(params, filtered_dict) return filtered_dict diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index a67fa1bb5..35c6bb34f 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -194,8 +194,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah" - } + "name": "blah"} self.api.post_server_action(created_server_id, post) LOG.debug("rebuilt server: %s" % created_server) @@ -224,8 +223,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah" - } + "name": "blah"} metadata = {} for i in range(30): @@ -267,8 +265,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah" - } + "name": "blah"} metadata = {} post['rebuild']['metadata'] = metadata -- cgit From a26e21040681fd6db5a6ae862ca18ee17689854c Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Wed, 1 Jun 2011 18:32:49 +0400 Subject: Moved memcached driver import to the top of modules. --- nova/auth/ldapdriver.py | 10 ++++++---- nova/auth/manager.py | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 91f412baa..e26a360af 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -69,6 +69,12 @@ flags.DEFINE_string('ldap_developer', LOG = logging.getLogger("nova.ldapdriver") +if FLAGS.memcached_servers: + import memcache +else: + from nova import fakememcache as memcache + + # TODO(vish): make an abstract base class with the same public methods # to define a set interface for AuthDrivers. I'm delaying # creating this now because I'm expecting an auth refactor @@ -121,10 +127,6 @@ class LdapDriver(object): LdapDriver.conn = self.ldap.initialize(FLAGS.ldap_url) LdapDriver.conn.simple_bind_s(FLAGS.ldap_user_dn, FLAGS.ldap_password) if LdapDriver.mc is None: - if FLAGS.memcached_servers: - import memcache - else: - from nova import fakememcache as memcache LdapDriver.mc = memcache.Client(FLAGS.memcached_servers, debug=0) def __enter__(self): diff --git a/nova/auth/manager.py b/nova/auth/manager.py index c887297f3..98c7dd263 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -73,6 +73,12 @@ flags.DEFINE_string('auth_driver', 'nova.auth.dbdriver.DbDriver', LOG = logging.getLogger('nova.auth.manager') +if FLAGS.memcached_servers: + import memcache +else: + from nova import fakememcache as memcache + + class AuthBase(object): """Base class for objects relating to auth @@ -224,10 +230,6 @@ class AuthManager(object): if driver or not getattr(self, 'driver', None): self.driver = utils.import_class(driver or FLAGS.auth_driver) if AuthManager.mc is None: - if FLAGS.memcached_servers: - import memcache - else: - from nova import fakememcache as memcache AuthManager.mc = memcache.Client(FLAGS.memcached_servers, debug=0) def authenticate(self, access, signature, params, verb='GET', -- cgit From 4d1271821f782d4e11934d69b4ffe3aced6072eb Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Wed, 1 Jun 2011 18:34:54 +0400 Subject: PEP8 fix. --- nova/auth/ldapdriver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index e26a360af..95e31ae3b 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -125,7 +125,8 @@ class LdapDriver(object): self.__cache = None if LdapDriver.conn is None: LdapDriver.conn = self.ldap.initialize(FLAGS.ldap_url) - LdapDriver.conn.simple_bind_s(FLAGS.ldap_user_dn, FLAGS.ldap_password) + LdapDriver.conn.simple_bind_s(FLAGS.ldap_user_dn, + FLAGS.ldap_password) if LdapDriver.mc is None: LdapDriver.mc = memcache.Client(FLAGS.memcached_servers, debug=0) -- cgit From 8b716bc23ac4e5e5398db9557757621fccb08204 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 10:37:54 -0400 Subject: fix pep8 issues --- nova/compute/api.py | 3 +-- .../migrate_repo/versions/016_make_quotas_key_and_value.py | 3 +-- nova/scheduler/host_filter.py | 3 +-- nova/tests/api/openstack/test_servers.py | 3 +-- nova/tests/integrated/test_servers.py | 9 +++------ nova/tests/test_host_filter.py | 14 +++++--------- nova/tests/test_zone_aware_scheduler.py | 10 +++------- tools/install_venv.py | 2 +- 8 files changed, 16 insertions(+), 31 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index de774e807..3e991e68a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -270,8 +270,7 @@ class API(base.Base): 'instance_type': instance_type, 'filter': 'nova.scheduler.host_filter.' - 'InstanceTypeFilter' - }, + 'InstanceTypeFilter'}, "availability_zone": availability_zone, "injected_files": injected_files, "admin_password": admin_password}}) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py index a2d8192ca..1a2a6d7ce 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py @@ -160,8 +160,7 @@ def convert_backward(migrate_engine, old_quotas, new_quotas): 'project_id': quota.project_id, 'created_at': quota.created_at, 'updated_at': quota.updated_at, - quota.resource: quota.hard_limit - } + quota.resource: quota.hard_limit} else: quotas[quota.project_id]['created_at'] = earliest( quota.created_at, quotas[quota.project_id]['created_at']) diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index 4260cbf42..8827db4d4 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -226,8 +226,7 @@ class JsonFilter(HostFilter): required_disk = instance_type['local_gb'] query = ['and', ['>=', '$compute.host_memory_free', required_ram], - ['>=', '$compute.disk_available', required_disk] - ] + ['>=', '$compute.disk_available', required_disk]] return (self._full_name(), json.dumps(query)) def _parse_string(self, string, host, services): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index fbde5c9ce..20379e2bd 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -774,8 +774,7 @@ class ServersTest(test.TestCase): def server_update(context, id, params): filtered_dict = dict( - display_name='server_test' - ) + display_name='server_test') self.assertEqual(params, filtered_dict) return filtered_dict diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index a67fa1bb5..35c6bb34f 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -194,8 +194,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah" - } + "name": "blah"} self.api.post_server_action(created_server_id, post) LOG.debug("rebuilt server: %s" % created_server) @@ -224,8 +223,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah" - } + "name": "blah"} metadata = {} for i in range(30): @@ -267,8 +265,7 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah" - } + "name": "blah"} metadata = {} post['rebuild']['metadata'] = metadata diff --git a/nova/tests/test_host_filter.py b/nova/tests/test_host_filter.py index 07817cc5a..098ebff3d 100644 --- a/nova/tests/test_host_filter.py +++ b/nova/tests/test_host_filter.py @@ -133,13 +133,11 @@ class HostFilterTestCase(test.TestCase): raw = ['or', ['and', ['<', '$compute.host_memory_free', 30], - ['<', '$compute.disk_available', 300] - ], + ['<', '$compute.disk_available', 300]], ['and', ['>', '$compute.host_memory_free', 70], - ['>', '$compute.disk_available', 700] - ] - ] + ['>', '$compute.disk_available', 700]]] + cooked = json.dumps(raw) hosts = hf.filter_hosts(self.zone_manager, cooked) @@ -183,13 +181,11 @@ class HostFilterTestCase(test.TestCase): self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps([]))) self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps({}))) self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps( - ['not', True, False, True, False] - ))) + ['not', True, False, True, False]))) try: hf.filter_hosts(self.zone_manager, json.dumps( - 'not', True, False, True, False - )) + 'not', True, False, True, False)) self.fail("Should give KeyError") except KeyError, e: pass diff --git a/nova/tests/test_zone_aware_scheduler.py b/nova/tests/test_zone_aware_scheduler.py index 37169fb97..90ae427e3 100644 --- a/nova/tests/test_zone_aware_scheduler.py +++ b/nova/tests/test_zone_aware_scheduler.py @@ -39,15 +39,11 @@ class FakeZoneManager(zone_manager.ZoneManager): def __init__(self): self.service_states = { 'host1': { - 'compute': {'ram': 1000} - }, + 'compute': {'ram': 1000}}, 'host2': { - 'compute': {'ram': 2000} - }, + 'compute': {'ram': 2000}}, 'host3': { - 'compute': {'ram': 3000} - } - } + 'compute': {'ram': 3000}}} class FakeEmptyZoneManager(zone_manager.ZoneManager): diff --git a/tools/install_venv.py b/tools/install_venv.py index 812b1dd0f..f4b6583ed 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -36,7 +36,7 @@ PY_VERSION = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) def die(message, *args): - print >>sys.stderr, message % args + print >> sys.stderr, message % args sys.exit(1) -- cgit From c80fedead72456c18c3a0e63348e1a4d40c7e7c5 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 10:58:17 -0400 Subject: updates to keep things looking better --- nova/compute/api.py | 7 +++++-- .../versions/016_make_quotas_key_and_value.py | 3 ++- nova/scheduler/host_filter.py | 3 ++- nova/tests/api/openstack/test_servers.py | 3 +-- nova/tests/integrated/test_servers.py | 9 ++++++--- nova/tests/test_host_filter.py | 7 +++++-- nova/tests/test_zone_aware_scheduler.py | 16 ++++++++++------ 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 3e991e68a..263e44bab 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -270,10 +270,13 @@ class API(base.Base): 'instance_type': instance_type, 'filter': 'nova.scheduler.host_filter.' - 'InstanceTypeFilter'}, + 'InstanceTypeFilter', + }, "availability_zone": availability_zone, "injected_files": injected_files, - "admin_password": admin_password}}) + "admin_password": admin_password, + }, + }) for group_id in security_groups: self.trigger_security_group_members_refresh(elevated, group_id) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py index 1a2a6d7ce..5d0593f2e 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py @@ -160,7 +160,8 @@ def convert_backward(migrate_engine, old_quotas, new_quotas): 'project_id': quota.project_id, 'created_at': quota.created_at, 'updated_at': quota.updated_at, - quota.resource: quota.hard_limit} + quota.resource: quota.hard_limit, + } else: quotas[quota.project_id]['created_at'] = earliest( quota.created_at, quotas[quota.project_id]['created_at']) diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index 8827db4d4..7d6ee0ee3 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -226,7 +226,8 @@ class JsonFilter(HostFilter): required_disk = instance_type['local_gb'] query = ['and', ['>=', '$compute.host_memory_free', required_ram], - ['>=', '$compute.disk_available', required_disk]] + ['>=', '$compute.disk_available', required_disk], + ] return (self._full_name(), json.dumps(query)) def _parse_string(self, string, host, services): diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 20379e2bd..ee27d24eb 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -773,8 +773,7 @@ class ServersTest(test.TestCase): self.body = json.dumps(dict(server=inst_dict)) def server_update(context, id, params): - filtered_dict = dict( - display_name='server_test') + filtered_dict = dict(display_name='server_test') self.assertEqual(params, filtered_dict) return filtered_dict diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index 35c6bb34f..fcb517cf5 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -194,7 +194,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah"} + "name": "blah", + } self.api.post_server_action(created_server_id, post) LOG.debug("rebuilt server: %s" % created_server) @@ -223,7 +224,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah"} + "name": "blah", + } metadata = {} for i in range(30): @@ -265,7 +267,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah"} + "name": "blah", + } metadata = {} post['rebuild']['metadata'] = metadata diff --git a/nova/tests/test_host_filter.py b/nova/tests/test_host_filter.py index 098ebff3d..3361c7b73 100644 --- a/nova/tests/test_host_filter.py +++ b/nova/tests/test_host_filter.py @@ -133,10 +133,13 @@ class HostFilterTestCase(test.TestCase): raw = ['or', ['and', ['<', '$compute.host_memory_free', 30], - ['<', '$compute.disk_available', 300]], + ['<', '$compute.disk_available', 300], + ], ['and', ['>', '$compute.host_memory_free', 70], - ['>', '$compute.disk_available', 700]]] + ['>', '$compute.disk_available', 700], + ], + ] cooked = json.dumps(raw) hosts = hf.filter_hosts(self.zone_manager, cooked) diff --git a/nova/tests/test_zone_aware_scheduler.py b/nova/tests/test_zone_aware_scheduler.py index 90ae427e3..72b74be20 100644 --- a/nova/tests/test_zone_aware_scheduler.py +++ b/nova/tests/test_zone_aware_scheduler.py @@ -38,12 +38,16 @@ class FakeZoneAwareScheduler(zone_aware_scheduler.ZoneAwareScheduler): class FakeZoneManager(zone_manager.ZoneManager): def __init__(self): self.service_states = { - 'host1': { - 'compute': {'ram': 1000}}, - 'host2': { - 'compute': {'ram': 2000}}, - 'host3': { - 'compute': {'ram': 3000}}} + 'host1': { + 'compute': {'ram': 1000}, + }, + 'host2': { + 'compute': {'ram': 2000}, + }, + 'host3': { + 'compute': {'ram': 3000}, + }, + } class FakeEmptyZoneManager(zone_manager.ZoneManager): -- cgit From 3bf3255f91aab28aa6915a2836dad77f17312e03 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 11:52:33 -0700 Subject: basic reservation id support to GET /servers --- nova/api/openstack/servers.py | 34 +++++----------------------------- nova/api/openstack/zones.py | 1 - 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 67b3fd23f..2bfcbac81 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -87,7 +87,11 @@ class Controller(controller.OpenstackCreateInstanceController): builder - the response model builder """ - instance_list = self.compute_api.get_all(req.environ['nova.context']) + reservation_id = req.str_GET.get('reservation_id') + LOG.exception(_(" ************* RESERVATION ID %s"), reservation_id) + instance_list = self.compute_api.get_all( + req.environ['nova.context'], + reservation_id=reservation_id) limited_list = self._limit_items(instance_list, req) builder = self._get_view_builder(req) servers = [builder.build(inst, is_detail)['server'] @@ -132,34 +136,6 @@ class Controller(controller.OpenstackCreateInstanceController): server['server']['adminPass'] = extra_values['password'] return server - def _get_injected_files(self, personality): - """ - Create a list of injected files from the personality attribute - - At this time, injected_files must be formatted as a list of - (file_path, file_content) pairs for compatibility with the - underlying compute service. - """ - injected_files = [] - - for item in personality: - try: - path = item['path'] - contents = item['contents'] - except KeyError as key: - expl = _('Bad personality format: missing %s') % key - raise exc.HTTPBadRequest(explanation=expl) - except TypeError: - expl = _('Bad personality format') - raise exc.HTTPBadRequest(explanation=expl) - try: - contents = base64.b64decode(contents) - except TypeError: - expl = _('Personality content for %s cannot be decoded') % path - raise exc.HTTPBadRequest(explanation=expl) - injected_files.append((path, contents)) - return injected_files - @scheduler_api.redirect_handler def update(self, req, id): """ Updates the server name or password """ diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 687978b08..acd01a1ff 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -129,7 +129,6 @@ class Controller(controller.OpenstackCreateInstanceController): Returns a reservation ID (a UUID). """ - print "************** IN ZONE BOOT" extra_values, result = \ self.create_instance(req, self.compute_api.create_all_at_once) if extra_values is None: -- cgit From ad964ef8934a14329a9100946bed26bcf37b1d52 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 1 Jun 2011 14:56:06 -0400 Subject: Updates to the 018_rename_server_management_url to avoid adding and dropping a column. Just simply rename the column. --- .../versions/018_rename_server_management_url.py | 29 ++++------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py b/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py index a169afb40..73c76f666 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py @@ -14,23 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. -from sqlalchemy import Column, Integer, MetaData, String, Table -#from nova import log as logging +from sqlalchemy import MetaData, Table meta = MetaData() -c_manageent = Column('server_manageent_url', - String(length=255, convert_unicode=False, - assert_unicode=None, unicode_error=None, - _warn_on_bytestring=False), - nullable=True) - -c_management = Column('server_management_url', - String(length=255, convert_unicode=False, - assert_unicode=None, unicode_error=None, - _warn_on_bytestring=False), - nullable=True) - def upgrade(migrate_engine): # Upgrade operations go here. Don't create your own engine; @@ -40,11 +27,8 @@ def upgrade(migrate_engine): tokens = Table('auth_tokens', meta, autoload=True, autoload_with=migrate_engine) - tokens.create_column(c_management) - migrate_engine.execute(tokens.update() - .values(server_management_url=tokens.c.server_manageent_url)) - - tokens.c.server_manageent_url.drop() + c_manageent = tokens.c.server_manageent_url + c_manageent.alter(name='server_management_url') def downgrade(migrate_engine): @@ -53,8 +37,5 @@ def downgrade(migrate_engine): tokens = Table('auth_tokens', meta, autoload=True, autoload_with=migrate_engine) - tokens.create_column(c_manageent) - migrate_engine.execute(tokens.update() - .values(server_manageent_url=tokens.c.server_management_url)) - - tokens.c.server_management_url.drop() + c_management = tokens.c.server_management_url + c_management.alter(name='server_manageent_url') -- cgit From 15257606e5346f0bf9a67145e5d4df7ba57c386a Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 14:58:17 -0400 Subject: touch ups --- nova/image/glance.py | 12 ++++++------ nova/tests/api/openstack/test_common.py | 3 +-- nova/tests/integrated/test_servers.py | 9 ++++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/nova/image/glance.py b/nova/image/glance.py index 06f546027..61308431d 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -64,9 +64,9 @@ class GlanceImageService(service.BaseImageService): # `get_images` here because we need `is_public` and `properties` # included so we can filter by user filtered = [] - image_metas = self.client.get_images_detailed(marker=marker, - limit=limit, - filters=filters) + image_metas = self.client.get_images_detailed(filters=filters, + marker=marker, + limit=limit) for image_meta in image_metas: if self._is_image_available(context, image_meta): meta_subset = utils.subset_dict(image_meta, ('id', 'name')) @@ -76,9 +76,9 @@ class GlanceImageService(service.BaseImageService): def detail(self, context, filters=None, marker=None, limit=None): """Calls out to Glance for a list of detailed image information.""" filtered = [] - image_metas = self.client.get_images_detailed(marker=marker, - limit=limit, - filters=filters) + image_metas = self.client.get_images_detailed(filters=filters, + marker=marker, + limit=limit) for image_meta in image_metas: if self._is_image_available(context, image_meta): base_image_meta = self._translate_to_base(image_meta) diff --git a/nova/tests/api/openstack/test_common.py b/nova/tests/api/openstack/test_common.py index 55142ffe1..c4a6e3ebf 100644 --- a/nova/tests/api/openstack/test_common.py +++ b/nova/tests/api/openstack/test_common.py @@ -24,8 +24,7 @@ import webob.exc from webob import Request from nova import test -from nova.api.openstack.common import limited -from nova.api.openstack.common import get_pagination_params +from nova.api.openstack.common import limited, get_pagination_params class LimiterTest(test.TestCase): diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index 35c6bb34f..fcb517cf5 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -194,7 +194,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah"} + "name": "blah", + } self.api.post_server_action(created_server_id, post) LOG.debug("rebuilt server: %s" % created_server) @@ -223,7 +224,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah"} + "name": "blah", + } metadata = {} for i in range(30): @@ -265,7 +267,8 @@ class ServersTest(integrated_helpers._IntegratedTestBase): post = {} post['rebuild'] = { "imageRef": "https://localhost/v1.1/32278/images/2", - "name": "blah"} + "name": "blah", + } metadata = {} post['rebuild']['metadata'] = metadata -- cgit From b05dcdc69387ecd54e40063e66355961d39b4430 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 12:39:31 -0700 Subject: reservation id's properly forwarded to child zones on create --- nova/api/openstack/create_instance_controller.py | 30 ++++++++++++++++++++++++ nova/scheduler/zone_aware_scheduler.py | 6 +++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index c79638bd9..786d74e37 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -116,6 +116,8 @@ class OpenstackCreateInstanceController(common.OpenstackController): zone_blob = env['server'].get('blob') reservation_id = env['server'].get('reservation_id') + LOG.exception("******* CREATE_INSTANCE RES_ID=%s of %s" % (reservation_id, env)) + inst_type = instance_types.get_instance_type_by_flavor_id(flavor_id) extra_values = { 'instance_type': inst_type, @@ -221,6 +223,34 @@ class OpenstackCreateInstanceController(common.OpenstackController): raise exception.RamdiskNotFoundForImage(image_id=image_id) return kernel_id, ramdisk_id + + def _get_injected_files(self, personality): + """ + Create a list of injected files from the personality attribute + + At this time, injected_files must be formatted as a list of + (file_path, file_content) pairs for compatibility with the + underlying compute service. + """ + injected_files = [] + + for item in personality: + try: + path = item['path'] + contents = item['contents'] + except KeyError as key: + expl = _('Bad personality format: missing %s') % key + raise exc.HTTPBadRequest(explanation=expl) + except TypeError: + expl = _('Bad personality format') + raise exc.HTTPBadRequest(explanation=expl) + try: + contents = base64.b64decode(contents) + except TypeError: + expl = _('Personality content for %s cannot be decoded') % path + raise exc.HTTPBadRequest(explanation=expl) + injected_files.append((path, contents)) + return injected_files class ServerCreateRequestXMLDeserializer(object): diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 35ffdbde1..4b96f9877 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -90,6 +90,7 @@ class ZoneAwareScheduler(driver.Scheduler): image_id = instance_properties['image_id'] meta = instance_properties['metadata'] flavor_id = instance_type['flavorid'] + reservation_id = instance_properties['reservation_id'] files = kwargs['injected_files'] ipgroup = None # Not supported in OS API ... yet @@ -98,7 +99,8 @@ class ZoneAwareScheduler(driver.Scheduler): child_blob = zone_info['child_blob'] zone = db.zone_get(context, child_zone) url = zone.api_url - LOG.debug(_("Forwarding instance create call to child zone %(url)s") + LOG.debug(_("Forwarding instance create call to child zone %(url)s" + ". ReservationID=%(reservation_id)s") % locals()) nova = None try: @@ -109,7 +111,7 @@ class ZoneAwareScheduler(driver.Scheduler): "to talk to zone at %(url)s.") % locals()) nova.servers.create(name, image_id, flavor_id, ipgroup, meta, files, - child_blob) + child_blob, reservation_id=reservation_id) def _provision_resource_from_blob(self, context, item, instance_id, request_spec, kwargs): -- cgit From d77aa5862762bc6efda46d92940143a1b9cbccf5 Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Wed, 1 Jun 2011 14:46:05 -0500 Subject: Allow SSL AMQP connections. --- nova/flags.py | 1 + nova/rpc.py | 1 + 2 files changed, 2 insertions(+) diff --git a/nova/flags.py b/nova/flags.py index 9eaac5596..d5090edba 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -296,6 +296,7 @@ DEFINE_bool('fake_network', False, 'should we use fake network devices and addresses') DEFINE_string('rabbit_host', 'localhost', 'rabbit host') DEFINE_integer('rabbit_port', 5672, 'rabbit port') +DEFINE_bool('rabbit_use_ssl', False, 'connect over SSL') DEFINE_string('rabbit_userid', 'guest', 'rabbit userid') DEFINE_string('rabbit_password', 'guest', 'rabbit password') DEFINE_string('rabbit_virtual_host', '/', 'rabbit virtual host') diff --git a/nova/rpc.py b/nova/rpc.py index c5277c6a9..2e78a31e7 100644 --- a/nova/rpc.py +++ b/nova/rpc.py @@ -65,6 +65,7 @@ class Connection(carrot_connection.BrokerConnection): if new or not hasattr(cls, '_instance'): params = dict(hostname=FLAGS.rabbit_host, port=FLAGS.rabbit_port, + ssl=FLAGS.rabbit_use_ssl, userid=FLAGS.rabbit_userid, password=FLAGS.rabbit_password, virtual_host=FLAGS.rabbit_virtual_host) -- cgit From ced79009e6555eb75f3862184834a883d37b2062 Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 1 Jun 2011 16:01:41 -0700 Subject: fixed as per peer review to make more consistent --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index 51373d282..5de4d9e81 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -536,7 +536,7 @@ class FloatingIpCommands(object): for floating_ip in floating_ips: instance = None if floating_ip['fixed_ip']: - instance = floating_ip['fixed_ip']['instance'].hostname + instance = floating_ip['fixed_ip']['instance']['hostname'] print "%s\t%s\t%s" % (floating_ip['host'], floating_ip['address'], instance) -- cgit From 5d89721f5fa3212146749236c666f0e584c8590f Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 1 Jun 2011 16:27:51 -0700 Subject: merged, with trunk, fixed the test failure, and split the test into 3 as per peer review. --- nova/tests/test_cloud.py | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 04fd02ba3..02b7c8a38 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -445,38 +445,41 @@ class CloudTestCase(test.TestCase): self.cloud.delete_key_pair(self.context, 'test') def test_run_instances(self): - all_instances = db.instance_get_all(context.get_admin_context()) - self.assertEqual(0, len(all_instances)) - - def fake_show_decrypt(self, context, id): - return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, - 'type': 'machine', 'image_state': 'decrypting'}} - - def fake_show_no_state(self, context, id): - return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, - 'type': 'machine'}} - - image_id = FLAGS.default_image - instance_type = FLAGS.default_instance_type - max_count = 1 - kwargs = {'image_id': image_id, - 'instance_type': instance_type, - 'max_count': max_count} + kwargs = {'image_id': FLAGS.default_image, + 'instance_type': FLAGS.default_instance_type, + 'max_count': 1} run_instances = self.cloud.run_instances - # when image has valid image_state result = run_instances(self.context, **kwargs) instance = result['instancesSet'][0] self.assertEqual(instance['imageId'], 'ami-00000001') self.assertEqual(instance['displayName'], 'Server 1') self.assertEqual(instance['instanceId'], 'i-00000001') - self.assertEqual(instance['instanceState']['name'], 'scheduling') + self.assertEqual(instance['instanceState']['name'], 'networking') self.assertEqual(instance['instanceType'], 'm1.small') - # when image doesn't have 'image_state' attr at all + + def test_run_instances_image_state_none(self): + kwargs = {'image_id': FLAGS.default_image, + 'instance_type': FLAGS.default_instance_type, + 'max_count': 1} + run_instances = self.cloud.run_instances + def fake_show_no_state(self, context, id): + return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, + 'type': 'machine'}} + self.stubs.UnsetAll() self.stubs.Set(local.LocalImageService, 'show', fake_show_no_state) self.assertRaises(exception.ApiError, run_instances, self.context, **kwargs) - # when image has 'image_state' yet not 'available' + + def test_run_instances_image_state_invalid(self): + kwargs = {'image_id': FLAGS.default_image, + 'instance_type': FLAGS.default_instance_type, + 'max_count': 1} + run_instances = self.cloud.run_instances + def fake_show_decrypt(self, context, id): + return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, + 'type': 'machine', 'image_state': 'decrypting'}} + self.stubs.UnsetAll() self.stubs.Set(local.LocalImageService, 'show', fake_show_decrypt) self.assertRaises(exception.ApiError, run_instances, -- cgit From ef1f5b3aadde2fedb4b2d197af0f1c0f07375714 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 1 Jun 2011 16:51:26 -0700 Subject: fix novarc to work on mac and zsh --- nova/auth/novarc.template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/auth/novarc.template b/nova/auth/novarc.template index 8170fcafe..4a1f41802 100644 --- a/nova/auth/novarc.template +++ b/nova/auth/novarc.template @@ -1,4 +1,5 @@ -NOVA_KEY_DIR=$(dirname $(readlink -f ${BASH_SOURCE})) +NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE-0}) +NOVA_KEY_DIR=$(dirname ${NOVARC}) export EC2_ACCESS_KEY="%(access)s:%(project)s" export EC2_SECRET_KEY="%(secret)s" export EC2_URL="%(ec2)s" -- cgit From cf464dc7f2093ea3d1f831915ce22f54f0d1c90a Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 17:35:49 -0700 Subject: list --reservation now works across zones --- nova/api/openstack/create_instance_controller.py | 2 -- nova/api/openstack/views/servers.py | 12 +++++++++--- nova/compute/api.py | 22 ++++++++++++++++++++-- nova/scheduler/api.py | 8 +++++--- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index 786d74e37..edb1a5007 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -116,8 +116,6 @@ class OpenstackCreateInstanceController(common.OpenstackController): zone_blob = env['server'].get('blob') reservation_id = env['server'].get('reservation_id') - LOG.exception("******* CREATE_INSTANCE RES_ID=%s of %s" % (reservation_id, env)) - inst_type = instance_types.get_instance_type_by_flavor_id(flavor_id) extra_values = { 'instance_type': inst_type, diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 0be468edc..0ee461dde 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -41,10 +41,13 @@ class ViewBuilder(object): def build(self, inst, is_detail): """Return a dict that represenst a server.""" - if is_detail: - server = self._build_detail(inst) + if inst.get('_is_precooked', False): + server = dict(server=inst) else: - server = self._build_simple(inst) + if is_detail: + server = self._build_detail(inst) + else: + server = self._build_simple(inst) self._build_extra(server, inst) @@ -78,6 +81,9 @@ class ViewBuilder(object): ctxt = nova.context.get_admin_context() compute_api = nova.compute.API() + + # TODO(sandy): Could be a bug here since the instance ID + # may have come from another Zone. if compute_api.has_finished_migration(ctxt, inst['id']): inst_dict['status'] = 'RESIZE-CONFIRM' diff --git a/nova/compute/api.py b/nova/compute/api.py index fc369ccd2..f9e76ffbc 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -543,6 +543,25 @@ class API(base.Base): """ return self.get(context, instance_id) + def get_all_across_zones(self, context, reservation_id): + """Get all instances with this reservation_id, across + all available Zones (if any). + """ + instances = self.db.instance_get_all_by_reservation( + context, reservation_id) + + children = scheduler_api.call_zone_method(context, "list", + novaclient_collection_name="servers", + reservation_id=reservation_id) + + for zone, servers in children: + for server in servers: + LOG.debug("**** INSTANCE= %s" % server._info) + # Results are ready to send to user. No need to scrub. + server._info['_is_precooked'] = True + instances.append(server._info) + return instances + def get_all(self, context, project_id=None, reservation_id=None, fixed_ip=None): """Get all instances filtered by one of the given parameters. @@ -552,8 +571,7 @@ class API(base.Base): """ if reservation_id is not None: - return self.db.instance_get_all_by_reservation( - context, reservation_id) + return self.get_all_across_zones(context, reservation_id) if fixed_ip is not None: return self.db.fixed_ip_get_instance(context, fixed_ip) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index de0660713..0f423655e 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -118,7 +118,8 @@ def _process(func, zone): return func(nova, zone) -def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): +def call_zone_method(context, method_name, errors_to_ignore=None, + novaclient_collection_name='zones', *args, **kwargs): """Returns a list of (zone, call_result) objects.""" if not isinstance(errors_to_ignore, (list, tuple)): # This will also handle the default None @@ -138,11 +139,12 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs): #TODO (dabo) - add logic for failure counts per zone, # with escalation after a given number of failures. continue - zone_method = getattr(nova.zones, method) + novaclient_collection = getattr(nova, novaclient_collection_name) + collection_method = getattr(novaclient_collection, method_name) def _error_trap(*args, **kwargs): try: - return zone_method(*args, **kwargs) + return collection_method(*args, **kwargs) except Exception as e: if type(e) in errors_to_ignore: return None -- cgit From e0d2dde5d370d76cd8ff55e47dbbf749be43a4c9 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 17:49:49 -0700 Subject: tests all passing again --- nova/api/openstack/create_instance_controller.py | 5 +++-- nova/api/openstack/servers.py | 1 - nova/compute/api.py | 1 - nova/scheduler/api.py | 5 +---- nova/tests/test_scheduler.py | 8 +------- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index edb1a5007..3a8bbb3c9 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -15,13 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. +import base64 import re +import webob + from urlparse import urlparse from webob import exc from xml.dom import minidom -import webob - from nova import exception from nova import flags from nova import log as logging diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 2bfcbac81..e5b04db43 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -88,7 +88,6 @@ class Controller(controller.OpenstackCreateInstanceController): builder - the response model builder """ reservation_id = req.str_GET.get('reservation_id') - LOG.exception(_(" ************* RESERVATION ID %s"), reservation_id) instance_list = self.compute_api.get_all( req.environ['nova.context'], reservation_id=reservation_id) diff --git a/nova/compute/api.py b/nova/compute/api.py index f9e76ffbc..9cb572720 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -556,7 +556,6 @@ class API(base.Base): for zone, servers in children: for server in servers: - LOG.debug("**** INSTANCE= %s" % server._info) # Results are ready to send to user. No need to scrub. server._info['_is_precooked'] = True instances.append(server._info) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 0f423655e..432f22b90 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -148,10 +148,7 @@ def call_zone_method(context, method_name, errors_to_ignore=None, except Exception as e: if type(e) in errors_to_ignore: return None - # TODO (dabo) - want to be able to re-raise here. - # Returning a string now; raising was causing issues. - # raise e - return "ERROR", "%s" % e + raise e res = pool.spawn(_error_trap, *args, **kwargs) results.append((zone, res)) diff --git a/nova/tests/test_scheduler.py b/nova/tests/test_scheduler.py index 54b3f80fb..5d8f34efd 100644 --- a/nova/tests/test_scheduler.py +++ b/nova/tests/test_scheduler.py @@ -1109,10 +1109,4 @@ class CallZoneMethodTest(test.TestCase): def test_call_zone_method_generates_exception(self): context = {} method = 'raises_exception' - results = api.call_zone_method(context, method) - - # FIXME(sirp): for now the _error_trap code is catching errors and - # converting them to a ("ERROR", "string") tuples. The code (and this - # test) should eventually handle real exceptions. - expected = [(1, ('ERROR', 'testing'))] - self.assertEqual(expected, results) + self.assertRaises(Exception, api.call_zone_method, context, method) -- cgit From d31ad6211956e69644894490ce37f6c3e8ea5e6e Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 17:53:45 -0700 Subject: pep8 and all that --- nova/api/openstack/create_instance_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index 3a8bbb3c9..0ab262b6e 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -222,7 +222,7 @@ class OpenstackCreateInstanceController(common.OpenstackController): raise exception.RamdiskNotFoundForImage(image_id=image_id) return kernel_id, ramdisk_id - + def _get_injected_files(self, personality): """ Create a list of injected files from the personality attribute -- cgit From 970415346b356f03f9d6152bfd4744b94bb59bbd Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 1 Jun 2011 18:17:04 -0700 Subject: Little cleanups --- nova/api/openstack/views/servers.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 0ee461dde..84086b3b2 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -49,7 +49,7 @@ class ViewBuilder(object): else: server = self._build_simple(inst) - self._build_extra(server, inst) + self._build_extra(server, inst) return server @@ -82,8 +82,6 @@ class ViewBuilder(object): ctxt = nova.context.get_admin_context() compute_api = nova.compute.API() - # TODO(sandy): Could be a bug here since the instance ID - # may have come from another Zone. if compute_api.has_finished_migration(ctxt, inst['id']): inst_dict['status'] = 'RESIZE-CONFIRM' -- cgit From 8ee41f679bd72af6aab098f9d9735e342b281635 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 1 Jun 2011 18:55:41 -0700 Subject: missed a couple chars --- nova/auth/novarc.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/auth/novarc.template b/nova/auth/novarc.template index 4a1f41802..92eed3520 100644 --- a/nova/auth/novarc.template +++ b/nova/auth/novarc.template @@ -1,4 +1,4 @@ -NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE-0}) +NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE:-$0}) NOVA_KEY_DIR=$(dirname ${NOVARC}) export EC2_ACCESS_KEY="%(access)s:%(project)s" export EC2_SECRET_KEY="%(secret)s" -- cgit From 4fb46873ef4332c6570d3ac5559557745056dee6 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 23:09:37 -0400 Subject: cleanup based on waldon's comments, also caught a few other issues --- nova/api/openstack/common.py | 18 +--- nova/api/openstack/images.py | 8 +- nova/api/openstack/servers.py | 1 + nova/tests/api/openstack/fakes.py | 25 ++--- nova/tests/api/openstack/test_common.py | 180 +++++++++++++------------------ nova/tests/api/openstack/test_images.py | 33 ++++-- nova/tests/api/openstack/test_servers.py | 1 + nova/tests/integrated/test_servers.py | 3 + 8 files changed, 115 insertions(+), 154 deletions(-) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 342cc8b2e..c9e3dbb64 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -50,7 +50,7 @@ def get_pagination_params(request): try: marker = int(request.GET.get('marker', 0)) except ValueError: - raise webob.exc.HTTPBadRequest(_('offset param must be an integer')) + raise webob.exc.HTTPBadRequest(_('marker param must be an integer')) try: limit = int(request.GET.get('limit', 0)) @@ -102,19 +102,11 @@ def limited(items, request, max_limit=FLAGS.osapi_max_limit): def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit): """Return a slice of items according to the requested marker and limit.""" + print "TEST LIMIT" + (marker, limit) = get_pagination_params(request) - try: - marker = int(request.GET.get('marker', 0)) - except ValueError: - raise webob.exc.HTTPBadRequest(_('marker param must be an integer')) - - try: - limit = int(request.GET.get('limit', max_limit)) - except ValueError: - raise webob.exc.HTTPBadRequest(_('limit param must be an integer')) - - if limit < 0: - raise webob.exc.HTTPBadRequest(_('limit param must be positive')) + if limit == 0: + limit = max_limit limit = min(max_limit, limit) start_index = 0 diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index dcedd3db2..4ef9a5974 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -46,9 +46,6 @@ class Controller(object): self._compute_service = compute_service or compute.API() self._image_service = image_service or _default_service - def _limit_items(self, items, req): - return common.limited(items, req) - def index(self, req): """Return an index listing of images available to the request. @@ -162,13 +159,11 @@ class ControllerV11(Controller): base_url = request.application_url return images_view.ViewBuilderV11(base_url) - def get_default_xmlns(self, req): - return common.XML_NS_V11 - def index(self, req): """Return an index listing of images available to the request. :param req: `wsgi.Request` object + """ context = req.environ['nova.context'] filters = self._get_filters(req) @@ -182,6 +177,7 @@ class ControllerV11(Controller): """Return a detailed index listing of images available to the request. :param req: `wsgi.Request` object. + """ context = req.environ['nova.context'] filters = self._get_filters(req) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index f2ce64e78..ad556ca84 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -55,6 +55,7 @@ class Controller(object): def detail(self, req): """ Returns a list of server details for a given user """ + print "DETAIL" return self._items(req, is_detail=True) def _image_id_from_req_data(self, data): diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index bc21d66b4..67cd395ad 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -166,7 +166,7 @@ def stub_out_glance(stubs, initial_fixtures=None): def __init__(self, initial_fixtures): self.fixtures = initial_fixtures or [] - def fake_get_images(self, filters=None, marker=None, limit=None): + def _filter_images(self, filters=None, marker=None, limit=None): found = True if marker: found = False @@ -184,29 +184,16 @@ def stub_out_glance(stubs, initial_fixtures=None): if f['id'] == marker: found = True + return fixtures + + def fake_get_images(self, filters=None, marker=None, limit=None): + fixtures = self._filter_images(filters, marker, limit) return [dict(id=f['id'], name=f['name']) for f in fixtures] def fake_get_images_detailed(self, filters=None, marker=None, limit=None): - found = True - if marker: - found = False - if limit == 0: - limit = None - - fixtures = [] - count = 0 - for f in self.fixtures: - if limit and count >= limit: - break - if found: - fixtures.append(f) - count = count + 1 - if f['id'] == marker: - found = True - - return fixtures + return self._filter_images(filters, marker, limit) def fake_get_image_meta(self, image_id): image = self._find_image(image_id) diff --git a/nova/tests/api/openstack/test_common.py b/nova/tests/api/openstack/test_common.py index c4a6e3ebf..9a9d9125c 100644 --- a/nova/tests/api/openstack/test_common.py +++ b/nova/tests/api/openstack/test_common.py @@ -24,7 +24,7 @@ import webob.exc from webob import Request from nova import test -from nova.api.openstack.common import limited, get_pagination_params +from nova.api.openstack import common class LimiterTest(test.TestCase): @@ -35,9 +35,7 @@ class LimiterTest(test.TestCase): """ def setUp(self): - """ - Run before each test. - """ + """ Run before each test. """ super(LimiterTest, self).setUp() self.tiny = range(1) self.small = range(10) @@ -45,130 +43,112 @@ class LimiterTest(test.TestCase): self.large = range(10000) def test_limiter_offset_zero(self): - """ - Test offset key works with 0. - """ + """ Test offset key works with 0. """ req = Request.blank('/?offset=0') - self.assertEqual(limited(self.tiny, req), self.tiny) - self.assertEqual(limited(self.small, req), self.small) - self.assertEqual(limited(self.medium, req), self.medium) - self.assertEqual(limited(self.large, req), self.large[:1000]) + self.assertEqual(common.limited(self.tiny, req), self.tiny) + self.assertEqual(common.limited(self.small, req), self.small) + self.assertEqual(common.limited(self.medium, req), self.medium) + self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_offset_medium(self): - """ - Test offset key works with a medium sized number. - """ + """ Test offset key works with a medium sized number. """ req = Request.blank('/?offset=10') - self.assertEqual(limited(self.tiny, req), []) - self.assertEqual(limited(self.small, req), self.small[10:]) - self.assertEqual(limited(self.medium, req), self.medium[10:]) - self.assertEqual(limited(self.large, req), self.large[10:1010]) + self.assertEqual(common.limited(self.tiny, req), []) + self.assertEqual(common.limited(self.small, req), self.small[10:]) + self.assertEqual(common.limited(self.medium, req), self.medium[10:]) + self.assertEqual(common.limited(self.large, req), self.large[10:1010]) def test_limiter_offset_over_max(self): - """ - Test offset key works with a number over 1000 (max_limit). - """ + """ Test offset key works with a number over 1000 (max_limit). """ req = Request.blank('/?offset=1001') - self.assertEqual(limited(self.tiny, req), []) - self.assertEqual(limited(self.small, req), []) - self.assertEqual(limited(self.medium, req), []) - self.assertEqual(limited(self.large, req), self.large[1001:2001]) + self.assertEqual(common.limited(self.tiny, req), []) + self.assertEqual(common.limited(self.small, req), []) + self.assertEqual(common.limited(self.medium, req), []) + self.assertEqual( + common.limited(self.large, req), self.large[1001:2001]) def test_limiter_offset_blank(self): - """ - Test offset key works with a blank offset. - """ + """ Test offset key works with a blank offset. """ req = Request.blank('/?offset=') - self.assertRaises(webob.exc.HTTPBadRequest, limited, self.tiny, req) + self.assertRaises( + webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_offset_bad(self): - """ - Test offset key works with a BAD offset. - """ + """ Test offset key works with a BAD offset. """ req = Request.blank(u'/?offset=\u0020aa') - self.assertRaises(webob.exc.HTTPBadRequest, limited, self.tiny, req) + self.assertRaises( + webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_nothing(self): - """ - Test request with no offset or limit - """ + """ Test request with no offset or limit """ req = Request.blank('/') - self.assertEqual(limited(self.tiny, req), self.tiny) - self.assertEqual(limited(self.small, req), self.small) - self.assertEqual(limited(self.medium, req), self.medium) - self.assertEqual(limited(self.large, req), self.large[:1000]) + self.assertEqual(common.limited(self.tiny, req), self.tiny) + self.assertEqual(common.limited(self.small, req), self.small) + self.assertEqual(common.limited(self.medium, req), self.medium) + self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_limit_zero(self): - """ - Test limit of zero. - """ + """ Test limit of zero. """ req = Request.blank('/?limit=0') - self.assertEqual(limited(self.tiny, req), self.tiny) - self.assertEqual(limited(self.small, req), self.small) - self.assertEqual(limited(self.medium, req), self.medium) - self.assertEqual(limited(self.large, req), self.large[:1000]) + self.assertEqual(common.limited(self.tiny, req), self.tiny) + self.assertEqual(common.limited(self.small, req), self.small) + self.assertEqual(common.limited(self.medium, req), self.medium) + self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_limit_medium(self): - """ - Test limit of 10. - """ + """ Test limit of 10. """ req = Request.blank('/?limit=10') - self.assertEqual(limited(self.tiny, req), self.tiny) - self.assertEqual(limited(self.small, req), self.small) - self.assertEqual(limited(self.medium, req), self.medium[:10]) - self.assertEqual(limited(self.large, req), self.large[:10]) + self.assertEqual(common.limited(self.tiny, req), self.tiny) + self.assertEqual(common.limited(self.small, req), self.small) + self.assertEqual(common.limited(self.medium, req), self.medium[:10]) + self.assertEqual(common.limited(self.large, req), self.large[:10]) def test_limiter_limit_over_max(self): - """ - Test limit of 3000. - """ + """ Test limit of 3000. """ req = Request.blank('/?limit=3000') - self.assertEqual(limited(self.tiny, req), self.tiny) - self.assertEqual(limited(self.small, req), self.small) - self.assertEqual(limited(self.medium, req), self.medium) - self.assertEqual(limited(self.large, req), self.large[:1000]) + self.assertEqual(common.limited(self.tiny, req), self.tiny) + self.assertEqual(common.limited(self.small, req), self.small) + self.assertEqual(common.limited(self.medium, req), self.medium) + self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_limit_and_offset(self): - """ - Test request with both limit and offset. - """ + """ Test request with both limit and offset. """ items = range(2000) req = Request.blank('/?offset=1&limit=3') - self.assertEqual(limited(items, req), items[1:4]) + self.assertEqual(common.limited(items, req), items[1:4]) req = Request.blank('/?offset=3&limit=0') - self.assertEqual(limited(items, req), items[3:1003]) + self.assertEqual(common.limited(items, req), items[3:1003]) req = Request.blank('/?offset=3&limit=1500') - self.assertEqual(limited(items, req), items[3:1003]) + self.assertEqual(common.limited(items, req), items[3:1003]) req = Request.blank('/?offset=3000&limit=10') - self.assertEqual(limited(items, req), []) + self.assertEqual(common.limited(items, req), []) def test_limiter_custom_max_limit(self): - """ - Test a max_limit other than 1000. - """ + """ Test a max_limit other than 1000. """ items = range(2000) req = Request.blank('/?offset=1&limit=3') - self.assertEqual(limited(items, req, max_limit=2000), items[1:4]) + self.assertEqual( + common.limited(items, req, max_limit=2000), items[1:4]) req = Request.blank('/?offset=3&limit=0') - self.assertEqual(limited(items, req, max_limit=2000), items[3:]) + self.assertEqual( + common.limited(items, req, max_limit=2000), items[3:]) req = Request.blank('/?offset=3&limit=2500') - self.assertEqual(limited(items, req, max_limit=2000), items[3:]) + self.assertEqual( + common.limited(items, req, max_limit=2000), items[3:]) req = Request.blank('/?offset=3000&limit=10') - self.assertEqual(limited(items, req, max_limit=2000), []) + self.assertEqual(common.limited(items, req, max_limit=2000), []) def test_limiter_negative_limit(self): - """ - Test a negative limit. - """ + """ Test a negative limit. """ req = Request.blank('/?limit=-3000') - self.assertRaises(webob.exc.HTTPBadRequest, limited, self.tiny, req) + self.assertRaises( + webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_negative_offset(self): - """ - Test a negative offset. - """ + """ Test a negative offset. """ req = Request.blank('/?offset=-30') - self.assertRaises(webob.exc.HTTPBadRequest, limited, self.tiny, req) + self.assertRaises( + webob.exc.HTTPBadRequest, common.limited, self.tiny, req) class PaginationParamsTest(test.TestCase): @@ -179,38 +159,28 @@ class PaginationParamsTest(test.TestCase): """ def test_no_params(self): - """ - Test no params. - """ + """ Test no params. """ req = Request.blank('/') - self.assertEqual(get_pagination_params(req), (0, 0)) + self.assertEqual(common.get_pagination_params(req), (0, 0)) def test_valid_marker(self): - """ - Test valid marker param. - """ + """ Test valid marker param. """ req = Request.blank('/?marker=1') - self.assertEqual(get_pagination_params(req), (1, 0)) + self.assertEqual(common.get_pagination_params(req), (1, 0)) def test_invalid_marker(self): - """ - Test invalid marker param. - """ + """ Test invalid marker param. """ req = Request.blank('/?marker=-2') - self.assertRaises(webob.exc.HTTPBadRequest, - get_pagination_params, req) + self.assertRaises( + webob.exc.HTTPBadRequest, common.get_pagination_params, req) def test_valid_limit(self): - """ - Test valid limit param. - """ + """ Test valid limit param. """ req = Request.blank('/?limit=10') - self.assertEqual(get_pagination_params(req), (0, 10)) + self.assertEqual(common.get_pagination_params(req), (0, 10)) def test_invalid_limit(self): - """ - Test invalid limit param. - """ + """ Test invalid limit param. """ req = Request.blank('/?limit=-2') - self.assertRaises(webob.exc.HTTPBadRequest, - get_pagination_params, req) + self.assertRaises( + webob.exc.HTTPBadRequest, common.get_pagination_params, req) diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 667f2866b..38823c377 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -239,7 +239,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): i = 0 for meta in image_metas: expected = {'id': 'DONTCARE', - 'name': 'TestImage %d' % (i)} + 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -256,7 +256,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): i = 2 for meta in image_metas: expected = {'id': 'DONTCARE', - 'name': 'TestImage %d' % (i)} + 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -284,7 +284,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): i = 4 for meta in image_metas: expected = {'id': 'DONTCARE', - 'name': 'TestImage %d' % (i)} + 'name': 'TestImage %d' % (i)} self.assertDictMatch(meta, expected) i = i + 1 @@ -300,10 +300,17 @@ class GlanceImageServiceTest(_BaseImageServiceTests): self.assertEquals(len(image_metas), 8) i = 2 for meta in image_metas: - expected = {'id': 'DONTCARE', 'status': None, - 'is_public': True, 'properties': { - 'updated': None, 'created': None}, - 'name': 'TestImage %d' % (i)} + expected = { + 'id': 'DONTCARE', + 'status': None, + 'is_public': True, + 'name': 'TestImage %d' % (i), + 'properties': { + 'updated': None, + 'created': None, + }, + } + self.assertDictMatch(meta, expected) i = i + 1 @@ -330,10 +337,14 @@ class GlanceImageServiceTest(_BaseImageServiceTests): self.assertEquals(len(image_metas), 3) i = 4 for meta in image_metas: - expected = {'id': 'DONTCARE', 'status': None, - 'is_public': True, 'properties': { - 'updated': None, 'created': None}, - 'name': 'TestImage %d' % (i)} + expected = { + 'id': 'DONTCARE', + 'status': None, + 'is_public': True, + 'name': 'TestImage %d' % (i), + 'properties': { + 'updated': None, 'created': None}, + } self.assertDictMatch(meta, expected) i = i + 1 diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 51def1980..3de7865cd 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -448,6 +448,7 @@ class ServersTest(test.TestCase): req = webob.Request.blank('/v1.1/servers?limit=2&marker=asdf') res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 400) + print "BODY",res.body self.assertTrue(res.body.find('marker param') > -1) def _setup_for_create_instance(self): diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index fcb517cf5..89987b645 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -88,12 +88,15 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Check it's there found_server = self.api.get_server(created_server_id) + print "FOUND_SERVER:", found_server self.assertEqual(created_server_id, found_server['id']) # It should also be in the all-servers list servers = self.api.get_servers() + print "SERVERS:", servers server_ids = [server['id'] for server in servers] self.assertTrue(created_server_id in server_ids) + return # Wait (briefly) for creation retries = 0 -- cgit From 5ded1f2c1d0d14b3c04df137f7cc6a0b65e53fda Mon Sep 17 00:00:00 2001 From: William Wolf Date: Wed, 1 Jun 2011 23:11:50 -0400 Subject: got rid of print debugs --- nova/api/openstack/common.py | 1 - nova/api/openstack/servers.py | 1 - nova/tests/api/openstack/test_images.py | 2 +- nova/tests/api/openstack/test_servers.py | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index c9e3dbb64..559b44ef5 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -102,7 +102,6 @@ def limited(items, request, max_limit=FLAGS.osapi_max_limit): def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit): """Return a slice of items according to the requested marker and limit.""" - print "TEST LIMIT" (marker, limit) = get_pagination_params(request) if limit == 0: diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index ad556ca84..f2ce64e78 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -55,7 +55,6 @@ class Controller(object): def detail(self, req): """ Returns a list of server details for a given user """ - print "DETAIL" return self._items(req, is_detail=True) def _image_id_from_req_data(self, data): diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 38823c377..c2b03c281 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -306,7 +306,7 @@ class GlanceImageServiceTest(_BaseImageServiceTests): 'is_public': True, 'name': 'TestImage %d' % (i), 'properties': { - 'updated': None, + 'updated': None, 'created': None, }, } diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 3de7865cd..51def1980 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -448,7 +448,6 @@ class ServersTest(test.TestCase): req = webob.Request.blank('/v1.1/servers?limit=2&marker=asdf') res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 400) - print "BODY",res.body self.assertTrue(res.body.find('marker param') > -1) def _setup_for_create_instance(self): -- cgit From 0e419c00ef9a463acc704f034e4c37929f0ef2eb Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Wed, 1 Jun 2011 23:37:51 -0400 Subject: image href should be passed through the rebuild pipeline, not the image id. --- nova/api/openstack/servers.py | 3 +-- nova/compute/api.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 55fed408c..0ef1a83da 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -714,7 +714,6 @@ class ControllerV11(Controller): LOG.debug(msg) return faults.Fault(exc.HTTPBadRequest(explanation=msg)) - image_id = common.get_id_from_href(image_href) personalities = info["rebuild"].get("personality", []) metadata = info["rebuild"].get("metadata") name = info["rebuild"].get("name") @@ -724,7 +723,7 @@ class ControllerV11(Controller): self._decode_personalities(personalities) try: - self.compute_api.rebuild(context, instance_id, image_id, name, + self.compute_api.rebuild(context, instance_id, image_href, name, metadata, personalities) except exception.BuildInProgress: msg = _("Instance %d is currently being rebuilt.") % instance_id diff --git a/nova/compute/api.py b/nova/compute/api.py index 2b353cebb..6a1c68561 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -529,8 +529,8 @@ class API(base.Base): """Reboot the given instance.""" self._cast_compute_message('reboot_instance', context, instance_id) - def rebuild(self, context, instance_id, image_id, name=None, metadata=None, - files_to_inject=None): + def rebuild(self, context, instance_id, image_href, name=None, + metadata=None, files_to_inject=None): """Rebuild the given instance with the provided metadata.""" instance = db.api.instance_get(context, instance_id) @@ -550,7 +550,7 @@ class API(base.Base): self.db.instance_update(context, instance_id, values) rebuild_params = { - "image_ref": image_ref, + "image_ref": image_href, "injected_files": files_to_inject, } -- cgit From b39b0e66f16d49890189c63fba528734ef476068 Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Thu, 2 Jun 2011 10:29:58 +0400 Subject: Refactored after review, fixed merge. --- nova/image/fake.py | 5 +---- nova/tests/test_libvirt.py | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/nova/image/fake.py b/nova/image/fake.py index 4bf25d9af..019d683f4 100644 --- a/nova/image/fake.py +++ b/nova/image/fake.py @@ -82,12 +82,9 @@ class _FakeImageService(service.BaseImageService): :raises: Duplicate if the image already exist. """ - #image_id = int(metadata['id']) - # metadata['id'] may not exists, and since image_id is - # randomly generated in local.py, let us do the same here try: image_id = int(metadata['id']) - except: + except KeyError: image_id = random.randint(0, 2 ** 31 - 1) if self.images.get(image_id): diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index d9316ab4f..d008a149e 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -328,14 +328,14 @@ class LibvirtConnTestCase(test.TestCase): # To work with it from snapshot, the single image_service is needed recv_meta = image_service.create(context, sent_meta) - self.mox.StubOutWithMock(libvirt_conn.LibvirtConnection, '_conn') - libvirt_conn.LibvirtConnection._conn.lookupByName = fake_lookup - self.mox.StubOutWithMock(libvirt_conn.utils, 'execute') - libvirt_conn.utils.execute = fake_execute + self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') + connection.LibvirtConnection._conn.lookupByName = fake_lookup + self.mox.StubOutWithMock(connection.utils, 'execute') + connection.utils.execute = fake_execute self.mox.ReplayAll() - conn = libvirt_conn.LibvirtConnection(False) + conn = connection.LibvirtConnection(False) conn.snapshot(instance_ref, recv_meta['id']) snapshot = image_service.show(context, recv_meta['id']) -- cgit From 7b24750057cfef1d0f14b21cb83b1ac9c0869836 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Thu, 2 Jun 2011 08:53:13 -0400 Subject: got rid of prints --- nova/tests/integrated/test_servers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index 89987b645..1733896fd 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -88,12 +88,10 @@ class ServersTest(integrated_helpers._IntegratedTestBase): # Check it's there found_server = self.api.get_server(created_server_id) - print "FOUND_SERVER:", found_server self.assertEqual(created_server_id, found_server['id']) # It should also be in the all-servers list servers = self.api.get_servers() - print "SERVERS:", servers server_ids = [server['id'] for server in servers] self.assertTrue(created_server_id in server_ids) return -- cgit From e28a6e96ec45439ed24a363f27d0421d720add0b Mon Sep 17 00:00:00 2001 From: William Wolf Date: Thu, 2 Jun 2011 09:34:01 -0400 Subject: move index and detail functions to v10 controller --- nova/api/openstack/images.py | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 4ef9a5974..7f06c53df 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -46,30 +46,6 @@ class Controller(object): self._compute_service = compute_service or compute.API() self._image_service = image_service or _default_service - def index(self, req): - """Return an index listing of images available to the request. - - :param req: `wsgi.Request` object - """ - context = req.environ['nova.context'] - filters = self._get_filters(req) - images = self._image_service.index(context, filters) - images = common.limited(images, req) - builder = self.get_builder(req).build - return dict(images=[builder(image, detail=False) for image in images]) - - def detail(self, req): - """Return a detailed index listing of images available to the request. - - :param req: `wsgi.Request` object. - """ - context = req.environ['nova.context'] - filters = self._get_filters(req) - images = self._image_service.detail(context, filters) - images = common.limited(images, req) - builder = self.get_builder(req).build - return dict(images=[builder(image, detail=True) for image in images]) - def _get_filters(self, req): """ Return a dictionary of query param filters from the request @@ -150,6 +126,30 @@ class ControllerV10(Controller): base_url = request.application_url return images_view.ViewBuilderV10(base_url) + def index(self, req): + """Return an index listing of images available to the request. + + :param req: `wsgi.Request` object + """ + context = req.environ['nova.context'] + filters = self._get_filters(req) + images = self._image_service.index(context, filters) + images = common.limited(images, req) + builder = self.get_builder(req).build + return dict(images=[builder(image, detail=False) for image in images]) + + def detail(self, req): + """Return a detailed index listing of images available to the request. + + :param req: `wsgi.Request` object. + """ + context = req.environ['nova.context'] + filters = self._get_filters(req) + images = self._image_service.detail(context, filters) + images = common.limited(images, req) + builder = self.get_builder(req).build + return dict(images=[builder(image, detail=True) for image in images]) + class ControllerV11(Controller): """Version 1.1 specific controller logic.""" -- cgit From 3fb467e44b5e5715e364c6c616998e54d7f20f92 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Thu, 2 Jun 2011 07:57:35 -0700 Subject: get_all with reservation id across zone tests --- nova/compute/api.py | 16 ---------- nova/scheduler/api.py | 7 ----- nova/scheduler/driver.py | 7 ----- nova/scheduler/zone_aware_scheduler.py | 6 ---- nova/tests/api/openstack/test_servers.py | 50 ++++++++++++++++++++++++++++++-- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 9cb572720..b99d1d0a3 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -377,22 +377,6 @@ class API(base.Base): return [dict(x.iteritems()) for x in instances] - def smart_create(self, *args, **kwargs): - """ - Ask the scheduler if we should do single shot instance requests - or all-at-once. - - Cache this information on first request and act accordingly. - """ - - if API.should_create_all_at_once == None: - API.should_create_all_at_once = \ - scheduler_api.should_create_all_at_once(context) - - if API.should_create_all_at_once: - return self.create_all_at_once(*args, **kwargs) - return self.create(*args, **kwargs) - def has_finished_migration(self, context, instance_id): """Returns true if an instance has a finished migration.""" try: diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 432f22b90..789993890 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -87,13 +87,6 @@ def select(context, specs=None): params={"request_spec": specs}) -def should_create_all_at_once(context): - """Returns a tuple of rules for how instances should - be created given the current Scheduler driver being used.""" - return _call_scheduler('should_create_all_at_once', context=context, - params={}) - - def update_service_capabilities(context, service_name, host, capabilities): """Send an update to all the scheduler services informing them of the capabilities of this service.""" diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 237e31c04..2094e3565 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -72,13 +72,6 @@ class Scheduler(object): for service in services if self.service_is_up(service)] - def should_create_all_at_once(self, context=None, *args, **kwargs): - """ - Does this driver prefer single-shot requests or all-at-once? - By default, prefer single-shot. - """ - return False - def schedule(self, context, topic, *_args, **_kwargs): """Must override at least this method for scheduler to work.""" raise NotImplementedError(_("Must implement a fallback schedule")) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 4b96f9877..5e8d63038 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -159,12 +159,6 @@ class ZoneAwareScheduler(driver.Scheduler): self._provision_resource_from_blob(context, item, instance_id, request_spec, kwargs) - def should_create_all_at_once(self, context=None, *args, **kwargs): - """ - This driver prefers all-at-once requests. - """ - return True - def schedule_run_instance(self, context, instance_id, request_spec, *args, **kwargs): """This method is called from nova.compute.api to provision diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 3d5f92dea..ae3fad2dc 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -36,6 +36,7 @@ import nova.compute.api from nova.compute import instance_types from nova.compute import power_state import nova.db.api +import nova.scheduler.api from nova.db.sqlalchemy.models import Instance from nova.db.sqlalchemy.models import InstanceMetadata import nova.rpc @@ -68,6 +69,26 @@ def return_servers(context, user_id=1): return [stub_instance(i, user_id) for i in xrange(5)] +def return_servers_by_reservation(context, reservation_id=""): + return [stub_instance(i, reservation_id) for i in xrange(5)] + + +def return_servers_from_child_zones(*args, **kwargs): + class Server(object): + pass + + zones = [] + for zone in xrange(3): + servers = [] + for server_id in xrange(5): + server = Server() + server._info = stub_instance(server_id, reservation_id="child") + servers.append(server) + + zones.append(("Zone%d" % zone, servers)) + return zones + + def return_security_group(context, instance_id, security_group_id): pass @@ -81,7 +102,7 @@ def instance_address(context, instance_id): def stub_instance(id, user_id=1, private_address=None, public_addresses=None, - host=None, power_state=0): + host=None, power_state=0, reservation_id=""): metadata = [] metadata.append(InstanceMetadata(key='seq', value=id)) @@ -93,6 +114,11 @@ def stub_instance(id, user_id=1, private_address=None, public_addresses=None, if host is not None: host = str(host) + # ReservationID isn't sent back, hack it in there. + server_name = "server%s" % id + if reservation_id != "": + server_name = "reservation_%s" % (reservation_id, ) + instance = { "id": id, "admin_pass": "", @@ -113,13 +139,13 @@ def stub_instance(id, user_id=1, private_address=None, public_addresses=None, "host": host, "instance_type": dict(inst_type), "user_data": "", - "reservation_id": "", + "reservation_id": reservation_id, "mac_address": "", "scheduled_at": datetime.datetime.now(), "launched_at": datetime.datetime.now(), "terminated_at": datetime.datetime.now(), "availability_zone": "", - "display_name": "server%s" % id, + "display_name": server_name, "display_description": "", "locked": False, "metadata": metadata} @@ -364,6 +390,24 @@ class ServersTest(test.TestCase): self.assertEqual(s.get('imageId', None), None) i += 1 + def test_get_server_list_with_reservation_id(self): + self.stubs.Set(nova.db.api, 'instance_get_all_by_reservation', + return_servers_by_reservation) + self.stubs.Set(nova.scheduler.api, 'call_zone_method', + return_servers_from_child_zones) + req = webob.Request.blank('/v1.0/servers/detail?reservation_id=foo') + res = req.get_response(fakes.wsgi_app()) + res_dict = json.loads(res.body) + + i = 0 + for s in res_dict['servers']: + print "SERVER", s + if '_is_precooked' in s: + self.assertEqual(s.get('reservation_id'), 'child') + else: + self.assertEqual(s.get('name'), 'server%d' % i) + i += 1 + def test_get_server_list_v1_1(self): req = webob.Request.blank('/v1.1/servers') res = req.get_response(fakes.wsgi_app()) -- cgit From 983bff090da0f09f944dd4152173a4586866a895 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Thu, 2 Jun 2011 08:05:46 -0700 Subject: more tests (empty responses) --- nova/tests/api/openstack/test_servers.py | 45 +++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index ae3fad2dc..ba76b6691 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -73,6 +73,14 @@ def return_servers_by_reservation(context, reservation_id=""): return [stub_instance(i, reservation_id) for i in xrange(5)] +def return_servers_by_reservation_empty(context, reservation_id=""): + return [] + + +def return_servers_from_child_zones_empty(*args, **kwargs): + return [] + + def return_servers_from_child_zones(*args, **kwargs): class Server(object): pass @@ -395,19 +403,54 @@ class ServersTest(test.TestCase): return_servers_by_reservation) self.stubs.Set(nova.scheduler.api, 'call_zone_method', return_servers_from_child_zones) + req = webob.Request.blank('/v1.0/servers?reservation_id=foo') + res = req.get_response(fakes.wsgi_app()) + res_dict = json.loads(res.body) + + i = 0 + for s in res_dict['servers']: + if '_is_precooked' in s: + self.assertEqual(s.get('reservation_id'), 'child') + else: + self.assertEqual(s.get('name'), 'server%d' % i) + i += 1 + + def test_get_server_list_with_reservation_id_empty(self): + self.stubs.Set(nova.db.api, 'instance_get_all_by_reservation', + return_servers_by_reservation_empty) + self.stubs.Set(nova.scheduler.api, 'call_zone_method', + return_servers_from_child_zones_empty) req = webob.Request.blank('/v1.0/servers/detail?reservation_id=foo') res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) i = 0 for s in res_dict['servers']: - print "SERVER", s if '_is_precooked' in s: self.assertEqual(s.get('reservation_id'), 'child') else: self.assertEqual(s.get('name'), 'server%d' % i) i += 1 + def test_get_server_list_with_reservation_id_details(self): + self.stubs.Set(nova.db.api, 'instance_get_all_by_reservation', + return_servers_by_reservation) + self.stubs.Set(nova.scheduler.api, 'call_zone_method', + return_servers_from_child_zones) + req = webob.Request.blank('/v1.0/servers/detail?reservation_id=foo') + res = req.get_response(fakes.wsgi_app()) + res_dict = json.loads(res.body) + + i = 0 + for s in res_dict['servers']: + if '_is_precooked' in s: + self.assertEqual(s.get('reservation_id'), 'child') + else: + self.assertEqual(s.get('name'), 'server%d' % i) + i += 1 + + + def test_get_server_list_v1_1(self): req = webob.Request.blank('/v1.1/servers') res = req.get_response(fakes.wsgi_app()) -- cgit From b380e0de4b7c24607c16734a46b3e11d64947b01 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 2 Jun 2011 11:12:35 -0400 Subject: Remove a rogue comment. --- nova/image/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/image/__init__.py b/nova/image/__init__.py index f42332a29..93d83df24 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -70,7 +70,6 @@ def get_glance_client(image_href): except: raise exception.InvalidImageRef(image_href=image_href) glance_client = GlanceClient(host, port) - #glance_client = client.Client(host, port) return (glance_client, image_id) -- cgit From 052f08256d2be2dda5ed792be48aa4f97cb93a93 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 2 Jun 2011 11:38:20 -0400 Subject: Remove comment about imageRef not being implemented. --- nova/tests/integrated/integrated_helpers.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index 5eacc829d..522c7cb0e 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -207,10 +207,7 @@ class _IntegratedTestBase(test.TestCase): if 'imageRef' in image: image_href = image['imageRef'] else: - # NOTE(justinsb): The imageRef code hasn't yet landed - LOG.warning("imageRef not yet in images output") image_href = image['id'] - image_href = 'http://fake.server/%s' % image_href # We now have a valid imageId -- cgit From 9f1027069c47ea83e1dfca9bed48b2a403463689 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Thu, 2 Jun 2011 11:58:17 -0400 Subject: got rid of more test debugging stuff that shouldnt have made it in --- nova/tests/integrated/test_servers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index 1733896fd..fcb517cf5 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -94,7 +94,6 @@ class ServersTest(integrated_helpers._IntegratedTestBase): servers = self.api.get_servers() server_ids = [server['id'] for server in servers] self.assertTrue(created_server_id in server_ids) - return # Wait (briefly) for creation retries = 0 -- cgit From 7ca707c1cbfb3164d4b6f706a4e9720e54bcc35f Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Thu, 2 Jun 2011 12:02:16 -0400 Subject: Minor comment formatting changes. --- nova/api/openstack/common.py | 6 +++--- nova/api/openstack/images.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 559b44ef5..40fb59765 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -36,16 +36,16 @@ XML_NS_V11 = 'http://docs.openstack.org/compute/api/v1.1' def get_pagination_params(request): - """ - Return marker, limit tuple from request + """Return marker, limit tuple from request. - @param request: `wsgi.Request` possibly containing 'marker' and 'limit' + :param request: `wsgi.Request` possibly containing 'marker' and 'limit' GET variables. 'marker' is the id of the last element the client has seen, and 'limit' is the maximum number of items to return. If 'limit' is not specified, 0, or > max_limit, we default to max_limit. Negative values for either marker or limit will cause exc.HTTPBadRequest() exceptions to be raised. + """ try: marker = int(request.GET.get('marker', 0)) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 7f06c53df..73249b485 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -130,6 +130,7 @@ class ControllerV10(Controller): """Return an index listing of images available to the request. :param req: `wsgi.Request` object + """ context = req.environ['nova.context'] filters = self._get_filters(req) @@ -142,6 +143,7 @@ class ControllerV10(Controller): """Return a detailed index listing of images available to the request. :param req: `wsgi.Request` object. + """ context = req.environ['nova.context'] filters = self._get_filters(req) -- cgit From 9034bb2fcd5f03df2b25d6114adc4e7d5f3549fe Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 2 Jun 2011 13:00:17 -0400 Subject: Remove some of the extra image service calls from the OS API images controller. --- nova/api/openstack/images.py | 6 ++---- nova/tests/api/openstack/fakes.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 87cbef791..59d9e3082 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -94,8 +94,7 @@ class Controller(object): context = req.environ['nova.context'] try: - (image_service, image_id) = nova.image.get_image_service(id) - image = image_service.show(context, image_id) + image = self._image_service.show(context, id) except (exception.NotFound, exception.InvalidImageRef): explanation = _("Image not found.") raise faults.Fault(webob.exc.HTTPNotFound(explanation=explanation)) @@ -109,8 +108,7 @@ class Controller(object): :param id: Image identifier (integer) """ context = req.environ['nova.context'] - (image_service, image_id) = nova.image.get_image_service(id) - image_service.delete(context, image_id) + self._image_service.delete(context, id) return webob.exc.HTTPNoContent() def create(self, req, body): diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 97fc3900d..17d6d591c 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -211,7 +211,7 @@ def stub_out_glance(stubs, initial_fixtures=None): def _find_image(self, image_id): for f in self.fixtures: - if f['id'] == image_id: + if str(f['id']) == str(image_id): return f return None -- cgit From be2f5e986e41f8f8d63c0ef7a5c03916c70ba455 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Jun 2011 10:20:26 -0700 Subject: don't use python if readlink is available --- nova/auth/novarc.template | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/auth/novarc.template b/nova/auth/novarc.template index 92eed3520..d30bd849c 100644 --- a/nova/auth/novarc.template +++ b/nova/auth/novarc.template @@ -1,5 +1,6 @@ -NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE:-$0}) -NOVA_KEY_DIR=$(dirname ${NOVARC}) +NOVARC=$(readlink -f "${BASH_SOURCE:-${0}}" 2>/dev/null) || + NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' "${BASH_SOURCE:-${0}}") +NOVA_KEY_DIR=${NOVARC%/*} export EC2_ACCESS_KEY="%(access)s:%(project)s" export EC2_SECRET_KEY="%(secret)s" export EC2_URL="%(ec2)s" -- cgit From 28320ced7afb2c224ab4e1cfb8a607646a2bd2e3 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Jun 2011 11:28:41 -0700 Subject: use %% because % is a replacement string character --- nova/auth/novarc.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/auth/novarc.template b/nova/auth/novarc.template index d30bd849c..eba3a8537 100644 --- a/nova/auth/novarc.template +++ b/nova/auth/novarc.template @@ -1,6 +1,6 @@ NOVARC=$(readlink -f "${BASH_SOURCE:-${0}}" 2>/dev/null) || NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' "${BASH_SOURCE:-${0}}") -NOVA_KEY_DIR=${NOVARC%/*} +NOVA_KEY_DIR=${NOVARC%%/*} export EC2_ACCESS_KEY="%(access)s:%(project)s" export EC2_SECRET_KEY="%(secret)s" export EC2_URL="%(ec2)s" -- cgit From ae1842174f4b079c8d84b32ddad4df1b7ff29bec Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Jun 2011 12:01:49 -0700 Subject: Tests to assure all exceptions can be raised as well as fixing NotAuthorized --- nova/exception.py | 4 ++-- nova/tests/test_misc.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/nova/exception.py b/nova/exception.py index d3d58f3b2..5b824bba6 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -65,7 +65,7 @@ class BuildInProgress(Error): class DBError(Error): """Wraps an implementation specific exception.""" - def __init__(self, inner_exception): + def __init__(self, inner_exception=None): self.inner_exception = inner_exception super(DBError, self).__init__(str(inner_exception)) @@ -122,7 +122,7 @@ class NotAuthorized(NovaException): message = _("Not authorized.") def __init__(self, *args, **kwargs): - super(NotFound, self).__init__(**kwargs) + super(NotAuthorized, self).__init__(**kwargs) class AdminRequired(NotAuthorized): diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py index cf8f4c05e..c5875a843 100644 --- a/nova/tests/test_misc.py +++ b/nova/tests/test_misc.py @@ -21,11 +21,24 @@ import select from eventlet import greenpool from eventlet import greenthread +from nova import exception from nova import test from nova import utils from nova.utils import parse_mailmap, str_dict_replace +class ExceptionTestCase(test.TestCase): + @staticmethod + def _raise_exc(exc): + raise exc() + + def test_exceptions_raise(self): + for name in dir(exception): + exc = getattr(exception, name) + if isinstance(exc, type): + self.assertRaises(exc, self._raise_exc, exc) + + class ProjectTestCase(test.TestCase): def test_authors_up_to_date(self): topdir = os.path.normpath(os.path.dirname(__file__) + '/../../') -- cgit From b2fb1738db489206557abccb631b13991c31fd4e Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Jun 2011 14:23:05 -0700 Subject: make all uses of utcnow use our testable utils.utcnow --- bin/nova-manage | 3 +-- nova/api/ec2/admin.py | 3 +-- nova/api/ec2/cloud.py | 5 ++-- nova/api/openstack/auth.py | 5 ++-- nova/api/openstack/contrib/__init__.py | 2 +- nova/api/openstack/limits.py | 2 +- nova/api/openstack/ratelimiting/__init__.py | 2 +- nova/compute/api.py | 3 +-- nova/compute/manager.py | 3 +-- nova/compute/monitor.py | 2 +- nova/context.py | 1 - nova/db/sqlalchemy/api.py | 29 +++++++++++----------- .../versions/016_make_quotas_key_and_value.py | 10 ++++---- nova/db/sqlalchemy/models.py | 9 +++---- nova/network/manager.py | 2 +- nova/notifier/api.py | 7 +++--- nova/scheduler/driver.py | 3 ++- nova/scheduler/simple.py | 11 ++++---- nova/test.py | 4 +-- nova/tests/api/openstack/fakes.py | 3 +-- nova/tests/api/openstack/test_images.py | 1 - nova/tests/api/openstack/test_servers.py | 8 +++--- nova/tests/test_compute.py | 5 ++-- nova/tests/test_console.py | 2 -- nova/tests/test_middleware.py | 1 - nova/tests/test_scheduler.py | 16 ++++++------ nova/utils.py | 2 +- nova/virt/xenapi/fake.py | 4 +-- nova/volume/api.py | 5 ++-- nova/volume/manager.py | 4 +-- 30 files changed, 69 insertions(+), 88 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 5de4d9e81..b545c4246 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -53,7 +53,6 @@ CLI interface for nova management. """ -import datetime import gettext import glob import json @@ -689,7 +688,7 @@ class ServiceCommands(object): """Show a list of all running services. Filter by host & service name. args: [host] [service]""" ctxt = context.get_admin_context() - now = datetime.datetime.utcnow() + now = utils.utcnow() services = db.service_get_all(ctxt) if host: services = [s for s in services if s['host'] == host] diff --git a/nova/api/ec2/admin.py b/nova/api/ec2/admin.py index ea94d9c1f..aeebd86fb 100644 --- a/nova/api/ec2/admin.py +++ b/nova/api/ec2/admin.py @@ -21,7 +21,6 @@ Admin API controller, exposed through http via the api worker. """ import base64 -import datetime from nova import db from nova import exception @@ -305,7 +304,7 @@ class AdminController(object): * Volume Count """ services = db.service_get_all(context, False) - now = datetime.datetime.utcnow() + now = utils.utcnow() hosts = [] rv = [] for host in [service['host'] for service in services]: diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 79cc3b3bf..04675174f 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -23,7 +23,6 @@ datastore. """ import base64 -import datetime import IPy import os import urllib @@ -235,7 +234,7 @@ class CloudController(object): 'zoneState': 'available'}]} services = db.service_get_all(context, False) - now = datetime.datetime.utcnow() + now = utils.utcnow() hosts = [] for host in [service['host'] for service in services]: if not host in hosts: @@ -595,7 +594,7 @@ class CloudController(object): instance_id = ec2utils.ec2_id_to_id(ec2_id) output = self.compute_api.get_console_output( context, instance_id=instance_id) - now = datetime.datetime.utcnow() + now = utils.utcnow() return {"InstanceId": ec2_id, "Timestamp": now, "output": base64.b64encode(output)} diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index 6c6ee22a2..b49bf449b 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -13,9 +13,8 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License.import datetime +# under the License. -import datetime import hashlib import time @@ -127,7 +126,7 @@ class AuthMiddleware(wsgi.Middleware): except exception.NotFound: return None if token: - delta = datetime.datetime.utcnow() - token['created_at'] + delta = utils.utcnow() - token['created_at'] if delta.days >= 2: self.db.auth_token_destroy(ctxt, token['token_hash']) else: diff --git a/nova/api/openstack/contrib/__init__.py b/nova/api/openstack/contrib/__init__.py index b42a1d89d..acb5eb280 100644 --- a/nova/api/openstack/contrib/__init__.py +++ b/nova/api/openstack/contrib/__init__.py @@ -13,7 +13,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License.import datetime +# under the License. """Contrib contains extensions that are shipped with nova. diff --git a/nova/api/openstack/limits.py b/nova/api/openstack/limits.py index 4d46b92df..dc2bc6bbc 100644 --- a/nova/api/openstack/limits.py +++ b/nova/api/openstack/limits.py @@ -11,7 +11,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License.import datetime +# under the License. """ Module dedicated functions/classes dealing with rate limiting requests. diff --git a/nova/api/openstack/ratelimiting/__init__.py b/nova/api/openstack/ratelimiting/__init__.py index 88ffc3246..9ede548c2 100644 --- a/nova/api/openstack/ratelimiting/__init__.py +++ b/nova/api/openstack/ratelimiting/__init__.py @@ -13,7 +13,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License.import datetime +# under the License. """Rate limiting of arbitrary actions.""" diff --git a/nova/compute/api.py b/nova/compute/api.py index 7122ebe67..de87ddd88 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -18,7 +18,6 @@ """Handles all requests relating to instances (guest vms).""" -import datetime import eventlet import re import time @@ -405,7 +404,7 @@ class API(base.Base): instance['id'], state_description='terminating', state=0, - terminated_at=datetime.datetime.utcnow()) + terminated_at=utils.utcnow()) host = instance['host'] if host: diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 3897b3a9e..a57d6e246 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -35,7 +35,6 @@ terminating it. """ -import datetime import os import socket import sys @@ -159,7 +158,7 @@ class ComputeManager(manager.SchedulerDependentManager): def _update_launched_at(self, context, instance_id, launched_at=None): """Update the launched_at parameter of the given instance.""" - data = {'launched_at': launched_at or datetime.datetime.utcnow()} + data = {'launched_at': launched_at or utils.utcnow()} self.db.instance_update(context, instance_id, data) def _update_image_id(self, context, instance_id, image_id): diff --git a/nova/compute/monitor.py b/nova/compute/monitor.py index 3bb54a382..613734bef 100644 --- a/nova/compute/monitor.py +++ b/nova/compute/monitor.py @@ -86,7 +86,7 @@ RRD_VALUES = { ]} -utcnow = datetime.datetime.utcnow +utcnow = utils.utcnow LOG = logging.getLogger('nova.compute.monitor') diff --git a/nova/context.py b/nova/context.py index c113f7ea7..99085ed75 100644 --- a/nova/context.py +++ b/nova/context.py @@ -18,7 +18,6 @@ """RequestContext: context for requests that persist through all of nova.""" -import datetime import random from nova import exception diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index c3a971a82..bb7bf5b89 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -19,7 +19,6 @@ Implementation of SQLAlchemy backend. """ -import datetime import warnings from nova import db @@ -674,7 +673,7 @@ def fixed_ip_disassociate_all_by_timeout(_context, host, time): filter_by(allocated=0).\ update({'instance_id': None, 'leased': 0, - 'updated_at': datetime.datetime.utcnow()}, + 'updated_at': utils.utcnow()}, synchronize_session='fetch') return result @@ -820,17 +819,17 @@ def instance_destroy(context, instance_id): session.query(models.Instance).\ filter_by(id=instance_id).\ update({'deleted': True, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupInstanceAssociation).\ filter_by(instance_id=instance_id).\ update({'deleted': True, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.InstanceMetadata).\ filter_by(instance_id=instance_id).\ update({'deleted': True, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1123,7 +1122,7 @@ def key_pair_destroy_all_by_user(context, user_id): session.query(models.KeyPair).\ filter_by(user_id=user_id).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1655,7 +1654,7 @@ def volume_destroy(context, volume_id): session.query(models.Volume).\ filter_by(id=volume_id).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.ExportDevice).\ filter_by(volume_id=volume_id).\ @@ -1813,7 +1812,7 @@ def snapshot_destroy(context, snapshot_id): session.query(models.Snapshot).\ filter_by(id=snapshot_id).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1968,17 +1967,17 @@ def security_group_destroy(context, security_group_id): session.query(models.SecurityGroup).\ filter_by(id=security_group_id).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupInstanceAssociation).\ filter_by(security_group_id=security_group_id).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupIngressRule).\ filter_by(group_id=security_group_id).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1989,11 +1988,11 @@ def security_group_destroy_all(context, session=None): with session.begin(): session.query(models.SecurityGroup).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupIngressRule).\ update({'deleted': 1, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -2627,7 +2626,7 @@ def instance_metadata_delete(context, instance_id, key): filter_by(key=key).\ filter_by(deleted=False).\ update({'deleted': True, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -2638,7 +2637,7 @@ def instance_metadata_delete_all(context, instance_id): filter_by(instance_id=instance_id).\ filter_by(deleted=False).\ update({'deleted': True, - 'deleted_at': datetime.datetime.utcnow(), + 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py index 5d0593f2e..a4fe3e482 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py @@ -17,7 +17,7 @@ from sqlalchemy import Boolean, Column, DateTime, Integer from sqlalchemy import MetaData, String, Table -import datetime +from nova import utils meta = MetaData() @@ -35,9 +35,9 @@ def old_style_quotas_table(name): return Table(name, meta, Column('id', Integer(), primary_key=True), Column('created_at', DateTime(), - default=datetime.datetime.utcnow), + default=utils.utcnow), Column('updated_at', DateTime(), - onupdate=datetime.datetime.utcnow), + onupdate=utils.utcnow), Column('deleted_at', DateTime()), Column('deleted', Boolean(), default=False), Column('project_id', @@ -57,9 +57,9 @@ def new_style_quotas_table(name): return Table(name, meta, Column('id', Integer(), primary_key=True), Column('created_at', DateTime(), - default=datetime.datetime.utcnow), + default=utils.utcnow), Column('updated_at', DateTime(), - onupdate=datetime.datetime.utcnow), + onupdate=utils.utcnow), Column('deleted_at', DateTime()), Column('deleted', Boolean(), default=False), Column('project_id', diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 22a1a84e8..dbe72efd9 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -19,8 +19,6 @@ SQLAlchemy models for nova data. """ -import datetime - from sqlalchemy.orm import relationship, backref, object_mapper from sqlalchemy import Column, Integer, String, schema from sqlalchemy import ForeignKey, DateTime, Boolean, Text @@ -33,6 +31,7 @@ from nova.db.sqlalchemy.session import get_session from nova import auth from nova import exception from nova import flags +from nova import utils FLAGS = flags.FLAGS @@ -43,8 +42,8 @@ class NovaBase(object): """Base class for Nova Models.""" __table_args__ = {'mysql_engine': 'InnoDB'} __table_initialized__ = False - created_at = Column(DateTime, default=datetime.datetime.utcnow) - updated_at = Column(DateTime, onupdate=datetime.datetime.utcnow) + created_at = Column(DateTime, default=utils.utcnow) + updated_at = Column(DateTime, onupdate=utils.utcnow) deleted_at = Column(DateTime) deleted = Column(Boolean, default=False) @@ -64,7 +63,7 @@ class NovaBase(object): def delete(self, session=None): """Delete this object.""" self.deleted = True - self.deleted_at = datetime.datetime.utcnow() + self.deleted_at = utils.utcnow() self.save(session=session) def __setitem__(self, key, value): diff --git a/nova/network/manager.py b/nova/network/manager.py index 5a6fdde5a..f726c4b26 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -235,7 +235,7 @@ class NetworkManager(manager.SchedulerDependentManager): inst_addr = instance_ref['mac_address'] raise exception.Error(_('IP %(address)s leased to bad mac' ' %(inst_addr)s vs %(mac)s') % locals()) - now = datetime.datetime.utcnow() + now = utils.utcnow() self.db.fixed_ip_update(context, fixed_ip_ref['address'], {'leased': True, diff --git a/nova/notifier/api.py b/nova/notifier/api.py index a3e7a039e..d49517c8b 100644 --- a/nova/notifier/api.py +++ b/nova/notifier/api.py @@ -11,9 +11,8 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License.import datetime +# under the License. -import datetime import uuid from nova import flags @@ -64,7 +63,7 @@ def notify(publisher_id, event_type, priority, payload): {'message_id': str(uuid.uuid4()), 'publisher_id': 'compute.host1', - 'timestamp': datetime.datetime.utcnow(), + 'timestamp': utils.utcnow(), 'priority': 'WARN', 'event_type': 'compute.create_instance', 'payload': {'instance_id': 12, ... }} @@ -79,5 +78,5 @@ def notify(publisher_id, event_type, priority, payload): event_type=event_type, priority=priority, payload=payload, - timestamp=str(datetime.datetime.utcnow())) + timestamp=str(utils.utcnow())) driver.notify(msg) diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 2094e3565..0b257c5d8 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -28,6 +28,7 @@ from nova import exception from nova import flags from nova import log as logging from nova import rpc +from nova import utils from nova.compute import power_state FLAGS = flags.FLAGS @@ -61,7 +62,7 @@ class Scheduler(object): """Check whether a service is up based on last heartbeat.""" last_heartbeat = service['updated_at'] or service['created_at'] # Timestamps in DB are UTC. - elapsed = datetime.datetime.utcnow() - last_heartbeat + elapsed = utils.utcnow() - last_heartbeat return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time) def hosts_up(self, context, topic): diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py index dd568d2c6..87cdef11d 100644 --- a/nova/scheduler/simple.py +++ b/nova/scheduler/simple.py @@ -21,10 +21,9 @@ Simple Scheduler """ -import datetime - from nova import db from nova import flags +from nova import utils from nova.scheduler import driver from nova.scheduler import chance @@ -54,7 +53,7 @@ class SimpleScheduler(chance.ChanceScheduler): # TODO(vish): this probably belongs in the manager, if we # can generalize this somehow - now = datetime.datetime.utcnow() + now = utils.utcnow() db.instance_update(context, instance_id, {'host': host, 'scheduled_at': now}) return host @@ -66,7 +65,7 @@ class SimpleScheduler(chance.ChanceScheduler): if self.service_is_up(service): # NOTE(vish): this probably belongs in the manager, if we # can generalize this somehow - now = datetime.datetime.utcnow() + now = utils.utcnow() db.instance_update(context, instance_id, {'host': service['host'], @@ -90,7 +89,7 @@ class SimpleScheduler(chance.ChanceScheduler): # TODO(vish): this probably belongs in the manager, if we # can generalize this somehow - now = datetime.datetime.utcnow() + now = utils.utcnow() db.volume_update(context, volume_id, {'host': host, 'scheduled_at': now}) return host @@ -103,7 +102,7 @@ class SimpleScheduler(chance.ChanceScheduler): if self.service_is_up(service): # NOTE(vish): this probably belongs in the manager, if we # can generalize this somehow - now = datetime.datetime.utcnow() + now = utils.utcnow() db.volume_update(context, volume_id, {'host': service['host'], diff --git a/nova/test.py b/nova/test.py index 80b2d0a74..60b599ce4 100644 --- a/nova/test.py +++ b/nova/test.py @@ -23,7 +23,6 @@ inline callbacks. """ -import datetime import functools import os import shutil @@ -37,6 +36,7 @@ from eventlet import greenthread from nova import fakerabbit from nova import flags from nova import rpc +from nova import utils from nova import service from nova import wsgi from nova.virt import fake @@ -69,7 +69,7 @@ class TestCase(unittest.TestCase): # NOTE(vish): We need a better method for creating fixtures for tests # now that we have some required db setup for the system # to work properly. - self.start = datetime.datetime.utcnow() + self.start = utils.utcnow() shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db), os.path.join(FLAGS.state_path, FLAGS.sqlite_db)) diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 8e0156afa..4fb0613fc 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -16,7 +16,6 @@ # under the License. import copy -import datetime import json import random import string @@ -253,7 +252,7 @@ class FakeAuthDatabase(object): @staticmethod def auth_token_create(context, token): - fake_token = FakeToken(created_at=datetime.datetime.now(), **token) + fake_token = FakeToken(created_at=utils.utcnow(), **token) FakeAuthDatabase.data[fake_token.token_hash] = fake_token FakeAuthDatabase.data['id_%i' % fake_token.id] = fake_token return fake_token diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 9f1f28611..93b402081 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -22,7 +22,6 @@ and as a WSGI layer import copy import json -import datetime import os import shutil import tempfile diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 11dcaaade..50d5fe980 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -16,7 +16,6 @@ # under the License. import base64 -import datetime import json import unittest from xml.dom import minidom @@ -29,6 +28,7 @@ from nova import db from nova import exception from nova import flags from nova import test +from nova import utils import nova.api.openstack from nova.api.openstack import servers import nova.compute.api @@ -114,9 +114,9 @@ def stub_instance(id, user_id=1, private_address=None, public_addresses=None, "user_data": "", "reservation_id": "", "mac_address": "", - "scheduled_at": datetime.datetime.now(), - "launched_at": datetime.datetime.now(), - "terminated_at": datetime.datetime.now(), + "scheduled_at": utils.utcnow(), + "launched_at": utils.utcnow(), + "terminated_at": utils.utcnow(), "availability_zone": "", "display_name": "server%s" % id, "display_description": "", diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 9170837b6..c726080ee 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -19,7 +19,6 @@ Tests For Compute """ -import datetime import mox import stubout @@ -217,12 +216,12 @@ class ComputeTestCase(test.TestCase): instance_ref = db.instance_get(self.context, instance_id) self.assertEqual(instance_ref['launched_at'], None) self.assertEqual(instance_ref['deleted_at'], None) - launch = datetime.datetime.utcnow() + launch = utils.utcnow() self.compute.run_instance(self.context, instance_id) instance_ref = db.instance_get(self.context, instance_id) self.assert_(instance_ref['launched_at'] > launch) self.assertEqual(instance_ref['deleted_at'], None) - terminate = datetime.datetime.utcnow() + terminate = utils.utcnow() self.compute.terminate_instance(self.context, instance_id) self.context = self.context.elevated(True) instance_ref = db.instance_get(self.context, instance_id) diff --git a/nova/tests/test_console.py b/nova/tests/test_console.py index 1a9a867ee..831e7670f 100644 --- a/nova/tests/test_console.py +++ b/nova/tests/test_console.py @@ -20,8 +20,6 @@ Tests For Console proxy. """ -import datetime - from nova import context from nova import db from nova import exception diff --git a/nova/tests/test_middleware.py b/nova/tests/test_middleware.py index 6564a6955..40d117c45 100644 --- a/nova/tests/test_middleware.py +++ b/nova/tests/test_middleware.py @@ -16,7 +16,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime import webob import webob.dec import webob.exc diff --git a/nova/tests/test_scheduler.py b/nova/tests/test_scheduler.py index 54b3f80fb..1cf6bbfbf 100644 --- a/nova/tests/test_scheduler.py +++ b/nova/tests/test_scheduler.py @@ -196,7 +196,7 @@ class ZoneSchedulerTestCase(test.TestCase): service.topic = 'compute' service.id = kwargs['id'] service.availability_zone = kwargs['zone'] - service.created_at = datetime.datetime.utcnow() + service.created_at = utils.utcnow() return service def test_with_two_zones(self): @@ -290,7 +290,7 @@ class SimpleDriverTestCase(test.TestCase): dic['host'] = kwargs.get('host', 'dummy') s_ref = db.service_create(self.context, dic) if 'created_at' in kwargs.keys() or 'updated_at' in kwargs.keys(): - t = datetime.datetime.utcnow() - datetime.timedelta(0) + t = utils.utcnow() - datetime.timedelta(0) dic['created_at'] = kwargs.get('created_at', t) dic['updated_at'] = kwargs.get('updated_at', t) db.service_update(self.context, s_ref['id'], dic) @@ -401,7 +401,7 @@ class SimpleDriverTestCase(test.TestCase): FLAGS.compute_manager) compute1.start() s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - now = datetime.datetime.utcnow() + now = utils.utcnow() delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) past = now - delta db.service_update(self.context, s1['id'], {'updated_at': past}) @@ -542,7 +542,7 @@ class SimpleDriverTestCase(test.TestCase): def test_wont_sechedule_if_specified_host_is_down(self): compute1 = self.start_service('compute', host='host1') s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') - now = datetime.datetime.utcnow() + now = utils.utcnow() delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) past = now - delta db.service_update(self.context, s1['id'], {'updated_at': past}) @@ -692,7 +692,7 @@ class SimpleDriverTestCase(test.TestCase): dic = {'instance_id': instance_id, 'size': 1} v_ref = db.volume_create(self.context, {'instance_id': instance_id, 'size': 1}) - t1 = datetime.datetime.utcnow() - datetime.timedelta(1) + t1 = utils.utcnow() - datetime.timedelta(1) dic = {'created_at': t1, 'updated_at': t1, 'binary': 'nova-volume', 'topic': 'volume', 'report_count': 0} s_ref = db.service_create(self.context, dic) @@ -709,7 +709,7 @@ class SimpleDriverTestCase(test.TestCase): """Confirms src-compute node is alive.""" instance_id = self._create_instance() i_ref = db.instance_get(self.context, instance_id) - t = datetime.datetime.utcnow() - datetime.timedelta(10) + t = utils.utcnow() - datetime.timedelta(10) s_ref = self._create_compute_service(created_at=t, updated_at=t, host=i_ref['host']) @@ -737,7 +737,7 @@ class SimpleDriverTestCase(test.TestCase): """Confirms exception raises in case dest host does not exist.""" instance_id = self._create_instance() i_ref = db.instance_get(self.context, instance_id) - t = datetime.datetime.utcnow() - datetime.timedelta(10) + t = utils.utcnow() - datetime.timedelta(10) s_ref = self._create_compute_service(created_at=t, updated_at=t, host=i_ref['host']) @@ -796,7 +796,7 @@ class SimpleDriverTestCase(test.TestCase): # mocks for live_migration_common_check() instance_id = self._create_instance() i_ref = db.instance_get(self.context, instance_id) - t1 = datetime.datetime.utcnow() - datetime.timedelta(10) + t1 = utils.utcnow() - datetime.timedelta(10) s_ref = self._create_compute_service(created_at=t1, updated_at=t1, host=dest) diff --git a/nova/utils.py b/nova/utils.py index 361fc9873..b1638e72c 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -307,7 +307,7 @@ def get_my_linklocal(interface): def utcnow(): - """Overridable version of datetime.datetime.utcnow.""" + """Overridable version of utils.utcnow.""" if utcnow.override_time: return utcnow.override_time return datetime.datetime.utcnow() diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index 76988b172..165888cb2 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -51,13 +51,13 @@ A fake XenAPI SDK. """ -import datetime import uuid from pprint import pformat from nova import exception from nova import log as logging +from nova import utils _CLASSES = ['host', 'network', 'session', 'SR', 'VBD', @@ -540,7 +540,7 @@ class SessionBase(object): except Failure, exc: task['error_info'] = exc.details task['status'] = 'failed' - task['finished'] = datetime.datetime.now() + task['finished'] = utils.utcnow() return task_ref def _check_session(self, params): diff --git a/nova/volume/api.py b/nova/volume/api.py index 5804955f7..b07f2e94b 100644 --- a/nova/volume/api.py +++ b/nova/volume/api.py @@ -20,14 +20,13 @@ Handles all requests relating to volumes. """ -import datetime -from nova import db from nova import exception from nova import flags from nova import log as logging from nova import quota from nova import rpc +from nova import utils from nova.db import base FLAGS = flags.FLAGS @@ -78,7 +77,7 @@ class API(base.Base): volume = self.get(context, volume_id) if volume['status'] != "available": raise exception.ApiError(_("Volume status must be available")) - now = datetime.datetime.utcnow() + now = utils.utcnow() self.db.volume_update(context, volume_id, {'status': 'deleting', 'terminated_at': now}) host = volume['host'] diff --git a/nova/volume/manager.py b/nova/volume/manager.py index ff53f0701..798bd379a 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -42,8 +42,6 @@ intact. """ -import datetime - from nova import context from nova import exception @@ -127,7 +125,7 @@ class VolumeManager(manager.SchedulerDependentManager): volume_ref['id'], {'status': 'error'}) raise - now = datetime.datetime.utcnow() + now = utils.utcnow() self.db.volume_update(context, volume_ref['id'], {'status': 'available', 'launched_at': now}) -- cgit From 4762aebe4ddc57d8502ed3b5aec56b613d0ec93b Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Jun 2011 14:51:30 -0700 Subject: switch zones to use utcnow --- nova/scheduler/zone_manager.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/nova/scheduler/zone_manager.py b/nova/scheduler/zone_manager.py index 3ddf6f3c3..3f483adff 100644 --- a/nova/scheduler/zone_manager.py +++ b/nova/scheduler/zone_manager.py @@ -17,16 +17,17 @@ ZoneManager oversees all communications with child Zones. """ +import datetime import novaclient import thread import traceback -from datetime import datetime from eventlet import greenpool from nova import db from nova import flags from nova import log as logging +from nova import utils FLAGS = flags.FLAGS flags.DEFINE_integer('zone_db_check_interval', 60, @@ -42,7 +43,7 @@ class ZoneState(object): self.name = None self.capabilities = None self.attempt = 0 - self.last_seen = datetime.min + self.last_seen = datetime.datetime.min self.last_exception = None self.last_exception_time = None @@ -56,7 +57,7 @@ class ZoneState(object): def update_metadata(self, zone_metadata): """Update zone metadata after successful communications with child zone.""" - self.last_seen = datetime.now() + self.last_seen = utils.utcnow() self.attempt = 0 self.name = zone_metadata.get("name", "n/a") self.capabilities = ", ".join(["%s=%s" % (k, v) @@ -72,7 +73,7 @@ class ZoneState(object): """Something went wrong. Check to see if zone should be marked as offline.""" self.last_exception = exception - self.last_exception_time = datetime.now() + self.last_exception_time = utils.utcnow() api_url = self.api_url logging.warning(_("'%(exception)s' error talking to " "zone %(api_url)s") % locals()) @@ -104,7 +105,7 @@ def _poll_zone(zone): class ZoneManager(object): """Keeps the zone states updated.""" def __init__(self): - self.last_zone_db_check = datetime.min + self.last_zone_db_check = datetime.datetime.min self.zone_states = {} # { : ZoneState } self.service_states = {} # { : { : { cap k : v }}} self.green_pool = greenpool.GreenPool() @@ -158,10 +159,10 @@ class ZoneManager(object): def ping(self, context=None): """Ping should be called periodically to update zone status.""" - diff = datetime.now() - self.last_zone_db_check + diff = utils.utcnow() - self.last_zone_db_check if diff.seconds >= FLAGS.zone_db_check_interval: logging.debug(_("Updating zone cache from db.")) - self.last_zone_db_check = datetime.now() + self.last_zone_db_check = utils.utcnow() self._refresh_from_db(context) self._poll_zones(context) -- cgit From d7d628d58612b94491310a1a03727e1afa9d5ad5 Mon Sep 17 00:00:00 2001 From: Justin Shepherd Date: Thu, 2 Jun 2011 20:45:36 -0500 Subject: Added paramiko to tools/pip-requires --- tools/pip-requires | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/pip-requires b/tools/pip-requires index f1c5b2003..e81ef944a 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -33,3 +33,4 @@ suds==0.4 coverage nosexcover GitPython +paramiko -- cgit From a3b8b3467d836463dda806c93756841a52c055d3 Mon Sep 17 00:00:00 2001 From: Justin Shepherd Date: Thu, 2 Jun 2011 21:18:09 -0500 Subject: added nova_adminclient to tools/pip-requires --- tools/pip-requires | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/pip-requires b/tools/pip-requires index e81ef944a..035e4347d 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -34,3 +34,4 @@ coverage nosexcover GitPython paramiko +nova_adminclient -- cgit From 9ee103a91fe3bed03c3f4c6c1a6e89fa474e1aae Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 3 Jun 2011 12:37:58 +0400 Subject: Fixed FakeLdapDriver, made it call LdapDriver.__init__ --- nova/auth/ldapdriver.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 95e31ae3b..183f7a985 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -676,6 +676,7 @@ class LdapDriver(object): class FakeLdapDriver(LdapDriver): """Fake Ldap Auth driver""" - def __init__(self): # pylint: disable=W0231 - __import__('nova.auth.fakeldap') - self.ldap = sys.modules['nova.auth.fakeldap'] + def __init__(self): + import nova.auth.fakeldap + sys.modules['ldap'] = nova.auth.fakeldap + super(FakeLdapDriver, self).__init__() -- cgit From 72a47784dc09d9b840db146d58ea71f6af30a8ea Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 3 Jun 2011 13:39:22 +0400 Subject: Flush AuthManager's cache before each test. --- nova/tests/test_auth.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/tests/test_auth.py b/nova/tests/test_auth.py index f02dd94b7..7d00bddfe 100644 --- a/nova/tests/test_auth.py +++ b/nova/tests/test_auth.py @@ -86,6 +86,7 @@ class _AuthManagerBaseTestCase(test.TestCase): super(_AuthManagerBaseTestCase, self).setUp() self.flags(connection_type='fake') self.manager = manager.AuthManager(new=True) + self.manager.mc.cache = {} def test_create_and_find_user(self): with user_generator(self.manager): -- cgit From 29eec21f6752ef2c03412213a74aa12745286c82 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Fri, 3 Jun 2011 05:23:43 -0700 Subject: little tweaks --- doc/source/devref/distributed_scheduler.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index 28ba20af7..eb6a1a03e 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -1,7 +1,3 @@ - - - - .. Copyright 2011 OpenStack LLC All Rights Reserved. @@ -40,7 +36,7 @@ Some Costs are more esoteric. Consider a rule that says we should prefer Hosts t An example of some other costs might include selecting: * a GPU-based host over a standard CPU * a host with fast ethernet over a 10mbps line -* a host than can run Windows instances +* a host that can run Windows instances * a host in the EU vs North America * etc -- cgit From 8739529368cb755d33c3d8c532dd1c5d86f0bf85 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 3 Jun 2011 08:50:30 -0400 Subject: Implement OSAPI v1.1 style image create. --- nova/api/openstack/images.py | 11 ++++++++- nova/tests/api/openstack/fakes.py | 2 +- nova/tests/api/openstack/test_images.py | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 59d9e3082..48ea04248 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -123,7 +123,7 @@ class Controller(object): raise webob.exc.HTTPBadRequest() try: - server_id = body["image"]["serverId"] + server_id = self._server_id_from_req_data(body) image_name = body["image"]["name"] except KeyError: raise webob.exc.HTTPBadRequest() @@ -135,6 +135,9 @@ class Controller(object): """Indicates that you must use a Controller subclass.""" raise NotImplementedError + def _server_id_from_req_data(self, data): + raise NotImplementedError() + class ControllerV10(Controller): """Version 1.0 specific controller logic.""" @@ -144,6 +147,9 @@ class ControllerV10(Controller): base_url = request.application_url return images_view.ViewBuilderV10(base_url) + def _server_id_from_req_data(self, data): + return data['image']['serverId'] + class ControllerV11(Controller): """Version 1.1 specific controller logic.""" @@ -153,6 +159,9 @@ class ControllerV11(Controller): base_url = request.application_url return images_view.ViewBuilderV11(base_url) + def _server_id_from_req_data(self, data): + return data['image']['serverRef'] + def create_resource(version='1.0'): controller = { diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 17d6d591c..e9b46f933 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -143,7 +143,7 @@ def stub_out_networking(stubs): def stub_out_compute_api_snapshot(stubs): def snapshot(self, context, instance_id, name): - return 123 + return dict(id='123') stubs.Set(nova.compute.API, 'snapshot', snapshot) diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 9f1f28611..961c271ca 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -249,6 +249,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): fakes.stub_out_key_pair_funcs(self.stubs) self.fixtures = self._make_image_fixtures() fakes.stub_out_glance(self.stubs, initial_fixtures=self.fixtures) + fakes.stub_out_compute_api_snapshot(self.stubs) def tearDown(self): """Run after each test.""" @@ -871,6 +872,46 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 404) + def test_create_image(self): + + body = dict(image=dict(serverId='123', name='Backup 1')) + req = webob.Request.blank('/v1.0/images') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(200, response.status_int) + + def test_create_image_no_server_id(self): + + body = dict(image=dict(name='Backup 1')) + req = webob.Request.blank('/v1.0/images') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(400, response.status_int) + + def test_create_image_v1_1(self): + + body = dict(image=dict(serverRef='123', name='Backup 1')) + req = webob.Request.blank('/v1.1/images') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(200, response.status_int) + + def test_create_image_v1_1_no_server_ref(self): + + body = dict(image=dict(name='Backup 1')) + req = webob.Request.blank('/v1.1/images') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(400, response.status_int) + @classmethod def _make_image_fixtures(cls): image_id = 123 -- cgit From a9f21962a9e1e703730fbfae120129618b7a79ca Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Fri, 3 Jun 2011 09:24:46 -0400 Subject: Fixed pylint: no metadata member in models.py --- nova/db/sqlalchemy/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index edb7ffe4b..82b521e77 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -47,6 +47,7 @@ class NovaBase(object): updated_at = Column(DateTime, onupdate=datetime.datetime.utcnow) deleted_at = Column(DateTime) deleted = Column(Boolean, default=False) + metadata = None def save(self, session=None): """Save this object.""" -- cgit From 0ef4a127e9539f90ac1d2f2846832ecc48b51e05 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 3 Jun 2011 09:31:43 -0400 Subject: Add serverRef to image metadata serialization list. --- nova/api/openstack/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 48ea04248..1fa3267dc 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -177,7 +177,7 @@ def create_resource(version='1.0'): metadata = { "attributes": { "image": ["id", "name", "updated", "created", "status", - "serverId", "progress"], + "serverId", "progress", "serverRef"], "link": ["rel", "type", "href"], }, } -- cgit From b45d07ded9db7c92e03cea1427413d4dda95d869 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 3 Jun 2011 10:23:38 -0400 Subject: Make libvirt snapshotting work with images that don't have an 'architecture' property. --- nova/virt/libvirt/connection.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index c491418ae..98cdff311 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -403,8 +403,7 @@ class LibvirtConnection(driver.ComputeDriver): 'is_public': False, 'status': 'active', 'name': snapshot['name'], - 'properties': {'architecture': - base['properties']['architecture'], + 'properties': { 'kernel_id': instance['kernel_id'], 'image_location': 'snapshot', 'image_state': 'available', @@ -412,6 +411,9 @@ class LibvirtConnection(driver.ComputeDriver): 'ramdisk_id': instance['ramdisk_id'], } } + if 'architecture' in base['properties']: + arch = base['properties']['architecture'] + metadata['properties']['architecture'] = arch # Make the snapshot snapshot_name = uuid.uuid4().hex -- cgit From 5b00ca3ac874d0fff1eb2835cd4219f49d8a169f Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Fri, 3 Jun 2011 11:08:43 -0400 Subject: Set pylint to ignore correct lines that it could not determine were correct, due to the means by which eventlet.green imported subprocess Minimized the number of these lines to ignore --- nova/utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nova/utils.py b/nova/utils.py index 361fc9873..4e1b7c26a 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -142,24 +142,26 @@ def execute(*cmd, **kwargs): env = os.environ.copy() if addl_env: env.update(addl_env) + _PIPE = subprocess.PIPE #pylint: disable=E1101 obj = subprocess.Popen(cmd, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stdin=_PIPE, + stdout=_PIPE, + stderr=_PIPE, env=env) result = None if process_input is not None: result = obj.communicate(process_input) else: result = obj.communicate() - obj.stdin.close() - if obj.returncode: - LOG.debug(_('Result was %s') % obj.returncode) + obj.stdin.close() #pylint: disable=E1101 + _returncode = obj.returncode #pylint: disable=E1101 + if _returncode: + LOG.debug(_('Result was %s') % _returncode) if type(check_exit_code) == types.IntType \ - and obj.returncode != check_exit_code: + and _returncode != check_exit_code: (stdout, stderr) = result raise exception.ProcessExecutionError( - exit_code=obj.returncode, + exit_code=_returncode, stdout=stdout, stderr=stderr, cmd=' '.join(cmd)) -- cgit From 24a90512f20310007f4ca8ab01da8e19a6b5bf6f Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Fri, 3 Jun 2011 11:28:49 -0400 Subject: Removed unused and erroneous (yes, it was both) function --- nova/api/ec2/admin.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nova/api/ec2/admin.py b/nova/api/ec2/admin.py index ea94d9c1f..4d981f70b 100644 --- a/nova/api/ec2/admin.py +++ b/nova/api/ec2/admin.py @@ -325,7 +325,3 @@ class AdminController(object): rv.append(host_dict(host, compute, instances, volume, volumes, now)) return {'hosts': rv} - - def describe_host(self, _context, name, **_kwargs): - """Returns status info for single node.""" - return host_dict(db.host_get(name)) -- cgit From eadabab8b70bdc4789615844e2263cbed7aa283c Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 3 Jun 2011 11:34:49 -0400 Subject: Added a test case for XML serialization. --- nova/tests/api/openstack/fakes.py | 3 ++- nova/tests/api/openstack/test_images.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index e9b46f933..601c1e9e4 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -143,7 +143,8 @@ def stub_out_networking(stubs): def stub_out_compute_api_snapshot(stubs): def snapshot(self, context, instance_id, name): - return dict(id='123') + return dict(id='123', status='ACTIVE', + properties=dict(instance_id='123')) stubs.Set(nova.compute.API, 'snapshot', snapshot) diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 961c271ca..ae7025146 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -902,6 +902,39 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): response = req.get_response(fakes.wsgi_app()) self.assertEqual(200, response.status_int) + def test_create_image_v1_1_xml_serialization(self): + + body = dict(image=dict(serverRef='123', name='Backup 1')) + req = webob.Request.blank('/v1.1/images') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + req.headers["accept"] = "application/xml" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(200, response.status_int) + resp_xml = minidom.parseString(response.body.replace(" ", "")) + expected_href = "http://localhost/v1.1/images/123" + expected_image = minidom.parseString(""" + + + + + + + + """.replace(" ", "") % (locals())) + + self.assertEqual(expected_image.toxml(), resp_xml.toxml()) + def test_create_image_v1_1_no_server_ref(self): body = dict(image=dict(name='Backup 1')) -- cgit From 25c8e9318c1ffbf2f2c88d3ed644df9e81b92b04 Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Fri, 3 Jun 2011 11:52:20 -0400 Subject: Fixed pip-requires double requirement. --- tools/pip-requires | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/pip-requires b/tools/pip-requires index 035e4347d..e81ef944a 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -34,4 +34,3 @@ coverage nosexcover GitPython paramiko -nova_adminclient -- cgit From a1ea80431ea46aea5ec67cf152c7a7af5fd5aeac Mon Sep 17 00:00:00 2001 From: Lvov Maxim Date: Fri, 3 Jun 2011 21:13:16 +0400 Subject: fix comment --- nova/api/openstack/auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index e220ffcc2..774426d58 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -59,7 +59,8 @@ class AuthMiddleware(wsgi.Middleware): try: account = req.headers["X-Auth-Project-Id"] except KeyError: - # FIXME: It needed only for compatibility + # FIXME(usrleon): It needed only for compatibility + # while osapi clients don't use this header accounts = self.auth.get_projects(user=user) if accounts: account = accounts[0] -- cgit From f521426039e8a9cc5dccc2c7e7e1797cfe778d7e Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 3 Jun 2011 14:14:28 -0400 Subject: Updated to use the '/v1/images' URL when uploading images to glance in the Xen glance plugin. Fixes issue where snapshots failed to get uploaded. --- plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index 0c00d168b..46031ebe8 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -244,7 +244,7 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port, os_type): conn = httplib.HTTPConnection(glance_host, glance_port) # NOTE(sirp): httplib under python2.4 won't accept a file-like object # to request - conn.putrequest('PUT', '/images/%s' % image_id) + conn.putrequest('PUT', '/v1/images/%s' % image_id) # NOTE(sirp): There is some confusion around OVF. Here's a summary of # where we currently stand: -- cgit From f6aa513024e14975709ef8facf1db6535eefbc44 Mon Sep 17 00:00:00 2001 From: Justin Shepherd Date: Fri, 3 Jun 2011 13:20:34 -0500 Subject: added 'nova-manage config list' which will list out all of the flags and their values. I also alphabetized the list of available categories --- bin/nova-manage | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 5de4d9e81..fb3810779 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1081,24 +1081,35 @@ class ImageCommands(object): self._convert_images(machine_images) +class ConfigCommands(object): + """Class for exposing the flags defined by flag_file(s).""" + + def __init__(self): + pass + + def list(self): + print FLAGS.FlagsIntoString() + + CATEGORIES = [ - ('user', UserCommands), ('account', AccountCommands), - ('project', ProjectCommands), - ('role', RoleCommands), - ('shell', ShellCommands), - ('vpn', VpnCommands), + ('config', ConfigCommands), + ('db', DbCommands), ('fixed', FixedIpCommands), + ('flavor', InstanceTypeCommands), ('floating', FloatingIpCommands), + ('instance_type', InstanceTypeCommands), + ('image', ImageCommands), ('network', NetworkCommands), - ('vm', VmCommands), + ('project', ProjectCommands), + ('role', RoleCommands), ('service', ServiceCommands), - ('db', DbCommands), + ('shell', ShellCommands), + ('user', UserCommands), + ('version', VersionCommands), + ('vm', VmCommands), ('volume', VolumeCommands), - ('instance_type', InstanceTypeCommands), - ('image', ImageCommands), - ('flavor', InstanceTypeCommands), - ('version', VersionCommands)] + ('vpn', VpnCommands)] def lazy_match(name, key_value_tuples): -- cgit From 9c38da46d121e65707346473e6d51da3a2cf021f Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 09:18:13 -0400 Subject: Fixed incorrect exception --- nova/db/sqlalchemy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index cf1a84cd5..6970a2168 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -738,7 +738,7 @@ def fixed_ip_get_all_by_instance(context, instance_id): filter_by(instance_id=instance_id).\ filter_by(deleted=False) if not rv: - raise exception.NoFloatingIpsFoundForInstance(instance_id=instance_id) + raise exception.NoFixedIpsFoundForInstance(instance_id=instance_id) return rv -- cgit From ec5e5bcd3592dca44d1d71455ccd99e2c7f24d26 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 10:49:29 -0400 Subject: Small pylint fixes --- nova/api/openstack/extensions.py | 6 ++++-- nova/api/openstack/views/limits.py | 9 --------- nova/tests/xenapi/stubs.py | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index 881b61733..9dad2f48d 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -137,7 +137,8 @@ class ActionExtensionResource(wsgi.Resource): def __init__(self, application): controller = ActionExtensionController(application) - super(ActionExtensionResource, self).__init__(controller) + #super(ActionExtensionResource, self).__init__(controller) + wsgi.Resource.__init__(self, controller) def add_action(self, action_name, handler): self.controller.add_action(action_name, handler) @@ -164,7 +165,8 @@ class RequestExtensionResource(wsgi.Resource): def __init__(self, application): controller = RequestExtensionController(application) - super(RequestExtensionResource, self).__init__(controller) + #super(RequestExtensionResource, self).__init__(controller) + wsgi.Resource.__init__(self, controller) def add_handler(self, handler): self.controller.add_handler(handler) diff --git a/nova/api/openstack/views/limits.py b/nova/api/openstack/views/limits.py index e21c9f2fd..934b4921a 100644 --- a/nova/api/openstack/views/limits.py +++ b/nova/api/openstack/views/limits.py @@ -29,9 +29,6 @@ class ViewBuilder(object): def _build_rate_limit(self, rate_limit): raise NotImplementedError() - def _build_absolute_limits(self, absolute_limit): - raise NotImplementedError() - def build(self, rate_limits, absolute_limits): rate_limits = self._build_rate_limits(rate_limits) absolute_limits = self._build_absolute_limits(absolute_limits) @@ -67,12 +64,6 @@ class ViewBuilder(object): limits[name] = value return limits - def _build_rate_limits(self, rate_limits): - raise NotImplementedError() - - def _build_rate_limit(self, rate_limit): - raise NotImplementedError() - class ViewBuilderV10(ViewBuilder): """Openstack API v1.0 limits view builder.""" diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 35308d95f..5d2d1641a 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -251,10 +251,10 @@ class FakeSessionForMigrationTests(fake.SessionBase): def __init__(self, uri): super(FakeSessionForMigrationTests, self).__init__(uri) - def VDI_get_by_uuid(*args): + def VDI_get_by_uuid(self, *args): return 'hurr' - def VDI_resize_online(*args): + def VDI_resize_online(self, *args): pass def VM_start(self, _1, ref, _2, _3): -- cgit From 3fb0b8fd8e4ad5911c85fddcb6ef5127fa4cd384 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 11:00:51 -0400 Subject: Removed extraneous code --- nova/tests/xenapi/stubs.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 5d2d1641a..151a3e909 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -42,20 +42,6 @@ def stubout_instance_snapshot(stubs): stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image) - def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref, - original_parent_uuid): - from nova.virt.xenapi.fake import create_vdi - name_label = "instance-%s" % instance_id - #TODO: create fake SR record - sr_ref = "fakesr" - vdi_ref = create_vdi(name_label=name_label, read_only=False, - sr_ref=sr_ref, sharable=False) - vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref) - vdi_uuid = vdi_rec['uuid'] - return vdi_uuid - - stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image) - def fake_parse_xmlrpc_value(val): return val -- cgit From a2f74c2f706bdf45ec36348468b1ba5797fcde87 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 11:20:25 -0400 Subject: Use super on an old style class --- nova/twistd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/twistd.py b/nova/twistd.py index c07ed991f..15cf67825 100644 --- a/nova/twistd.py +++ b/nova/twistd.py @@ -78,7 +78,7 @@ def WrapTwistedOptions(wrapped): self._absorbParameters() self._absorbHandlers() - super(TwistedOptionsToFlags, self).__init__() + wrapped.__init__(self) def _absorbFlags(self): twistd_flags = [] @@ -163,12 +163,12 @@ def WrapTwistedOptions(wrapped): def parseArgs(self, *args): # TODO(termie): figure out a decent way of dealing with args #return - super(TwistedOptionsToFlags, self).parseArgs(*args) + wrapped.parseArgs(self, *args) def postOptions(self): self._doHandlers() - super(TwistedOptionsToFlags, self).postOptions() + wrapped.postOptions(self) def __getitem__(self, key): key = key.replace('-', '_') -- cgit From 0eb6db6f994963d519f9fe07e3dbc41e0c8079c6 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 11:29:05 -0400 Subject: Removed Duplicate method --- nova/virt/xenapi/fake.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index 76988b172..5d3b67417 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -340,10 +340,6 @@ class SessionBase(object): return db_ref['xenstore_data'][key] = None - def network_get_all_records_where(self, _1, _2): - # TODO (salvatore-orlando): filter table on _2 - return _db_content['network'] - def VM_add_to_xenstore_data(self, _1, vm_ref, key, value): db_ref = _db_content['VM'][vm_ref] if not 'xenstore_data' in db_ref: @@ -354,7 +350,7 @@ class SessionBase(object): #Always return 12GB available return 12 * 1024 * 1024 * 1024 - def host_call_plugin(*args): + def host_call_plugin(self, *args): return 'herp' def network_get_all_records_where(self, _1, filter): -- cgit From 3d481e551ac81a35cafcd79c2b17d2bd9c8a050f Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 11:39:34 -0400 Subject: Ignore complaining about dynamic definition --- nova/api/direct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/direct.py b/nova/api/direct.py index ea20042a7..ea7425e19 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -324,7 +324,7 @@ class Limited(object): def __init__(self, proxy): self._proxy = proxy - if not self.__doc__: + if not self.__doc__: #pylint: disable=E0203 self.__doc__ = proxy.__doc__ if not self._allowed: self._allowed = [] -- cgit From 267178748e712098af4e55872029c5883af9a51c Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Mon, 6 Jun 2011 12:42:27 -0400 Subject: Change to a more generic error and update documentation. --- nova/db/sqlalchemy/api.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 56739e9db..6dbf53a6c 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -60,9 +60,7 @@ def is_user_context(context): def authorize_project_context(context, project_id): - """Ensures that the request context has permission to access the - given project. - """ + """Ensures a request has permission to access the given project.""" if is_user_context(context): if not context.project: raise exception.NotAuthorized() @@ -71,9 +69,7 @@ def authorize_project_context(context, project_id): def authorize_user_context(context, user_id): - """Ensures that the request context has permission to access the - given user. - """ + """Ensures a request has permission to access the given user.""" if is_user_context(context): if not context.user: raise exception.NotAuthorized() @@ -89,9 +85,12 @@ def can_read_deleted(context): def require_admin_context(f): - """Decorator used to indicate that the method requires an - administrator context. + """Decorator to require admin request context. + + The first argument to the wrapped function must be the context. + """ + def wrapper(*args, **kwargs): if not is_admin_context(args[0]): raise exception.AdminRequired() @@ -100,12 +99,19 @@ def require_admin_context(f): def require_context(f): - """Decorator used to indicate that the method requires either - an administrator or normal user context. + """Decorator to require *any* user or admin context. + + This does no authorization for user or project access matching, see + :py:func:`authorize_project_context` and + :py:func:`authorize_user_context`. + + The first argument to the wrapped function must be the context. + """ + def wrapper(*args, **kwargs): if not is_admin_context(args[0]) and not is_user_context(args[0]): - raise exception.AdminRequired() + raise exception.NotAuthorized() return f(*args, **kwargs) return wrapper -- cgit From 9fca0b2156f1e7f3d007916ef18b2ed9fbc761df Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Mon, 6 Jun 2011 15:59:20 -0400 Subject: Added test case for snapshoting base image without architecture. --- nova/tests/test_libvirt.py | 92 +++++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index b6b36745a..d0bdaa738 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import copy import eventlet import mox import os @@ -125,6 +126,7 @@ class CacheConcurrencyTestCase(test.TestCase): class LibvirtConnTestCase(test.TestCase): + def setUp(self): super(LibvirtConnTestCase, self).setUp() connection._late_load_cheetah() @@ -207,6 +209,31 @@ class LibvirtConnTestCase(test.TestCase): self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') connection.LibvirtConnection._conn = fake + def fake_lookup(self, instance_name): + class FakeVirtDomain(object): + + def __init__(self): + pass + + def snapshotCreateXML(self, *args): + return None + + def XMLDesc(self, *args): + return """ + + + + + + + + """ + + return FakeVirtDomain() + + def fake_execute(self, *args): + open(args[-1], "a").close() + def create_service(self, **kwargs): service_ref = {'host': kwargs.get('host', 'dummy'), 'binary': 'nova-compute', @@ -283,43 +310,56 @@ class LibvirtConnTestCase(test.TestCase): self._check_xml_and_container(instance_data) def test_snapshot(self): + if not self.lazy_load_library_exists(): + return + FLAGS.image_service = 'nova.image.fake.FakeImageService' - # Only file-based instance storages are supported at the moment - test_xml = """ - - - - - - - - """ + # Start test + image_service = utils.import_object(FLAGS.image_service) - class FakeVirtDomain(object): + # Assuming that base image already exists in image_service + instance_ref = db.instance_create(self.context, self.test_instance) + properties = {'instance_id': instance_ref['id'], + 'user_id': str(self.context.user_id)} + snapshot_name = 'test-snap' + sent_meta = {'name': snapshot_name, 'is_public': False, + 'status': 'creating', 'properties': properties} + # Create new image. It will be updated in snapshot method + # To work with it from snapshot, the single image_service is needed + recv_meta = image_service.create(context, sent_meta) - def __init__(self): - pass + self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') + connection.LibvirtConnection._conn.lookupByName = self.fake_lookup + self.mox.StubOutWithMock(connection.utils, 'execute') + connection.utils.execute = self.fake_execute - def snapshotCreateXML(self, *args): - return None + self.mox.ReplayAll() - def XMLDesc(self, *args): - return test_xml + conn = connection.LibvirtConnection(False) + conn.snapshot(instance_ref, recv_meta['id']) - def fake_lookup(instance_name): - if instance_name == instance_ref.name: - return FakeVirtDomain() + snapshot = image_service.show(context, recv_meta['id']) + self.assertEquals(snapshot['properties']['image_state'], 'available') + self.assertEquals(snapshot['status'], 'active') + self.assertEquals(snapshot['name'], snapshot_name) - def fake_execute(*args): - # Touch filename to pass 'with open(out_path)' - open(args[-1], "a").close() + def test_snapshot_no_image_architecture(self): + if not self.lazy_load_library_exists(): + return + + FLAGS.image_service = 'nova.image.fake.FakeImageService' # Start test image_service = utils.import_object(FLAGS.image_service) + # Assign image_ref = 2 from nova/images/fakes for testing different + # base image + test_instance = copy.deepcopy(self.test_instance) + test_instance["image_ref"] = "2" + # Assuming that base image already exists in image_service - instance_ref = db.instance_create(self.context, self.test_instance) + instance_ref = db.instance_create(self.context, test_instance) properties = {'instance_id': instance_ref['id'], 'user_id': str(self.context.user_id)} snapshot_name = 'test-snap' @@ -330,9 +370,9 @@ class LibvirtConnTestCase(test.TestCase): recv_meta = image_service.create(context, sent_meta) self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') - connection.LibvirtConnection._conn.lookupByName = fake_lookup + connection.LibvirtConnection._conn.lookupByName = self.fake_lookup self.mox.StubOutWithMock(connection.utils, 'execute') - connection.utils.execute = fake_execute + connection.utils.execute = self.fake_execute self.mox.ReplayAll() -- cgit From 57df676a3302f8d754ef54e415d2fd82a4291f49 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 6 Jun 2011 15:59:39 -0400 Subject: Removed commented code --- nova/api/openstack/extensions.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index 9dad2f48d..54e17e23d 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -137,7 +137,6 @@ class ActionExtensionResource(wsgi.Resource): def __init__(self, application): controller = ActionExtensionController(application) - #super(ActionExtensionResource, self).__init__(controller) wsgi.Resource.__init__(self, controller) def add_action(self, action_name, handler): @@ -165,7 +164,6 @@ class RequestExtensionResource(wsgi.Resource): def __init__(self, application): controller = RequestExtensionController(application) - #super(RequestExtensionResource, self).__init__(controller) wsgi.Resource.__init__(self, controller) def add_handler(self, handler): -- cgit From e745c21724e5990874a12c4abff53127755185ea Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 6 Jun 2011 16:08:58 -0400 Subject: Use True/False instead of 1/0 when setting updating 'deleted' column attributes.Fixes casting issues when running nova with Postgres. --- nova/db/sqlalchemy/api.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 6dbf53a6c..103668b94 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1127,7 +1127,7 @@ def key_pair_destroy_all_by_user(context, user_id): with session.begin(): session.query(models.KeyPair).\ filter_by(user_id=user_id).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1659,7 +1659,7 @@ def volume_destroy(context, volume_id): with session.begin(): session.query(models.Volume).\ filter_by(id=volume_id).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.ExportDevice).\ @@ -1817,7 +1817,7 @@ def snapshot_destroy(context, snapshot_id): with session.begin(): session.query(models.Snapshot).\ filter_by(id=snapshot_id).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1972,17 +1972,17 @@ def security_group_destroy(context, security_group_id): with session.begin(): session.query(models.SecurityGroup).\ filter_by(id=security_group_id).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupInstanceAssociation).\ filter_by(security_group_id=security_group_id).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupIngressRule).\ filter_by(group_id=security_group_id).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -1993,11 +1993,11 @@ def security_group_destroy_all(context, session=None): session = get_session() with session.begin(): session.query(models.SecurityGroup).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) session.query(models.SecurityGroupIngressRule).\ - update({'deleted': 1, + update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) @@ -2678,7 +2678,7 @@ def instance_metadata_update_or_create(context, instance_id, metadata): meta_ref = models.InstanceMetadata() meta_ref.update({"key": key, "value": value, "instance_id": instance_id, - "deleted": 0}) + "deleted": False}) meta_ref.save(session=session) return metadata -- cgit From 727317333978ac5cf0fb1cd3f86e49e9868f1e19 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 6 Jun 2011 17:58:40 -0700 Subject: fixed up tests after trunk merge --- nova/api/openstack/zones.py | 13 ++++--------- nova/compute/api.py | 10 +++++----- nova/tests/api/openstack/test_zones.py | 3 +++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 330aee85f..0f83afb34 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -58,12 +58,7 @@ def check_encryption_key(func): return wrapped -class Controller(common.OpenstackController): - - _serialization_metadata = { - 'application/xml': { - "attributes": { - "zone": ["id", "api_url", "name", "capabilities"]}}} +class Controller(object): def index(self, req): """Return all zones in brief""" @@ -114,12 +109,12 @@ class Controller(common.OpenstackController): return dict(zone=_scrub_zone(zone)) @check_encryption_key - def select(self, req): + def select(self, req, body): """Returns a weighted list of costs to create instances of desired capabilities.""" ctx = req.environ['nova.context'] - json_specs = json.loads(req.body) - specs = json.loads(json_specs) + print "**** ZONES ", body + specs = json.loads(body) build_plan = api.select(ctx, specs=specs) cooked = self._scrub_build_plan(build_plan) return {"weights": cooked} diff --git a/nova/compute/api.py b/nova/compute/api.py index 24f04f226..e09127d5c 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -134,7 +134,7 @@ class API(base.Base): raise quota.QuotaError(msg, "MetadataLimitExceeded") def _check_create_parameters(self, context, instance_type, - image_id, kernel_id=None, ramdisk_id=None, + image_href, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, display_name='', display_description='', key_name=None, key_data=None, security_group='default', @@ -300,7 +300,7 @@ class API(base.Base): "injected_files": injected_files}}) def create_all_at_once(self, context, instance_type, - image_id, kernel_id=None, ramdisk_id=None, + image_href, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, display_name='', display_description='', key_name=None, key_data=None, security_group='default', @@ -312,7 +312,7 @@ class API(base.Base): num_instances, base_options, security_groups = \ self._check_create_parameters( context, instance_type, - image_id, kernel_id, ramdisk_id, + image_href, kernel_id, ramdisk_id, min_count, max_count, display_name, display_description, key_name, key_data, security_group, @@ -328,7 +328,7 @@ class API(base.Base): return base_options['reservation_id'] def create(self, context, instance_type, - image_id, kernel_id=None, ramdisk_id=None, + image_href, kernel_id=None, ramdisk_id=None, min_count=1, max_count=1, display_name='', display_description='', key_name=None, key_data=None, security_group='default', @@ -346,7 +346,7 @@ class API(base.Base): num_instances, base_options, security_groups = \ self._check_create_parameters( context, instance_type, - image_id, kernel_id, ramdisk_id, + image_href, kernel_id, ramdisk_id, min_count, max_count, display_name, display_description, key_name, key_data, security_group, diff --git a/nova/tests/api/openstack/test_zones.py b/nova/tests/api/openstack/test_zones.py index e21b5ce86..fc70a1679 100644 --- a/nova/tests/api/openstack/test_zones.py +++ b/nova/tests/api/openstack/test_zones.py @@ -210,11 +210,14 @@ class ZonesTest(test.TestCase): req = webob.Request.blank('/v1.0/zones/select') req.method = 'POST' + req.headers["Content-Type"] = "application/json" # Select queries end up being JSON encoded twice. # Once to a string and again as an HTTP POST Body req.body = json.dumps(json.dumps({})) + print "********** BODY", req.body res = req.get_response(fakes.wsgi_app()) + print "********** RES", res res_dict = json.loads(res.body) self.assertEqual(res.status_int, 200) -- cgit From 225c8cb8843de17abe192b5efc7c0bd9db0b4d75 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 6 Jun 2011 19:05:31 -0700 Subject: sanity check --- nova/api/openstack/zones.py | 1 - nova/scheduler/zone_aware_scheduler.py | 1 + nova/tests/api/openstack/test_zones.py | 2 -- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 0f83afb34..b2f7898cb 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -113,7 +113,6 @@ class Controller(object): """Returns a weighted list of costs to create instances of desired capabilities.""" ctx = req.environ['nova.context'] - print "**** ZONES ", body specs = json.loads(body) build_plan = api.select(ctx, specs=specs) cooked = self._scrub_build_plan(build_plan) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index c125c7436..faa969124 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -22,6 +22,7 @@ across zones. There are two expansion points to this class for: import operator import json + import M2Crypto import novaclient diff --git a/nova/tests/api/openstack/test_zones.py b/nova/tests/api/openstack/test_zones.py index fc70a1679..098577e4c 100644 --- a/nova/tests/api/openstack/test_zones.py +++ b/nova/tests/api/openstack/test_zones.py @@ -215,9 +215,7 @@ class ZonesTest(test.TestCase): # Once to a string and again as an HTTP POST Body req.body = json.dumps(json.dumps({})) - print "********** BODY", req.body res = req.get_response(fakes.wsgi_app()) - print "********** RES", res res_dict = json.loads(res.body) self.assertEqual(res.status_int, 200) -- cgit From f0c4767dc14f950f7d18cc02e16e4d310774435d Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 7 Jun 2011 09:56:51 -0400 Subject: Fixed type causing pylint "exception is not callable" Added param to fake_instance_create, fake objects should appear like the real object. pylint "No value passed for parameter 'values' in function call" --- nova/tests/test_vmwareapi.py | 2 +- nova/tests/vmwareapi/db_fakes.py | 2 +- nova/virt/xenapi/vmops.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py index e5ebd1600..eddf01e9f 100644 --- a/nova/tests/test_vmwareapi.py +++ b/nova/tests/test_vmwareapi.py @@ -69,7 +69,7 @@ class VMWareAPIVMTestCase(test.TestCase): 'instance_type': 'm1.large', 'mac_address': 'aa:bb:cc:dd:ee:ff', } - self.instance = db.instance_create(values) + self.instance = db.instance_create(None, values) def _create_vm(self): """Create and spawn the VM.""" diff --git a/nova/tests/vmwareapi/db_fakes.py b/nova/tests/vmwareapi/db_fakes.py index 764de42d8..d4eb87daf 100644 --- a/nova/tests/vmwareapi/db_fakes.py +++ b/nova/tests/vmwareapi/db_fakes.py @@ -52,7 +52,7 @@ def stub_out_db_instance_api(stubs): else: raise NotImplementedError() - def fake_instance_create(values): + def fake_instance_create(context, values): """Stubs out the db.instance_create method.""" type_data = INSTANCE_TYPES[values['instance_type']] diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 32dae97c2..c6d2b0936 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -101,7 +101,7 @@ class VMOps(object): if not vm_ref: vm_ref = VMHelper.lookup(self._session, instance.name) if vm_ref is None: - raise exception(_('Attempted to power on non-existent instance' + raise Exception(_('Attempted to power on non-existent instance' ' bad instance id %s') % instance.id) LOG.debug(_("Starting instance %s"), instance.name) self._session.call_xenapi('VM.start', vm_ref, False, False) -- cgit From 8747611e4bd69b6da204b2c021fd5400c961db1d Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Tue, 7 Jun 2011 10:47:29 -0400 Subject: Removed empty init --- nova/tests/test_libvirt.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index d0bdaa738..8b4183164 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -210,10 +210,8 @@ class LibvirtConnTestCase(test.TestCase): connection.LibvirtConnection._conn = fake def fake_lookup(self, instance_name): - class FakeVirtDomain(object): - def __init__(self): - pass + class FakeVirtDomain(object): def snapshotCreateXML(self, *args): return None -- cgit From 7bae412d230171baf1ba7bec7262705404d1ed7f Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Tue, 7 Jun 2011 10:47:14 -0500 Subject: Add the option to specify a default IPv6 gateway. --- bin/nova-manage | 13 +++++++++---- nova/network/manager.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index b0cd343f5..7f024f9ca 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -96,6 +96,7 @@ flags.DECLARE('network_size', 'nova.network.manager') flags.DECLARE('vlan_start', 'nova.network.manager') flags.DECLARE('vpn_start', 'nova.network.manager') flags.DECLARE('fixed_range_v6', 'nova.network.manager') +flags.DECLARE('gateway_v6', 'nova.network.manager') flags.DECLARE('images_path', 'nova.image.local') flags.DECLARE('libvirt_type', 'nova.virt.libvirt.connection') flags.DEFINE_flag(flags.HelpFlag()) @@ -545,13 +546,14 @@ class FloatingIpCommands(object): class NetworkCommands(object): """Class for managing networks.""" - def create(self, fixed_range=None, num_networks=None, - network_size=None, vlan_start=None, - vpn_start=None, fixed_range_v6=None, label='public'): + def create(self, fixed_range=None, num_networks=None, network_size=None, + vlan_start=None, vpn_start=None, fixed_range_v6=None, + gateway_v6=None, label='public'): """Creates fixed ips for host by range arguments: fixed_range=FLAG, [num_networks=FLAG], [network_size=FLAG], [vlan_start=FLAG], - [vpn_start=FLAG], [fixed_range_v6=FLAG]""" + [vpn_start=FLAG], [fixed_range_v6=FLAG], + [gateway_v6=FLAG]""" if not fixed_range: msg = _('Fixed range in the form of 10.0.0.0/8 is ' 'required to create networks.') @@ -567,6 +569,8 @@ class NetworkCommands(object): vpn_start = FLAGS.vpn_start if not fixed_range_v6: fixed_range_v6 = FLAGS.fixed_range_v6 + if not gateway_v6: + gateway_v6 = FLAGS.gateway_v6 net_manager = utils.import_object(FLAGS.network_manager) try: net_manager.create_networks(context.get_admin_context(), @@ -576,6 +580,7 @@ class NetworkCommands(object): vlan_start=int(vlan_start), vpn_start=int(vpn_start), cidr_v6=fixed_range_v6, + gateway_v6=gateway_v6, label=label) except ValueError, e: print e diff --git a/nova/network/manager.py b/nova/network/manager.py index f726c4b26..b5352ca0f 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -86,6 +86,7 @@ flags.DEFINE_string('floating_range', '4.4.4.0/24', 'Floating IP address block') flags.DEFINE_string('fixed_range', '10.0.0.0/8', 'Fixed IP address block') flags.DEFINE_string('fixed_range_v6', 'fd00::/48', 'Fixed IPv6 address block') +flags.DEFINE_string('gateway_v6', None, 'Default IPv6 gateway') flags.DEFINE_integer('cnt_vpn_clients', 0, 'Number of addresses reserved for vpn clients') flags.DEFINE_string('network_driver', 'nova.network.linux_net', @@ -292,7 +293,7 @@ class NetworkManager(manager.SchedulerDependentManager): return host def create_networks(self, context, cidr, num_networks, network_size, - cidr_v6, label, *args, **kwargs): + cidr_v6, gateway_v6, label, *args, **kwargs): """Create networks based on parameters.""" fixed_net = IPy.IP(cidr) fixed_net_v6 = IPy.IP(cidr_v6) @@ -324,7 +325,13 @@ class NetworkManager(manager.SchedulerDependentManager): significant_bits_v6) net['cidr_v6'] = cidr_v6 project_net_v6 = IPy.IP(cidr_v6) - net['gateway_v6'] = str(project_net_v6[1]) + + if gateway_v6: + # use a pre-defined gateway if one is provided + net['gateway_v6'] = str(gateway_v6) + else: + net['gateway_v6'] = str(project_net_v6[1]) + net['netmask_v6'] = str(project_net_v6.prefixlen()) network_ref = self.db.network_create_safe(context, net) -- cgit From aa343c994c4738374bd91531ae2e260175690a56 Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Tue, 7 Jun 2011 11:45:25 -0500 Subject: Remove unnecessary docstrings. --- bin/nova-manage | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 7f024f9ca..0147ae21b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -549,11 +549,7 @@ class NetworkCommands(object): def create(self, fixed_range=None, num_networks=None, network_size=None, vlan_start=None, vpn_start=None, fixed_range_v6=None, gateway_v6=None, label='public'): - """Creates fixed ips for host by range - arguments: fixed_range=FLAG, [num_networks=FLAG], - [network_size=FLAG], [vlan_start=FLAG], - [vpn_start=FLAG], [fixed_range_v6=FLAG], - [gateway_v6=FLAG]""" + """Creates fixed ips for host by range""" if not fixed_range: msg = _('Fixed range in the form of 10.0.0.0/8 is ' 'required to create networks.') -- cgit From c680176d11edb46a28ba065f0548e18cbf1297d5 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 7 Jun 2011 13:32:53 -0400 Subject: Fixed incorrect error message Added missing import Fixed Typo (pylint "undefined variable NoneV") --- nova/compute/instance_types.py | 2 +- nova/compute/monitor.py | 1 + nova/console/vmrc.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py index 1275a6fdd..1d246e445 100644 --- a/nova/compute/instance_types.py +++ b/nova/compute/instance_types.py @@ -114,7 +114,7 @@ def get_instance_type(id): ctxt = context.get_admin_context() return db.instance_type_get_by_id(ctxt, id) except exception.DBError: - raise exception.ApiError(_("Unknown instance type: %s") % name) + raise exception.ApiError(_("Unknown instance type: %s") % id) def get_instance_type_by_name(name): diff --git a/nova/compute/monitor.py b/nova/compute/monitor.py index 613734bef..9d8e2a25d 100644 --- a/nova/compute/monitor.py +++ b/nova/compute/monitor.py @@ -36,6 +36,7 @@ from twisted.application import service from nova import flags from nova import log as logging +from nova import utils from nova.virt import connection as virt_connection diff --git a/nova/console/vmrc.py b/nova/console/vmrc.py index cc8b0cdf5..fa805e019 100644 --- a/nova/console/vmrc.py +++ b/nova/console/vmrc.py @@ -119,7 +119,7 @@ class VMRCSessionConsole(VMRCConsole): """ vms = vim_session._call_method(vim_util, 'get_objects', 'VirtualMachine', ['name']) - vm_ref = NoneV + vm_ref = None for vm in vms: if vm.propSet[0].val == instance_name: vm_ref = vm.obj -- cgit From e8d6740fefcac3734021edaf53a40ecb145ccaa3 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 7 Jun 2011 13:47:40 -0400 Subject: DRY up the image_state logic. Fix an issue where glance style images (which aren't required to have an 'image_state' property) couldn't be used to run instances on the EC2 controller. --- nova/api/ec2/cloud.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index ac73cd595..316298c39 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -136,6 +136,13 @@ class CloudController(object): return services[0]['availability_zone'] return 'unknown zone' + def _get_image_state(self, image): + # NOTE(vish): fallback status if image_state isn't set + state = image.get('status') + if state == 'active': + state = 'available' + return image['properties'].get('image_state', state) + def get_metadata(self, address): ctxt = context.get_admin_context() instance_ref = self.compute_api.get_all(ctxt, fixed_ip=address) @@ -896,14 +903,13 @@ class CloudController(object): ramdisk = self._get_image(context, kwargs['ramdisk_id']) kwargs['ramdisk_id'] = ramdisk['id'] image = self._get_image(context, kwargs['image_id']) - if not image: + + if image: + image_state = self._get_image_state(image) + else: raise exception.ImageNotFound(image_id=kwargs['image_id']) - try: - available = (image['properties']['image_state'] == 'available') - except KeyError: - available = False - if not available: + if image_state != 'available': raise exception.ApiError(_('Image must be available')) instances = self.compute_api.create(context, @@ -1021,11 +1027,8 @@ class CloudController(object): get('image_location'), name) else: i['imageLocation'] = image['properties'].get('image_location') - # NOTE(vish): fallback status if image_state isn't set - state = image.get('status') - if state == 'active': - state = 'available' - i['imageState'] = image['properties'].get('image_state', state) + + i['imageState'] = self._get_image_state(image) i['displayName'] = name i['description'] = image.get('description') display_mapping = {'aki': 'kernel', -- cgit From d920e7f53e59b1def67f7528dd6b6bcf35ba96b4 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 7 Jun 2011 14:33:01 -0400 Subject: Disabled pylint complaining about no 'self' parameter in a decorator function --- nova/auth/ldapdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 183f7a985..7bcaa34b5 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -139,7 +139,7 @@ class LdapDriver(object): self.__cache = None return False - def __local_cache(key_fmt): + def __local_cache(key_fmt): #pylint: disable=E0213 """Wrap function to cache it's result in self.__cache. Works only with functions with one fixed argument. """ -- cgit From 22c71e27cef8131c8432b57d5965bd14e5300428 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 7 Jun 2011 15:36:43 -0300 Subject: Added illustrations for Distributed Scheduler and fixed up formatting --- doc/.autogenerated | 3276 ++++++++++++++++++++ doc/source/devref/distributed_scheduler.rst | 90 +- doc/source/images/costs_weights.png | Bin 0 -> 35723 bytes doc/source/images/dating_service.png | Bin 0 -> 31945 bytes doc/source/images/filtering.png | Bin 0 -> 18779 bytes doc/source/images/nova.compute.api.create.png | Bin 0 -> 50171 bytes .../images/nova.compute.api.create_all_at_once.png | Bin 0 -> 62263 bytes doc/source/images/zone_aware_overview.png | Bin 0 -> 56142 bytes doc/source/images/zone_aware_scheduler.png | Bin 0 -> 20902 bytes 9 files changed, 3329 insertions(+), 37 deletions(-) create mode 100644 doc/source/images/costs_weights.png create mode 100644 doc/source/images/dating_service.png create mode 100644 doc/source/images/filtering.png create mode 100755 doc/source/images/nova.compute.api.create.png create mode 100755 doc/source/images/nova.compute.api.create_all_at_once.png create mode 100755 doc/source/images/zone_aware_overview.png create mode 100644 doc/source/images/zone_aware_scheduler.png diff --git a/doc/.autogenerated b/doc/.autogenerated index 456c8ad1e..5f9630a57 100644 --- a/doc/.autogenerated +++ b/doc/.autogenerated @@ -281,3 +281,3279 @@ source/api/nova..volume.driver.rst source/api/nova..volume.manager.rst source/api/nova..volume.san.rst source/api/nova..wsgi.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst +source/api/nova.crypto.rst +source/api/nova.cloudpipe.pipelib.rst +source/api/nova.context.rst +source/api/nova.quota.rst +source/api/nova.tests.test_compute.rst +source/api/nova.tests.test_quota.rst +source/api/nova.tests.test_flags.rst +source/api/nova.tests.test_objectstore.rst +source/api/nova.tests.test_crypto.rst +source/api/nova.tests.runtime_flags.rst +source/api/nova.tests.test_exception.rst +source/api/nova.tests.vmwareapi.db_fakes.rst +source/api/nova.tests.vmwareapi.stubs.rst +source/api/nova.tests.test_host_filter.rst +source/api/nova.tests.test_network.rst +source/api/nova.tests.network.base.rst +source/api/nova.tests.declare_flags.rst +source/api/nova.tests.test_localization.rst +source/api/nova.tests.test_access.rst +source/api/nova.tests.test_libvirt.rst +source/api/nova.tests.image.test_glance.rst +source/api/nova.tests.test_direct.rst +source/api/nova.tests.fake_utils.rst +source/api/nova.tests.integrated.test_login.rst +source/api/nova.tests.integrated.test_extensions.rst +source/api/nova.tests.integrated.integrated_helpers.rst +source/api/nova.tests.integrated.test_servers.rst +source/api/nova.tests.integrated.test_xml.rst +source/api/nova.tests.integrated.api.client.rst +source/api/nova.tests.integrated.test_volumes.rst +source/api/nova.tests.test_rpc.rst +source/api/nova.tests.test_volume.rst +source/api/nova.tests.test_notifier.rst +source/api/nova.tests.fake_flags.rst +source/api/nova.tests.test_log.rst +source/api/nova.tests.test_service.rst +source/api/nova.tests.test_twistd.rst +source/api/nova.tests.test_misc.rst +source/api/nova.tests.test_cloud.rst +source/api/nova.tests.glance.stubs.rst +source/api/nova.tests.test_auth.rst +source/api/nova.tests.test_utils.rst +source/api/nova.tests.test_vmwareapi.rst +source/api/nova.tests.test_vlan_network.rst +source/api/nova.tests.test_zones.rst +source/api/nova.tests.test_middleware.rst +source/api/nova.tests.test_ipv6.rst +source/api/nova.tests.xenapi.stubs.rst +source/api/nova.tests.test_api.rst +source/api/nova.tests.scheduler.test_host_filter.rst +source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst +source/api/nova.tests.scheduler.test_least_cost_scheduler.rst +source/api/nova.tests.scheduler.test_scheduler.rst +source/api/nova.tests.db.fakes.rst +source/api/nova.tests.test_instance_types.rst +source/api/nova.tests.test_console.rst +source/api/nova.tests.api.test_wsgi.rst +source/api/nova.tests.api.openstack.test_users.rst +source/api/nova.tests.api.openstack.fakes.rst +source/api/nova.tests.api.openstack.common.rst +source/api/nova.tests.api.openstack.test_wsgi.rst +source/api/nova.tests.api.openstack.test_accounts.rst +source/api/nova.tests.api.openstack.test_flavors.rst +source/api/nova.tests.api.openstack.test_extensions.rst +source/api/nova.tests.api.openstack.test_adminapi.rst +source/api/nova.tests.api.openstack.test_versions.rst +source/api/nova.tests.api.openstack.test_image_metadata.rst +source/api/nova.tests.api.openstack.test_auth.rst +source/api/nova.tests.api.openstack.test_servers.rst +source/api/nova.tests.api.openstack.test_zones.rst +source/api/nova.tests.api.openstack.test_images.rst +source/api/nova.tests.api.openstack.test_api.rst +source/api/nova.tests.api.openstack.test_faults.rst +source/api/nova.tests.api.openstack.test_limits.rst +source/api/nova.tests.api.openstack.test_server_metadata.rst +source/api/nova.tests.api.openstack.test_shared_ip_groups.rst +source/api/nova.tests.api.openstack.test_common.rst +source/api/nova.tests.api.openstack.extensions.foxinsocks.rst +source/api/nova.tests.test_xenapi.rst +source/api/nova.tests.hyperv_unittest.rst +source/api/nova.tests.test_test.rst +source/api/nova.tests.test_flat_network.rst +source/api/nova.network.linux_net.rst +source/api/nova.network.api.rst +source/api/nova.network.manager.rst +source/api/nova.network.vmwareapi_net.rst +source/api/nova.network.xenapi_net.rst +source/api/nova.volume.driver.rst +source/api/nova.volume.api.rst +source/api/nova.volume.san.rst +source/api/nova.volume.manager.rst +source/api/nova.virt.images.rst +source/api/nova.virt.driver.rst +source/api/nova.virt.vmwareapi.io_util.rst +source/api/nova.virt.vmwareapi.error_util.rst +source/api/nova.virt.vmwareapi.vmops.rst +source/api/nova.virt.vmwareapi.fake.rst +source/api/nova.virt.vmwareapi.vim.rst +source/api/nova.virt.vmwareapi.read_write_util.rst +source/api/nova.virt.vmwareapi.vmware_images.rst +source/api/nova.virt.vmwareapi.network_utils.rst +source/api/nova.virt.vmwareapi.vim_util.rst +source/api/nova.virt.vmwareapi.vm_util.rst +source/api/nova.virt.xenapi_conn.rst +source/api/nova.virt.fake.rst +source/api/nova.virt.vmwareapi_conn.rst +source/api/nova.virt.connection.rst +source/api/nova.virt.disk.rst +source/api/nova.virt.libvirt.connection.rst +source/api/nova.virt.libvirt.firewall.rst +source/api/nova.virt.libvirt.netutils.rst +source/api/nova.virt.hyperv.rst +source/api/nova.virt.xenapi.vmops.rst +source/api/nova.virt.xenapi.fake.rst +source/api/nova.virt.xenapi.volume_utils.rst +source/api/nova.virt.xenapi.network_utils.rst +source/api/nova.virt.xenapi.vm_utils.rst +source/api/nova.virt.xenapi.volumeops.rst +source/api/nova.exception.rst +source/api/nova.image.fake.rst +source/api/nova.image.local.rst +source/api/nova.image.glance.rst +source/api/nova.image.service.rst +source/api/nova.image.s3.rst +source/api/nova.objectstore.s3server.rst +source/api/nova.ipv6.account_identifier.rst +source/api/nova.ipv6.api.rst +source/api/nova.ipv6.rfc2462.rst +source/api/nova.notifier.no_op_notifier.rst +source/api/nova.notifier.log_notifier.rst +source/api/nova.notifier.rabbit_notifier.rst +source/api/nova.notifier.api.rst +source/api/nova.vcsversion.rst +source/api/nova.compute.instance_types.rst +source/api/nova.compute.power_state.rst +source/api/nova.compute.api.rst +source/api/nova.compute.manager.rst +source/api/nova.compute.monitor.rst +source/api/nova.wsgi.rst +source/api/nova.console.vmrc_manager.rst +source/api/nova.console.fake.rst +source/api/nova.console.vmrc.rst +source/api/nova.console.api.rst +source/api/nova.console.manager.rst +source/api/nova.console.xvp.rst +source/api/nova.version.rst +source/api/nova.utils.rst +source/api/nova.auth.dbdriver.rst +source/api/nova.auth.fakeldap.rst +source/api/nova.auth.ldapdriver.rst +source/api/nova.auth.signer.rst +source/api/nova.auth.manager.rst +source/api/nova.manager.rst +source/api/nova.scheduler.driver.rst +source/api/nova.scheduler.host_filter.rst +source/api/nova.scheduler.zone.rst +source/api/nova.scheduler.simple.rst +source/api/nova.scheduler.zone_aware_scheduler.rst +source/api/nova.scheduler.zone_manager.rst +source/api/nova.scheduler.api.rst +source/api/nova.scheduler.least_cost.rst +source/api/nova.scheduler.manager.rst +source/api/nova.scheduler.chance.rst +source/api/nova.vnc.auth.rst +source/api/nova.vnc.proxy.rst +source/api/nova.db.base.rst +source/api/nova.db.migration.rst +source/api/nova.db.sqlalchemy.session.rst +source/api/nova.db.sqlalchemy.migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.manage.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst +source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst +source/api/nova.db.sqlalchemy.api.rst +source/api/nova.db.sqlalchemy.models.rst +source/api/nova.db.api.rst +source/api/nova.twistd.rst +source/api/nova.test.rst +source/api/nova.fakerabbit.rst +source/api/nova.service.rst +source/api/nova.flags.rst +source/api/nova.api.ec2.ec2utils.rst +source/api/nova.api.ec2.metadatarequesthandler.rst +source/api/nova.api.ec2.cloud.rst +source/api/nova.api.ec2.admin.rst +source/api/nova.api.ec2.apirequest.rst +source/api/nova.api.openstack.images.rst +source/api/nova.api.openstack.faults.rst +source/api/nova.api.openstack.shared_ip_groups.rst +source/api/nova.api.openstack.common.rst +source/api/nova.api.openstack.ips.rst +source/api/nova.api.openstack.extensions.rst +source/api/nova.api.openstack.servers.rst +source/api/nova.api.openstack.consoles.rst +source/api/nova.api.openstack.users.rst +source/api/nova.api.openstack.auth.rst +source/api/nova.api.openstack.versions.rst +source/api/nova.api.openstack.zones.rst +source/api/nova.api.openstack.limits.rst +source/api/nova.api.openstack.flavors.rst +source/api/nova.api.openstack.image_metadata.rst +source/api/nova.api.openstack.contrib.volumes.rst +source/api/nova.api.openstack.wsgi.rst +source/api/nova.api.openstack.accounts.rst +source/api/nova.api.openstack.views.images.rst +source/api/nova.api.openstack.views.addresses.rst +source/api/nova.api.openstack.views.servers.rst +source/api/nova.api.openstack.views.versions.rst +source/api/nova.api.openstack.views.limits.rst +source/api/nova.api.openstack.views.flavors.rst +source/api/nova.api.openstack.server_metadata.rst +source/api/nova.api.openstack.backup_schedules.rst +source/api/nova.api.direct.rst +source/api/nova.log.rst +source/api/nova.rpc.rst +source/api/nova.fakememcache.rst diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index eb6a1a03e..cc9e78916 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -15,10 +15,12 @@ under the License. Distributed Scheduler -===== +===================== The Scheduler is akin to a Dating Service. Requests for the creation of new instances come in and the most applicable Compute nodes are selected from a large pool of potential candidates. In a small deployment we may be happy with the currently available Change Scheduler which randomly selects a Host from the available pool. Or if you need something a little more fancy you may want to use the Availability Zone Scheduler, which selects Compute hosts from a logical partitioning of available hosts (within a single Zone). + .. image:: /images/dating_service.png + But for larger deployments a more complex scheduling algorithm is required. Additionally, if you are using Zones in your Nova setup, you'll need a scheduler that understand how to pass instance requests from Zone to Zone. This is the purpose of the Distributed Scheduler (DS). The DS utilizes the Capabilities of a Zone and its component services to make informed decisions on where a new instance should be created. When making this decision it consults not only all the Compute nodes in the current Zone, but the Compute nodes in each Child Zone. This continues recursively until the ideal host is found. @@ -27,70 +29,82 @@ So, how does this all work? This document will explain the strategy employed by the `ZoneAwareScheduler` and its derivations. You should read the Zones documentation before reading this. + .. image:: /images/zone_aware_scheduler.png + Costs & Weights ----------- +--------------- When deciding where to place an Instance, we compare a Weighted Cost for each Host. The Weighting, currently, is just the sum of each Cost. Costs are nothing more than integers from `0 - max_int`. Costs are computed by looking at the various Capabilities of the Host relative to the specs of the Instance being asked for. Trying to putting a plain vanilla instance on a high performance host should have a very high cost. But putting a vanilla instance on a vanilla Host should have a low cost. Some Costs are more esoteric. Consider a rule that says we should prefer Hosts that don't already have an instance on it that is owned by the user requesting it (to mitigate against machine failures). Here we have to look at all the other Instances on the host to compute our cost. An example of some other costs might include selecting: -* a GPU-based host over a standard CPU -* a host with fast ethernet over a 10mbps line -* a host that can run Windows instances -* a host in the EU vs North America -* etc + * a GPU-based host over a standard CPU + * a host with fast ethernet over a 10mbps line + * a host that can run Windows instances + * a host in the EU vs North America + * etc This Weight is computed for each Instance requested. If the customer asked for 1000 instances, the consumed resources on each Host are "virtually" depleted so the Cost can change accordingly. + .. image:: /images/costs_weights.png + nova.scheduler.zone_aware_scheduler.ZoneAwareScheduler ------------ +------------------------------------------------------ As we explained in the Zones documentation, each Scheduler has a `ZoneManager` object that collects "Capabilities" about child Zones and each of the services running in the current Zone. The `ZoneAwareScheduler` uses this information to make its decisions. Here is how it works: -1. The compute nodes are filtered and the nodes remaining are weighed. -1a. Filtering the hosts is a simple matter of ensuring the compute node has ample resources (CPU, RAM, Disk, etc) to fulfil the request. -1b. Weighing of the remaining compute nodes assigns a number based on their suitability for the request. -2. The same request is sent to each child Zone and step #1 is done there too. The resulting weighted list is returned to the parent. -3. The parent Zone sorts and aggregates all the weights and a final build plan is constructed. -4. The build plan is executed upon. Concurrently, instance create requests are sent to each of the selected hosts, be they local or in a child zone. Child Zones may forward the requests to their child Zones as needed. + 1. The compute nodes are filtered and the nodes remaining are weighed. + 2. Filtering the hosts is a simple matter of ensuring the compute node has ample resources (CPU, RAM, Disk, etc) to fulfil the request. + 3. Weighing of the remaining compute nodes assigns a number based on their suitability for the request. + 4. The same request is sent to each child Zone and step #1 is done there too. The resulting weighted list is returned to the parent. + 5. The parent Zone sorts and aggregates all the weights and a final build plan is constructed. + 6. The build plan is executed upon. Concurrently, instance create requests are sent to each of the selected hosts, be they local or in a child zone. Child Zones may forward the requests to their child Zones as needed. + + .. image:: /images/zone_aware_overview.png `ZoneAwareScheduler` by itself is not capable of handling all the provisioning itself. Derived classes are used to select which host filtering and weighing strategy will be used. Filtering and Weighing ------------- +---------------------- The filtering (excluding compute nodes incapable of fulfilling the request) and weighing (computing the relative "fitness" of a compute node to fulfill the request) rules used are very subjective operations ... Service Providers will probably have a very different set of filtering and weighing rules than private cloud administrators. The filtering and weighing aspects of the `ZoneAwareScheduler` are flexible and extensible. + .. image:: /images/filtering.png + Requesting a new instance ------------- +------------------------- Prior to the `ZoneAwareScheduler`, to request a new instance, a call was made to `nova.compute.api.create()`. The type of instance created depended on the value of the `InstanceType` record being passed in. The `InstanceType` determined the amount of disk, CPU, RAM and network required for the instance. Administrators can add new `InstanceType` records to suit their needs. For more complicated instance requests we need to go beyond the default fields in the `InstanceType` table. `nova.compute.api.create()` performed the following actions: -1. it validated all the fields passed into it. -2. it created an entry in the `Instance` table for each instance requested -3. it put one `run_instance` message in the scheduler queue for each instance requested -4. the schedulers picked off the messages and decided which compute node should handle the request. -5. the `run_instance` message was forwarded to the compute node for processing and the instance is created. -6. it returned a list of dicts representing each of the `Instance` records (even if the instance has not been activated yet). At least the `instance_id`s are valid. + 1. it validated all the fields passed into it. + 2. it created an entry in the `Instance` table for each instance requested + 3. it put one `run_instance` message in the scheduler queue for each instance requested + 4. the schedulers picked off the messages and decided which compute node should handle the request. + 5. the `run_instance` message was forwarded to the compute node for processing and the instance is created. + 6. it returned a list of dicts representing each of the `Instance` records (even if the instance has not been activated yet). At least the `instance_ids` are valid. + + .. image:: /images/nova.compute.api.create.png Generally, the standard schedulers (like `ChanceScheduler` and `AvailabilityZoneScheduler`) only operate in the current Zone. They have no concept of child Zones. The problem with this approach is each request is scattered amongst each of the schedulers. If we are asking for 1000 instances, each scheduler gets the requests one-at-a-time. There is no possability of optimizing the requests to take into account all 1000 instances as a group. We call this Single-Shot vs. All-at-Once. For the `ZoneAwareScheduler` we need to use the All-at-Once approach. We need to consider all the hosts across all the Zones before deciding where they should reside. In order to handle this we have a new method `nova.compute.api.create_all_at_once()`. This method does things a little differently: -1. it validates all the fields passed into it. -2. it creates a single `reservation_id` for all of instances created. This is a UUID. -3. it creates a single `run_instance` request in the scheduler queue -4. a scheduler picks the message off the queue and works on it. -5. the scheduler sends off an OS API `POST /zones/select` command to each child Zone. The `BODY` payload of the call contains the `request_spec`. -6. the child Zones use the `request_spec` to compute a weighted list for each instance requested. No attempt to actually create an instance is done at this point. We're only estimating the suitability of the Zones. -7. if the child Zone has its own child Zones, the `/zones/select` call will be sent down to them as well. -8. Finally, when all the estimates have bubbled back to the Zone that initiated the call, all the results are merged, sorted and processed. -9. Now the instances can be created. The initiating Zone either forwards the `run_instance` message to the local Compute node to do the work, or it issues a `POST /servers` call to the relevant child Zone. The parameters to the child Zone call are the same as what was passed in by the user. -10. The `reservation_id` is passed back to the caller. Later we explain how the user can check on the status of the command with this `reservation_id`. + 1. it validates all the fields passed into it. + 2. it creates a single `reservation_id` for all of instances created. This is a UUID. + 3. it creates a single `run_instance` request in the scheduler queue + 4. a scheduler picks the message off the queue and works on it. + 5. the scheduler sends off an OS API `POST /zones/select` command to each child Zone. The `BODY` payload of the call contains the `request_spec`. + 6. the child Zones use the `request_spec` to compute a weighted list for each instance requested. No attempt to actually create an instance is done at this point. We're only estimating the suitability of the Zones. + 7. if the child Zone has its own child Zones, the `/zones/select` call will be sent down to them as well. + 8. Finally, when all the estimates have bubbled back to the Zone that initiated the call, all the results are merged, sorted and processed. + 9. Now the instances can be created. The initiating Zone either forwards the `run_instance` message to the local Compute node to do the work, or it issues a `POST /servers` call to the relevant child Zone. The parameters to the child Zone call are the same as what was passed in by the user. + 10. The `reservation_id` is passed back to the caller. Later we explain how the user can check on the status of the command with this `reservation_id`. + + .. image:: /images/nova.compute.api.create_all_at_once.png The Catch -------------- +--------- This all seems pretty straightforward but, like most things, there's a catch. Zones are expected to operate in complete isolation from each other. Each Zone has its own AMQP service, database and set of Nova services. But, for security reasons Zones should never leak information about the architectural layout internally. That means Zones cannot leak information about hostnames or service IP addresses outside of its world. When `POST /zones/select` is called to estimate which compute node to use, time passes until the `POST /servers` call is issued. If we only passed the weight back from the `select` we would have to re-compute the appropriate compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to child Zones asking for estimates. @@ -117,7 +131,7 @@ Finally, we need to give the user a way to get information on each of the instan `python-novaclient` will be extended to support both of these changes. Host Filter --------------- +----------- As we mentioned earlier, filtering hosts is a very deployment-specific process. Service Providers may have a different set of criteria for filtering Compute nodes than a University. To faciliate this the `nova.scheduler.host_filter` module supports a variety of filtering strategies as well as an easy means for plugging in your own algorithms. @@ -130,21 +144,22 @@ The filter used is determined by the `--default_host_filter` flag, which points To create your own `HostFilter` the user simply has to derive from `nova.scheduler.host_filter.HostFilter` and implement two methods: `instance_type_to_filter` and `filter_hosts`. Since Nova is currently dependent on the `InstanceType` structure, the `instance_type_to_filter` method should take an `InstanceType` and turn it into an internal data structure usable by your filter. This is for backward compatibility with existing OpenStack and EC2 API calls. If you decide to create your own call for creating instances not based on `Flavors` or `InstanceTypes` you can ignore this method. The real work is done in `filter_hosts` which must return a list of host tuples for each appropriate host. The set of all available hosts is in the `ZoneManager` object passed into the call as well as the filter query. The host tuple contains (``, ``) where `` is whatever you want it to be. Cost Scheduler Weighing --------------- +----------------------- Every `ZoneAwareScheduler` derivation must also override the `weigh_hosts` method. This takes the list of filtered hosts (generated by the `filter_hosts` method) and returns a list of weight dicts. The weight dicts must contain two keys: `weight` and `hostname` where `weight` is simply an integer (lower is better) and `hostname` is the name of the host. The list does not need to be sorted, this will be done by the `ZoneAwareScheduler` base class when all the results have been assembled. Simple Zone Aware Scheduling --------------- +---------------------------- The easiest way to get started with the `ZoneAwareScheduler` is to use the `nova.scheduler.host_filter.HostFilterScheduler`. This scheduler uses the default Host Filter as and the `weight_hosts` method simply returns a weight of 1 for all hosts. But, from this, you can see calls being routed from Zone to Zone and follow the flow of things. The `--scheduler_driver` flag is how you specify the scheduler class name. Flags --------------- +----- All this Zone and Distributed Scheduler stuff can seem a little daunting to configure, but it's actually not too bad. Here are some of the main flags you should set in your `nova.conf` file: :: + --allow_admin_api=true --enable_zone_routing=true --zone_name=zone1 @@ -162,6 +177,7 @@ All this Zone and Distributed Scheduler stuff can seem a little daunting to conf Some optional flags which are handy for debugging are: :: + --connection_type=fake --verbose diff --git a/doc/source/images/costs_weights.png b/doc/source/images/costs_weights.png new file mode 100644 index 000000000..b65e98b0c Binary files /dev/null and b/doc/source/images/costs_weights.png differ diff --git a/doc/source/images/dating_service.png b/doc/source/images/dating_service.png new file mode 100644 index 000000000..49f1bd86a Binary files /dev/null and b/doc/source/images/dating_service.png differ diff --git a/doc/source/images/filtering.png b/doc/source/images/filtering.png new file mode 100644 index 000000000..4303bded8 Binary files /dev/null and b/doc/source/images/filtering.png differ diff --git a/doc/source/images/nova.compute.api.create.png b/doc/source/images/nova.compute.api.create.png new file mode 100755 index 000000000..999f39ed9 Binary files /dev/null and b/doc/source/images/nova.compute.api.create.png differ diff --git a/doc/source/images/nova.compute.api.create_all_at_once.png b/doc/source/images/nova.compute.api.create_all_at_once.png new file mode 100755 index 000000000..c3ce86d03 Binary files /dev/null and b/doc/source/images/nova.compute.api.create_all_at_once.png differ diff --git a/doc/source/images/zone_aware_overview.png b/doc/source/images/zone_aware_overview.png new file mode 100755 index 000000000..470e78138 Binary files /dev/null and b/doc/source/images/zone_aware_overview.png differ diff --git a/doc/source/images/zone_aware_scheduler.png b/doc/source/images/zone_aware_scheduler.png new file mode 100644 index 000000000..a144e1212 Binary files /dev/null and b/doc/source/images/zone_aware_scheduler.png differ -- cgit From b7556544d222741c9bc0d312ae75ab5f84b4cd2d Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 7 Jun 2011 14:48:13 -0400 Subject: Removed use of super --- nova/api/openstack/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index 9db160102..4c682302f 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -35,7 +35,7 @@ class Versions(wsgi.Resource): 'application/xml': wsgi.XMLDictSerializer(metadata=metadata), } - super(Versions, self).__init__(None, serializers=serializers) + wsgi.Resource.__init__(self, None, serializers=serializers) def dispatch(self, request, *args): """Respond to a request for all OpenStack API versions.""" -- cgit From 641f16a5343ca5d95ea10ec5031a27a7f131c337 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 7 Jun 2011 15:17:34 -0400 Subject: pep8 --- nova/api/direct.py | 2 +- nova/utils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/api/direct.py b/nova/api/direct.py index ea7425e19..ec79151b1 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -324,7 +324,7 @@ class Limited(object): def __init__(self, proxy): self._proxy = proxy - if not self.__doc__: #pylint: disable=E0203 + if not self.__doc__: # pylint: disable=E0203 self.__doc__ = proxy.__doc__ if not self._allowed: self._allowed = [] diff --git a/nova/utils.py b/nova/utils.py index e77c80262..691134ada 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -142,7 +142,7 @@ def execute(*cmd, **kwargs): env = os.environ.copy() if addl_env: env.update(addl_env) - _PIPE = subprocess.PIPE #pylint: disable=E1101 + _PIPE = subprocess.PIPE # pylint: disable=E1101 obj = subprocess.Popen(cmd, stdin=_PIPE, stdout=_PIPE, @@ -153,8 +153,8 @@ def execute(*cmd, **kwargs): result = obj.communicate(process_input) else: result = obj.communicate() - obj.stdin.close() #pylint: disable=E1101 - _returncode = obj.returncode #pylint: disable=E1101 + obj.stdin.close() # pylint: disable=E1101 + _returncode = obj.returncode # pylint: disable=E1101 if _returncode: LOG.debug(_('Result was %s') % _returncode) if type(check_exit_code) == types.IntType \ -- cgit From 8f93aa59aca5440a4d9668942703bf235379ed59 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 7 Jun 2011 16:05:03 -0400 Subject: Added test_run_instances_image_status_active to test_cloud. --- nova/tests/test_cloud.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index a58e8bc39..ba133c860 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -487,6 +487,21 @@ class CloudTestCase(test.TestCase): self.assertRaises(exception.ApiError, run_instances, self.context, **kwargs) + def test_run_instances_image_status_active(self): + kwargs = {'image_id': FLAGS.default_image, + 'instance_type': FLAGS.default_instance_type, + 'max_count': 1} + run_instances = self.cloud.run_instances + + def fake_show_stat_active(self, context, id): + return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1, + 'type': 'machine'}, 'status': 'active'} + + self.stubs.Set(local.LocalImageService, 'show', fake_show_stat_active) + + result = run_instances(self.context, **kwargs) + self.assertEqual(len(result['instancesSet']), 1) + def test_terminate_instances(self): inst1 = db.instance_create(self.context, {'reservation_id': 'a', 'image_ref': 1, -- cgit From d4742cf8505ff86a4732f8d198fe6cedf260898e Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 7 Jun 2011 16:08:25 -0400 Subject: Added virtual environment to PEP8 tests --- run_tests.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 9aa555484..c7bcd5d67 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -67,14 +67,11 @@ function run_pep8 { srcfiles=`find bin -type f ! -name "nova.conf*"` srcfiles+=" `find tools/*`" srcfiles+=" nova setup.py plugins/xenserver/xenapi/etc/xapi.d/plugins/glance" - pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py ${srcfiles} + # Just run PEP8 in current environment + ${wrapper} pep8 --repeat --show-pep8 --show-source \ + --exclude=vcsversion.py ${srcfiles} } -if [ $just_pep8 -eq 1 ]; then - run_pep8 - exit -fi - NOSETESTS="python run_tests.py $noseargs" if [ $never_venv -eq 0 ] @@ -103,6 +100,11 @@ then fi fi +if [ $just_pep8 -eq 1 ]; then + run_pep8 + exit +fi + run_tests || exit # Also run pep8 if no options were provided. -- cgit From a90974347dd396990d8e6fadeac15abd07cb19ea Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 7 Jun 2011 14:36:40 -0700 Subject: adding Authorizer key for ImportPublicKey --- nova/api/ec2/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 1915d007d..890d57fe7 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -242,6 +242,7 @@ class Authorizer(wsgi.Middleware): 'CreateKeyPair': ['all'], 'DeleteKeyPair': ['all'], 'DescribeSecurityGroups': ['all'], + 'ImportPublicKey': ['all'], 'AuthorizeSecurityGroupIngress': ['netadmin'], 'RevokeSecurityGroupIngress': ['netadmin'], 'CreateSecurityGroup': ['netadmin'], -- cgit From 49dcee9ac6a4f78cb021181d5310541d9a42fafd Mon Sep 17 00:00:00 2001 From: Lvov Maxim Date: Wed, 8 Jun 2011 13:49:00 +0400 Subject: fix fake driver for using string project --- nova/tests/api/openstack/fakes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 8e0156afa..ce24bd860 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -328,6 +328,11 @@ class FakeAuthManager(object): return user.admin def is_project_member(self, user, project): + if not isinstance(project, Project): + try: + project = self.get_project(project) + except: + raise webob.exc.HTTPUnauthorized() return ((user.id in project.member_ids) or (user.id == project.project_manager_id)) -- cgit From f93717c7d74b24311c04f66b9e710322510d0ed2 Mon Sep 17 00:00:00 2001 From: Lvov Maxim Date: Wed, 8 Jun 2011 13:50:33 +0400 Subject: added tests for X-Auth-Project-Id header --- nova/tests/api/openstack/test_auth.py | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/nova/tests/api/openstack/test_auth.py b/nova/tests/api/openstack/test_auth.py index 8f189c744..04ce78880 100644 --- a/nova/tests/api/openstack/test_auth.py +++ b/nova/tests/api/openstack/test_auth.py @@ -114,6 +114,28 @@ class Test(test.TestCase): self.assertEqual(result.status, '401 Unauthorized') self.assertEqual(self.destroy_called, True) + def test_authorize_project(self): + f = fakes.FakeAuthManager() + user = nova.auth.manager.User('id1', 'user1', 'user1_key', None, None) + f.add_user(user) + f.create_project('user1_project', user) + f.create_project('user2_project', user) + + req = webob.Request.blank('/v1.0/', {'HTTP_HOST': 'foo'}) + req.headers['X-Auth-User'] = 'user1' + req.headers['X-Auth-Key'] = 'user1_key' + result = req.get_response(fakes.wsgi_app()) + self.assertEqual(result.status, '204 No Content') + + token = result.headers['X-Auth-Token'] + self.stubs.Set(nova.api.openstack, 'APIRouterV10', fakes.FakeRouter) + req = webob.Request.blank('/v1.0/fake') + req.headers['X-Auth-Token'] = token + req.headers['X-Auth-Project-Id'] = 'user2_project' + result = req.get_response(fakes.wsgi_app()) + self.assertEqual(result.status, '200 OK') + self.assertEqual(result.headers['X-Test-Success'], 'True') + def test_bad_user_bad_key(self): req = webob.Request.blank('/v1.0/') req.headers['X-Auth-User'] = 'unknown_user' @@ -143,6 +165,48 @@ class Test(test.TestCase): result = req.get_response(fakes.wsgi_app()) self.assertEqual(result.status, '401 Unauthorized') + def test_bad_project(self): + f = fakes.FakeAuthManager() + user1 = nova.auth.manager.User('id1', 'user1', 'user1_key', None, None) + user2 = nova.auth.manager.User('id2', 'user2', 'user2_key', None, None) + f.add_user(user1) + f.add_user(user2) + f.create_project('user1_project', user1) + f.create_project('user2_project', user2) + + req = webob.Request.blank('/v1.0/', {'HTTP_HOST': 'foo'}) + req.headers['X-Auth-User'] = 'user1' + req.headers['X-Auth-Key'] = 'user1_key' + result = req.get_response(fakes.wsgi_app()) + self.assertEqual(result.status, '204 No Content') + + token = result.headers['X-Auth-Token'] + self.stubs.Set(nova.api.openstack, 'APIRouterV10', fakes.FakeRouter) + req = webob.Request.blank('/v1.0/fake') + req.headers['X-Auth-Token'] = token + req.headers['X-Auth-Project-Id'] = 'user2_project' + result = req.get_response(fakes.wsgi_app()) + self.assertEqual(result.status, '401 Unauthorized') + + def test_not_existing_project(self): + f = fakes.FakeAuthManager() + user1 = nova.auth.manager.User('id1', 'user1', 'user1_key', None, None) + f.add_user(user1) + f.create_project('user1_project', user1) + + req = webob.Request.blank('/v1.0/', {'HTTP_HOST': 'foo'}) + req.headers['X-Auth-User'] = 'user1' + req.headers['X-Auth-Key'] = 'user1_key' + result = req.get_response(fakes.wsgi_app()) + self.assertEqual(result.status, '204 No Content') + + token = result.headers['X-Auth-Token'] + self.stubs.Set(nova.api.openstack, 'APIRouterV10', fakes.FakeRouter) + req = webob.Request.blank('/v1.0/fake') + req.headers['X-Auth-Token'] = token + req.headers['X-Auth-Project-Id'] = 'unknown_project' + result = req.get_response(fakes.wsgi_app()) + self.assertEqual(result.status, '401 Unauthorized') class TestFunctional(test.TestCase): def test_token_expiry(self): -- cgit From 03ef0d1091cc1b6d9c3049b1d7b8cfae0019631e Mon Sep 17 00:00:00 2001 From: Lvov Maxim Date: Wed, 8 Jun 2011 13:52:02 +0400 Subject: added field NOVA_PROJECT_ID to template for future using --- nova/auth/novarc.template | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/auth/novarc.template b/nova/auth/novarc.template index 8170fcafe..28a3696a2 100644 --- a/nova/auth/novarc.template +++ b/nova/auth/novarc.template @@ -12,4 +12,5 @@ alias ec2-bundle-image="ec2-bundle-image --cert ${EC2_CERT} --privatekey ${EC2_P alias ec2-upload-bundle="ec2-upload-bundle -a ${EC2_ACCESS_KEY} -s ${EC2_SECRET_KEY} --url ${S3_URL} --ec2cert ${NOVA_CERT}" export NOVA_API_KEY="%(access)s" export NOVA_USERNAME="%(user)s" +export NOVA_PROJECT_ID="%(project)s" export NOVA_URL="%(os)s" -- cgit From bb308603a05915aa486a790267b4b3cc9dbdd624 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 8 Jun 2011 08:59:28 -0300 Subject: removed autogen file --- doc/.autogenerated | 3559 ---------------------------------------------------- 1 file changed, 3559 deletions(-) delete mode 100644 doc/.autogenerated diff --git a/doc/.autogenerated b/doc/.autogenerated deleted file mode 100644 index 5f9630a57..000000000 --- a/doc/.autogenerated +++ /dev/null @@ -1,3559 +0,0 @@ -source/api/nova..adminclient.rst -source/api/nova..api.direct.rst -source/api/nova..api.ec2.admin.rst -source/api/nova..api.ec2.apirequest.rst -source/api/nova..api.ec2.cloud.rst -source/api/nova..api.ec2.metadatarequesthandler.rst -source/api/nova..api.openstack.auth.rst -source/api/nova..api.openstack.backup_schedules.rst -source/api/nova..api.openstack.common.rst -source/api/nova..api.openstack.consoles.rst -source/api/nova..api.openstack.faults.rst -source/api/nova..api.openstack.flavors.rst -source/api/nova..api.openstack.images.rst -source/api/nova..api.openstack.servers.rst -source/api/nova..api.openstack.shared_ip_groups.rst -source/api/nova..api.openstack.zones.rst -source/api/nova..auth.dbdriver.rst -source/api/nova..auth.fakeldap.rst -source/api/nova..auth.ldapdriver.rst -source/api/nova..auth.manager.rst -source/api/nova..auth.signer.rst -source/api/nova..cloudpipe.pipelib.rst -source/api/nova..compute.api.rst -source/api/nova..compute.instance_types.rst -source/api/nova..compute.manager.rst -source/api/nova..compute.monitor.rst -source/api/nova..compute.power_state.rst -source/api/nova..console.api.rst -source/api/nova..console.fake.rst -source/api/nova..console.manager.rst -source/api/nova..console.xvp.rst -source/api/nova..context.rst -source/api/nova..crypto.rst -source/api/nova..db.api.rst -source/api/nova..db.base.rst -source/api/nova..db.migration.rst -source/api/nova..db.sqlalchemy.api.rst -source/api/nova..db.sqlalchemy.migrate_repo.manage.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.007_add_instance_types.rst -source/api/nova..db.sqlalchemy.migration.rst -source/api/nova..db.sqlalchemy.models.rst -source/api/nova..db.sqlalchemy.session.rst -source/api/nova..exception.rst -source/api/nova..fakememcache.rst -source/api/nova..fakerabbit.rst -source/api/nova..flags.rst -source/api/nova..image.glance.rst -source/api/nova..image.local.rst -source/api/nova..image.s3.rst -source/api/nova..image.service.rst -source/api/nova..log.rst -source/api/nova..manager.rst -source/api/nova..network.api.rst -source/api/nova..network.linux_net.rst -source/api/nova..network.manager.rst -source/api/nova..objectstore.bucket.rst -source/api/nova..objectstore.handler.rst -source/api/nova..objectstore.image.rst -source/api/nova..objectstore.stored.rst -source/api/nova..quota.rst -source/api/nova..rpc.rst -source/api/nova..scheduler.chance.rst -source/api/nova..scheduler.driver.rst -source/api/nova..scheduler.manager.rst -source/api/nova..scheduler.simple.rst -source/api/nova..scheduler.zone.rst -source/api/nova..service.rst -source/api/nova..test.rst -source/api/nova..tests.api.openstack.fakes.rst -source/api/nova..tests.api.openstack.test_adminapi.rst -source/api/nova..tests.api.openstack.test_api.rst -source/api/nova..tests.api.openstack.test_auth.rst -source/api/nova..tests.api.openstack.test_common.rst -source/api/nova..tests.api.openstack.test_faults.rst -source/api/nova..tests.api.openstack.test_flavors.rst -source/api/nova..tests.api.openstack.test_images.rst -source/api/nova..tests.api.openstack.test_ratelimiting.rst -source/api/nova..tests.api.openstack.test_servers.rst -source/api/nova..tests.api.openstack.test_shared_ip_groups.rst -source/api/nova..tests.api.openstack.test_zones.rst -source/api/nova..tests.api.test_wsgi.rst -source/api/nova..tests.db.fakes.rst -source/api/nova..tests.declare_flags.rst -source/api/nova..tests.fake_flags.rst -source/api/nova..tests.glance.stubs.rst -source/api/nova..tests.hyperv_unittest.rst -source/api/nova..tests.objectstore_unittest.rst -source/api/nova..tests.real_flags.rst -source/api/nova..tests.runtime_flags.rst -source/api/nova..tests.test_access.rst -source/api/nova..tests.test_api.rst -source/api/nova..tests.test_auth.rst -source/api/nova..tests.test_cloud.rst -source/api/nova..tests.test_compute.rst -source/api/nova..tests.test_console.rst -source/api/nova..tests.test_direct.rst -source/api/nova..tests.test_flags.rst -source/api/nova..tests.test_instance_types.rst -source/api/nova..tests.test_localization.rst -source/api/nova..tests.test_log.rst -source/api/nova..tests.test_middleware.rst -source/api/nova..tests.test_misc.rst -source/api/nova..tests.test_network.rst -source/api/nova..tests.test_quota.rst -source/api/nova..tests.test_rpc.rst -source/api/nova..tests.test_scheduler.rst -source/api/nova..tests.test_service.rst -source/api/nova..tests.test_test.rst -source/api/nova..tests.test_twistd.rst -source/api/nova..tests.test_utils.rst -source/api/nova..tests.test_virt.rst -source/api/nova..tests.test_volume.rst -source/api/nova..tests.test_xenapi.rst -source/api/nova..tests.xenapi.stubs.rst -source/api/nova..twistd.rst -source/api/nova..utils.rst -source/api/nova..version.rst -source/api/nova..virt.connection.rst -source/api/nova..virt.disk.rst -source/api/nova..virt.fake.rst -source/api/nova..virt.hyperv.rst -source/api/nova..virt.images.rst -source/api/nova..virt.libvirt_conn.rst -source/api/nova..virt.xenapi.fake.rst -source/api/nova..virt.xenapi.network_utils.rst -source/api/nova..virt.xenapi.vm_utils.rst -source/api/nova..virt.xenapi.vmops.rst -source/api/nova..virt.xenapi.volume_utils.rst -source/api/nova..virt.xenapi.volumeops.rst -source/api/nova..virt.xenapi_conn.rst -source/api/nova..volume.api.rst -source/api/nova..volume.driver.rst -source/api/nova..volume.manager.rst -source/api/nova..volume.san.rst -source/api/nova..wsgi.rst -source/api/autoindex.rst -source/api/nova..adminclient.rst -source/api/nova..api.direct.rst -source/api/nova..api.ec2.admin.rst -source/api/nova..api.ec2.apirequest.rst -source/api/nova..api.ec2.cloud.rst -source/api/nova..api.ec2.metadatarequesthandler.rst -source/api/nova..api.openstack.auth.rst -source/api/nova..api.openstack.backup_schedules.rst -source/api/nova..api.openstack.common.rst -source/api/nova..api.openstack.consoles.rst -source/api/nova..api.openstack.faults.rst -source/api/nova..api.openstack.flavors.rst -source/api/nova..api.openstack.images.rst -source/api/nova..api.openstack.servers.rst -source/api/nova..api.openstack.shared_ip_groups.rst -source/api/nova..api.openstack.zones.rst -source/api/nova..auth.dbdriver.rst -source/api/nova..auth.fakeldap.rst -source/api/nova..auth.ldapdriver.rst -source/api/nova..auth.manager.rst -source/api/nova..auth.signer.rst -source/api/nova..cloudpipe.pipelib.rst -source/api/nova..compute.api.rst -source/api/nova..compute.instance_types.rst -source/api/nova..compute.manager.rst -source/api/nova..compute.monitor.rst -source/api/nova..compute.power_state.rst -source/api/nova..console.api.rst -source/api/nova..console.fake.rst -source/api/nova..console.manager.rst -source/api/nova..console.xvp.rst -source/api/nova..context.rst -source/api/nova..crypto.rst -source/api/nova..db.api.rst -source/api/nova..db.base.rst -source/api/nova..db.migration.rst -source/api/nova..db.sqlalchemy.api.rst -source/api/nova..db.sqlalchemy.migrate_repo.manage.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova..db.sqlalchemy.migrate_repo.versions.007_add_instance_types.rst -source/api/nova..db.sqlalchemy.migration.rst -source/api/nova..db.sqlalchemy.models.rst -source/api/nova..db.sqlalchemy.session.rst -source/api/nova..exception.rst -source/api/nova..fakememcache.rst -source/api/nova..fakerabbit.rst -source/api/nova..flags.rst -source/api/nova..image.glance.rst -source/api/nova..image.local.rst -source/api/nova..image.s3.rst -source/api/nova..image.service.rst -source/api/nova..log.rst -source/api/nova..manager.rst -source/api/nova..network.api.rst -source/api/nova..network.linux_net.rst -source/api/nova..network.manager.rst -source/api/nova..objectstore.bucket.rst -source/api/nova..objectstore.handler.rst -source/api/nova..objectstore.image.rst -source/api/nova..objectstore.stored.rst -source/api/nova..quota.rst -source/api/nova..rpc.rst -source/api/nova..scheduler.chance.rst -source/api/nova..scheduler.driver.rst -source/api/nova..scheduler.manager.rst -source/api/nova..scheduler.simple.rst -source/api/nova..scheduler.zone.rst -source/api/nova..service.rst -source/api/nova..test.rst -source/api/nova..tests.api.openstack.fakes.rst -source/api/nova..tests.api.openstack.test_adminapi.rst -source/api/nova..tests.api.openstack.test_api.rst -source/api/nova..tests.api.openstack.test_auth.rst -source/api/nova..tests.api.openstack.test_common.rst -source/api/nova..tests.api.openstack.test_faults.rst -source/api/nova..tests.api.openstack.test_flavors.rst -source/api/nova..tests.api.openstack.test_images.rst -source/api/nova..tests.api.openstack.test_ratelimiting.rst -source/api/nova..tests.api.openstack.test_servers.rst -source/api/nova..tests.api.openstack.test_shared_ip_groups.rst -source/api/nova..tests.api.openstack.test_zones.rst -source/api/nova..tests.api.test_wsgi.rst -source/api/nova..tests.db.fakes.rst -source/api/nova..tests.declare_flags.rst -source/api/nova..tests.fake_flags.rst -source/api/nova..tests.glance.stubs.rst -source/api/nova..tests.hyperv_unittest.rst -source/api/nova..tests.objectstore_unittest.rst -source/api/nova..tests.real_flags.rst -source/api/nova..tests.runtime_flags.rst -source/api/nova..tests.test_access.rst -source/api/nova..tests.test_api.rst -source/api/nova..tests.test_auth.rst -source/api/nova..tests.test_cloud.rst -source/api/nova..tests.test_compute.rst -source/api/nova..tests.test_console.rst -source/api/nova..tests.test_direct.rst -source/api/nova..tests.test_flags.rst -source/api/nova..tests.test_instance_types.rst -source/api/nova..tests.test_localization.rst -source/api/nova..tests.test_log.rst -source/api/nova..tests.test_middleware.rst -source/api/nova..tests.test_misc.rst -source/api/nova..tests.test_network.rst -source/api/nova..tests.test_quota.rst -source/api/nova..tests.test_rpc.rst -source/api/nova..tests.test_scheduler.rst -source/api/nova..tests.test_service.rst -source/api/nova..tests.test_test.rst -source/api/nova..tests.test_twistd.rst -source/api/nova..tests.test_utils.rst -source/api/nova..tests.test_virt.rst -source/api/nova..tests.test_volume.rst -source/api/nova..tests.test_xenapi.rst -source/api/nova..tests.xenapi.stubs.rst -source/api/nova..twistd.rst -source/api/nova..utils.rst -source/api/nova..version.rst -source/api/nova..virt.connection.rst -source/api/nova..virt.disk.rst -source/api/nova..virt.fake.rst -source/api/nova..virt.hyperv.rst -source/api/nova..virt.images.rst -source/api/nova..virt.libvirt_conn.rst -source/api/nova..virt.xenapi.fake.rst -source/api/nova..virt.xenapi.network_utils.rst -source/api/nova..virt.xenapi.vm_utils.rst -source/api/nova..virt.xenapi.vmops.rst -source/api/nova..virt.xenapi.volume_utils.rst -source/api/nova..virt.xenapi.volumeops.rst -source/api/nova..virt.xenapi_conn.rst -source/api/nova..volume.api.rst -source/api/nova..volume.driver.rst -source/api/nova..volume.manager.rst -source/api/nova..volume.san.rst -source/api/nova..wsgi.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -source/api/nova.crypto.rst -source/api/nova.cloudpipe.pipelib.rst -source/api/nova.context.rst -source/api/nova.quota.rst -source/api/nova.tests.test_compute.rst -source/api/nova.tests.test_quota.rst -source/api/nova.tests.test_flags.rst -source/api/nova.tests.test_objectstore.rst -source/api/nova.tests.test_crypto.rst -source/api/nova.tests.runtime_flags.rst -source/api/nova.tests.test_exception.rst -source/api/nova.tests.vmwareapi.db_fakes.rst -source/api/nova.tests.vmwareapi.stubs.rst -source/api/nova.tests.test_host_filter.rst -source/api/nova.tests.test_network.rst -source/api/nova.tests.network.base.rst -source/api/nova.tests.declare_flags.rst -source/api/nova.tests.test_localization.rst -source/api/nova.tests.test_access.rst -source/api/nova.tests.test_libvirt.rst -source/api/nova.tests.image.test_glance.rst -source/api/nova.tests.test_direct.rst -source/api/nova.tests.fake_utils.rst -source/api/nova.tests.integrated.test_login.rst -source/api/nova.tests.integrated.test_extensions.rst -source/api/nova.tests.integrated.integrated_helpers.rst -source/api/nova.tests.integrated.test_servers.rst -source/api/nova.tests.integrated.test_xml.rst -source/api/nova.tests.integrated.api.client.rst -source/api/nova.tests.integrated.test_volumes.rst -source/api/nova.tests.test_rpc.rst -source/api/nova.tests.test_volume.rst -source/api/nova.tests.test_notifier.rst -source/api/nova.tests.fake_flags.rst -source/api/nova.tests.test_log.rst -source/api/nova.tests.test_service.rst -source/api/nova.tests.test_twistd.rst -source/api/nova.tests.test_misc.rst -source/api/nova.tests.test_cloud.rst -source/api/nova.tests.glance.stubs.rst -source/api/nova.tests.test_auth.rst -source/api/nova.tests.test_utils.rst -source/api/nova.tests.test_vmwareapi.rst -source/api/nova.tests.test_vlan_network.rst -source/api/nova.tests.test_zones.rst -source/api/nova.tests.test_middleware.rst -source/api/nova.tests.test_ipv6.rst -source/api/nova.tests.xenapi.stubs.rst -source/api/nova.tests.test_api.rst -source/api/nova.tests.scheduler.test_host_filter.rst -source/api/nova.tests.scheduler.test_zone_aware_scheduler.rst -source/api/nova.tests.scheduler.test_least_cost_scheduler.rst -source/api/nova.tests.scheduler.test_scheduler.rst -source/api/nova.tests.db.fakes.rst -source/api/nova.tests.test_instance_types.rst -source/api/nova.tests.test_console.rst -source/api/nova.tests.api.test_wsgi.rst -source/api/nova.tests.api.openstack.test_users.rst -source/api/nova.tests.api.openstack.fakes.rst -source/api/nova.tests.api.openstack.common.rst -source/api/nova.tests.api.openstack.test_wsgi.rst -source/api/nova.tests.api.openstack.test_accounts.rst -source/api/nova.tests.api.openstack.test_flavors.rst -source/api/nova.tests.api.openstack.test_extensions.rst -source/api/nova.tests.api.openstack.test_adminapi.rst -source/api/nova.tests.api.openstack.test_versions.rst -source/api/nova.tests.api.openstack.test_image_metadata.rst -source/api/nova.tests.api.openstack.test_auth.rst -source/api/nova.tests.api.openstack.test_servers.rst -source/api/nova.tests.api.openstack.test_zones.rst -source/api/nova.tests.api.openstack.test_images.rst -source/api/nova.tests.api.openstack.test_api.rst -source/api/nova.tests.api.openstack.test_faults.rst -source/api/nova.tests.api.openstack.test_limits.rst -source/api/nova.tests.api.openstack.test_server_metadata.rst -source/api/nova.tests.api.openstack.test_shared_ip_groups.rst -source/api/nova.tests.api.openstack.test_common.rst -source/api/nova.tests.api.openstack.extensions.foxinsocks.rst -source/api/nova.tests.test_xenapi.rst -source/api/nova.tests.hyperv_unittest.rst -source/api/nova.tests.test_test.rst -source/api/nova.tests.test_flat_network.rst -source/api/nova.network.linux_net.rst -source/api/nova.network.api.rst -source/api/nova.network.manager.rst -source/api/nova.network.vmwareapi_net.rst -source/api/nova.network.xenapi_net.rst -source/api/nova.volume.driver.rst -source/api/nova.volume.api.rst -source/api/nova.volume.san.rst -source/api/nova.volume.manager.rst -source/api/nova.virt.images.rst -source/api/nova.virt.driver.rst -source/api/nova.virt.vmwareapi.io_util.rst -source/api/nova.virt.vmwareapi.error_util.rst -source/api/nova.virt.vmwareapi.vmops.rst -source/api/nova.virt.vmwareapi.fake.rst -source/api/nova.virt.vmwareapi.vim.rst -source/api/nova.virt.vmwareapi.read_write_util.rst -source/api/nova.virt.vmwareapi.vmware_images.rst -source/api/nova.virt.vmwareapi.network_utils.rst -source/api/nova.virt.vmwareapi.vim_util.rst -source/api/nova.virt.vmwareapi.vm_util.rst -source/api/nova.virt.xenapi_conn.rst -source/api/nova.virt.fake.rst -source/api/nova.virt.vmwareapi_conn.rst -source/api/nova.virt.connection.rst -source/api/nova.virt.disk.rst -source/api/nova.virt.libvirt.connection.rst -source/api/nova.virt.libvirt.firewall.rst -source/api/nova.virt.libvirt.netutils.rst -source/api/nova.virt.hyperv.rst -source/api/nova.virt.xenapi.vmops.rst -source/api/nova.virt.xenapi.fake.rst -source/api/nova.virt.xenapi.volume_utils.rst -source/api/nova.virt.xenapi.network_utils.rst -source/api/nova.virt.xenapi.vm_utils.rst -source/api/nova.virt.xenapi.volumeops.rst -source/api/nova.exception.rst -source/api/nova.image.fake.rst -source/api/nova.image.local.rst -source/api/nova.image.glance.rst -source/api/nova.image.service.rst -source/api/nova.image.s3.rst -source/api/nova.objectstore.s3server.rst -source/api/nova.ipv6.account_identifier.rst -source/api/nova.ipv6.api.rst -source/api/nova.ipv6.rfc2462.rst -source/api/nova.notifier.no_op_notifier.rst -source/api/nova.notifier.log_notifier.rst -source/api/nova.notifier.rabbit_notifier.rst -source/api/nova.notifier.api.rst -source/api/nova.vcsversion.rst -source/api/nova.compute.instance_types.rst -source/api/nova.compute.power_state.rst -source/api/nova.compute.api.rst -source/api/nova.compute.manager.rst -source/api/nova.compute.monitor.rst -source/api/nova.wsgi.rst -source/api/nova.console.vmrc_manager.rst -source/api/nova.console.fake.rst -source/api/nova.console.vmrc.rst -source/api/nova.console.api.rst -source/api/nova.console.manager.rst -source/api/nova.console.xvp.rst -source/api/nova.version.rst -source/api/nova.utils.rst -source/api/nova.auth.dbdriver.rst -source/api/nova.auth.fakeldap.rst -source/api/nova.auth.ldapdriver.rst -source/api/nova.auth.signer.rst -source/api/nova.auth.manager.rst -source/api/nova.manager.rst -source/api/nova.scheduler.driver.rst -source/api/nova.scheduler.host_filter.rst -source/api/nova.scheduler.zone.rst -source/api/nova.scheduler.simple.rst -source/api/nova.scheduler.zone_aware_scheduler.rst -source/api/nova.scheduler.zone_manager.rst -source/api/nova.scheduler.api.rst -source/api/nova.scheduler.least_cost.rst -source/api/nova.scheduler.manager.rst -source/api/nova.scheduler.chance.rst -source/api/nova.vnc.auth.rst -source/api/nova.vnc.proxy.rst -source/api/nova.db.base.rst -source/api/nova.db.migration.rst -source/api/nova.db.sqlalchemy.session.rst -source/api/nova.db.sqlalchemy.migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.manage.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.018_rename_server_management_url.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.017_make_instance_type_id_an_integer.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.010_add_os_type_to_instances.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.013_add_flavors_to_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.009_add_instance_migrations.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.002_bexar.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.020_add_snapshot_id_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.016_make_quotas_key_and_value.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.003_add_label_to_networks.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.021_rename_image_ids.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.006_add_provider_data_to_volumes.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.008_add_instance_types.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.019_add_volume_snapshot_support.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.001_austin.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.011_live_migration.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.005_add_instance_metadata.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.004_add_zone_tables.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.012_add_ipv6_flatmanager.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.015_add_auto_assign_to_floating_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.007_add_ipv6_to_fixed_ips.rst -source/api/nova.db.sqlalchemy.migrate_repo.versions.014_add_instance_type_id_to_instances.rst -source/api/nova.db.sqlalchemy.api.rst -source/api/nova.db.sqlalchemy.models.rst -source/api/nova.db.api.rst -source/api/nova.twistd.rst -source/api/nova.test.rst -source/api/nova.fakerabbit.rst -source/api/nova.service.rst -source/api/nova.flags.rst -source/api/nova.api.ec2.ec2utils.rst -source/api/nova.api.ec2.metadatarequesthandler.rst -source/api/nova.api.ec2.cloud.rst -source/api/nova.api.ec2.admin.rst -source/api/nova.api.ec2.apirequest.rst -source/api/nova.api.openstack.images.rst -source/api/nova.api.openstack.faults.rst -source/api/nova.api.openstack.shared_ip_groups.rst -source/api/nova.api.openstack.common.rst -source/api/nova.api.openstack.ips.rst -source/api/nova.api.openstack.extensions.rst -source/api/nova.api.openstack.servers.rst -source/api/nova.api.openstack.consoles.rst -source/api/nova.api.openstack.users.rst -source/api/nova.api.openstack.auth.rst -source/api/nova.api.openstack.versions.rst -source/api/nova.api.openstack.zones.rst -source/api/nova.api.openstack.limits.rst -source/api/nova.api.openstack.flavors.rst -source/api/nova.api.openstack.image_metadata.rst -source/api/nova.api.openstack.contrib.volumes.rst -source/api/nova.api.openstack.wsgi.rst -source/api/nova.api.openstack.accounts.rst -source/api/nova.api.openstack.views.images.rst -source/api/nova.api.openstack.views.addresses.rst -source/api/nova.api.openstack.views.servers.rst -source/api/nova.api.openstack.views.versions.rst -source/api/nova.api.openstack.views.limits.rst -source/api/nova.api.openstack.views.flavors.rst -source/api/nova.api.openstack.server_metadata.rst -source/api/nova.api.openstack.backup_schedules.rst -source/api/nova.api.direct.rst -source/api/nova.log.rst -source/api/nova.rpc.rst -source/api/nova.fakememcache.rst -- cgit From a605905c11d8898e8cc15e830c17de3ce8c80fda Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Wed, 8 Jun 2011 09:21:38 -0400 Subject: pep8 --- nova/auth/ldapdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index 7bcaa34b5..e9532473d 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -139,7 +139,7 @@ class LdapDriver(object): self.__cache = None return False - def __local_cache(key_fmt): #pylint: disable=E0213 + def __local_cache(key_fmt): # pylint: disable=E0213 """Wrap function to cache it's result in self.__cache. Works only with functions with one fixed argument. """ -- cgit From dcb0d38aa829e1e2492defffaf6ad393b809289b Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 8 Jun 2011 08:13:23 -0700 Subject: removed straggler code --- nova/compute/api.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index e09127d5c..b0949a729 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -55,11 +55,6 @@ def generate_default_hostname(instance_id): class API(base.Base): """API for interacting with the compute manager.""" - # Should we create instances all-at-once or as single-shot requests. - # Different schedulers use different approaches. - # This is cached across all API instances. - should_create_all_at_once = None # None implies uninitialized. - def __init__(self, image_service=None, network_api=None, volume_api=None, hostname_factory=generate_default_hostname, **kwargs): -- cgit From a66ae006e0a6103ee6db49ad2b8dc4506969178e Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Wed, 8 Jun 2011 15:45:23 +0000 Subject: Look for vm_mode property on images and use that if it exists to determine if image should be run in PV or HVM mode. If it doesn't exist, fall back to existing logic --- nova/compute/api.py | 6 ++- .../versions/022_add_vm_mode_to_instances.py | 43 ++++++++++++++++++++++ nova/db/sqlalchemy/models.py | 1 + nova/virt/xenapi/vmops.py | 11 ++++-- 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py diff --git a/nova/compute/api.py b/nova/compute/api.py index 4f327fab1..5ea086088 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -166,6 +166,9 @@ class API(base.Base): os_type = None if 'properties' in image and 'os_type' in image['properties']: os_type = image['properties']['os_type'] + vm_mode = None + if 'properties' in image and 'vm_mode' in image['properties']: + vm_mode = image['properties']['vm_mode'] if kernel_id is None: kernel_id = image['properties'].get('kernel_id', None) @@ -224,7 +227,8 @@ class API(base.Base): 'locked': False, 'metadata': metadata, 'availability_zone': availability_zone, - 'os_type': os_type} + 'os_type': os_type, + 'vm_mode': vm_mode} elevated = context.elevated() instances = [] LOG.debug(_("Going to run %s instances..."), num_instances) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py new file mode 100644 index 000000000..5b6a25e41 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py @@ -0,0 +1,43 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import Column, Integer, MetaData, String, Table + +meta = MetaData() + +instances = Table('instances', meta, + Column('id', Integer(), primary_key=True, nullable=False), + ) + +instances_vm_mode = Column('vm_mode', + String(length=255, convert_unicode=False, + assert_unicode=None, unicode_error=None, + _warn_on_bytestring=False), + nullable=True) + + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + + instances.create_column(instances_vm_mode) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + + instances.drop_column('vm_mode') diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 239f6e96a..612ccc93f 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -232,6 +232,7 @@ class Instance(BASE, NovaBase): locked = Column(Boolean) os_type = Column(String(255)) + vm_mode = Column(String(255)) # TODO(vish): see Ewan's email about state improvements, probably # should be in a driver base class or some such diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 32dae97c2..3b793113f 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -160,9 +160,14 @@ class VMOps(object): # Create the VM ref and attach the first disk first_vdi_ref = self._session.call_xenapi('VDI.get_by_uuid', vdis[0]['vdi_uuid']) - use_pv_kernel = VMHelper.determine_is_pv(self._session, - instance.id, first_vdi_ref, disk_image_type, - instance.os_type) + if instance.vm_mode in ('pv', 'PV'): + use_pv_kernel = True + elif instance.vm_mode in ('hv', 'HV', 'hvm', 'HVM'): + use_pv_kernel = False + else: + use_pv_kernel = VMHelper.determine_is_pv(self._session, + instance.id, first_vdi_ref, disk_image_type, + instance.os_type) vm_ref = VMHelper.create_vm(self._session, instance, kernel, ramdisk, use_pv_kernel) VMHelper.create_vbd(session=self._session, vm_ref=vm_ref, -- cgit From 3da61c0b225f824025f617f0a88f72c00e31b83e Mon Sep 17 00:00:00 2001 From: Lvov Maxim Date: Wed, 8 Jun 2011 21:03:52 +0400 Subject: fix exception type catched --- nova/tests/api/openstack/fakes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index ce24bd860..8a17f0374 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -331,7 +331,7 @@ class FakeAuthManager(object): if not isinstance(project, Project): try: project = self.get_project(project) - except: + except exc.NotFound: raise webob.exc.HTTPUnauthorized() return ((user.id in project.member_ids) or (user.id == project.project_manager_id)) -- cgit From f786c112ce4753dfc1838eecbfc5a20314a5e35d Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Wed, 8 Jun 2011 21:58:59 +0400 Subject: PEP8 fix. --- nova/tests/api/openstack/test_auth.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/tests/api/openstack/test_auth.py b/nova/tests/api/openstack/test_auth.py index 04ce78880..af3478c7d 100644 --- a/nova/tests/api/openstack/test_auth.py +++ b/nova/tests/api/openstack/test_auth.py @@ -208,6 +208,7 @@ class Test(test.TestCase): result = req.get_response(fakes.wsgi_app()) self.assertEqual(result.status, '401 Unauthorized') + class TestFunctional(test.TestCase): def test_token_expiry(self): ctx = context.get_admin_context() -- cgit From e5fdcc315cc8c3993f0c37078cf4c89cacc34106 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 8 Jun 2011 11:04:41 -0700 Subject: tweaks --- tools/pip-requires | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pip-requires b/tools/pip-requires index 8f8018765..1fa69cd06 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -10,7 +10,7 @@ boto==1.9b carrot==0.10.5 eventlet==0.9.12 lockfile==0.8 -python-novaclient==2.3 +python-novaclient==2.5 python-daemon==1.5.5 python-gflags==1.3 redis==2.0.0 -- cgit From 70e4d73778d448cb7f122bc0a2a0c43a78fff46a Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 8 Jun 2011 15:23:33 -0700 Subject: added a test for allocate_address & added error handling for api instead of returning 'UnknownError', will give information 'AllocateAddressError: NoMoreAddresses --- nova/api/ec2/__init__.py | 6 ++++++ nova/tests/test_cloud.py | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 1915d007d..459ecb442 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -348,6 +348,12 @@ class Executor(wsgi.Application): LOG.debug(_('KeyPairExists raised: %s'), unicode(ex), context=context) return self._error(req, context, type(ex).__name__, unicode(ex)) + except rpc.RemoteError as ex: + LOG.debug(_('RemoteError raised: %s'), ex.exc_type, + context=context) + if ex.exc_type == 'NoMoreAddresses': + return self._error(req, context, 'AllocateAddressError', + ex.exc_type) except Exception as ex: extra = {'environment': req.environ} LOG.exception(_('Unexpected error raised: %s'), unicode(ex), diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index ba133c860..d6d90e873 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -115,6 +115,16 @@ class CloudTestCase(test.TestCase): public_ip=address) db.floating_ip_destroy(self.context, address) + def test_allocate_address(self): + address = "10.10.10.10" + allocate = self.cloud.allocate_address + db.floating_ip_create(self.context, + {'address': address, + 'host': self.network.host}) + self.assertEqual(allocate(self.context)['publicIp'], address) + db.floating_ip_destroy(self.context, address) + self.assertRaises(rpc.RemoteError, allocate, self.context) + def test_associate_disassociate_address(self): """Verifies associate runs cleanly without raising an exception""" address = "10.10.10.10" -- cgit From f20c73bbe395a93c087562966b10ade3c9f32afc Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Wed, 8 Jun 2011 22:28:28 +0000 Subject: Normalize and update database with used vm_mode --- nova/virt/xenapi/vmops.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 3b793113f..99d2dc758 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -160,14 +160,24 @@ class VMOps(object): # Create the VM ref and attach the first disk first_vdi_ref = self._session.call_xenapi('VDI.get_by_uuid', vdis[0]['vdi_uuid']) - if instance.vm_mode in ('pv', 'PV'): + + vm_mode = instance.vm_mode and instance.vm_mode.lower() + if vm_mode == 'pv': use_pv_kernel = True - elif instance.vm_mode in ('hv', 'HV', 'hvm', 'HVM'): + elif vm_mode in ('hv', 'hvm'): use_pv_kernel = False + vm_mode = 'hvm' # Normalize else: use_pv_kernel = VMHelper.determine_is_pv(self._session, instance.id, first_vdi_ref, disk_image_type, instance.os_type) + vm_mode = use_pv_kernel and 'pv' or 'hvm' + + if instance.vm_mode != vm_mode: + # Update database with normalized (or determined) value + db.instance_update(context.get_admin_context(), + instance['id'], {'vm_mode': vm_mode}) + vm_ref = VMHelper.create_vm(self._session, instance, kernel, ramdisk, use_pv_kernel) VMHelper.create_vbd(session=self._session, vm_ref=vm_ref, -- cgit From 3764be9d65483a9e431b69f37e3516fa20961362 Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 8 Jun 2011 17:15:35 -0700 Subject: raises exception.NoFloatingIpsDefined instead of UnknownError --- nova/api/ec2/cloud.py | 8 ++++++-- nova/tests/test_cloud.py | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 316298c39..6c5dba8ed 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -39,6 +39,7 @@ from nova import flags from nova import ipv6 from nova import log as logging from nova import network +from nova import rpc from nova import utils from nova import volume from nova.api.ec2 import ec2utils @@ -872,8 +873,11 @@ class CloudController(object): def allocate_address(self, context, **kwargs): LOG.audit(_("Allocate address"), context=context) - public_ip = self.network_api.allocate_floating_ip(context) - return {'publicIp': public_ip} + try: + public_ip = self.network_api.allocate_floating_ip(context) + return {'publicIp': public_ip} + except rpc.RemoteError: + raise exception.NoFloatingIpsDefined def release_address(self, context, public_ip, **kwargs): LOG.audit(_("Release address %s"), public_ip, context=context) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index d6d90e873..7cb13c919 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -123,7 +123,8 @@ class CloudTestCase(test.TestCase): 'host': self.network.host}) self.assertEqual(allocate(self.context)['publicIp'], address) db.floating_ip_destroy(self.context, address) - self.assertRaises(rpc.RemoteError, allocate, self.context) + self.assertRaises(exception.NoFloatingIpsDefined, allocate, + self.context) def test_associate_disassociate_address(self): """Verifies associate runs cleanly without raising an exception""" -- cgit From b11cf9bc7b1b9792bdab77aa72dc6163f3e44ca1 Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 8 Jun 2011 17:17:40 -0700 Subject: removing custom exception, instead using NoFloatingIpsDefined --- nova/api/ec2/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 459ecb442..1915d007d 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -348,12 +348,6 @@ class Executor(wsgi.Application): LOG.debug(_('KeyPairExists raised: %s'), unicode(ex), context=context) return self._error(req, context, type(ex).__name__, unicode(ex)) - except rpc.RemoteError as ex: - LOG.debug(_('RemoteError raised: %s'), ex.exc_type, - context=context) - if ex.exc_type == 'NoMoreAddresses': - return self._error(req, context, 'AllocateAddressError', - ex.exc_type) except Exception as ex: extra = {'environment': req.environ} LOG.exception(_('Unexpected error raised: %s'), unicode(ex), -- cgit From 8096ee6c79c608fd84e016d5da7663549a95896f Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 9 Jun 2011 03:35:59 +0000 Subject: Support multiple glance-api servers --- nova/flags.py | 6 ++++-- nova/image/__init__.py | 7 ++++++- nova/image/glance.py | 24 +++++++++++++++++------- nova/virt/images.py | 7 +++++-- nova/virt/xenapi/vm_utils.py | 13 +++++++++---- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index d5090edba..51f0536e8 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -270,8 +270,10 @@ DEFINE_list('region_list', DEFINE_string('connection_type', 'libvirt', 'libvirt, xenapi or fake') DEFINE_string('aws_access_key_id', 'admin', 'AWS Access ID') DEFINE_string('aws_secret_access_key', 'admin', 'AWS Access Key') -DEFINE_integer('glance_port', 9292, 'glance port') -DEFINE_string('glance_host', '$my_ip', 'glance host') +# NOTE(sirp): my_ip interpolation doesn't work within nested structures +DEFINE_list('glance_api_servers', + [('127.0.0.1', 9292)], + 'list of glance servers available to nova') DEFINE_integer('s3_port', 3333, 's3 port') DEFINE_string('s3_host', '$my_ip', 's3 host (for infrastructure)') DEFINE_string('s3_dmz', '$my_ip', 's3 dmz ip (for instances)') diff --git a/nova/image/__init__.py b/nova/image/__init__.py index 93d83df24..a27d649d4 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -22,6 +22,7 @@ import nova from nova import exception from nova import utils from nova import flags +from nova.image import glance as glance_image_service FLAGS = flags.FLAGS @@ -48,6 +49,8 @@ def get_default_image_service(): return ImageService() +# FIXME(sirp): perhaps this should be moved to nova/images/glance so that we +# keep Glance specific code together for the most part def get_glance_client(image_href): """Get the correct glance client and id for the given image_href. @@ -62,7 +65,9 @@ def get_glance_client(image_href): """ image_href = image_href or 0 if str(image_href).isdigit(): - glance_client = GlanceClient(FLAGS.glance_host, FLAGS.glance_port) + glance_host, glance_port = \ + glance_image_service.pick_glance_api_server() + glance_client = GlanceClient(glance_host, glance_port) return (glance_client, int(image_href)) try: diff --git a/nova/image/glance.py b/nova/image/glance.py index 61308431d..b68415844 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -20,6 +20,7 @@ from __future__ import absolute_import import datetime +import random from glance.common import exception as glance_exception @@ -39,6 +40,15 @@ FLAGS = flags.FLAGS GlanceClient = utils.import_class('glance.client.Client') +def pick_glance_api_server(): + """Return which Glance API server to use for the request + + Returns (host, port) + """ + host, port = random.choice(FLAGS.glance_api_servers) + return host, port + + class GlanceImageService(service.BaseImageService): """Provides storage and retrieval of disk image objects within Glance.""" @@ -50,13 +60,13 @@ class GlanceImageService(service.BaseImageService): SERVICE_IMAGE_ATTRS = service.BaseImageService.BASE_IMAGE_ATTRS +\ GLANCE_ONLY_ATTRS - def __init__(self, client=None): - # FIXME(sirp): can we avoid dependency-injection here by using - # stubbing out a fake? - if client is None: - self.client = GlanceClient(FLAGS.glance_host, FLAGS.glance_port) - else: - self.client = client + @property + def client(self): + # NOTE(sirp): we want to load balance each request across glance + # servers. Since GlanceImageService is a long-lived object, `client` + # is made to choose a new server each time via this property. + glance_host, glance_port = pick_glance_api_server() + return GlanceClient(glance_host, glance_port) def index(self, context, filters=None, marker=None, limit=None): """Calls out to Glance for a list of images available.""" diff --git a/nova/virt/images.py b/nova/virt/images.py index de7ac61df..e6f3d3c9e 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -23,6 +23,7 @@ Handling of VM disk images. from nova import context from nova import flags +from nova.image import glance as glance_image_service import nova.image from nova import log as logging from nova import utils @@ -48,7 +49,9 @@ def fetch(image_href, path, _user, _project): # of retrieving the image using this method. def image_url(image): if FLAGS.image_service == "nova.image.glance.GlanceImageService": - return "http://%s:%s/images/%s" % (FLAGS.glance_host, - FLAGS.glance_port, image) + glance_host, glance_port = \ + glance_image_service.pick_glance_api_server() + return "http://%s:%s/images/%s" % (glance_host, glance_port, image) + return "http://%s:%s/_images/%s/image" % (FLAGS.s3_host, FLAGS.s3_port, image) diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 98668e6ae..ccde6cbfe 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -33,6 +33,7 @@ import glance.client from nova import exception from nova import flags 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 @@ -358,10 +359,12 @@ class VMHelper(HelperBase): os_type = instance.os_type or FLAGS.default_os_type + glance_host, glance_port = \ + glance_image_service.pick_glance_api_server() params = {'vdi_uuids': vdi_uuids, 'image_id': image_id, - 'glance_host': FLAGS.glance_host, - 'glance_port': FLAGS.glance_port, + 'glance_host': glance_host, + 'glance_port': glance_port, 'sr_path': cls.get_sr_path(session), 'os_type': os_type} @@ -409,9 +412,11 @@ class VMHelper(HelperBase): # here (under Python 2.6+) and pass them as arguments uuid_stack = [str(uuid.uuid4()) for i in xrange(2)] + glance_host, glance_port = \ + glance_image_service.pick_glance_api_server() params = {'image_id': image, - 'glance_host': FLAGS.glance_host, - 'glance_port': FLAGS.glance_port, + 'glance_host': glance_host, + 'glance_port': glance_port, 'uuid_stack': uuid_stack, 'sr_path': cls.get_sr_path(session)} -- cgit From 463e0388308760dbf3bf2b3fa901d8076d002f91 Mon Sep 17 00:00:00 2001 From: John Tran Date: Thu, 9 Jun 2011 00:01:42 -0700 Subject: matched the inner exception specifically, instead of catching all RemoteError exceptions --- nova/api/ec2/cloud.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 6c5dba8ed..84a83d8e6 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -876,8 +876,11 @@ class CloudController(object): try: public_ip = self.network_api.allocate_floating_ip(context) return {'publicIp': public_ip} - except rpc.RemoteError: - raise exception.NoFloatingIpsDefined + except rpc.RemoteError as ex: + if ex.exc_type == 'NoMoreAddresses': + raise exception.NoFloatingIpsDefined + else: + raise def release_address(self, context, public_ip, **kwargs): LOG.audit(_("Release address %s"), public_ip, context=context) -- cgit From eda8a1aaa2cf7cc31c7fda4723849feee3bc6766 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 9 Jun 2011 14:43:24 +0000 Subject: Fixing the tests --- nova/image/glance.py | 12 ++++++++++-- nova/tests/image/test_glance.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/nova/image/glance.py b/nova/image/glance.py index b68415844..f82c0f4a3 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -60,14 +60,22 @@ class GlanceImageService(service.BaseImageService): SERVICE_IMAGE_ATTRS = service.BaseImageService.BASE_IMAGE_ATTRS +\ GLANCE_ONLY_ATTRS - @property - def client(self): + _client = None + + def _get_client(self): # NOTE(sirp): we want to load balance each request across glance # servers. Since GlanceImageService is a long-lived object, `client` # is made to choose a new server each time via this property. + if self._client is not None: + return self._client glance_host, glance_port = pick_glance_api_server() return GlanceClient(glance_host, glance_port) + def _set_client(self, client): + self._client = client + + client = property(_get_client, _set_client) + def index(self, context, filters=None, marker=None, limit=None): """Calls out to Glance for a list of images available.""" # NOTE(sirp): We need to use `get_images_detailed` and not diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index 041da1e13..033b8389c 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -17,6 +17,7 @@ import datetime +import stubout import unittest from nova import context @@ -60,12 +61,16 @@ class BaseGlanceTest(unittest.TestCase): NOW_DATETIME = datetime.datetime(2010, 10, 11, 10, 30, 22) def setUp(self): - # FIXME(sirp): we can probably use stubs library here rather than - # dependency injection + self.stubs = stubout.StubOutForTesting() self.client = StubGlanceClient(None) - self.service = glance.GlanceImageService(self.client) + self.service = glance.GlanceImageService() + self.stubs.Set(self.service, 'client', self.client) self.context = context.RequestContext(None, None) + def tearDown(self): + self.stubs.UnsetAll() + super(BaseGlanceTest, self).tearDown() + def assertDateTimesFilled(self, image_meta): self.assertEqual(image_meta['created_at'], self.NOW_DATETIME) self.assertEqual(image_meta['updated_at'], self.NOW_DATETIME) -- cgit From 467bda72a05a0fd9fa4d7d417da422eea04de220 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Thu, 9 Jun 2011 18:51:21 +0000 Subject: 022 migration has already been added, so make ours 023 now --- .../versions/022_add_vm_mode_to_instances.py | 43 ---------------------- .../versions/023_add_vm_mode_to_instances.py | 43 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) delete mode 100644 nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py deleted file mode 100644 index 5b6a25e41..000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/022_add_vm_mode_to_instances.py +++ /dev/null @@ -1,43 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 OpenStack LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from sqlalchemy import Column, Integer, MetaData, String, Table - -meta = MetaData() - -instances = Table('instances', meta, - Column('id', Integer(), primary_key=True, nullable=False), - ) - -instances_vm_mode = Column('vm_mode', - String(length=255, convert_unicode=False, - assert_unicode=None, unicode_error=None, - _warn_on_bytestring=False), - nullable=True) - - -def upgrade(migrate_engine): - # Upgrade operations go here. Don't create your own engine; - # bind migrate_engine to your metadata - meta.bind = migrate_engine - - instances.create_column(instances_vm_mode) - - -def downgrade(migrate_engine): - meta.bind = migrate_engine - - instances.drop_column('vm_mode') diff --git a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py new file mode 100644 index 000000000..5b6a25e41 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py @@ -0,0 +1,43 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import Column, Integer, MetaData, String, Table + +meta = MetaData() + +instances = Table('instances', meta, + Column('id', Integer(), primary_key=True, nullable=False), + ) + +instances_vm_mode = Column('vm_mode', + String(length=255, convert_unicode=False, + assert_unicode=None, unicode_error=None, + _warn_on_bytestring=False), + nullable=True) + + +def upgrade(migrate_engine): + # Upgrade operations go here. Don't create your own engine; + # bind migrate_engine to your metadata + meta.bind = migrate_engine + + instances.create_column(instances_vm_mode) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + + instances.drop_column('vm_mode') -- cgit From e307bf5dd60dc84587f76d88956499ee1f1013fb Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 9 Jun 2011 21:36:20 +0000 Subject: Fixing code per review comments --- nova/flags.py | 4 ++-- nova/image/glance.py | 7 +++++-- nova/tests/image/test_glance.py | 9 +-------- nova/virt/images.py | 12 ------------ nova/virt/xenapi/vm_utils.py | 3 ++- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index 545cf90fe..acfcf8d68 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -272,8 +272,8 @@ DEFINE_string('aws_access_key_id', 'admin', 'AWS Access ID') DEFINE_string('aws_secret_access_key', 'admin', 'AWS Access Key') # NOTE(sirp): my_ip interpolation doesn't work within nested structures DEFINE_list('glance_api_servers', - [('127.0.0.1', 9292)], - 'list of glance servers available to nova') + ['127.0.0.1:9292'], + 'list of glance api servers available to nova (host:port)') DEFINE_integer('s3_port', 3333, 's3 port') DEFINE_string('s3_host', '$my_ip', 's3 host (for infrastructure)') DEFINE_string('s3_dmz', '$my_ip', 's3 dmz ip (for instances)') diff --git a/nova/image/glance.py b/nova/image/glance.py index f82c0f4a3..5712215bb 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -45,7 +45,9 @@ def pick_glance_api_server(): Returns (host, port) """ - host, port = random.choice(FLAGS.glance_api_servers) + host_port = random.choice(FLAGS.glance_api_servers) + host, port_str = host_port.split(':') + port = int(port_str) return host, port @@ -60,7 +62,8 @@ class GlanceImageService(service.BaseImageService): SERVICE_IMAGE_ATTRS = service.BaseImageService.BASE_IMAGE_ATTRS +\ GLANCE_ONLY_ATTRS - _client = None + def __init__(self, client=None): + self._client = client def _get_client(self): # NOTE(sirp): we want to load balance each request across glance diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index 033b8389c..223e7ae57 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -17,7 +17,6 @@ import datetime -import stubout import unittest from nova import context @@ -61,16 +60,10 @@ class BaseGlanceTest(unittest.TestCase): NOW_DATETIME = datetime.datetime(2010, 10, 11, 10, 30, 22) def setUp(self): - self.stubs = stubout.StubOutForTesting() self.client = StubGlanceClient(None) - self.service = glance.GlanceImageService() - self.stubs.Set(self.service, 'client', self.client) + self.service = glance.GlanceImageService(client=self.client) self.context = context.RequestContext(None, None) - def tearDown(self): - self.stubs.UnsetAll() - super(BaseGlanceTest, self).tearDown() - def assertDateTimesFilled(self, image_meta): self.assertEqual(image_meta['created_at'], self.NOW_DATETIME) self.assertEqual(image_meta['updated_at'], self.NOW_DATETIME) diff --git a/nova/virt/images.py b/nova/virt/images.py index e6f3d3c9e..40bf6107c 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -43,15 +43,3 @@ def fetch(image_href, path, _user, _project): elevated = context.get_admin_context() metadata = image_service.get(elevated, image_id, image_file) return metadata - - -# TODO(vish): xenapi should use the glance client code directly instead -# of retrieving the image using this method. -def image_url(image): - if FLAGS.image_service == "nova.image.glance.GlanceImageService": - glance_host, glance_port = \ - glance_image_service.pick_glance_api_server() - return "http://%s:%s/images/%s" % (glance_host, glance_port, image) - - return "http://%s:%s/_images/%s/image" % (FLAGS.s3_host, FLAGS.s3_port, - image) diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index ccde6cbfe..b9d4346e4 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -581,7 +581,8 @@ class VMHelper(HelperBase): Returns: A single filename if image_type is KERNEL_RAMDISK A list of dictionaries that describe VDIs, otherwise """ - url = images.image_url(image) + url = "http://%s:%s/_images/%s/image" % (FLAGS.s3_host, FLAGS.s3_port, + image) LOG.debug(_("Asking xapi to fetch %(url)s as %(access)s") % locals()) if image_type == ImageType.KERNEL_RAMDISK: fn = 'get_kernel' -- cgit From 361fd763eb0cf3e62e0184dafd0f4a024e1871f5 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 9 Jun 2011 21:50:34 +0000 Subject: Adding caveat --- nova/image/glance.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/image/glance.py b/nova/image/glance.py index 5712215bb..6e058ab2f 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -43,6 +43,10 @@ GlanceClient = utils.import_class('glance.client.Client') def pick_glance_api_server(): """Return which Glance API server to use for the request + This method provides a very primitive form of load-balancing suitable for + testing and sandbox environments. In production, it would be better to use + one IP and route that to a real load-balancer. + Returns (host, port) """ host_port = random.choice(FLAGS.glance_api_servers) -- cgit From 810b580cb41b076b083ace1c4670c13b2f16c5a5 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Thu, 9 Jun 2011 16:19:24 -0700 Subject: forgot some debugging statements --- nova/api/openstack/create_instance_controller.py | 8 -------- nova/api/openstack/servers.py | 3 --- nova/compute/api.py | 1 - nova/image/__init__.py | 2 -- 4 files changed, 14 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index 613a33b25..cffd944f7 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -76,7 +76,6 @@ class OpenstackCreateInstanceController(object): [instance dicts] vs. reservation_id). So the handling of the return type from this method is left to the caller. """ - print "************************ A" if not body: return (None, faults.Fault(exc.HTTPUnprocessableEntity())) @@ -84,7 +83,6 @@ class OpenstackCreateInstanceController(object): password = self._get_server_admin_password(body['server']) - print "************************ B" key_name = None key_data = None key_pairs = auth_manager.AuthManager.get_key_pairs(context) @@ -93,15 +91,11 @@ class OpenstackCreateInstanceController(object): key_name = key_pair['name'] key_data = key_pair['public_key'] - print "************************ C" image_href = self._image_ref_from_req_data(body) try: - print "************************ Ca" image_service, image_id = nova.image.get_image_service(image_href) - print "************************ Cb" kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( req, image_id) - print "************************ Ce" images = set([str(x['id']) for x in image_service.index(context)]) assert str(image_id) in images except Exception, e: @@ -109,7 +103,6 @@ class OpenstackCreateInstanceController(object): locals()) return (None, faults.Fault(exc.HTTPBadRequest(msg))) - print "************************ D" personality = body['server'].get('personality') injected_files = [] @@ -118,7 +111,6 @@ class OpenstackCreateInstanceController(object): flavor_id = self._flavor_id_from_req_data(body) - print "************************ E" if not 'name' in body['server']: msg = _("Server name is not defined") return (None, exc.HTTPBadRequest(msg)) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 23bb1c869..387b0343a 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -110,14 +110,11 @@ class Controller(base_controller.OpenstackCreateInstanceController): def create(self, req, body): """ Creates a new server for a given user """ - print "************************ 1" extra_values, result = \ self.create_instance(req, body, self.compute_api.create) - print "************************ 2" if extra_values is None: return result # a Fault. - print "************************ 3" instances = result (inst, ) = instances diff --git a/nova/compute/api.py b/nova/compute/api.py index 09ac7a2c6..c7db167c1 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -361,7 +361,6 @@ class API(base.Base): for num in range(num_instances): instance = self.create_db_entry_for_new_instance(context, base_options, security_groups, num=num) - print "*********** INSTANCE = ", instance instances.append(instance) instance_id = instance['id'] diff --git a/nova/image/__init__.py b/nova/image/__init__.py index bde600f70..93d83df24 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -84,12 +84,10 @@ def get_image_service(image_href): :returns: a tuple of the form (image_service, image_id) """ - print "******** XX" image_href = image_href or 0 if str(image_href).isdigit(): return (get_default_image_service(), int(image_href)) - print "******** X" (glance_client, image_id) = get_glance_client(image_href) image_service = nova.image.glance.GlanceImageService(glance_client) return (image_service, image_id) -- cgit From 1261d1340631206c8d47c6373ebd783e75f389ac Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Fri, 10 Jun 2011 05:27:05 -0700 Subject: fixed reraise in trap_error --- nova/scheduler/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 789993890..ffe59d2c1 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -141,7 +141,7 @@ def call_zone_method(context, method_name, errors_to_ignore=None, except Exception as e: if type(e) in errors_to_ignore: return None - raise e + raise res = pool.spawn(_error_trap, *args, **kwargs) results.append((zone, res)) -- cgit From c2ed9160e9aba986e98a32514cb27ab34be9bf0c Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Fri, 10 Jun 2011 09:48:17 -0300 Subject: source illustrations added & spelling/grammar based on comstud's feedback --- doc/source/devref/distributed_scheduler.rst | 16 ++++++++++------ doc/source/devref/zone.rst | 4 ++-- doc/source/image_src/zones_distsched_illustrations.odp | Bin 0 -> 182810 bytes 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100755 doc/source/image_src/zones_distsched_illustrations.odp diff --git a/doc/source/devref/distributed_scheduler.rst b/doc/source/devref/distributed_scheduler.rst index cc9e78916..e33fda4d2 100644 --- a/doc/source/devref/distributed_scheduler.rst +++ b/doc/source/devref/distributed_scheduler.rst @@ -14,10 +14,14 @@ License for the specific language governing permissions and limitations under the License. + Source for illustrations in doc/source/image_src/zone_distsched_illustrations.odp + (OpenOffice Impress format) Illustrations are "exported" to png and then scaled + to 400x300 or 640x480 as needed and placed in the doc/source/images directory. + Distributed Scheduler ===================== -The Scheduler is akin to a Dating Service. Requests for the creation of new instances come in and the most applicable Compute nodes are selected from a large pool of potential candidates. In a small deployment we may be happy with the currently available Change Scheduler which randomly selects a Host from the available pool. Or if you need something a little more fancy you may want to use the Availability Zone Scheduler, which selects Compute hosts from a logical partitioning of available hosts (within a single Zone). +The Scheduler is akin to a Dating Service. Requests for the creation of new instances come in and the most applicable Compute nodes are selected from a large pool of potential candidates. In a small deployment we may be happy with the currently available Chance Scheduler which randomly selects a Host from the available pool. Or if you need something a little more fancy you may want to use the Availability Zone Scheduler, which selects Compute hosts from a logical partitioning of available hosts (within a single Zone). .. image:: /images/dating_service.png @@ -27,13 +31,13 @@ This is the purpose of the Distributed Scheduler (DS). The DS utilizes the Capab So, how does this all work? -This document will explain the strategy employed by the `ZoneAwareScheduler` and its derivations. You should read the Zones documentation before reading this. +This document will explain the strategy employed by the `ZoneAwareScheduler` and its derivations. You should read the :doc:`devguide/zones` documentation before reading this. .. image:: /images/zone_aware_scheduler.png Costs & Weights --------------- -When deciding where to place an Instance, we compare a Weighted Cost for each Host. The Weighting, currently, is just the sum of each Cost. Costs are nothing more than integers from `0 - max_int`. Costs are computed by looking at the various Capabilities of the Host relative to the specs of the Instance being asked for. Trying to putting a plain vanilla instance on a high performance host should have a very high cost. But putting a vanilla instance on a vanilla Host should have a low cost. +When deciding where to place an Instance, we compare a Weighted Cost for each Host. The Weighting, currently, is just the sum of each Cost. Costs are nothing more than integers from `0 - max_int`. Costs are computed by looking at the various Capabilities of the Host relative to the specs of the Instance being asked for. Trying to put a plain vanilla instance on a high performance host should have a very high cost. But putting a vanilla instance on a vanilla Host should have a low cost. Some Costs are more esoteric. Consider a rule that says we should prefer Hosts that don't already have an instance on it that is owned by the user requesting it (to mitigate against machine failures). Here we have to look at all the other Instances on the host to compute our cost. @@ -107,7 +111,7 @@ The Catch --------- This all seems pretty straightforward but, like most things, there's a catch. Zones are expected to operate in complete isolation from each other. Each Zone has its own AMQP service, database and set of Nova services. But, for security reasons Zones should never leak information about the architectural layout internally. That means Zones cannot leak information about hostnames or service IP addresses outside of its world. -When `POST /zones/select` is called to estimate which compute node to use, time passes until the `POST /servers` call is issued. If we only passed the weight back from the `select` we would have to re-compute the appropriate compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to child Zones asking for estimates. +When `POST /zones/select` is called to estimate which compute node to use, time passes until the `POST /servers` call is issued. If we only passed the weight back from the `select` we would have to re-compute the appropriate compute node for the create command ... and we could end up with a different host. Somehow we need to remember the results of our computations and pass them outside of the Zone. Now, we could store this information in the local database and return a reference to it, but remember that the vast majority of weights are going to be ignored. Storing them in the database would result in a flood of disk access and then we have to clean up all these entries periodically. Recall that there are going to be many many `select` calls issued to child Zones asking for estimates. Instead, we take a rather innovative approach to the problem. We encrypt all the child zone internal details and pass them back the to parent Zone. If the parent zone decides to use a child Zone for the instance it simply passes the encrypted data back to the child during the `POST /servers` call as an extra parameter. The child Zone can then decrypt the hint and go directly to the Compute node previously selected. If the estimate isn't used, it is simply discarded by the parent. It's for this reason that it is so important that each Zone defines a unique encryption key via `--build_plan_encryption_key` @@ -122,7 +126,7 @@ NOTE: The features described in this section are related to the up-coming 'merge The OpenStack API allows a user to list all the instances they own via the `GET /servers/` command or the details on a particular instance via `GET /servers/###`. This mechanism is usually sufficient since OS API only allows for creating one instance at a time, unlike the EC2 API which allows you to specify a quantity of instances to be created. -NOTE: currently the `GET /servers` command is not Zone-aware since all operations done in child Zones are done via a single administrative account. Therefore, asking a child Zone to `GET /servers` would return all the active instances ... and that would be what the user intended. Later, when the Keystone Auth system is integrated with Nova, this functionality will be enabled. +NOTE: currently the `GET /servers` command is not Zone-aware since all operations done in child Zones are done via a single administrative account. Therefore, asking a child Zone to `GET /servers` would return all the active instances ... and that would not be what the user intended. Later, when the Keystone Auth system is integrated with Nova, this functionality will be enabled. We could use the OS API 1.1 Extensions mechanism to accept a `num_instances` parameter, but this would result in a different return code. Instead of getting back an `Instance` record, we would be getting back a `reservation_id`. So, instead, we've implemented a new command `POST /zones/boot` command which is nearly identical to `POST /servers` except that it takes a `num_instances` parameter and returns a `reservation_id`. Perhaps in OS API 2.x we can unify these approaches. @@ -149,7 +153,7 @@ Every `ZoneAwareScheduler` derivation must also override the `weigh_hosts` metho Simple Zone Aware Scheduling ---------------------------- -The easiest way to get started with the `ZoneAwareScheduler` is to use the `nova.scheduler.host_filter.HostFilterScheduler`. This scheduler uses the default Host Filter as and the `weight_hosts` method simply returns a weight of 1 for all hosts. But, from this, you can see calls being routed from Zone to Zone and follow the flow of things. +The easiest way to get started with the `ZoneAwareScheduler` is to use the `nova.scheduler.host_filter.HostFilterScheduler`. This scheduler uses the default Host Filter and the `weight_hosts` method simply returns a weight of 1 for all hosts. But, from this, you can see calls being routed from Zone to Zone and follow the flow of things. The `--scheduler_driver` flag is how you specify the scheduler class name. diff --git a/doc/source/devref/zone.rst b/doc/source/devref/zone.rst index 263560ee2..3dc0f80fd 100644 --- a/doc/source/devref/zone.rst +++ b/doc/source/devref/zone.rst @@ -21,7 +21,7 @@ A Nova deployment is called a Zone. A Zone allows you to partition your deployme The idea behind Zones is, if a particular deployment is not capable of servicing a particular request, the request may be forwarded to (child) Zones for possible processing. Zones may be nested in a tree fashion. -Zones only know about their immediate children, they do not know about their parent Zones and may in fact have more than one parent. Likewise, a Zone's children may themselves have child Zones. +Zones only know about their immediate children, they do not know about their parent Zones and may in fact have more than one parent. Likewise, a Zone's children may themselves have child Zones and, in those cases, the grandchild's internal structure would not be known to the grand-parent. Zones share nothing. They communicate via the public OpenStack API only. No database, queue, user or project definition is shared between Zones. @@ -99,7 +99,7 @@ You can get the `child zone api url`, `nova api key` and `username` from the `no export NOVA_URL="http://192.168.2.120:8774/v1.0/" -This equates to a POST operation to `.../zones/` to add a new zone. No connection attempt to the child zone is done when this command. It only puts an entry in the db at this point. After about 30 seconds the `ZoneManager` in the Scheduler services will attempt to talk to the child zone and get its information. +This equates to a POST operation to `.../zones/` to add a new zone. No connection attempt to the child zone is done with this command. It only puts an entry in the db at this point. After about 30 seconds the `ZoneManager` in the Scheduler services will attempt to talk to the child zone and get its information. Getting a list of child Zones ----------------------------- diff --git a/doc/source/image_src/zones_distsched_illustrations.odp b/doc/source/image_src/zones_distsched_illustrations.odp new file mode 100755 index 000000000..8762a183b Binary files /dev/null and b/doc/source/image_src/zones_distsched_illustrations.odp differ -- cgit From e763a0ac8981bdbee44c054c6be08b9f1a5d634d Mon Sep 17 00:00:00 2001 From: John Tran Date: Fri, 10 Jun 2011 10:24:24 -0700 Subject: style change --- nova/tests/test_cloud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 7cb13c919..c8313a5d3 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -123,7 +123,8 @@ class CloudTestCase(test.TestCase): 'host': self.network.host}) self.assertEqual(allocate(self.context)['publicIp'], address) db.floating_ip_destroy(self.context, address) - self.assertRaises(exception.NoFloatingIpsDefined, allocate, + self.assertRaises(exception.NoFloatingIpsDefined, + allocate, self.context) def test_associate_disassociate_address(self): -- cgit From a86523d5ae17b4e5507b14fade0a87c5434f2cac Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Fri, 10 Jun 2011 17:26:25 +0000 Subject: Fix copyright year --- .../db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py index 5b6a25e41..16b9826d9 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2010 OpenStack LLC. +# Copyright 2011 OpenStack LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain -- cgit From 0e7a2042cc5922bb014a77080ec0bdb93bbf575c Mon Sep 17 00:00:00 2001 From: John Tran Date: Fri, 10 Jun 2011 10:28:03 -0700 Subject: raise instance instead of class --- nova/api/ec2/cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 84a83d8e6..5ed473b73 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -878,7 +878,7 @@ class CloudController(object): return {'publicIp': public_ip} except rpc.RemoteError as ex: if ex.exc_type == 'NoMoreAddresses': - raise exception.NoFloatingIpsDefined + raise exception.NoFloatingIpsDefined() else: raise -- cgit From 05fecdf873a5c02dcb13c841304df872411d4183 Mon Sep 17 00:00:00 2001 From: John Tran Date: Fri, 10 Jun 2011 11:10:58 -0700 Subject: added new exception more descriptive of not having available floating addresses avail for allocation --- nova/api/ec2/cloud.py | 2 +- nova/exception.py | 4 ++++ nova/tests/test_cloud.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 5ed473b73..e1c65ae40 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -878,7 +878,7 @@ class CloudController(object): return {'publicIp': public_ip} except rpc.RemoteError as ex: if ex.exc_type == 'NoMoreAddresses': - raise exception.NoFloatingIpsDefined() + raise exception.NoMoreFloatingIps() else: raise diff --git a/nova/exception.py b/nova/exception.py index 69b3e0359..1571dd032 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -376,6 +376,10 @@ class NoFloatingIpsDefinedForInstance(NoFloatingIpsDefined): message = _("Zero floating ips defined for instance %(instance_id)s.") +class NoMoreFloatingIps(NotFound): + message = _("Zero floating ips available.") + + class KeypairNotFound(NotFound): message = _("Keypair %(keypair_name)s not found for user %(user_id)s") diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index c8313a5d3..13046f861 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -123,7 +123,7 @@ class CloudTestCase(test.TestCase): 'host': self.network.host}) self.assertEqual(allocate(self.context)['publicIp'], address) db.floating_ip_destroy(self.context, address) - self.assertRaises(exception.NoFloatingIpsDefined, + self.assertRaises(exception.NoMoreFloatingIps, allocate, self.context) -- cgit From e986887d513855d5a5fd6ca90998860f67fcb1d3 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Fri, 10 Jun 2011 15:28:17 -0400 Subject: force utf-8 encoding on toprettyxml call for XMLDictSerializer --- nova/api/openstack/wsgi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index ddf4e6fa9..6760735c4 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -225,7 +225,7 @@ class XMLDictSerializer(DictSerializer): if not xmlns and self.xmlns: node.setAttribute('xmlns', self.xmlns) - return node.toprettyxml(indent=' ') + return node.toprettyxml(indent=' ', encoding='utf-8') def _to_xml_node(self, doc, metadata, nodename, data): """Recursive method to convert data members to XML nodes.""" -- cgit From 92423564aa24124b0144264d6cd1c57c78eaf5dd Mon Sep 17 00:00:00 2001 From: William Wolf Date: Fri, 10 Jun 2011 16:41:14 -0400 Subject: return body correctly as object instead of a string, with tests, also check for empty body on requests that need a body --- nova/api/openstack/server_metadata.py | 11 +++++++++-- nova/api/openstack/wsgi.py | 4 ++++ nova/tests/api/openstack/test_server_metadata.py | 25 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/server_metadata.py index b38b84a2a..c17d77d46 100644 --- a/nova/api/openstack/server_metadata.py +++ b/nova/api/openstack/server_metadata.py @@ -37,12 +37,18 @@ class Controller(object): meta_dict[key] = value return dict(metadata=meta_dict) + def _check_body(self, body): + if not body: + expl = _('No Request Body') + raise exc.HTTPBadRequest(explanation=expl) + def index(self, req, server_id): """ Returns the list of metadata for a given instance """ context = req.environ['nova.context'] return self._get_metadata(context, server_id) def create(self, req, server_id, body): + self._check_body(body) context = req.environ['nova.context'] metadata = body.get('metadata') try: @@ -51,9 +57,10 @@ class Controller(object): metadata) except quota.QuotaError as error: self._handle_quota_error(error) - return req.body + return body def update(self, req, server_id, id, body): + self._check_body(body) context = req.environ['nova.context'] if not id in body: expl = _('Request body and URI mismatch') @@ -68,7 +75,7 @@ class Controller(object): except quota.QuotaError as error: self._handle_quota_error(error) - return req.body + return body def show(self, req, server_id, id): """ Return a single metadata item """ diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index ddf4e6fa9..8c30cdeb9 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -348,16 +348,20 @@ class Resource(wsgi.Application): LOG.debug("%(method)s %(url)s" % {"method": request.method, "url": request.url}) + print "CALL" try: action, action_args, accept = self.deserializer.deserialize( request) except exception.InvalidContentType: return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) + print "CALL2" action_result = self.dispatch(request, action, action_args) + print "ACTION RESULT:", action_result, isinstance(action_result, str) #TODO(bcwaldon): find a more elegant way to pass through non-dict types if type(action_result) is dict: + print "DICT" response = self.serializer.serialize(action_result, accept) else: response = action_result diff --git a/nova/tests/api/openstack/test_server_metadata.py b/nova/tests/api/openstack/test_server_metadata.py index c4d1d4fd8..b583d40fe 100644 --- a/nova/tests/api/openstack/test_server_metadata.py +++ b/nova/tests/api/openstack/test_server_metadata.py @@ -89,6 +89,7 @@ class ServerMetaDataTest(unittest.TestCase): res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) self.assertEqual(200, res.status_int) + self.assertEqual('application/json', res.headers['Content-Type']) self.assertEqual('value1', res_dict['metadata']['key1']) def test_index_no_data(self): @@ -99,6 +100,7 @@ class ServerMetaDataTest(unittest.TestCase): res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) self.assertEqual(200, res.status_int) + self.assertEqual('application/json', res.headers['Content-Type']) self.assertEqual(0, len(res_dict['metadata'])) def test_show(self): @@ -109,6 +111,7 @@ class ServerMetaDataTest(unittest.TestCase): res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) self.assertEqual(200, res.status_int) + self.assertEqual('application/json', res.headers['Content-Type']) self.assertEqual('value5', res_dict['key5']) def test_show_meta_not_found(self): @@ -140,8 +143,19 @@ class ServerMetaDataTest(unittest.TestCase): res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) self.assertEqual(200, res.status_int) + self.assertEqual('application/json', res.headers['Content-Type']) self.assertEqual('value1', res_dict['metadata']['key1']) + def test_create_empty_body(self): + self.stubs.Set(nova.db.api, 'instance_metadata_update_or_create', + return_create_instance_metadata) + req = webob.Request.blank('/v1.1/servers/1/meta') + req.environ['api.version'] = '1.1' + req.method = 'POST' + req.headers["content-type"] = "application/json" + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(400, res.status_int) + def test_update_item(self): self.stubs.Set(nova.db.api, 'instance_metadata_update_or_create', return_create_instance_metadata) @@ -152,9 +166,20 @@ class ServerMetaDataTest(unittest.TestCase): req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app()) self.assertEqual(200, res.status_int) + self.assertEqual('application/json', res.headers['Content-Type']) res_dict = json.loads(res.body) self.assertEqual('value1', res_dict['key1']) + def test_update_item_empty_body(self): + self.stubs.Set(nova.db.api, 'instance_metadata_update_or_create', + return_create_instance_metadata) + req = webob.Request.blank('/v1.1/servers/1/meta/key1') + req.environ['api.version'] = '1.1' + req.method = 'PUT' + req.headers["content-type"] = "application/json" + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(400, res.status_int) + def test_update_item_too_many_keys(self): self.stubs.Set(nova.db.api, 'instance_metadata_update_or_create', return_create_instance_metadata) -- cgit From cbaa94ac255cde729bae3257da6657a114755224 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Fri, 10 Jun 2011 16:43:13 -0400 Subject: got rid of prints for debugging --- nova/api/openstack/wsgi.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 8c30cdeb9..ddf4e6fa9 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -348,20 +348,16 @@ class Resource(wsgi.Application): LOG.debug("%(method)s %(url)s" % {"method": request.method, "url": request.url}) - print "CALL" try: action, action_args, accept = self.deserializer.deserialize( request) except exception.InvalidContentType: return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) - print "CALL2" action_result = self.dispatch(request, action, action_args) - print "ACTION RESULT:", action_result, isinstance(action_result, str) #TODO(bcwaldon): find a more elegant way to pass through non-dict types if type(action_result) is dict: - print "DICT" response = self.serializer.serialize(action_result, accept) else: response = action_result -- cgit -- cgit From 8146b92f7d81eada6408f939ef25cb5393650008 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 10 Jun 2011 18:39:58 -0400 Subject: adding support for cusom serialization methods --- nova/api/openstack/wsgi.py | 11 +++++++---- nova/tests/api/openstack/test_wsgi.py | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index ddf4e6fa9..e71b80e2c 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -189,7 +189,10 @@ class DictSerializer(object): def serialize(self, data, action='default'): """Find local serialization method and encode response body.""" - action_method = getattr(self, action, self.default) + if action is None: + action_method = self.default + else: + action_method = getattr(self, action, self.default) return action_method(data) def default(self, data): @@ -296,7 +299,7 @@ class ResponseSerializer(object): } self.serializers.update(serializers or {}) - def serialize(self, response_data, content_type): + def serialize(self, response_data, content_type, action='default'): """Serialize a dict into a string and wrap in a wsgi.Request object. :param response_data: dict produced by the Controller @@ -307,7 +310,7 @@ class ResponseSerializer(object): response.headers['Content-Type'] = content_type serializer = self.get_serializer(content_type) - response.body = serializer.serialize(response_data) + response.body = serializer.serialize(response_data, action) return response @@ -358,7 +361,7 @@ class Resource(wsgi.Application): #TODO(bcwaldon): find a more elegant way to pass through non-dict types if type(action_result) is dict: - response = self.serializer.serialize(action_result, accept) + response = self.serializer.serialize(action_result, accept, action) else: response = action_result diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index ebbdc9409..0329ab218 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -171,11 +171,11 @@ class XMLDeserializerTest(test.TestCase): class ResponseSerializerTest(test.TestCase): def setUp(self): class JSONSerializer(object): - def serialize(self, data): + def serialize(self, data, action='default'): return 'pew_json' class XMLSerializer(object): - def serialize(self, data): + def serialize(self, data, action='default'): return 'pew_xml' self.serializers = { @@ -211,11 +211,11 @@ class ResponseSerializerTest(test.TestCase): class RequestDeserializerTest(test.TestCase): def setUp(self): class JSONDeserializer(object): - def deserialize(self, data): + def deserialize(self, data, action='default'): return 'pew_json' class XMLDeserializer(object): - def deserialize(self, data): + def deserialize(self, data, action='default'): return 'pew_xml' self.deserializers = { -- cgit From 73303a34652c738064821ede0258a799435c63d1 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sat, 11 Jun 2011 22:12:59 -0400 Subject: Updated so that we use a 'tmp' subdirectory under the Xen SR when staging migrations. Fixes an issue where you would get a 'File exists' error because the directory under 'images' already existed (created via the rsync copy). --- plugins/xenserver/xenapi/etc/xapi.d/plugins/migration | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration index 75c653408..ac1c50ad9 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration @@ -44,7 +44,7 @@ def move_vhds_into_sr(session, args): new_cow_uuid = params['new_cow_uuid'] sr_path = params['sr_path'] - sr_temp_path = "%s/images/" % sr_path + sr_temp_path = "%s/tmp/" % sr_path # Discover the copied VHDs locally, and then set up paths to copy # them to under the SR -- cgit From bd31a85575ce53dfa80f414dd359b3bdb2855292 Mon Sep 17 00:00:00 2001 From: William Wolf Date: Mon, 13 Jun 2011 08:53:34 -0400 Subject: check for none and empty string, this way empty dicts/lists will be ok --- nova/api/openstack/server_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/server_metadata.py index c17d77d46..57666f6b7 100644 --- a/nova/api/openstack/server_metadata.py +++ b/nova/api/openstack/server_metadata.py @@ -38,7 +38,7 @@ class Controller(object): return dict(metadata=meta_dict) def _check_body(self, body): - if not body: + if body == None or body == "": expl = _('No Request Body') raise exc.HTTPBadRequest(explanation=expl) -- cgit From 67e11fa809c83f25af9d09eac1bbe1c69a22a311 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 13 Jun 2011 10:10:45 -0400 Subject: fixed bug 796619 --- nova/crypto.py | 3 ++- nova/tests/test_crypto.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/nova/crypto.py b/nova/crypto.py index bdc32482a..8d535f426 100644 --- a/nova/crypto.py +++ b/nova/crypto.py @@ -176,7 +176,8 @@ def revoke_certs_by_project(project_id): def revoke_certs_by_user_and_project(user_id, project_id): """Revoke certs for user in project.""" admin = context.get_admin_context() - for cert in db.certificate_get_all_by_user(admin, user_id, project_id): + for cert in db.certificate_get_all_by_user_and_project(admin, + user_id, project_id): revoke_cert(cert['project_id'], cert['file_name']) diff --git a/nova/tests/test_crypto.py b/nova/tests/test_crypto.py index 945d78794..1356ec8b8 100644 --- a/nova/tests/test_crypto.py +++ b/nova/tests/test_crypto.py @@ -16,7 +16,10 @@ Tests for Crypto module. """ +import mox + from nova import crypto +from nova import db from nova import test @@ -46,3 +49,69 @@ class SymmetricKeyTestCase(test.TestCase): plain = decrypt(cipher_text) self.assertEquals(plain_text, plain) + + +class RevokeCertsTest(test.TestCase): + + def test_revoke_certs_by_user_and_project(self): + user_id = 'test_user' + project_id = 2 + file_name = 'test_file' + + certificates = [{"user_id": user_id, "project_id": project_id, + "file_name": file_name}] + + self.mox.StubOutWithMock(db, 'certificate_get_all_by_user_and_project') + db.certificate_get_all_by_user_and_project(mox.IgnoreArg(), \ + user_id, project_id).AndReturn(certificates) + + self.mox.StubOutWithMock(crypto, 'revoke_cert') + crypto.revoke_cert(project_id, mox.IgnoreArg()) + + self.mox.ReplayAll() + + crypto.revoke_certs_by_user_and_project(user_id, project_id) + + self.mox.VerifyAll() + + def test_revoke_certs_by_user(self): + user_id = 'test_user' + project_id = 2 + file_name = 'test_file' + + certificates = [{"user_id": user_id, "project_id": project_id, + "file_name": file_name}] + + self.mox.StubOutWithMock(db, 'certificate_get_all_by_user') + db.certificate_get_all_by_user(mox.IgnoreArg(), \ + user_id).AndReturn(certificates) + + self.mox.StubOutWithMock(crypto, 'revoke_cert') + crypto.revoke_cert(project_id, mox.IgnoreArg()) + + self.mox.ReplayAll() + + crypto.revoke_certs_by_user(user_id) + + self.mox.VerifyAll() + + def test_revoke_certs_by_project(self): + user_id = 'test_user' + project_id = 2 + file_name = 'test_file' + + certificates = [{"user_id": user_id, "project_id": project_id, + "file_name": file_name}] + + self.mox.StubOutWithMock(db, 'certificate_get_all_by_project') + db.certificate_get_all_by_project(mox.IgnoreArg(), \ + project_id).AndReturn(certificates) + + self.mox.StubOutWithMock(crypto, 'revoke_cert') + crypto.revoke_cert(project_id, mox.IgnoreArg()) + + self.mox.ReplayAll() + + crypto.revoke_certs_by_project(project_id) + + self.mox.VerifyAll() -- cgit From db3280e5177df92484bf0a52b5f6ed89dfea63dd Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 13 Jun 2011 09:39:58 -0700 Subject: zones image_id/image_href support for 1.0/1.1 --- nova/api/openstack/__init__.py | 8 ++++---- nova/api/openstack/create_instance_controller.py | 2 -- nova/api/openstack/servers.py | 2 -- nova/api/openstack/zones.py | 19 +++++++++++-------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 4650445d7..e0ae55105 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -81,7 +81,7 @@ class APIRouter(base_wsgi.Router): self._setup_routes(mapper) super(APIRouter, self).__init__(mapper) - def _setup_routes(self, mapper): + def _setup_routes(self, mapper, version='1.0'): server_members = self.server_members server_members['action'] = 'POST' if FLAGS.allow_admin_api: @@ -99,7 +99,7 @@ class APIRouter(base_wsgi.Router): server_members['inject_network_info'] = 'POST' mapper.resource("zone", "zones", - controller=zones.create_resource(), + controller=zones.create_resource(version), collection={'detail': 'GET', 'info': 'GET', 'select': 'POST', @@ -126,7 +126,7 @@ class APIRouterV10(APIRouter): """Define routes specific to OpenStack API V1.0.""" def _setup_routes(self, mapper): - super(APIRouterV10, self)._setup_routes(mapper) + super(APIRouterV10, self)._setup_routes(mapper, version='1.0') mapper.resource("server", "servers", controller=servers.create_resource('1.0'), collection={'detail': 'GET'}, @@ -162,7 +162,7 @@ class APIRouterV11(APIRouter): """Define routes specific to OpenStack API V1.1.""" def _setup_routes(self, mapper): - super(APIRouterV11, self)._setup_routes(mapper) + super(APIRouterV11, self)._setup_routes(mapper, version='1.1') mapper.resource("server", "servers", controller=servers.create_resource('1.1'), collection={'detail': 'GET'}, diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index cffd944f7..2d807470a 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -19,7 +19,6 @@ import base64 import re import webob -from urlparse import urlparse from webob import exc from xml.dom import minidom @@ -31,7 +30,6 @@ from nova import quota from nova import utils from nova.compute import instance_types -from nova.api.openstack import common from nova.api.openstack import faults from nova.api.openstack import wsgi from nova.auth import manager as auth_manager diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 387b0343a..9799c3dea 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -17,7 +17,6 @@ import base64 import traceback from webob import exc -from xml.dom import minidom from nova import compute from nova import exception @@ -32,7 +31,6 @@ import nova.api.openstack.views.flavors import nova.api.openstack.views.images import nova.api.openstack.views.servers from nova.api.openstack import wsgi -from nova.auth import manager as auth_manager import nova.api.openstack from nova.scheduler import api as scheduler_api diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 250848165..91b063cad 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -69,8 +69,9 @@ class Controller(controller.OpenstackCreateInstanceController): doing that (shared with Servers). """ - def __init__(self): + def __init__(self, version): self.compute_api = compute.API() + self.version = version super(Controller, self).__init__() def index(self, req): @@ -160,16 +161,18 @@ class Controller(controller.OpenstackCreateInstanceController): blob=cipher_text)) return cooked - # Assume OS 1.0 functionality for these overrides. - - def _image_id_from_req_data(self, data): - return data['server']['imageId'] + def _image_ref_from_req_data(self, data): + if self.version == '1.0': + return data['server']['imageId'] + return data['server']['imageRef'] def _flavor_id_from_req_data(self, data): - return data['server']['flavorId'] + if self.version == '1.0': + return data['server']['flavorId'] + return data['server']['flavorRef'] -def create_resource(): +def create_resource(version): metadata = { "attributes": { "zone": ["id", "api_url", "name", "capabilities"], @@ -185,5 +188,5 @@ def create_resource(): 'application/xml': controller.ServerXMLDeserializer(), } - return wsgi.Resource(Controller(), serializers=serializers, + return wsgi.Resource(Controller(version), serializers=serializers, deserializers=deserializers) -- cgit From e7e501a1a77f01247d84fa88275e858a338c6c95 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 13 Jun 2011 10:59:58 -0700 Subject: removed yucky None return types --- nova/api/openstack/create_instance_controller.py | 16 ++++++++++++---- nova/api/openstack/servers.py | 11 +++++++---- nova/api/openstack/zones.py | 8 +++++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py index 2d807470a..90f2542d9 100644 --- a/nova/api/openstack/create_instance_controller.py +++ b/nova/api/openstack/create_instance_controller.py @@ -39,6 +39,14 @@ LOG = logging.getLogger('nova.api.openstack.create_instance_controller') FLAGS = flags.FLAGS +class CreateFault(exception.NovaException): + message = _("Invalid parameters given to create_instance.") + + def __init__(self, fault): + self.fault = fault + super(CreateFault, self).__init__() + + class OpenstackCreateInstanceController(object): """This is the base class for OS API Controllers that are capable of creating instances (currently Servers and Zones). @@ -75,7 +83,7 @@ class OpenstackCreateInstanceController(object): return type from this method is left to the caller. """ if not body: - return (None, faults.Fault(exc.HTTPUnprocessableEntity())) + raise faults.Fault(exc.HTTPUnprocessableEntity()) context = req.environ['nova.context'] @@ -99,7 +107,7 @@ class OpenstackCreateInstanceController(object): except Exception, e: msg = _("Cannot find requested image %(image_href)s: %(e)s" % locals()) - return (None, faults.Fault(exc.HTTPBadRequest(msg))) + raise faults.Fault(exc.HTTPBadRequest(msg)) personality = body['server'].get('personality') @@ -111,7 +119,7 @@ class OpenstackCreateInstanceController(object): if not 'name' in body['server']: msg = _("Server name is not defined") - return (None, exc.HTTPBadRequest(msg)) + raise exc.HTTPBadRequest(msg) zone_blob = body['server'].get('blob') name = body['server']['name'] @@ -150,7 +158,7 @@ class OpenstackCreateInstanceController(object): self._handle_quota_error(error) except exception.ImageNotFound as error: msg = _("Can not find requested image") - return faults.Fault(exc.HTTPBadRequest(msg)) + raise faults.Fault(exc.HTTPBadRequest(msg)) # Let the caller deal with unhandled exceptions. diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 9799c3dea..1b18c4ecb 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -108,10 +108,13 @@ class Controller(base_controller.OpenstackCreateInstanceController): def create(self, req, body): """ Creates a new server for a given user """ - extra_values, result = \ - self.create_instance(req, body, self.compute_api.create) - if extra_values is None: - return result # a Fault. + extra_values = None + result = None + try: + extra_values, result = \ + self.create_instance(req, body, self.compute_api.create) + except faults.Fault, f: + return f instances = result diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 91b063cad..7ccb8555b 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -130,10 +130,12 @@ class Controller(controller.OpenstackCreateInstanceController): Returns a reservation ID (a UUID). """ - extra_values, result = self.create_instance(req, body, + result = None + try: + extra_values, result = self.create_instance(req, body, self.compute_api.create_all_at_once) - if extra_values is None: - return result # a Fault. + except faults.Fault, f: + return f reservation_id = result return {'reservation_id': reservation_id} -- cgit From f2ca12fc5ea236bb8940acce80065a3bcbe37d2a Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Mon, 13 Jun 2011 15:03:26 -0400 Subject: wsgi can now handle dispatching action None more elegantly --- nova/api/openstack/wsgi.py | 13 ++++++------- nova/tests/api/openstack/test_wsgi.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index e71b80e2c..385ae4625 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -60,8 +60,9 @@ class TextDeserializer(object): def deserialize(self, datastring, action='default'): """Find local deserialization method and parse request body.""" - action_method = getattr(self, action, self.default) - return action_method(datastring) + action_method = getattr(self, str(action), self.default) + output = action_method(datastring) + return output def default(self, datastring): """Default deserialization code should live here""" @@ -189,11 +190,9 @@ class DictSerializer(object): def serialize(self, data, action='default'): """Find local serialization method and encode response body.""" - if action is None: - action_method = self.default - else: - action_method = getattr(self, action, self.default) - return action_method(data) + action_method = getattr(self, str(action), self.default) + output = action_method(data) + return output def default(self, data): """Default serialization code should live here""" diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index 0329ab218..5ec7712dd 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -89,6 +89,13 @@ class DictSerializerTest(test.TestCase): serializer.default = lambda x: 'trousers' self.assertEqual(serializer.serialize({}, 'update'), 'trousers') + def test_dispatch_action_None(self): + serializer = wsgi.DictSerializer() + serializer.create = lambda x: 'pants' + serializer.default = lambda x: 'trousers' + self.assertEqual(serializer.serialize({}, None), 'trousers') + + class XMLDictSerializerTest(test.TestCase): def test_xml(self): @@ -123,6 +130,12 @@ class TextDeserializerTest(test.TestCase): deserializer.default = lambda x: 'trousers' self.assertEqual(deserializer.deserialize({}, 'update'), 'trousers') + def test_dispatch_action_None(self): + deserializer = wsgi.TextDeserializer() + deserializer.create = lambda x: 'pants' + deserializer.default = lambda x: 'trousers' + self.assertEqual(deserializer.deserialize({}, None), 'trousers') + class JSONDeserializerTest(test.TestCase): def test_json(self): -- cgit From 83df6e50fa90620dd7510e1a06d9128d4de7cb29 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Mon, 13 Jun 2011 15:08:00 -0400 Subject: removing unnecessary lines --- nova/api/openstack/wsgi.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 385ae4625..6cb73d8bf 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -61,8 +61,7 @@ class TextDeserializer(object): def deserialize(self, datastring, action='default'): """Find local deserialization method and parse request body.""" action_method = getattr(self, str(action), self.default) - output = action_method(datastring) - return output + return action_method(datastring) def default(self, datastring): """Default deserialization code should live here""" @@ -191,8 +190,7 @@ class DictSerializer(object): def serialize(self, data, action='default'): """Find local serialization method and encode response body.""" action_method = getattr(self, str(action), self.default) - output = action_method(data) - return output + return action_method(data) def default(self, data): """Default serialization code should live here""" -- cgit From bdfded59fda6716adbbcf981a45d1ed90aa23f89 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 13 Jun 2011 15:18:55 -0400 Subject: Improved tests --- nova/tests/test_crypto.py | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/nova/tests/test_crypto.py b/nova/tests/test_crypto.py index 1356ec8b8..8eaef3293 100644 --- a/nova/tests/test_crypto.py +++ b/nova/tests/test_crypto.py @@ -17,6 +17,7 @@ Tests for Crypto module. """ import mox +import stubout from nova import crypto from nova import db @@ -53,20 +54,31 @@ class SymmetricKeyTestCase(test.TestCase): class RevokeCertsTest(test.TestCase): + def setUp(self): + super(RevokeCertsTest, self).setUp() + self.stubs = stubout.StubOutForTesting() + + def tearDown(self): + self.stubs.UnsetAll() + super(RevokeCertsTest, self).tearDown() + def test_revoke_certs_by_user_and_project(self): user_id = 'test_user' project_id = 2 file_name = 'test_file' - certificates = [{"user_id": user_id, "project_id": project_id, - "file_name": file_name}] + def mock_certificate_get_all_by_user_and_project(context, + user_id, + project_id): + + return [{"user_id": user_id, "project_id": project_id, + "file_name": file_name}] - self.mox.StubOutWithMock(db, 'certificate_get_all_by_user_and_project') - db.certificate_get_all_by_user_and_project(mox.IgnoreArg(), \ - user_id, project_id).AndReturn(certificates) + self.stubs.Set(db, 'certificate_get_all_by_user_and_project', + mock_certificate_get_all_by_user_and_project) self.mox.StubOutWithMock(crypto, 'revoke_cert') - crypto.revoke_cert(project_id, mox.IgnoreArg()) + crypto.revoke_cert(project_id, file_name) self.mox.ReplayAll() @@ -79,12 +91,13 @@ class RevokeCertsTest(test.TestCase): project_id = 2 file_name = 'test_file' - certificates = [{"user_id": user_id, "project_id": project_id, - "file_name": file_name}] + def mock_certificate_get_all_by_user(context, user_id): + + return [{"user_id": user_id, "project_id": project_id, + "file_name": file_name}] - self.mox.StubOutWithMock(db, 'certificate_get_all_by_user') - db.certificate_get_all_by_user(mox.IgnoreArg(), \ - user_id).AndReturn(certificates) + self.stubs.Set(db, 'certificate_get_all_by_user', + mock_certificate_get_all_by_user) self.mox.StubOutWithMock(crypto, 'revoke_cert') crypto.revoke_cert(project_id, mox.IgnoreArg()) @@ -100,12 +113,13 @@ class RevokeCertsTest(test.TestCase): project_id = 2 file_name = 'test_file' - certificates = [{"user_id": user_id, "project_id": project_id, - "file_name": file_name}] + def mock_certificate_get_all_by_project(context, project_id): + + return [{"user_id": user_id, "project_id": project_id, + "file_name": file_name}] - self.mox.StubOutWithMock(db, 'certificate_get_all_by_project') - db.certificate_get_all_by_project(mox.IgnoreArg(), \ - project_id).AndReturn(certificates) + self.stubs.Set(db, 'certificate_get_all_by_project', + mock_certificate_get_all_by_project) self.mox.StubOutWithMock(crypto, 'revoke_cert') crypto.revoke_cert(project_id, mox.IgnoreArg()) -- cgit From 431b9d52f2eb325c8be90d45d102c9e238d02325 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 13 Jun 2011 15:24:02 -0400 Subject: pep8 --- nova/tests/test_crypto.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nova/tests/test_crypto.py b/nova/tests/test_crypto.py index 8eaef3293..6c25b396e 100644 --- a/nova/tests/test_crypto.py +++ b/nova/tests/test_crypto.py @@ -67,15 +67,15 @@ class RevokeCertsTest(test.TestCase): project_id = 2 file_name = 'test_file' - def mock_certificate_get_all_by_user_and_project(context, + def mock_certificate_get_all_by_user_and_project(context, user_id, project_id): - return [{"user_id": user_id, "project_id": project_id, + return [{"user_id": user_id, "project_id": project_id, "file_name": file_name}] - self.stubs.Set(db, 'certificate_get_all_by_user_and_project', - mock_certificate_get_all_by_user_and_project) + self.stubs.Set(db, 'certificate_get_all_by_user_and_project', + mock_certificate_get_all_by_user_and_project) self.mox.StubOutWithMock(crypto, 'revoke_cert') crypto.revoke_cert(project_id, file_name) @@ -91,12 +91,12 @@ class RevokeCertsTest(test.TestCase): project_id = 2 file_name = 'test_file' - def mock_certificate_get_all_by_user(context, user_id): + def mock_certificate_get_all_by_user(context, user_id): - return [{"user_id": user_id, "project_id": project_id, + return [{"user_id": user_id, "project_id": project_id, "file_name": file_name}] - self.stubs.Set(db, 'certificate_get_all_by_user', + self.stubs.Set(db, 'certificate_get_all_by_user', mock_certificate_get_all_by_user) self.mox.StubOutWithMock(crypto, 'revoke_cert') @@ -115,10 +115,10 @@ class RevokeCertsTest(test.TestCase): def mock_certificate_get_all_by_project(context, project_id): - return [{"user_id": user_id, "project_id": project_id, + return [{"user_id": user_id, "project_id": project_id, "file_name": file_name}] - self.stubs.Set(db, 'certificate_get_all_by_project', + self.stubs.Set(db, 'certificate_get_all_by_project', mock_certificate_get_all_by_project) self.mox.StubOutWithMock(crypto, 'revoke_cert') -- cgit From bebeaa6b0bf69c0a4017d429e79174401df28550 Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Mon, 13 Jun 2011 15:20:43 -0500 Subject: Removed clocksource=jiffies from PV_args. --- nova/tests/test_xenapi.py | 2 +- nova/virt/xenapi/vm_utils.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 3a175b106..d1c88287a 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -331,7 +331,7 @@ class XenAPIVMTestCase(test.TestCase): def check_vm_params_for_linux(self): self.assertEquals(self.vm['platform']['nx'], 'false') - self.assertEquals(self.vm['PV_args'], 'clocksource=jiffies') + self.assertEquals(self.vm['PV_args'], '') self.assertEquals(self.vm['PV_bootloader'], 'pygrub') # check that these are not set diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index b9d4346e4..11da221f2 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -157,7 +157,6 @@ class VMHelper(HelperBase): rec['PV_ramdisk'] = ramdisk else: # 2. Use kernel within the image - rec['PV_args'] = 'clocksource=jiffies' rec['PV_bootloader'] = 'pygrub' else: # 3. Using hardware virtualization -- cgit From 2f422747cc7ffcbbe952e9a3fb5fd1de6a417901 Mon Sep 17 00:00:00 2001 From: Lorin Hochstein Date: Mon, 13 Jun 2011 16:41:31 -0400 Subject: Test now passes even if the rpc call does not complete on time --- nova/tests/test_cloud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 13046f861..b491448eb 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -466,7 +466,8 @@ class CloudTestCase(test.TestCase): self.assertEqual(instance['imageId'], 'ami-00000001') self.assertEqual(instance['displayName'], 'Server 1') self.assertEqual(instance['instanceId'], 'i-00000001') - self.assertEqual(instance['instanceState']['name'], 'networking') + self.assertTrue(instance['instanceState']['name'] in + ['networking', 'scheduling']) self.assertEqual(instance['instanceType'], 'm1.small') def test_run_instances_image_state_none(self): -- cgit From d9c2a7112ba239fb64ecc76ce844caed9146a5dc Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Mon, 13 Jun 2011 20:46:25 +0000 Subject: Load table schema automatically instead of stubbing out --- .../sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py index 16b9826d9..2f7bfddcb 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py @@ -18,9 +18,7 @@ from sqlalchemy import Column, Integer, MetaData, String, Table meta = MetaData() -instances = Table('instances', meta, - Column('id', Integer(), primary_key=True, nullable=False), - ) +instances = Table('instances', meta, autoload=True) instances_vm_mode = Column('vm_mode', String(length=255, convert_unicode=False, -- cgit From f3381ee03355d8800d229efb7f799df9e6c915e2 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Mon, 13 Jun 2011 21:14:26 -0400 Subject: pep8 --- nova/api/openstack/limits.py | 2 +- nova/compute/api.py | 2 +- nova/tests/scheduler/test_host_filter.py | 8 ++++---- nova/tests/scheduler/test_least_cost_scheduler.py | 8 ++++---- nova/tests/scheduler/test_zone_aware_scheduler.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nova/api/openstack/limits.py b/nova/api/openstack/limits.py index dc2bc6bbc..fede96e33 100644 --- a/nova/api/openstack/limits.py +++ b/nova/api/openstack/limits.py @@ -99,7 +99,7 @@ def create_resource(version='1.0'): serializers = { 'application/xml': wsgi.XMLDictSerializer(xmlns=xmlns, - metadata=metadata) + metadata=metadata), } return wsgi.Resource(controller, serializers=serializers) diff --git a/nova/compute/api.py b/nova/compute/api.py index b0949a729..5afc0480a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -281,7 +281,7 @@ class API(base.Base): 'instance_type': instance_type, 'filter': filter_class, 'blob': zone_blob, - 'num_instances': num_instances + 'num_instances': num_instances, } rpc.cast(context, diff --git a/nova/tests/scheduler/test_host_filter.py b/nova/tests/scheduler/test_host_filter.py index 07817cc5a..10eafde08 100644 --- a/nova/tests/scheduler/test_host_filter.py +++ b/nova/tests/scheduler/test_host_filter.py @@ -133,11 +133,11 @@ class HostFilterTestCase(test.TestCase): raw = ['or', ['and', ['<', '$compute.host_memory_free', 30], - ['<', '$compute.disk_available', 300] + ['<', '$compute.disk_available', 300], ], ['and', ['>', '$compute.host_memory_free', 70], - ['>', '$compute.disk_available', 700] + ['>', '$compute.disk_available', 700], ] ] cooked = json.dumps(raw) @@ -183,12 +183,12 @@ class HostFilterTestCase(test.TestCase): self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps([]))) self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps({}))) self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps( - ['not', True, False, True, False] + ['not', True, False, True, False], ))) try: hf.filter_hosts(self.zone_manager, json.dumps( - 'not', True, False, True, False + 'not', True, False, True, False, )) self.fail("Should give KeyError") except KeyError, e: diff --git a/nova/tests/scheduler/test_least_cost_scheduler.py b/nova/tests/scheduler/test_least_cost_scheduler.py index 506fa62fb..9a5318aee 100644 --- a/nova/tests/scheduler/test_least_cost_scheduler.py +++ b/nova/tests/scheduler/test_least_cost_scheduler.py @@ -44,7 +44,7 @@ class WeightedSumTestCase(test.TestCase): hosts = [ FakeHost(1, 512 * MB, 100), FakeHost(2, 256 * MB, 400), - FakeHost(3, 512 * MB, 100) + FakeHost(3, 512 * MB, 100), ] weighted_fns = [ @@ -96,7 +96,7 @@ class LeastCostSchedulerTestCase(test.TestCase): def test_noop_cost_fn(self): FLAGS.least_cost_scheduler_cost_functions = [ - 'nova.scheduler.least_cost.noop_cost_fn' + 'nova.scheduler.least_cost.noop_cost_fn', ] FLAGS.noop_cost_fn_weight = 1 @@ -110,7 +110,7 @@ class LeastCostSchedulerTestCase(test.TestCase): def test_cost_fn_weights(self): FLAGS.least_cost_scheduler_cost_functions = [ - 'nova.scheduler.least_cost.noop_cost_fn' + 'nova.scheduler.least_cost.noop_cost_fn', ] FLAGS.noop_cost_fn_weight = 2 @@ -124,7 +124,7 @@ class LeastCostSchedulerTestCase(test.TestCase): def test_fill_first_cost_fn(self): FLAGS.least_cost_scheduler_cost_functions = [ - 'nova.scheduler.least_cost.fill_first_cost_fn' + 'nova.scheduler.least_cost.fill_first_cost_fn', ] FLAGS.fill_first_cost_fn_weight = 1 diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index 9f70b9dbc..37c6488cc 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -201,7 +201,7 @@ class ZoneAwareSchedulerTestCase(test.TestCase): 'instance_properties': {}, 'instance_type': {}, 'filter_driver': 'nova.scheduler.host_filter.AllHostsFilter', - 'blob': "Non-None blob data" + 'blob': "Non-None blob data", } result = sched.schedule_run_instance(None, 1, request_spec) -- cgit From 00071a6e0bd9bf70d7e7afd1656fea39d5149e68 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 14 Jun 2011 01:21:08 +0000 Subject: Adds --show-elapsed option for run_tests --- run_tests.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++-------------- run_tests.sh | 1 + 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/run_tests.py b/run_tests.py index d5d8acd16..ace916535 100644 --- a/run_tests.py +++ b/run_tests.py @@ -56,9 +56,11 @@ To run a single test module: """ import gettext +import heapq import os import unittest import sys +import time gettext.install('nova', unicode=1) @@ -185,7 +187,10 @@ class _NullColorizer(object): class NovaTestResult(result.TextTestResult): def __init__(self, *args, **kw): + self.show_elapsed = kw.pop('show_elapsed') result.TextTestResult.__init__(self, *args, **kw) + self.num_slow_tests = 5 + self.slow_tests = [] # this is a fixed-sized heap self._last_case = None self.colorizer = None # NOTE(vish): reset stdout for the terminal check @@ -200,25 +205,48 @@ class NovaTestResult(result.TextTestResult): def getDescription(self, test): return str(test) - # NOTE(vish): copied from unittest with edit to add color - def addSuccess(self, test): - unittest.TestResult.addSuccess(self, test) + def _handleElapsedTime(self, test): + self.elapsed_time = time.time() - self.start_time + item = (self.elapsed_time, test) + # Record only the n-slowest tests using heap + if len(self.slow_tests) >= self.num_slow_tests: + heapq.heappushpop(self.slow_tests, item) + else: + heapq.heappush(self.slow_tests, item) + + def _writeElapsedTime(self, test): + if self.elapsed_time >= 3.0: + color = 'red' + elif self.elapsed_time >= 1.0: + color = 'yellow' + else: + color = 'green' + + self.stream.write(' ' * 10) + self.colorizer.write("%.2f" % self.elapsed_time, color) + self.stream.write(' secs') + + def _writeResult(self, test, long_result, color, short_result): if self.showAll: - self.colorizer.write("OK", 'green') + self.colorizer.write(long_result, color) + if self.show_elapsed: + self._writeElapsedTime(test) self.stream.writeln() elif self.dots: - self.stream.write('.') + self.stream.write(short_result) self.stream.flush() + # NOTE(vish): copied from unittest with edit to add color + def addSuccess(self, test): + unittest.TestResult.addSuccess(self, test) + self._handleElapsedTime(test) + self._writeResult(test, 'OK', 'green', '.') + # NOTE(vish): copied from unittest with edit to add color def addFailure(self, test, err): unittest.TestResult.addFailure(self, test, err) - if self.showAll: - self.colorizer.write("FAIL", 'red') - self.stream.writeln() - elif self.dots: - self.stream.write('F') - self.stream.flush() + self._handleElapsedTime(test) + self._writeResult(test, 'FAIL', 'red', 'F') # NOTE(vish): copied from nose with edit to add color def addError(self, test, err): @@ -226,6 +254,7 @@ class NovaTestResult(result.TextTestResult): errorClasses. If the exception is a registered class, the error will be added to the list for that class, not errors. """ + self._handleElapsedTime(test) stream = getattr(self, 'stream', None) ec, ev, tb = err try: @@ -252,14 +281,11 @@ class NovaTestResult(result.TextTestResult): self.errors.append((test, exc_info)) test.passed = False if stream is not None: - if self.showAll: - self.colorizer.write("ERROR", 'red') - self.stream.writeln() - elif self.dots: - stream.write('E') + self._writeResult(test, 'ERROR', 'red', 'E') def startTest(self, test): unittest.TestResult.startTest(self, test) + self.start_time = time.time() current_case = test.test.__class__.__name__ if self.showAll: @@ -273,21 +299,38 @@ class NovaTestResult(result.TextTestResult): class NovaTestRunner(core.TextTestRunner): + def __init__(self, *args, **kwargs): + self.show_elapsed = kwargs.pop('show_elapsed') + core.TextTestRunner.__init__(self, *args, **kwargs) + def _makeResult(self): return NovaTestResult(self.stream, self.descriptions, self.verbosity, - self.config) + self.config, + show_elapsed=self.show_elapsed) + + def run(self, test): + result_ = core.TextTestRunner.run(self, test) + if self.show_elapsed: + self.stream.writeln("Slowest %i tests:" % result_.num_slow_tests) + for elapsed_time, test in reversed(sorted(result_.slow_tests)): + time_str = "%.2f secs" % elapsed_time + self.stream.writeln(" %s %s" % (time_str.ljust(10), test)) + return result_ if __name__ == '__main__': logging.setup() # If any argument looks like a test name but doesn't have "nova.tests" in # front of it, automatically add that so we don't have to type as much + show_elapsed = False argv = [] for x in sys.argv: if x.startswith('test_'): argv.append('nova.tests.%s' % x) + elif x.startswith('--show-elapsed'): + show_elapsed = True else: argv.append(x) @@ -300,5 +343,6 @@ if __name__ == '__main__': runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity, - config=c) + config=c, + show_elapsed=show_elapsed) sys.exit(not core.run(config=c, testRunner=runner, argv=argv)) diff --git a/run_tests.sh b/run_tests.sh index c7bcd5d67..5fc406035 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -10,6 +10,7 @@ function usage { echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." echo " -p, --pep8 Just run pep8" echo " -h, --help Print this usage message" + echo " --show-elapsed Print elapsed time for tests along with slowest tests" echo "" echo "Note: with no options specified, the script will try to run the tests in a virtual environment," echo " If no virtualenv is found, the script will ask if you would like to create one. If you " -- cgit From a3ddb45464204464c93b1deb692414c44ce99376 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 14 Jun 2011 10:16:51 -0400 Subject: Created new exception for handling malformed requests Wrote tests Raise httpBadRequest on malformed request bodies --- nova/api/openstack/wsgi.py | 16 +++++++++++++--- nova/exception.py | 4 ++++ nova/tests/api/openstack/test_api.py | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index b0e2cab2c..7f17471c4 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -2,6 +2,7 @@ import json import webob from xml.dom import minidom +from xml.parsers.expat import ExpatError from nova import exception from nova import log as logging @@ -71,7 +72,10 @@ class TextDeserializer(object): class JSONDeserializer(TextDeserializer): def default(self, datastring): - return utils.loads(datastring) + try: + return utils.loads(datastring) + except ValueError: + raise exception.MalformedRequestBody() class XMLDeserializer(TextDeserializer): @@ -86,8 +90,12 @@ class XMLDeserializer(TextDeserializer): def default(self, datastring): plurals = set(self.metadata.get('plurals', {})) - node = minidom.parseString(datastring).childNodes[0] - return {node.nodeName: self._from_xml_node(node, plurals)} + + try: + node = minidom.parseString(datastring).childNodes[0] + return {node.nodeName: self._from_xml_node(node, plurals)} + except ExpatError: + raise exception.MalformedRequestBody() def _from_xml_node(self, node, listnames): """Convert a minidom node to a simple Python type. @@ -353,6 +361,8 @@ class Resource(wsgi.Application): request) except exception.InvalidContentType: return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) + except exception.MalformedRequestBody: + return webob.exc.HTTPBadRequest(_("Malformed request")) action_result = self.dispatch(request, action, action_args) diff --git a/nova/exception.py b/nova/exception.py index 1571dd032..ffd88fbe7 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -585,3 +585,7 @@ class InstanceExists(Duplicate): class MigrationError(NovaException): message = _("Migration error") + ": %(reason)s" + + +class MalformedRequestBody(NovaException): + message = _("Malformed message body") + ": %(reason)s" diff --git a/nova/tests/api/openstack/test_api.py b/nova/tests/api/openstack/test_api.py index c63431a45..7321c329f 100644 --- a/nova/tests/api/openstack/test_api.py +++ b/nova/tests/api/openstack/test_api.py @@ -15,6 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. +import json + import webob.exc import webob.dec @@ -23,6 +25,7 @@ from webob import Request from nova import test from nova.api import openstack from nova.api.openstack import faults +from nova.tests.api.openstack import fakes class APITest(test.TestCase): @@ -31,6 +34,24 @@ class APITest(test.TestCase): # simpler version of the app than fakes.wsgi_app return openstack.FaultWrapper(inner_app) + def test_malformed_json(self): + req = webob.Request.blank('/') + req.method = 'POST' + req.body = '{' + req.headers["content-type"] = "application/json" + + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 400) + + def test_malformed_xml(self): + req = webob.Request.blank('/') + req.method = 'POST' + req.body = '' + req.headers["content-type"] = "application/xml" + + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 400) + def test_exceptions_are_converted_to_faults(self): @webob.dec.wsgify -- cgit From 70bb9494639ec26f12b71dc22052d3e5b343890f Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 14 Jun 2011 15:36:07 +0000 Subject: autoload with the appropriate engine during upgrade/downgrade --- .../migrate_repo/versions/023_add_vm_mode_to_instances.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py index 2f7bfddcb..0c587f569 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py @@ -18,8 +18,6 @@ from sqlalchemy import Column, Integer, MetaData, String, Table meta = MetaData() -instances = Table('instances', meta, autoload=True) - instances_vm_mode = Column('vm_mode', String(length=255, convert_unicode=False, assert_unicode=None, unicode_error=None, @@ -32,10 +30,16 @@ def upgrade(migrate_engine): # bind migrate_engine to your metadata meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True, + autoload_with=migrate_engine) + instances.create_column(instances_vm_mode) def downgrade(migrate_engine): meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True, + autoload_with=migrate_engine) + instances.drop_column('vm_mode') -- cgit From 9806dacb03023d1db22e9cf833845ba8498657a3 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 14 Jun 2011 12:02:15 -0400 Subject: Added faults wrapper --- nova/api/openstack/wsgi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 7f17471c4..affc781dc 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -5,6 +5,7 @@ from xml.dom import minidom from xml.parsers.expat import ExpatError from nova import exception +import faults from nova import log as logging from nova import utils from nova import wsgi @@ -362,7 +363,9 @@ class Resource(wsgi.Application): except exception.InvalidContentType: return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) except exception.MalformedRequestBody: - return webob.exc.HTTPBadRequest(_("Malformed request")) + explanation = _("Malformed request") + return faults.Fault(webob.exc.HTTPBadRequest( + explanation=explanation)) action_result = self.dispatch(request, action, action_args) -- cgit From e9f6e47a92090a9a7867c2a117ae6cf58db394ac Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 14 Jun 2011 12:36:46 -0400 Subject: Improved errors --- nova/api/openstack/wsgi.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index affc781dc..0b749e115 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -76,7 +76,8 @@ class JSONDeserializer(TextDeserializer): try: return utils.loads(datastring) except ValueError: - raise exception.MalformedRequestBody() + raise exception.MalformedRequestBody( + "malformed JSON in request body") class XMLDeserializer(TextDeserializer): @@ -96,7 +97,8 @@ class XMLDeserializer(TextDeserializer): node = minidom.parseString(datastring).childNodes[0] return {node.nodeName: self._from_xml_node(node, plurals)} except ExpatError: - raise exception.MalformedRequestBody() + raise exception.MalformedRequestBody( + "malformed XML in request Body") def _from_xml_node(self, node, listnames): """Convert a minidom node to a simple Python type. @@ -363,7 +365,7 @@ class Resource(wsgi.Application): except exception.InvalidContentType: return webob.exc.HTTPBadRequest(_("Unsupported Content-Type")) except exception.MalformedRequestBody: - explanation = _("Malformed request") + explanation = _("Malformed request body") return faults.Fault(webob.exc.HTTPBadRequest( explanation=explanation)) -- cgit From f46c9d7c96d591d1fffe2f45aee3e8d437e016bf Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 14 Jun 2011 16:39:37 +0000 Subject: Making timing points stricter, only show slow/sluggish tests in summary --- run_tests.py | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/run_tests.py b/run_tests.py index ace916535..3ecc146fd 100644 --- a/run_tests.py +++ b/run_tests.py @@ -185,6 +185,22 @@ class _NullColorizer(object): self.stream.write(text) +def classify_test_speed(elapsed_time): + if elapsed_time > 1.0: + return 'slow' + elif elapsed_time > 0.25: + return 'sluggish' + else: + return 'fast' + + +def get_elapsed_time_color(elapsed_time): + color_map = {'slow': 'red', 'sluggish': 'yellow', 'fast': 'green'} + slowness = classify_test_speed(elapsed_time) + color = color_map[slowness] + return color + + class NovaTestResult(result.TextTestResult): def __init__(self, *args, **kw): self.show_elapsed = kw.pop('show_elapsed') @@ -215,15 +231,8 @@ class NovaTestResult(result.TextTestResult): heapq.heappush(self.slow_tests, item) def _writeElapsedTime(self, test): - if self.elapsed_time >= 3.0: - color = 'red' - elif self.elapsed_time >= 1.0: - color = 'yellow' - else: - color = 'green' - - self.stream.write(' ' * 10) - self.colorizer.write("%.2f" % self.elapsed_time, color) + color = get_elapsed_time_color(self.elapsed_time) + self.colorizer.write(" %.2f" % self.elapsed_time, color) self.stream.write(' secs') def _writeResult(self, test, long_result, color, short_result): @@ -310,13 +319,22 @@ class NovaTestRunner(core.TextTestRunner): self.config, show_elapsed=self.show_elapsed) + def _writeSlowTests(self, result_): + # Pare out 'fast' tests + slow_tests = [item for item in result_.slow_tests + if classify_test_speed(item[0]) != 'fast'] + + slow_total_time = sum(item[0] for item in slow_tests) + self.stream.writeln("Slowest %i tests took %.2f secs:" + % (len(slow_tests), slow_total_time)) + for elapsed_time, test in sorted(slow_tests, reverse=True): + time_str = "%.2f secs" % elapsed_time + self.stream.writeln(" %s %s" % (time_str.ljust(10), test)) + def run(self, test): result_ = core.TextTestRunner.run(self, test) if self.show_elapsed: - self.stream.writeln("Slowest %i tests:" % result_.num_slow_tests) - for elapsed_time, test in reversed(sorted(result_.slow_tests)): - time_str = "%.2f secs" % elapsed_time - self.stream.writeln(" %s %s" % (time_str.ljust(10), test)) + self._writeSlowTests(result_) return result_ -- cgit From b44dfde77b501e7c0d84769cab3b4a1a317c738d Mon Sep 17 00:00:00 2001 From: Lorin Hochstein Date: Tue, 14 Jun 2011 13:14:00 -0400 Subject: Stub out the rpc call in a unit test to avoid a race condition --- nova/tests/test_cloud.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index b491448eb..afc661635 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -457,6 +457,12 @@ class CloudTestCase(test.TestCase): self.cloud.delete_key_pair(self.context, 'test') def test_run_instances(self): + # stub out the rpc call + def stub_cast(*args, **kwargs): + pass + + self.stubs.Set(rpc, 'cast', stub_cast) + kwargs = {'image_id': FLAGS.default_image, 'instance_type': FLAGS.default_instance_type, 'max_count': 1} @@ -466,8 +472,7 @@ class CloudTestCase(test.TestCase): self.assertEqual(instance['imageId'], 'ami-00000001') self.assertEqual(instance['displayName'], 'Server 1') self.assertEqual(instance['instanceId'], 'i-00000001') - self.assertTrue(instance['instanceState']['name'] in - ['networking', 'scheduling']) + self.assertEqual(instance['instanceState']['name'], 'scheduling') self.assertEqual(instance['instanceType'], 'm1.small') def test_run_instances_image_state_none(self): -- cgit From b00628c4767b440fa6123aa1683d88cd33517d21 Mon Sep 17 00:00:00 2001 From: Lorin Hochstein Date: Tue, 14 Jun 2011 13:17:13 -0400 Subject: pep8 fix --- nova/tests/test_cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index afc661635..d2ff14f27 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -462,7 +462,7 @@ class CloudTestCase(test.TestCase): pass self.stubs.Set(rpc, 'cast', stub_cast) - + kwargs = {'image_id': FLAGS.default_image, 'instance_type': FLAGS.default_instance_type, 'max_count': 1} -- cgit From e89aad7ca0ba7ab5e9b83fa6fd9cde7fb22924bf Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 14 Jun 2011 17:22:33 +0000 Subject: Really PEP8? A tab is inferior to 2 spaces? --- nova/virt/xenapi/vmops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 624588b6b..d105cf300 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -166,7 +166,7 @@ class VMOps(object): use_pv_kernel = True elif vm_mode in ('hv', 'hvm'): use_pv_kernel = False - vm_mode = 'hvm' # Normalize + vm_mode = 'hvm' # Normalize else: use_pv_kernel = VMHelper.determine_is_pv(self._session, instance.id, first_vdi_ref, disk_image_type, -- cgit From cf66a99314d6420725e32daf6a08404c98239107 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 14 Jun 2011 13:27:28 -0400 Subject: mp fixes --- nova/api/openstack/wsgi.py | 4 ++-- nova/exception.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 0b749e115..43b51b64a 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -77,7 +77,7 @@ class JSONDeserializer(TextDeserializer): return utils.loads(datastring) except ValueError: raise exception.MalformedRequestBody( - "malformed JSON in request body") + reason=_("malformed JSON in request body")) class XMLDeserializer(TextDeserializer): @@ -98,7 +98,7 @@ class XMLDeserializer(TextDeserializer): return {node.nodeName: self._from_xml_node(node, plurals)} except ExpatError: raise exception.MalformedRequestBody( - "malformed XML in request Body") + reason=_("malformed XML in request body")) def _from_xml_node(self, node, listnames): """Convert a minidom node to a simple Python type. diff --git a/nova/exception.py b/nova/exception.py index ffd88fbe7..f3a452228 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -588,4 +588,4 @@ class MigrationError(NovaException): class MalformedRequestBody(NovaException): - message = _("Malformed message body") + ": %(reason)s" + message = _("Malformed message body: %(reason)s") -- cgit From a3282ac30255a63f166947a052af0fcda4992621 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 14 Jun 2011 11:40:15 -0700 Subject: refactored out controller base class to use aggregation over inheritance --- nova/api/openstack/create_instance_controller.py | 344 ---------------------- nova/api/openstack/create_instance_helper.py | 346 +++++++++++++++++++++++ nova/api/openstack/servers.py | 33 ++- nova/api/openstack/zones.py | 48 ++-- nova/tests/api/openstack/test_servers.py | 14 +- 5 files changed, 404 insertions(+), 381 deletions(-) delete mode 100644 nova/api/openstack/create_instance_controller.py create mode 100644 nova/api/openstack/create_instance_helper.py diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py deleted file mode 100644 index 90f2542d9..000000000 --- a/nova/api/openstack/create_instance_controller.py +++ /dev/null @@ -1,344 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 OpenStack LLC. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import base64 -import re -import webob - -from webob import exc -from xml.dom import minidom - -from nova import exception -from nova import flags -from nova import log as logging -import nova.image -from nova import quota -from nova import utils - -from nova.compute import instance_types -from nova.api.openstack import faults -from nova.api.openstack import wsgi -from nova.auth import manager as auth_manager - - -LOG = logging.getLogger('nova.api.openstack.create_instance_controller') -FLAGS = flags.FLAGS - - -class CreateFault(exception.NovaException): - message = _("Invalid parameters given to create_instance.") - - def __init__(self, fault): - self.fault = fault - super(CreateFault, self).__init__() - - -class OpenstackCreateInstanceController(object): - """This is the base class for OS API Controllers that - are capable of creating instances (currently Servers and Zones). - - Once we stabilize the Zones portion of the API we may be able - to move this code back into servers.py - """ - - def __init__(self): - """We need the image service to create an instance.""" - self._image_service = utils.import_object(FLAGS.image_service) - super(OpenstackCreateInstanceController, self).__init__() - - # Default to the 1.0 naming scheme. - - def _image_ref_from_req_data(self, data): - return data['server']['imageId'] - - def _flavor_id_from_req_data(self, data): - return data['server']['flavorId'] - - def _get_server_admin_password(self, server): - """ Determine the admin password for a server on creation """ - return utils.generate_password(16) - - def create_instance(self, req, body, create_method): - """Creates a new server for the given user. The approach - used depends on the create_method. For example, the standard - POST /server call uses compute.api.create(), while - POST /zones/server uses compute.api.create_all_at_once(). - - The problem is, both approaches return different values (i.e. - [instance dicts] vs. reservation_id). So the handling of the - return type from this method is left to the caller. - """ - if not body: - raise faults.Fault(exc.HTTPUnprocessableEntity()) - - context = req.environ['nova.context'] - - password = self._get_server_admin_password(body['server']) - - key_name = None - key_data = None - key_pairs = auth_manager.AuthManager.get_key_pairs(context) - if key_pairs: - key_pair = key_pairs[0] - key_name = key_pair['name'] - key_data = key_pair['public_key'] - - image_href = self._image_ref_from_req_data(body) - try: - image_service, image_id = nova.image.get_image_service(image_href) - kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( - req, image_id) - images = set([str(x['id']) for x in image_service.index(context)]) - assert str(image_id) in images - except Exception, e: - msg = _("Cannot find requested image %(image_href)s: %(e)s" % - locals()) - raise faults.Fault(exc.HTTPBadRequest(msg)) - - personality = body['server'].get('personality') - - injected_files = [] - if personality: - injected_files = self._get_injected_files(personality) - - flavor_id = self._flavor_id_from_req_data(body) - - if not 'name' in body['server']: - msg = _("Server name is not defined") - raise exc.HTTPBadRequest(msg) - - zone_blob = body['server'].get('blob') - name = body['server']['name'] - self._validate_server_name(name) - name = name.strip() - - reservation_id = body['server'].get('reservation_id') - - try: - inst_type = \ - instance_types.get_instance_type_by_flavor_id(flavor_id) - extra_values = { - 'instance_type': inst_type, - 'image_ref': image_href, - 'password': password - } - - return (extra_values, - create_method(context, - inst_type, - image_id, - kernel_id=kernel_id, - ramdisk_id=ramdisk_id, - display_name=name, - display_description=name, - key_name=key_name, - key_data=key_data, - metadata=body['server'].get('metadata', {}), - injected_files=injected_files, - admin_password=password, - zone_blob=zone_blob, - reservation_id=reservation_id - ) - ) - except quota.QuotaError as error: - self._handle_quota_error(error) - except exception.ImageNotFound as error: - msg = _("Can not find requested image") - raise faults.Fault(exc.HTTPBadRequest(msg)) - - # Let the caller deal with unhandled exceptions. - - def _handle_quota_error(self, error): - """ - Reraise quota errors as api-specific http exceptions - """ - if error.code == "OnsetFileLimitExceeded": - expl = _("Personality file limit exceeded") - raise exc.HTTPBadRequest(explanation=expl) - if error.code == "OnsetFilePathLimitExceeded": - expl = _("Personality file path too long") - raise exc.HTTPBadRequest(explanation=expl) - if error.code == "OnsetFileContentLimitExceeded": - expl = _("Personality file content too long") - raise exc.HTTPBadRequest(explanation=expl) - # if the original error is okay, just reraise it - raise error - - def _deserialize_create(self, request): - """ - Deserialize a create request - - Overrides normal behavior in the case of xml content - """ - if request.content_type == "application/xml": - deserializer = ServerCreateRequestXMLDeserializer() - return deserializer.deserialize(request.body) - else: - return self._deserialize(request.body, request.get_content_type()) - - def _validate_server_name(self, value): - if not isinstance(value, basestring): - msg = _("Server name is not a string or unicode") - raise exc.HTTPBadRequest(msg) - - if value.strip() == '': - msg = _("Server name is an empty string") - raise exc.HTTPBadRequest(msg) - - def _get_kernel_ramdisk_from_image(self, req, image_id): - """Fetch an image from the ImageService, then if present, return the - associated kernel and ramdisk image IDs. - """ - context = req.environ['nova.context'] - image_meta = self._image_service.show(context, image_id) - # NOTE(sirp): extracted to a separate method to aid unit-testing, the - # new method doesn't need a request obj or an ImageService stub - kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( - image_meta) - return kernel_id, ramdisk_id - - @staticmethod - def _do_get_kernel_ramdisk_from_image(image_meta): - """Given an ImageService image_meta, return kernel and ramdisk image - ids if present. - - This is only valid for `ami` style images. - """ - image_id = image_meta['id'] - if image_meta['status'] != 'active': - raise exception.ImageUnacceptable(image_id=image_id, - reason=_("status is not active")) - - if image_meta.get('container_format') != 'ami': - return None, None - - try: - kernel_id = image_meta['properties']['kernel_id'] - except KeyError: - raise exception.KernelNotFoundForImage(image_id=image_id) - - try: - ramdisk_id = image_meta['properties']['ramdisk_id'] - except KeyError: - raise exception.RamdiskNotFoundForImage(image_id=image_id) - - return kernel_id, ramdisk_id - - def _get_injected_files(self, personality): - """ - Create a list of injected files from the personality attribute - - At this time, injected_files must be formatted as a list of - (file_path, file_content) pairs for compatibility with the - underlying compute service. - """ - injected_files = [] - - for item in personality: - try: - path = item['path'] - contents = item['contents'] - except KeyError as key: - expl = _('Bad personality format: missing %s') % key - raise exc.HTTPBadRequest(explanation=expl) - except TypeError: - expl = _('Bad personality format') - raise exc.HTTPBadRequest(explanation=expl) - try: - contents = base64.b64decode(contents) - except TypeError: - expl = _('Personality content for %s cannot be decoded') % path - raise exc.HTTPBadRequest(explanation=expl) - injected_files.append((path, contents)) - return injected_files - - -class ServerXMLDeserializer(wsgi.XMLDeserializer): - """ - Deserializer to handle xml-formatted server create requests. - - Handles standard server attributes as well as optional metadata - and personality attributes - """ - - def create(self, string): - """Deserialize an xml-formatted server create request""" - dom = minidom.parseString(string) - server = self._extract_server(dom) - return {'server': server} - - def _extract_server(self, node): - """Marshal the server attribute of a parsed request""" - server = {} - server_node = self._find_first_child_named(node, 'server') - for attr in ["name", "imageId", "flavorId", "imageRef", "flavorRef"]: - if server_node.getAttribute(attr): - server[attr] = server_node.getAttribute(attr) - metadata = self._extract_metadata(server_node) - if metadata is not None: - server["metadata"] = metadata - personality = self._extract_personality(server_node) - if personality is not None: - server["personality"] = personality - return server - - def _extract_metadata(self, server_node): - """Marshal the metadata attribute of a parsed request""" - metadata_node = self._find_first_child_named(server_node, "metadata") - if metadata_node is None: - return None - metadata = {} - for meta_node in self._find_children_named(metadata_node, "meta"): - key = meta_node.getAttribute("key") - metadata[key] = self._extract_text(meta_node) - return metadata - - def _extract_personality(self, server_node): - """Marshal the personality attribute of a parsed request""" - personality_node = \ - self._find_first_child_named(server_node, "personality") - if personality_node is None: - return None - personality = [] - for file_node in self._find_children_named(personality_node, "file"): - item = {} - if file_node.hasAttribute("path"): - item["path"] = file_node.getAttribute("path") - item["contents"] = self._extract_text(file_node) - personality.append(item) - return personality - - def _find_first_child_named(self, parent, name): - """Search a nodes children for the first child with a given name""" - for node in parent.childNodes: - if node.nodeName == name: - return node - return None - - def _find_children_named(self, parent, name): - """Return all of a nodes children who have the given name""" - for node in parent.childNodes: - if node.nodeName == name: - yield node - - def _extract_text(self, node): - """Get the text field contained by the given node""" - if len(node.childNodes) == 1: - child = node.childNodes[0] - if child.nodeType == child.TEXT_NODE: - return child.nodeValue - return "" diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py new file mode 100644 index 000000000..fbc6318ef --- /dev/null +++ b/nova/api/openstack/create_instance_helper.py @@ -0,0 +1,346 @@ +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import base64 +import re +import webob + +from webob import exc +from xml.dom import minidom + +from nova import exception +from nova import flags +from nova import log as logging +import nova.image +from nova import quota +from nova import utils + +from nova.compute import instance_types +from nova.api.openstack import faults +from nova.api.openstack import wsgi +from nova.auth import manager as auth_manager + + +LOG = logging.getLogger('nova.api.openstack.create_instance_helper') +FLAGS = flags.FLAGS + + +class CreateFault(exception.NovaException): + message = _("Invalid parameters given to create_instance.") + + def __init__(self, fault): + self.fault = fault + super(CreateFault, self).__init__() + + +class CreateInstanceHelper(object): + """This is the base class for OS API Controllers that + are capable of creating instances (currently Servers and Zones). + + Once we stabilize the Zones portion of the API we may be able + to move this code back into servers.py + """ + + def __init__(self, controller): + """We need the image service to create an instance.""" + self.controller = controller + self._image_service = utils.import_object(FLAGS.image_service) + super(CreateInstanceHelper, self).__init__() + + def create_instance(self, req, body, create_method): + """Creates a new server for the given user. The approach + used depends on the create_method. For example, the standard + POST /server call uses compute.api.create(), while + POST /zones/server uses compute.api.create_all_at_once(). + + The problem is, both approaches return different values (i.e. + [instance dicts] vs. reservation_id). So the handling of the + return type from this method is left to the caller. + """ + if not body: + raise faults.Fault(exc.HTTPUnprocessableEntity()) + + context = req.environ['nova.context'] + + password = self.controller._get_server_admin_password(body['server']) + + key_name = None + key_data = None + key_pairs = auth_manager.AuthManager.get_key_pairs(context) + if key_pairs: + key_pair = key_pairs[0] + key_name = key_pair['name'] + key_data = key_pair['public_key'] + + image_href = self.controller._image_ref_from_req_data(body) + try: + image_service, image_id = nova.image.get_image_service(image_href) + kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( + req, image_id) + images = set([str(x['id']) for x in image_service.index(context)]) + assert str(image_id) in images + except Exception, e: + msg = _("Cannot find requested image %(image_href)s: %(e)s" % + locals()) + raise faults.Fault(exc.HTTPBadRequest(msg)) + + personality = body['server'].get('personality') + + injected_files = [] + if personality: + injected_files = self._get_injected_files(personality) + + flavor_id = self.controller._flavor_id_from_req_data(body) + + if not 'name' in body['server']: + msg = _("Server name is not defined") + raise exc.HTTPBadRequest(msg) + + zone_blob = body['server'].get('blob') + name = body['server']['name'] + self._validate_server_name(name) + name = name.strip() + + reservation_id = body['server'].get('reservation_id') + + try: + inst_type = \ + instance_types.get_instance_type_by_flavor_id(flavor_id) + extra_values = { + 'instance_type': inst_type, + 'image_ref': image_href, + 'password': password + } + + return (extra_values, + create_method(context, + inst_type, + image_id, + kernel_id=kernel_id, + ramdisk_id=ramdisk_id, + display_name=name, + display_description=name, + key_name=key_name, + key_data=key_data, + metadata=body['server'].get('metadata', {}), + injected_files=injected_files, + admin_password=password, + zone_blob=zone_blob, + reservation_id=reservation_id + ) + ) + except quota.QuotaError as error: + self._handle_quota_error(error) + except exception.ImageNotFound as error: + msg = _("Can not find requested image") + raise faults.Fault(exc.HTTPBadRequest(msg)) + + # Let the caller deal with unhandled exceptions. + + def _handle_quota_error(self, error): + """ + Reraise quota errors as api-specific http exceptions + """ + if error.code == "OnsetFileLimitExceeded": + expl = _("Personality file limit exceeded") + raise exc.HTTPBadRequest(explanation=expl) + if error.code == "OnsetFilePathLimitExceeded": + expl = _("Personality file path too long") + raise exc.HTTPBadRequest(explanation=expl) + if error.code == "OnsetFileContentLimitExceeded": + expl = _("Personality file content too long") + raise exc.HTTPBadRequest(explanation=expl) + # if the original error is okay, just reraise it + raise error + + def _deserialize_create(self, request): + """ + Deserialize a create request + + Overrides normal behavior in the case of xml content + """ + if request.content_type == "application/xml": + deserializer = ServerCreateRequestXMLDeserializer() + return deserializer.deserialize(request.body) + else: + return self._deserialize(request.body, request.get_content_type()) + + def _validate_server_name(self, value): + if not isinstance(value, basestring): + msg = _("Server name is not a string or unicode") + raise exc.HTTPBadRequest(msg) + + if value.strip() == '': + msg = _("Server name is an empty string") + raise exc.HTTPBadRequest(msg) + + def _get_kernel_ramdisk_from_image(self, req, image_id): + """Fetch an image from the ImageService, then if present, return the + associated kernel and ramdisk image IDs. + """ + context = req.environ['nova.context'] + image_meta = self._image_service.show(context, image_id) + # NOTE(sirp): extracted to a separate method to aid unit-testing, the + # new method doesn't need a request obj or an ImageService stub + kernel_id, ramdisk_id = self._do_get_kernel_ramdisk_from_image( + image_meta) + return kernel_id, ramdisk_id + + @staticmethod + def _do_get_kernel_ramdisk_from_image(image_meta): + """Given an ImageService image_meta, return kernel and ramdisk image + ids if present. + + This is only valid for `ami` style images. + """ + image_id = image_meta['id'] + if image_meta['status'] != 'active': + raise exception.ImageUnacceptable(image_id=image_id, + reason=_("status is not active")) + + if image_meta.get('container_format') != 'ami': + return None, None + + try: + kernel_id = image_meta['properties']['kernel_id'] + except KeyError: + raise exception.KernelNotFoundForImage(image_id=image_id) + + try: + ramdisk_id = image_meta['properties']['ramdisk_id'] + except KeyError: + raise exception.RamdiskNotFoundForImage(image_id=image_id) + + return kernel_id, ramdisk_id + + def _get_injected_files(self, personality): + """ + Create a list of injected files from the personality attribute + + At this time, injected_files must be formatted as a list of + (file_path, file_content) pairs for compatibility with the + underlying compute service. + """ + injected_files = [] + + for item in personality: + try: + path = item['path'] + contents = item['contents'] + except KeyError as key: + expl = _('Bad personality format: missing %s') % key + raise exc.HTTPBadRequest(explanation=expl) + except TypeError: + expl = _('Bad personality format') + raise exc.HTTPBadRequest(explanation=expl) + try: + contents = base64.b64decode(contents) + except TypeError: + expl = _('Personality content for %s cannot be decoded') % path + raise exc.HTTPBadRequest(explanation=expl) + injected_files.append((path, contents)) + return injected_files + + def _get_server_admin_password_old_style(self, server): + """ Determine the admin password for a server on creation """ + return utils.generate_password(16) + + def _get_server_admin_password_new_style(self, server): + """ Determine the admin password for a server on creation """ + password = server.get('adminPass') + + if password is None: + return utils.generate_password(16) + if not isinstance(password, basestring) or password == '': + msg = _("Invalid adminPass") + raise exc.HTTPBadRequest(msg) + return password + + +class ServerXMLDeserializer(wsgi.XMLDeserializer): + """ + Deserializer to handle xml-formatted server create requests. + + Handles standard server attributes as well as optional metadata + and personality attributes + """ + + def create(self, string): + """Deserialize an xml-formatted server create request""" + dom = minidom.parseString(string) + server = self._extract_server(dom) + return {'server': server} + + def _extract_server(self, node): + """Marshal the server attribute of a parsed request""" + server = {} + server_node = self._find_first_child_named(node, 'server') + for attr in ["name", "imageId", "flavorId", "imageRef", "flavorRef"]: + if server_node.getAttribute(attr): + server[attr] = server_node.getAttribute(attr) + metadata = self._extract_metadata(server_node) + if metadata is not None: + server["metadata"] = metadata + personality = self._extract_personality(server_node) + if personality is not None: + server["personality"] = personality + return server + + def _extract_metadata(self, server_node): + """Marshal the metadata attribute of a parsed request""" + metadata_node = self._find_first_child_named(server_node, "metadata") + if metadata_node is None: + return None + metadata = {} + for meta_node in self._find_children_named(metadata_node, "meta"): + key = meta_node.getAttribute("key") + metadata[key] = self._extract_text(meta_node) + return metadata + + def _extract_personality(self, server_node): + """Marshal the personality attribute of a parsed request""" + personality_node = \ + self._find_first_child_named(server_node, "personality") + if personality_node is None: + return None + personality = [] + for file_node in self._find_children_named(personality_node, "file"): + item = {} + if file_node.hasAttribute("path"): + item["path"] = file_node.getAttribute("path") + item["contents"] = self._extract_text(file_node) + personality.append(item) + return personality + + def _find_first_child_named(self, parent, name): + """Search a nodes children for the first child with a given name""" + for node in parent.childNodes: + if node.nodeName == name: + return node + return None + + def _find_children_named(self, parent, name): + """Return all of a nodes children who have the given name""" + for node in parent.childNodes: + if node.nodeName == name: + yield node + + def _extract_text(self, node): + """Get the text field contained by the given node""" + if len(node.childNodes) == 1: + child = node.childNodes[0] + if child.nodeType == child.TEXT_NODE: + return child.nodeValue + return "" diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 1b18c4ecb..5c967c40f 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -24,7 +24,7 @@ from nova import flags from nova import log as logging from nova import utils from nova.api.openstack import common -from nova.api.openstack import create_instance_controller as base_controller +from nova.api.openstack import create_instance_helper as helper from nova.api.openstack import faults import nova.api.openstack.views.addresses import nova.api.openstack.views.flavors @@ -39,11 +39,12 @@ LOG = logging.getLogger('nova.api.openstack.servers') FLAGS = flags.FLAGS -class Controller(base_controller.OpenstackCreateInstanceController): +class Controller(object): """ The Server API controller for the OpenStack API """ def __init__(self): self.compute_api = compute.API() + self.helper = helper.CreateInstanceHelper(self) super(Controller, self).__init__() def index(self, req): @@ -111,8 +112,8 @@ class Controller(base_controller.OpenstackCreateInstanceController): extra_values = None result = None try: - extra_values, result = \ - self.create_instance(req, body, self.compute_api.create) + extra_values, result = self.helper.create_instance( + req, body, self.compute_api.create) except faults.Fault, f: return f @@ -141,7 +142,7 @@ class Controller(base_controller.OpenstackCreateInstanceController): if 'name' in body['server']: name = body['server']['name'] - self._validate_server_name(name) + self.helper._validate_server_name(name) update_dict['display_name'] = name.strip() self._parse_update(ctxt, id, body, update_dict) @@ -403,6 +404,13 @@ class Controller(base_controller.OpenstackCreateInstanceController): class ControllerV10(Controller): + + def _image_ref_from_req_data(self, data): + return data['server']['imageId'] + + def _flavor_id_from_req_data(self, data): + return data['server']['flavorId'] + def _get_view_builder(self, req): addresses_builder = nova.api.openstack.views.addresses.ViewBuilderV10() return nova.api.openstack.views.servers.ViewBuilderV10( @@ -453,6 +461,10 @@ class ControllerV10(Controller): response.empty_body = True return response + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + return self.helper._get_server_admin_password_old_style(server) + class ControllerV11(Controller): def _image_ref_from_req_data(self, data): @@ -567,14 +579,7 @@ class ControllerV11(Controller): def _get_server_admin_password(self, server): """ Determine the admin password for a server on creation """ - password = server.get('adminPass') - - if password is None: - return utils.generate_password(16) - if not isinstance(password, basestring) or password == '': - msg = _("Invalid adminPass") - raise exc.HTTPBadRequest(msg) - return password + return self.helper._get_server_admin_password_new_style(server) def create_resource(version='1.0'): @@ -610,7 +615,7 @@ def create_resource(version='1.0'): } deserializers = { - 'application/xml': base_controller.ServerXMLDeserializer(), + 'application/xml': helper.ServerXMLDeserializer(), } return wsgi.Resource(controller, serializers=serializers, diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index 7ccb8555b..c34360e01 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -25,8 +25,9 @@ from nova import log as logging from nova.compute import api as compute from nova.scheduler import api -from nova.api.openstack import create_instance_controller as controller +from nova.api.openstack import create_instance_helper as helper from nova.api.openstack import common +from nova.api.openstack import faults from nova.api.openstack import wsgi @@ -62,16 +63,12 @@ def check_encryption_key(func): return wrapped -class Controller(controller.OpenstackCreateInstanceController): - """Controller for Zone resources. Since we can also create instances - via /zone/boot, this controller is derived from - OpenstackCreateInstanceController, which contains all the logic for - doing that (shared with Servers). - """ +class Controller(object): + """Controller for Zone resources.""" - def __init__(self, version): + def __init__(self): self.compute_api = compute.API() - self.version = version + self.helper = helper.CreateInstanceHelper(self) super(Controller, self).__init__() def index(self, req): @@ -132,7 +129,7 @@ class Controller(controller.OpenstackCreateInstanceController): """ result = None try: - extra_values, result = self.create_instance(req, body, + extra_values, result = self.helper.create_instance(req, body, self.compute_api.create_all_at_once) except faults.Fault, f: return f @@ -164,17 +161,36 @@ class Controller(controller.OpenstackCreateInstanceController): return cooked def _image_ref_from_req_data(self, data): - if self.version == '1.0': - return data['server']['imageId'] + return data['server']['imageId'] + + def _flavor_id_from_req_data(self, data): + return data['server']['flavorId'] + + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + return self.helper._get_server_admin_password_old_style(server) + + +class ControllerV11(object): + """Controller for 1.1 Zone resources.""" + + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + return self.helper._get_server_admin_password_new_style(server) + + def _image_ref_from_req_data(self, data): return data['server']['imageRef'] def _flavor_id_from_req_data(self, data): - if self.version == '1.0': - return data['server']['flavorId'] return data['server']['flavorRef'] def create_resource(version): + controller = { + '1.0': Controller, + '1.1': ControllerV11, + }[version]() + metadata = { "attributes": { "zone": ["id", "api_url", "name", "capabilities"], @@ -187,8 +203,8 @@ def create_resource(version): } deserializers = { - 'application/xml': controller.ServerXMLDeserializer(), + 'application/xml': helper.ServerXMLDeserializer(), } - return wsgi.Resource(Controller(version), serializers=serializers, + return wsgi.Resource(controller, serializers=serializers, deserializers=deserializers) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 529ca83c5..8357df594 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -31,7 +31,7 @@ from nova import test from nova import utils import nova.api.openstack from nova.api.openstack import servers -from nova.api.openstack import create_instance_controller +from nova.api.openstack import create_instance_helper import nova.compute.api from nova.compute import instance_types from nova.compute import power_state @@ -570,8 +570,7 @@ class ServersTest(test.TestCase): self.stubs.Set(nova.network.manager.VlanManager, 'allocate_fixed_ip', fake_method) self.stubs.Set( - nova.api.openstack.create_instance_controller.\ - OpenstackCreateInstanceController, + nova.api.openstack.create_instance_helper.CreateInstanceHelper, "_get_kernel_ramdisk_from_image", kernel_ramdisk_mapping) self.stubs.Set(nova.compute.api.API, "_find_host", find_host) @@ -1531,7 +1530,7 @@ class ServersTest(test.TestCase): class TestServerCreateRequestXMLDeserializer(unittest.TestCase): def setUp(self): - self.deserializer = create_instance_controller.ServerXMLDeserializer() + self.deserializer = create_instance_helper.ServerXMLDeserializer() def test_minimal_request(self): serial_request = """ @@ -1863,7 +1862,8 @@ class TestServerInstanceCreation(test.TestCase): compute_api = MockComputeAPI() self.stubs.Set(nova.compute, 'API', make_stub_method(compute_api)) - self.stubs.Set(nova.api.openstack.servers.Controller, + self.stubs.Set( + nova.api.openstack.create_instance_helper.CreateInstanceHelper, '_get_kernel_ramdisk_from_image', make_stub_method((1, 1))) return compute_api @@ -2119,6 +2119,6 @@ class TestGetKernelRamdiskFromImage(test.TestCase): @staticmethod def _get_k_r(image_meta): """Rebinding function to a shorter name for convenience""" - kernel_id, ramdisk_id = \ - servers.Controller._do_get_kernel_ramdisk_from_image(image_meta) + kernel_id, ramdisk_id = create_instance_helper.CreateInstanceHelper. \ + _do_get_kernel_ramdisk_from_image(image_meta) return kernel_id, ramdisk_id -- cgit From b331ae15cfaa0bfbe06bb4b1947f12e56033c333 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 14 Jun 2011 11:55:43 -0700 Subject: version passing cleanup --- nova/api/openstack/__init__.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index e0ae55105..a22889e83 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -81,7 +81,9 @@ class APIRouter(base_wsgi.Router): self._setup_routes(mapper) super(APIRouter, self).__init__(mapper) - def _setup_routes(self, mapper, version='1.0'): + def _setup_routes(self, mapper, version): + """Routes common to all versions.""" + server_members = self.server_members server_members['action'] = 'POST' if FLAGS.allow_admin_api: @@ -98,14 +100,6 @@ class APIRouter(base_wsgi.Router): server_members['reset_network'] = 'POST' server_members['inject_network_info'] = 'POST' - mapper.resource("zone", "zones", - controller=zones.create_resource(version), - collection={'detail': 'GET', - 'info': 'GET', - 'select': 'POST', - 'boot': 'POST' - }) - mapper.resource("user", "users", controller=users.create_resource(), collection={'detail': 'GET'}) @@ -114,11 +108,19 @@ class APIRouter(base_wsgi.Router): controller=accounts.create_resource(), collection={'detail': 'GET'}) - mapper.resource("console", "consoles", + mapper.resource("console", "consoles", controller=consoles.create_resource(), parent_resource=dict(member_name='server', collection_name='servers')) + mapper.resource("zone", "zones", + controller=zones.create_resource(version), + collection={'detail': 'GET', + 'info': 'GET', + 'select': 'POST', + 'boot': 'POST' + }) + super(APIRouter, self).__init__(mapper) @@ -126,7 +128,7 @@ class APIRouterV10(APIRouter): """Define routes specific to OpenStack API V1.0.""" def _setup_routes(self, mapper): - super(APIRouterV10, self)._setup_routes(mapper, version='1.0') + super(APIRouterV10, self)._setup_routes(mapper, '1.0') mapper.resource("server", "servers", controller=servers.create_resource('1.0'), collection={'detail': 'GET'}, @@ -162,7 +164,7 @@ class APIRouterV11(APIRouter): """Define routes specific to OpenStack API V1.1.""" def _setup_routes(self, mapper): - super(APIRouterV11, self)._setup_routes(mapper, version='1.1') + super(APIRouterV11, self)._setup_routes(mapper, '1.1') mapper.resource("server", "servers", controller=servers.create_resource('1.1'), collection={'detail': 'GET'}, -- cgit From 60a89dda55258bd7212e09e2113dca92ebd67a08 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 14 Jun 2011 12:34:10 -0700 Subject: duplicate routes moved to base class --- nova/api/openstack/__init__.py | 54 ++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index a22889e83..ddd9580d7 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -108,11 +108,6 @@ class APIRouter(base_wsgi.Router): controller=accounts.create_resource(), collection={'detail': 'GET'}) - mapper.resource("console", "consoles", - controller=consoles.create_resource(), - parent_resource=dict(member_name='server', - collection_name='servers')) - mapper.resource("zone", "zones", controller=zones.create_resource(version), collection={'detail': 'GET', @@ -121,6 +116,27 @@ class APIRouter(base_wsgi.Router): 'boot': 'POST' }) + mapper.resource("console", "consoles", + controller=consoles.create_resource(), + parent_resource=dict(member_name='server', + collection_name='servers')) + + mapper.resource("server", "servers", + controller=servers.create_resource(version), + collection={'detail': 'GET'}, + member=self.server_members) + + mapper.resource("image", "images", + controller=images.create_resource(version), + collection={'detail': 'GET'}) + + mapper.resource("limit", "limits", + controller=limits.create_resource(version)) + + mapper.resource("flavor", "flavors", + controller=flavors.create_resource(version), + collection={'detail': 'GET'}) + super(APIRouter, self).__init__(mapper) @@ -129,19 +145,10 @@ class APIRouterV10(APIRouter): def _setup_routes(self, mapper): super(APIRouterV10, self)._setup_routes(mapper, '1.0') - mapper.resource("server", "servers", - controller=servers.create_resource('1.0'), - collection={'detail': 'GET'}, - member=self.server_members) - mapper.resource("image", "images", controller=images.create_resource('1.0'), collection={'detail': 'GET'}) - mapper.resource("flavor", "flavors", - controller=flavors.create_resource('1.0'), - collection={'detail': 'GET'}) - mapper.resource("shared_ip_group", "shared_ip_groups", collection={'detail': 'GET'}, controller=shared_ip_groups.create_resource()) @@ -151,9 +158,6 @@ class APIRouterV10(APIRouter): parent_resource=dict(member_name='server', collection_name='servers')) - mapper.resource("limit", "limits", - controller=limits.create_resource('1.0')) - mapper.resource("ip", "ips", controller=ips.create_resource(), collection=dict(public='GET', private='GET'), parent_resource=dict(member_name='server', @@ -165,15 +169,6 @@ class APIRouterV11(APIRouter): def _setup_routes(self, mapper): super(APIRouterV11, self)._setup_routes(mapper, '1.1') - mapper.resource("server", "servers", - controller=servers.create_resource('1.1'), - collection={'detail': 'GET'}, - member=self.server_members) - - mapper.resource("image", "images", - controller=images.create_resource('1.1'), - collection={'detail': 'GET'}) - mapper.resource("image_meta", "meta", controller=image_metadata.create_resource(), parent_resource=dict(member_name='image', @@ -183,10 +178,3 @@ class APIRouterV11(APIRouter): controller=server_metadata.create_resource(), parent_resource=dict(member_name='server', collection_name='servers')) - - mapper.resource("flavor", "flavors", - controller=flavors.create_resource('1.1'), - collection={'detail': 'GET'}) - - mapper.resource("limit", "limits", - controller=limits.create_resource('1.1')) -- cgit From 6d960ff50d4cf8e6b2dc59aff0e8dea17498a9f0 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 14 Jun 2011 15:51:22 -0400 Subject: fixed HACKING --- nova/api/openstack/wsgi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 43b51b64a..27d19db53 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -2,10 +2,10 @@ import json import webob from xml.dom import minidom -from xml.parsers.expat import ExpatError +from xml.parsers import expat -from nova import exception import faults +from nova import exception from nova import log as logging from nova import utils from nova import wsgi @@ -96,7 +96,7 @@ class XMLDeserializer(TextDeserializer): try: node = minidom.parseString(datastring).childNodes[0] return {node.nodeName: self._from_xml_node(node, plurals)} - except ExpatError: + except expat.ExpatError: raise exception.MalformedRequestBody( reason=_("malformed XML in request body")) -- cgit From 0ce3e2af1b2d48d53c7ae6f59caca745946c6198 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 14 Jun 2011 12:59:16 -0700 Subject: removed extra init calls --- nova/api/openstack/servers.py | 1 - nova/api/openstack/zones.py | 1 - 2 files changed, 2 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 5c967c40f..798fdd7f7 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -45,7 +45,6 @@ class Controller(object): def __init__(self): self.compute_api = compute.API() self.helper = helper.CreateInstanceHelper(self) - super(Controller, self).__init__() def index(self, req): """ Returns a list of server names and ids for a given user """ diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index c34360e01..8864f825b 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -69,7 +69,6 @@ class Controller(object): def __init__(self): self.compute_api = compute.API() self.helper = helper.CreateInstanceHelper(self) - super(Controller, self).__init__() def index(self, req): """Return all zones in brief""" -- cgit From 3368a35ff9c06d74ec4b8fdb58d37771fc1a4f0d Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 15 Jun 2011 00:08:19 +0000 Subject: Removing seconds unit --- run_tests.py | 20 ++++++-------------- run_tests.sh | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/run_tests.py b/run_tests.py index 3ecc146fd..c29a3da43 100644 --- a/run_tests.py +++ b/run_tests.py @@ -185,20 +185,13 @@ class _NullColorizer(object): self.stream.write(text) -def classify_test_speed(elapsed_time): +def get_elapsed_time_color(elapsed_time): if elapsed_time > 1.0: - return 'slow' + return 'red' elif elapsed_time > 0.25: - return 'sluggish' + return 'yellow' else: - return 'fast' - - -def get_elapsed_time_color(elapsed_time): - color_map = {'slow': 'red', 'sluggish': 'yellow', 'fast': 'green'} - slowness = classify_test_speed(elapsed_time) - color = color_map[slowness] - return color + return 'green' class NovaTestResult(result.TextTestResult): @@ -233,7 +226,6 @@ class NovaTestResult(result.TextTestResult): def _writeElapsedTime(self, test): color = get_elapsed_time_color(self.elapsed_time) self.colorizer.write(" %.2f" % self.elapsed_time, color) - self.stream.write(' secs') def _writeResult(self, test, long_result, color, short_result): if self.showAll: @@ -322,13 +314,13 @@ class NovaTestRunner(core.TextTestRunner): def _writeSlowTests(self, result_): # Pare out 'fast' tests slow_tests = [item for item in result_.slow_tests - if classify_test_speed(item[0]) != 'fast'] + if get_elapsed_time_color(item[0]) != 'green'] slow_total_time = sum(item[0] for item in slow_tests) self.stream.writeln("Slowest %i tests took %.2f secs:" % (len(slow_tests), slow_total_time)) for elapsed_time, test in sorted(slow_tests, reverse=True): - time_str = "%.2f secs" % elapsed_time + time_str = "%.2f" % elapsed_time self.stream.writeln(" %s %s" % (time_str.ljust(10), test)) def run(self, test): diff --git a/run_tests.sh b/run_tests.sh index 5fc406035..90af35579 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -10,7 +10,7 @@ function usage { echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." echo " -p, --pep8 Just run pep8" echo " -h, --help Print this usage message" - echo " --show-elapsed Print elapsed time for tests along with slowest tests" + echo " --show-elapsed Print elapsed time in seconds for tests along with slowest tests" echo "" echo "Note: with no options specified, the script will try to run the tests in a virtual environment," echo " If no virtualenv is found, the script will ask if you would like to create one. If you " -- cgit From e20444542af9136c330d1cf469eb0e065860ded1 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 15 Jun 2011 01:16:53 +0000 Subject: Ensuring pep8 runs even when nose optons are passed --- run_tests.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 90af35579..b90e1e837 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -25,6 +25,7 @@ function process_option { -N|--no-virtual-env) let always_venv=0; let never_venv=1;; -f|--force) let force=1;; -p|--pep8) let just_pep8=1;; + -*) noseopts="$noseopts $1";; *) noseargs="$noseargs $1" esac } @@ -35,6 +36,7 @@ always_venv=0 never_venv=0 force=0 noseargs= +noseopts= wrapper="" just_pep8=0 @@ -73,7 +75,7 @@ function run_pep8 { --exclude=vcsversion.py ${srcfiles} } -NOSETESTS="python run_tests.py $noseargs" +NOSETESTS="python run_tests.py $noseopts $noseargs" if [ $never_venv -eq 0 ] then @@ -108,7 +110,10 @@ fi run_tests || exit -# Also run pep8 if no options were provided. +# NOTE(sirp): we only want to run pep8 when we're running the full-test suite, +# not when we're running tests individually. To handle this, we need to +# distinguish between options (noseopts), which begin with a '-', and +# arguments (noseargs). if [ -z "$noseargs" ]; then run_pep8 fi -- cgit From 43dd1ec6089497b6e977c49f9006d03c3e7a4117 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 15 Jun 2011 01:21:11 +0000 Subject: Showing elapsed time is now default --- run_tests.py | 6 +++--- run_tests.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/run_tests.py b/run_tests.py index c29a3da43..601c41e40 100644 --- a/run_tests.py +++ b/run_tests.py @@ -334,13 +334,13 @@ if __name__ == '__main__': logging.setup() # If any argument looks like a test name but doesn't have "nova.tests" in # front of it, automatically add that so we don't have to type as much - show_elapsed = False + show_elapsed = True argv = [] for x in sys.argv: if x.startswith('test_'): argv.append('nova.tests.%s' % x) - elif x.startswith('--show-elapsed'): - show_elapsed = True + elif x.startswith('--hide-elapsed'): + show_elapsed = False else: argv.append(x) diff --git a/run_tests.sh b/run_tests.sh index b90e1e837..c3f06f837 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -10,7 +10,7 @@ function usage { echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." echo " -p, --pep8 Just run pep8" echo " -h, --help Print this usage message" - echo " --show-elapsed Print elapsed time in seconds for tests along with slowest tests" + echo " --hide-elapsed Don't print the elapsed time for each test along with slow test list" echo "" echo "Note: with no options specified, the script will try to run the tests in a virtual environment," echo " If no virtualenv is found, the script will ask if you would like to create one. If you " -- cgit From 4d5a73bf7cc61d94ac1f29a7566def853d0efb1b Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 15 Jun 2011 04:05:37 +0000 Subject: Show only if we have slow tests, elapsed only if test success --- run_tests.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/run_tests.py b/run_tests.py index 601c41e40..0944bb585 100644 --- a/run_tests.py +++ b/run_tests.py @@ -227,10 +227,10 @@ class NovaTestResult(result.TextTestResult): color = get_elapsed_time_color(self.elapsed_time) self.colorizer.write(" %.2f" % self.elapsed_time, color) - def _writeResult(self, test, long_result, color, short_result): + def _writeResult(self, test, long_result, color, short_result, success): if self.showAll: self.colorizer.write(long_result, color) - if self.show_elapsed: + if self.show_elapsed and success: self._writeElapsedTime(test) self.stream.writeln() elif self.dots: @@ -241,13 +241,13 @@ class NovaTestResult(result.TextTestResult): def addSuccess(self, test): unittest.TestResult.addSuccess(self, test) self._handleElapsedTime(test) - self._writeResult(test, 'OK', 'green', '.') + self._writeResult(test, 'OK', 'green', '.', True) # NOTE(vish): copied from unittest with edit to add color def addFailure(self, test, err): unittest.TestResult.addFailure(self, test, err) self._handleElapsedTime(test) - self._writeResult(test, 'FAIL', 'red', 'F') + self._writeResult(test, 'FAIL', 'red', 'F', False) # NOTE(vish): copied from nose with edit to add color def addError(self, test, err): @@ -282,7 +282,7 @@ class NovaTestResult(result.TextTestResult): self.errors.append((test, exc_info)) test.passed = False if stream is not None: - self._writeResult(test, 'ERROR', 'red', 'E') + self._writeResult(test, 'ERROR', 'red', 'E', False) def startTest(self, test): unittest.TestResult.startTest(self, test) @@ -315,13 +315,13 @@ class NovaTestRunner(core.TextTestRunner): # Pare out 'fast' tests slow_tests = [item for item in result_.slow_tests if get_elapsed_time_color(item[0]) != 'green'] - - slow_total_time = sum(item[0] for item in slow_tests) - self.stream.writeln("Slowest %i tests took %.2f secs:" - % (len(slow_tests), slow_total_time)) - for elapsed_time, test in sorted(slow_tests, reverse=True): - time_str = "%.2f" % elapsed_time - self.stream.writeln(" %s %s" % (time_str.ljust(10), test)) + if slow_tests: + slow_total_time = sum(item[0] for item in slow_tests) + self.stream.writeln("Slowest %i tests took %.2f secs:" + % (len(slow_tests), slow_total_time)) + for elapsed_time, test in sorted(slow_tests, reverse=True): + time_str = "%.2f" % elapsed_time + self.stream.writeln(" %s %s" % (time_str.ljust(10), test)) def run(self, test): result_ = core.TextTestRunner.run(self, test) -- cgit From 6e2f79f5452b0a470d5001e9a0428fe90f987ac8 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 15 Jun 2011 06:40:42 -0700 Subject: None project_id now default --- nova/scheduler/api.py | 5 +++-- nova/scheduler/zone_aware_scheduler.py | 3 ++- nova/scheduler/zone_manager.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index ffe59d2c1..3b3195c2e 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -106,7 +106,8 @@ def _wrap_method(function, self): def _process(func, zone): """Worker stub for green thread pool. Give the worker an authenticated nova client and zone info.""" - nova = novaclient.OpenStack(zone.username, zone.password, zone.api_url) + nova = novaclient.OpenStack(zone.username, zone.password, None, + zone.api_url) nova.authenticate() return func(nova, zone) @@ -122,7 +123,7 @@ def call_zone_method(context, method_name, errors_to_ignore=None, results = [] for zone in db.zone_get_all(context): try: - nova = novaclient.OpenStack(zone.username, zone.password, + nova = novaclient.OpenStack(zone.username, zone.password, None, zone.api_url) nova.authenticate() except novaclient.exceptions.BadRequest, e: diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index f04defa64..69d4c6034 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -105,7 +105,8 @@ class ZoneAwareScheduler(driver.Scheduler): % locals()) nova = None try: - nova = novaclient.OpenStack(zone.username, zone.password, url) + nova = novaclient.OpenStack(zone.username, zone.password, None, + url) nova.authenticate() except novaclient.exceptions.BadRequest, e: raise exception.NotAuthorized(_("Bad credentials attempting " diff --git a/nova/scheduler/zone_manager.py b/nova/scheduler/zone_manager.py index 3f483adff..ba7403c15 100644 --- a/nova/scheduler/zone_manager.py +++ b/nova/scheduler/zone_manager.py @@ -89,7 +89,8 @@ class ZoneState(object): def _call_novaclient(zone): """Call novaclient. Broken out for testing purposes.""" - client = novaclient.OpenStack(zone.username, zone.password, zone.api_url) + client = novaclient.OpenStack(zone.username, zone.password, None, + zone.api_url) return client.zones.info()._info -- cgit From 4c54aa28a8c414752d73084e3a4094e5df79b618 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 15 Jun 2011 09:45:22 -0700 Subject: fixed up some little project_id things with new novaclient --- nova/scheduler/zone_aware_scheduler.py | 4 ++-- tools/pip-requires | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 69d4c6034..0ec83ec2e 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -88,7 +88,7 @@ class ZoneAwareScheduler(driver.Scheduler): instance_properties = request_spec['instance_properties'] name = instance_properties['display_name'] - image_id = instance_properties['image_id'] + image_ref = instance_properties['image_ref'] meta = instance_properties['metadata'] flavor_id = instance_type['flavorid'] reservation_id = instance_properties['reservation_id'] @@ -112,7 +112,7 @@ class ZoneAwareScheduler(driver.Scheduler): raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) - nova.servers.create(name, image_id, flavor_id, ipgroup, meta, files, + nova.servers.create(name, image_ref, flavor_id, ipgroup, meta, files, child_blob, reservation_id=reservation_id) def _provision_resource_from_blob(self, context, item, instance_id, diff --git a/tools/pip-requires b/tools/pip-requires index 168dacd40..57557bc9d 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -10,7 +10,7 @@ boto==1.9b carrot==0.10.5 eventlet==0.9.12 lockfile==0.8 -python-novaclient==2.5 +python-novaclient==2.5.2 python-daemon==1.5.5 python-gflags==1.3 redis==2.0.0 -- cgit From 79ff4ca91c9b47d1324af3a453406de44c5ce62b Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 15 Jun 2011 09:52:02 -0700 Subject: pip novaclient bump --- tools/pip-requires | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pip-requires b/tools/pip-requires index 57557bc9d..7849dbea9 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -10,7 +10,7 @@ boto==1.9b carrot==0.10.5 eventlet==0.9.12 lockfile==0.8 -python-novaclient==2.5.2 +python-novaclient==2.5.3 python-daemon==1.5.5 python-gflags==1.3 redis==2.0.0 -- cgit From 4b56c18bb4436c6ea76f44d2b266973f5d42817f Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 15 Jun 2011 10:21:41 -0700 Subject: don't provision to all child zones --- nova/scheduler/zone_aware_scheduler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 0ec83ec2e..e7bff2faa 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -185,7 +185,11 @@ class ZoneAwareScheduler(driver.Scheduler): if not build_plan: raise driver.NoValidHost(_('No hosts were available')) - for item in build_plan: + for num in xrange(request_spec['num_instances']): + if not build_plan: + break + + item = build_plan.pop(0) self._provision_resource(context, item, instance_id, request_spec, kwargs) -- cgit From e6eae8d21a7c261dae498f52430dbee60b28840e Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Wed, 15 Jun 2011 17:35:31 -0400 Subject: Added metadata joinedloads --- nova/db/sqlalchemy/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 73870d2f3..7119f43eb 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -907,6 +907,7 @@ def instance_get_all_by_host(context, host): options(joinedload_all('fixed_ip.floating_ips')).\ options(joinedload('security_groups')).\ options(joinedload_all('fixed_ip.network')).\ + options(joinedload('metadata')).\ options(joinedload('instance_type')).\ filter_by(host=host).\ filter_by(deleted=can_read_deleted(context)).\ @@ -922,6 +923,7 @@ def instance_get_all_by_project(context, project_id): options(joinedload_all('fixed_ip.floating_ips')).\ options(joinedload('security_groups')).\ options(joinedload_all('fixed_ip.network')).\ + options(joinedload('metadata')).\ options(joinedload('instance_type')).\ filter_by(project_id=project_id).\ filter_by(deleted=can_read_deleted(context)).\ @@ -937,6 +939,7 @@ def instance_get_all_by_reservation(context, reservation_id): options(joinedload_all('fixed_ip.floating_ips')).\ options(joinedload('security_groups')).\ options(joinedload_all('fixed_ip.network')).\ + options(joinedload('metadata')).\ options(joinedload('instance_type')).\ filter_by(reservation_id=reservation_id).\ filter_by(deleted=can_read_deleted(context)).\ @@ -946,6 +949,7 @@ def instance_get_all_by_reservation(context, reservation_id): options(joinedload_all('fixed_ip.floating_ips')).\ options(joinedload('security_groups')).\ options(joinedload_all('fixed_ip.network')).\ + options(joinedload('metadata')).\ options(joinedload('instance_type')).\ filter_by(project_id=context.project_id).\ filter_by(reservation_id=reservation_id).\ @@ -959,6 +963,8 @@ def instance_get_project_vpn(context, project_id): return session.query(models.Instance).\ options(joinedload_all('fixed_ip.floating_ips')).\ options(joinedload('security_groups')).\ + options(joinedload_all('fixed_ip.network')).\ + options(joinedload('metadata')).\ options(joinedload('instance_type')).\ filter_by(project_id=project_id).\ filter_by(image_ref=str(FLAGS.vpn_image_id)).\ -- cgit -- cgit