diff options
| author | Brian Waldon <brian.waldon@rackspace.com> | 2011-09-08 15:40:07 -0400 |
|---|---|---|
| committer | Brian Waldon <brian.waldon@rackspace.com> | 2011-09-08 15:40:07 -0400 |
| commit | b24189ad5df28ae9acfa8fc5feaa8971e676343e (patch) | |
| tree | bed3fa582e532243aa14a1687874869e8841c3d8 | |
| parent | 57aff93284bff196b37d0deb995ff46d4708bbda (diff) | |
| parent | 560698829e4c7168053775e7e5e9f1e92bb98fa8 (diff) | |
| download | nova-b24189ad5df28ae9acfa8fc5feaa8971e676343e.tar.gz nova-b24189ad5df28ae9acfa8fc5feaa8971e676343e.tar.xz nova-b24189ad5df28ae9acfa8fc5feaa8971e676343e.zip | |
merging trunk
| -rw-r--r-- | Authors | 1 | ||||
| -rw-r--r-- | nova/api/openstack/create_instance_helper.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/schemas/v1.1/server.rng | 2 | ||||
| -rw-r--r-- | nova/api/openstack/servers.py | 4 | ||||
| -rw-r--r-- | nova/api/openstack/views/servers.py | 2 | ||||
| -rw-r--r-- | nova/compute/api.py | 1 | ||||
| -rw-r--r-- | nova/exception.py | 4 | ||||
| -rw-r--r-- | nova/network/manager.py | 2 | ||||
| -rw-r--r-- | nova/tests/api/openstack/contrib/test_createserverext.py | 2 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_servers.py | 69 |
10 files changed, 76 insertions, 13 deletions
@@ -30,6 +30,7 @@ Devendra Modium <dmodium@isi.edu> Devin Carlen <devin.carlen@gmail.com> Donal Lafferty <donal.lafferty@citrix.com> Ed Leafe <ed@leafe.com> +Edouard Thuleau <thuleau@gmail.com> Eldar Nugaev <reldan@oscloud.ru> Eric Day <eday@oddments.org> Eric Windisch <eric@cloudscaling.com> diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py index 29e071609..67e669c17 100644 --- a/nova/api/openstack/create_instance_helper.py +++ b/nova/api/openstack/create_instance_helper.py @@ -282,7 +282,7 @@ class CreateInstanceHelper(object): try: ramdisk_id = image_meta['properties']['ramdisk_id'] except KeyError: - raise exception.RamdiskNotFoundForImage(image_id=image_id) + ramdisk_id = None return kernel_id, ramdisk_id diff --git a/nova/api/openstack/schemas/v1.1/server.rng b/nova/api/openstack/schemas/v1.1/server.rng index dbd169a83..ef835e408 100644 --- a/nova/api/openstack/schemas/v1.1/server.rng +++ b/nova/api/openstack/schemas/v1.1/server.rng @@ -1,6 +1,8 @@ <element name="server" ns="http://docs.openstack.org/compute/api/v1.1" xmlns="http://relaxng.org/ns/structure/1.0"> <attribute name="name"> <text/> </attribute> + <attribute name="userId"> <text/> </attribute> + <attribute name="tenantId"> <text/> </attribute> <attribute name="id"> <text/> </attribute> <attribute name="uuid"> <text/> </attribute> <attribute name="updated"> <text/> </attribute> diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index acd2209af..d084ac360 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -873,6 +873,8 @@ class ServerXMLSerializer(wsgi.XMLDictSerializer): def _add_server_attributes(self, node, server): node.setAttribute('id', str(server['id'])) + node.setAttribute('userId', str(server['user_id'])) + node.setAttribute('tenantId', str(server['tenant_id'])) node.setAttribute('uuid', str(server['uuid'])) node.setAttribute('hostId', str(server['hostId'])) node.setAttribute('name', server['name']) @@ -1009,7 +1011,7 @@ def create_resource(version='1.0'): "attributes": { "server": ["id", "imageId", "name", "flavorId", "hostId", "status", "progress", "adminPass", "flavorRef", - "imageRef"], + "imageRef", "userId", "tenantId"], "link": ["rel", "type", "href"], }, "dict_collections": { diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 3a13d15f1..ac09b5864 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -66,6 +66,8 @@ class ViewBuilder(object): inst_dict = { 'id': inst['id'], 'name': inst['display_name'], + 'user_id': inst.get('user_id', ''), + 'tenant_id': inst.get('project_id', ''), 'status': common.status_from_state(vm_state, task_state)} # Return the metadata as a dictionary diff --git a/nova/compute/api.py b/nova/compute/api.py index 6806522f7..4e2944bb7 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -877,6 +877,7 @@ class API(base.Base): 'image': 'image_ref', 'name': 'display_name', 'instance_name': 'name', + 'tenant_id': 'project_id', 'recurse_zones': None, 'flavor': _remap_flavor_filter, 'fixed_ip': _remap_fixed_ip_filter} diff --git a/nova/exception.py b/nova/exception.py index df6ff25cd..95d8229b5 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -403,10 +403,6 @@ class KernelNotFoundForImage(ImageNotFound): message = _("Kernel not found for image %(image_id)s.") -class RamdiskNotFoundForImage(ImageNotFound): - message = _("Ramdisk not found for image %(image_id)s.") - - class UserNotFound(NotFound): message = _("User %(user_id)s could not be found.") diff --git a/nova/network/manager.py b/nova/network/manager.py index e6b30d1a0..050cec250 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -448,7 +448,7 @@ class NetworkManager(manager.SchedulerDependentManager): try: fixed_ips = kwargs.get('fixed_ips') or \ self.db.fixed_ip_get_by_instance(context, instance_id) - except exceptions.FixedIpNotFoundForInstance: + except exception.FixedIpNotFoundForInstance: fixed_ips = [] LOG.debug(_("network deallocation for instance |%s|"), instance_id, context=context) diff --git a/nova/tests/api/openstack/contrib/test_createserverext.py b/nova/tests/api/openstack/contrib/test_createserverext.py index ba8fb925e..078b72d67 100644 --- a/nova/tests/api/openstack/contrib/test_createserverext.py +++ b/nova/tests/api/openstack/contrib/test_createserverext.py @@ -112,6 +112,8 @@ class CreateserverextTest(test.TestCase): return [{'id': '1234', 'display_name': 'fakeinstance', 'uuid': FAKE_UUID, + 'user_id': 'fake', + 'project_id': 'fake', 'created_at': "", 'updated_at': ""}] diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 1591ea56c..d063a60c2 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -347,6 +347,8 @@ class ServersTest(test.TestCase): "server": { "id": 1, "uuid": FAKE_UUID, + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 0, @@ -446,6 +448,8 @@ class ServersTest(test.TestCase): expected = minidom.parseString(""" <server id="1" uuid="%(expected_uuid)s" + userId="fake" + tenantId="fake" xmlns="http://docs.openstack.org/compute/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" name="server1" @@ -515,6 +519,8 @@ class ServersTest(test.TestCase): "server": { "id": 1, "uuid": FAKE_UUID, + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 100, @@ -610,6 +616,8 @@ class ServersTest(test.TestCase): "server": { "id": 1, "uuid": FAKE_UUID, + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 100, @@ -1199,6 +1207,26 @@ class ServersTest(test.TestCase): self.assertEqual(len(servers), 1) self.assertEqual(servers[0]['id'], 100) + def test_tenant_id_filter_converts_to_project_id_for_admin(self): + def fake_get_all(context, filters=None): + self.assertNotEqual(filters, None) + self.assertEqual(filters['project_id'], 'faketenant') + self.assertFalse(filters.get('tenant_id')) + return [stub_instance(100)] + + self.stubs.Set(nova.db.api, 'instance_get_all_by_filters', + fake_get_all) + self.flags(allow_admin_api=True) + + req = webob.Request.blank('/v1.1/fake/servers?tenant_id=faketenant') + # Use admin context + context = nova.context.RequestContext('testuser', 'testproject', + is_admin=True) + res = req.get_response(fakes.wsgi_app(fake_auth_context=context)) + res_dict = json.loads(res.body) + # Failure in fake_get_all returns non 200 status code + self.assertEqual(res.status_int, 200) + def test_get_servers_allows_flavor_v1_1(self): def fake_get_all(compute_self, context, search_opts=None): self.assertNotEqual(search_opts, None) @@ -1455,6 +1483,8 @@ class ServersTest(test.TestCase): 'access_ip_v4': '1.2.3.4', 'access_ip_v6': 'fead::1234', 'image_ref': image_ref, + 'user_id': 'fake', + 'project_id': 'fake', "created_at": datetime.datetime(2010, 10, 10, 12, 0, 0), "updated_at": datetime.datetime(2010, 11, 11, 11, 0, 0), "config_drive": self.config_drive, @@ -3103,7 +3133,7 @@ class TestServerCreateRequestXMLDeserializerV11(test.TestCase): "name": "new-server-test", "imageRef": "1", "flavorRef": "1", - "networks": [] + "networks": [], }} self.assertEquals(request['body'], expected) @@ -3330,6 +3360,8 @@ class TestServerInstanceCreation(test.TestCase): self.injected_files = None return [{'id': '1234', 'display_name': 'fakeinstance', + 'user_id': 'fake', + 'project_id': 'fake', 'uuid': FAKE_UUID}] def set_admin_password(self, *args, **kwargs): @@ -3583,10 +3615,14 @@ class TestGetKernelRamdiskFromImage(test.TestCase): self.assertRaises(exception.NotFound, self._get_k_r, image_meta) def test_ami_no_ramdisk(self): - """If an ami is missing a ramdisk it should raise NotFound""" + """If an ami is missing a ramdisk, return kernel ID and None for + ramdisk ID + """ image_meta = {'id': 1, 'status': 'active', 'container_format': 'ami', 'properties': {'kernel_id': 1}} - self.assertRaises(exception.NotFound, self._get_k_r, image_meta) + kernel_id, ramdisk_id = self._get_k_r(image_meta) + self.assertEqual(kernel_id, 1) + self.assertEqual(ramdisk_id, None) def test_ami_kernel_ramdisk_present(self): """Return IDs if both kernel and ramdisk are present""" @@ -3621,8 +3657,8 @@ class ServersViewBuilderV11Test(test.TestCase): "created_at": created_at, "updated_at": updated_at, "admin_pass": "", - "user_id": "", - "project_id": "", + "user_id": "fake", + "project_id": "fake", "image_ref": "5", "kernel_id": "", "ramdisk_id": "", @@ -3647,7 +3683,6 @@ class ServersViewBuilderV11Test(test.TestCase): "terminated_at": utils.utcnow(), "availability_zone": "", "display_name": "test_server", - "display_description": "", "locked": False, "metadata": [], "accessIPv4": "1.2.3.4", @@ -3730,6 +3765,8 @@ class ServersViewBuilderV11Test(test.TestCase): "server": { "id": 1, "uuid": self.instance['uuid'], + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 0, @@ -3785,6 +3822,8 @@ class ServersViewBuilderV11Test(test.TestCase): "server": { "id": 1, "uuid": self.instance['uuid'], + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 100, @@ -3841,6 +3880,8 @@ class ServersViewBuilderV11Test(test.TestCase): "server": { "id": 1, "uuid": self.instance['uuid'], + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 0, @@ -3897,6 +3938,8 @@ class ServersViewBuilderV11Test(test.TestCase): "server": { "id": 1, "uuid": self.instance['uuid'], + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 0, @@ -3956,6 +3999,8 @@ class ServersViewBuilderV11Test(test.TestCase): "server": { "id": 1, "uuid": self.instance['uuid'], + "user_id": "fake", + "tenant_id": "fake", "updated": "2010-11-11T11:00:00Z", "created": "2010-10-10T12:00:00Z", "progress": 0, @@ -4024,6 +4069,8 @@ class ServerXMLSerializationTest(test.TestCase): fixture = { "server": { "id": 1, + "user_id": "fake", + "tenant_id": "fake", "uuid": FAKE_UUID, 'created': self.TIMESTAMP, 'updated': self.TIMESTAMP, @@ -4161,6 +4208,8 @@ class ServerXMLSerializationTest(test.TestCase): "server": { "id": 1, "uuid": FAKE_UUID, + "user_id": "fake", + "tenant_id": "fake", 'created': self.TIMESTAMP, 'updated': self.TIMESTAMP, "progress": 0, @@ -4361,6 +4410,8 @@ class ServerXMLSerializationTest(test.TestCase): { "id": 1, "uuid": FAKE_UUID, + "user_id": "fake", + "tenant_id": "fake", 'created': self.TIMESTAMP, 'updated': self.TIMESTAMP, "progress": 0, @@ -4416,6 +4467,8 @@ class ServerXMLSerializationTest(test.TestCase): { "id": 2, "uuid": FAKE_UUID, + "user_id": 'fake', + "tenant_id": 'fake', 'created': self.TIMESTAMP, 'updated': self.TIMESTAMP, "progress": 100, @@ -4535,6 +4588,8 @@ class ServerXMLSerializationTest(test.TestCase): fixture = { "server": { "id": 1, + "user_id": "fake", + "tenant_id": "fake", "uuid": FAKE_UUID, 'created': self.TIMESTAMP, 'updated': self.TIMESTAMP, @@ -4671,6 +4726,8 @@ class ServerXMLSerializationTest(test.TestCase): "server": { "id": 1, "uuid": FAKE_UUID, + "user_id": "fake", + "tenant_id": "fake", 'created': self.TIMESTAMP, 'updated': self.TIMESTAMP, "progress": 0, |
