Extend project_id in object dicts (Newton only)

This is a work-around for bug 1630748 that can be backported to
stable/newton. This workaround will be reverted in Ocata and replaced
by a proper fix.

Partial-Bug: #1630748

(cherry picked from commit abc31a7ff2)
Change-Id: I4ec9340094bc51cd8aa6e5112bf8114aa26c2982
This commit is contained in:
Henry Gessau 2016-10-09 19:56:09 -04:00 committed by Armando Migliaccio
parent b3cf23cf08
commit 7c4563676a
5 changed files with 48 additions and 0 deletions

View File

@ -23,6 +23,7 @@ from oslo_versionedobjects import fields as obj_fields
import six
from neutron._i18n import _
from neutron.api.v2 import attributes
from neutron.db import api as db_api
from neutron.db import model_base
from neutron.db import standard_attr
@ -159,6 +160,7 @@ class NeutronObject(obj_base.VersionedObject,
dict_[field_name].to_dict() if value else None)
else:
dict_[field_name] = field.to_primitive(self, field_name, value)
attributes.populate_project_info(dict_)
return dict_
@classmethod

View File

@ -79,6 +79,17 @@ class AddressScopeTest(AddressScopeTestBase):
returned_address_scope['name'])
self.assertFalse(returned_address_scope['shared'])
@test.idempotent_id('bbd57364-6d57-48e4-b0f1-8b9a998f5e06')
@test.requires_ext(extension="project-id", service="network")
def test_show_address_scope_project_id(self):
address_scope = self._create_address_scope(ip_version=4)
body = self.client.show_address_scope(address_scope['id'])
show_addr_scope = body['address_scope']
self.assertIn('project_id', show_addr_scope)
self.assertIn('tenant_id', show_addr_scope)
self.assertEqual(self.client.tenant_id, show_addr_scope['project_id'])
self.assertEqual(self.client.tenant_id, show_addr_scope['tenant_id'])
@test.idempotent_id('85a259b2-ace6-4e32-9657-a9a392b452aa')
def test_tenant_update_address_scope(self):
self._test_update_address_scope_helper()

View File

@ -46,6 +46,19 @@ class QosTestJSON(base.BaseAdminNetworkTest):
policies_ids = [p['id'] for p in policies]
self.assertIn(policy['id'], policies_ids)
@test.idempotent_id('606a48e2-5403-4052-b40f-4d54b855af76')
@test.requires_ext(extension="project-id", service="network")
def test_show_policy_has_project_id(self):
policy = self.create_qos_policy(name='test-policy', shared=False)
body = self.admin_client.show_qos_policy(policy['id'])
show_policy = body['policy']
self.assertIn('project_id', show_policy)
self.assertIn('tenant_id', show_policy)
self.assertEqual(self.admin_client.tenant_id,
show_policy['project_id'])
self.assertEqual(self.admin_client.tenant_id,
show_policy['tenant_id'])
@test.idempotent_id('f8d20e92-f06d-4805-b54f-230f77715815')
def test_list_policy_filter_by_name(self):
self.create_qos_policy(name='test', description='test policy',

View File

@ -133,6 +133,17 @@ class SubnetPoolsTest(SubnetPoolsTestBase):
self.assertEqual(prefixlen, subnetpool['default_prefixlen'])
self.assertFalse(subnetpool['shared'])
@test.idempotent_id('5bf9f1e2-efc8-4195-acf3-d12b2bd68dd3')
@test.requires_ext(extension="project-id", service="network")
def test_show_subnetpool_has_project_id(self):
subnetpool = self._create_subnetpool()
body = self.client.show_subnetpool(subnetpool['id'])
show_subnetpool = body['subnetpool']
self.assertIn('project_id', show_subnetpool)
self.assertIn('tenant_id', show_subnetpool)
self.assertEqual(self.client.tenant_id, show_subnetpool['project_id'])
self.assertEqual(self.client.tenant_id, show_subnetpool['tenant_id'])
@test.idempotent_id('764f1b93-1c4a-4513-9e7b-6c2fc5e9270c')
def test_tenant_update_subnetpool(self):
created_subnetpool = self._create_subnetpool()

View File

@ -98,6 +98,17 @@ class TrunkTestJSON(TrunkTestJSONBase):
self.client.delete_trunk(trunk_id)
self.assertRaises(lib_exc.NotFound, self._show_trunk, trunk_id)
@test.idempotent_id('8d83a6ca-662d-45b8-8062-d513077296aa')
@test.requires_ext(extension="project-id", service="network")
def test_show_trunk_has_project_id(self):
trunk = self._create_trunk_with_network_and_parent(None)
body = self._show_trunk(trunk['trunk']['id'])
show_trunk = body['trunk']
self.assertIn('project_id', show_trunk)
self.assertIn('tenant_id', show_trunk)
self.assertEqual(self.client.tenant_id, show_trunk['project_id'])
self.assertEqual(self.client.tenant_id, show_trunk['tenant_id'])
@test.idempotent_id('4ce46c22-a2b6-4659-bc5a-0ef2463cab32')
def test_create_update_trunk(self):
trunk = self._create_trunk_with_network_and_parent(None)