Merge "Replace "tenant_id" with "project_id" in metering service"
This commit is contained in:
commit
b32d577658
@ -39,7 +39,7 @@ class MeteringDbMixin(metering.MeteringPluginBase):
|
||||
'name': metering_label['name'],
|
||||
'description': metering_label['description'],
|
||||
'shared': metering_label['shared'],
|
||||
'tenant_id': metering_label['tenant_id']}
|
||||
'project_id': metering_label['project_id']}
|
||||
return db_utils.resource_fields(res, fields)
|
||||
|
||||
def create_metering_label(self, context, metering_label):
|
||||
@ -47,7 +47,7 @@ class MeteringDbMixin(metering.MeteringPluginBase):
|
||||
|
||||
metering_obj = metering_objs.MeteringLabel(
|
||||
context, id=uuidutils.generate_uuid(),
|
||||
description=m['description'], project_id=m['tenant_id'],
|
||||
description=m['description'], project_id=m['project_id'],
|
||||
name=m['name'], shared=m['shared'])
|
||||
metering_obj.create()
|
||||
return self._make_metering_label_dict(metering_obj)
|
||||
@ -158,7 +158,7 @@ class MeteringDbMixin(metering.MeteringPluginBase):
|
||||
distributed = l3_dvr_db.is_distributed_router(router)
|
||||
res = {'id': router['id'],
|
||||
'name': router['name'],
|
||||
'tenant_id': router['tenant_id'],
|
||||
'project_id': router['project_id'],
|
||||
'admin_state_up': router['admin_state_up'],
|
||||
'status': router['status'],
|
||||
'gw_port_id': router['gw_port_id'],
|
||||
|
@ -41,8 +41,8 @@ class MeteringLabel(model_base.BASEV2,
|
||||
cascade="delete", lazy="subquery")
|
||||
routers = orm.relationship(
|
||||
l3_models.Router,
|
||||
primaryjoin="MeteringLabel.tenant_id==Router.tenant_id",
|
||||
foreign_keys='MeteringLabel.tenant_id',
|
||||
primaryjoin="MeteringLabel.project_id==Router.project_id",
|
||||
foreign_keys='MeteringLabel.project_id',
|
||||
lazy='subquery',
|
||||
uselist=True)
|
||||
shared = sa.Column(sa.Boolean, default=False, server_default=sql.false())
|
||||
|
@ -76,7 +76,7 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
|
||||
self.metering_loop.start(interval=measure_interval)
|
||||
self.host = host
|
||||
|
||||
self.label_tenant_id = {}
|
||||
self.label_project_id = {}
|
||||
self.routers = {}
|
||||
self.metering_infos = {}
|
||||
self.metering_labels = {}
|
||||
@ -123,7 +123,7 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
|
||||
self.set_project_id_for_granular_traffic_data(data, key)
|
||||
else:
|
||||
data['label_id'] = key
|
||||
data['tenant_id'] = self.label_tenant_id.get(key)
|
||||
data['project_id'] = self.label_project_id.get(key)
|
||||
|
||||
LOG.debug("Metering notification created [%s] with info data [%s], "
|
||||
"key[%s], and metering_labels configured [%s]. ", data, info,
|
||||
@ -150,7 +150,7 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
|
||||
if is_label_shared:
|
||||
self.configure_project_id_shared_labels(data, other_ids[:-1])
|
||||
else:
|
||||
data['project_id'] = self.label_tenant_id.get(actual_label_id)
|
||||
data['project_id'] = self.label_project_id.get(actual_label_id)
|
||||
elif driver.BASE_PROJECT_TRAFFIC_COUNTER_KEY in key:
|
||||
data['project_id'] = key.split(
|
||||
driver.BASE_PROJECT_TRAFFIC_COUNTER_KEY)[1]
|
||||
@ -177,7 +177,7 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
|
||||
def configure_project_id_based_on_router(self, data, router_id):
|
||||
if router_id in self.routers:
|
||||
router = self.routers[router_id]
|
||||
data['project_id'] = router['tenant_id']
|
||||
data['project_id'] = router['project_id']
|
||||
else:
|
||||
LOG.warning("Could not find router with ID [%s].", router_id)
|
||||
|
||||
@ -208,13 +208,13 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
|
||||
return info
|
||||
|
||||
def _add_metering_infos(self):
|
||||
self.label_tenant_id = {}
|
||||
self.label_project_id = {}
|
||||
for router in self.routers.values():
|
||||
tenant_id = router['tenant_id']
|
||||
project_id = router['project_id']
|
||||
labels = router.get(constants.METERING_LABEL_KEY, [])
|
||||
for label in labels:
|
||||
label_id = label['id']
|
||||
self.label_tenant_id[label_id] = tenant_id
|
||||
self.label_project_id[label_id] = project_id
|
||||
|
||||
LOG.debug("Retrieving traffic counters for routers [%s].",
|
||||
self.routers)
|
||||
|
@ -64,9 +64,9 @@ class MeteringAbstractDriver(object, metaclass=abc.ABCMeta):
|
||||
router_id, BASE_ROUTER_TRAFFIC_COUNTER_KEY)
|
||||
|
||||
@staticmethod
|
||||
def get_project_traffic_counter_key(tenant_id):
|
||||
def get_project_traffic_counter_key(project_id):
|
||||
return MeteringAbstractDriver._concat_base_key_with_id(
|
||||
tenant_id, BASE_PROJECT_TRAFFIC_COUNTER_KEY)
|
||||
project_id, BASE_PROJECT_TRAFFIC_COUNTER_KEY)
|
||||
|
||||
@staticmethod
|
||||
def get_label_traffic_counter_key(label_id):
|
||||
|
@ -541,9 +541,9 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
|
||||
`traffic_counters` dictionary.
|
||||
* labels -- label-<label_id>
|
||||
* routers -- router-<router_id>
|
||||
* project -- project-<tenant_id>
|
||||
* project -- project-<project_id>
|
||||
* router-label -- router-<router_id>-label-<label_id>
|
||||
* project-label -- project-<tenant_id>-label-<label_id>
|
||||
* project-label -- project-<project_id>-label-<label_id>
|
||||
|
||||
And last, but not least, if we are not able to retrieve the traffic
|
||||
counters from `iptables` for a given router, we will add it to
|
||||
@ -560,7 +560,7 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
|
||||
|
||||
default_traffic_counters = {'pkts': 0, 'bytes': 0}
|
||||
project_traffic_counter_key = self.get_project_traffic_counter_key(
|
||||
router['tenant_id'])
|
||||
router['project_id'])
|
||||
router_traffic_counter_key = self.get_router_traffic_counter_key(
|
||||
router_id)
|
||||
|
||||
|
@ -26,13 +26,13 @@ from neutron.tests import base
|
||||
|
||||
_uuid = uuidutils.generate_uuid
|
||||
|
||||
TENANT_ID = _uuid()
|
||||
PROJECT_ID = _uuid()
|
||||
LABEL_ID = _uuid()
|
||||
ROUTERS = [{'status': 'ACTIVE',
|
||||
'name': 'router1',
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'tenant_id': TENANT_ID,
|
||||
'project_id': PROJECT_ID,
|
||||
'_metering_labels': [{'rules': [],
|
||||
'id': LABEL_ID}],
|
||||
'id': _uuid()}]
|
||||
@ -41,7 +41,7 @@ ROUTERS_WITH_RULE = [{'status': 'ACTIVE',
|
||||
'name': 'router1',
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'tenant_id': TENANT_ID,
|
||||
'project_id': PROJECT_ID,
|
||||
'_metering_labels': [{'rule': {},
|
||||
'id': LABEL_ID}],
|
||||
'id': _uuid()}]
|
||||
@ -125,7 +125,7 @@ class TestMeteringOperations(base.BaseTestCase):
|
||||
self.assertEqual('l3.meter', n['event_type'])
|
||||
|
||||
payload = n['payload']
|
||||
self.assertEqual(TENANT_ID, payload['tenant_id'])
|
||||
self.assertEqual(PROJECT_ID, payload['project_id'])
|
||||
self.assertEqual(LABEL_ID, payload['label_id'])
|
||||
self.assertEqual(88, payload['pkts'])
|
||||
self.assertEqual(444, payload['bytes'])
|
||||
@ -164,7 +164,7 @@ class TestMeteringOperations(base.BaseTestCase):
|
||||
self.assertEqual('l3.meter', n['event_type'])
|
||||
|
||||
payload = n['payload']
|
||||
self.assertEqual(TENANT_ID, payload['tenant_id'])
|
||||
self.assertEqual(PROJECT_ID, payload['project_id'])
|
||||
self.assertEqual(LABEL_ID, payload['label_id'])
|
||||
self.assertLess((payload['time'] - report_interval),
|
||||
measure_interval, payload)
|
||||
|
@ -37,7 +37,7 @@ TEST_ROUTERS = [
|
||||
'name': 'router1',
|
||||
'distributed': False,
|
||||
'status': 'ACTIVE',
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
'project_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
{'_metering_labels': [
|
||||
{'id': 'eeef45da-c600-4a2a-b2f4-c0fb6df73c83',
|
||||
'rules': [{
|
||||
@ -52,7 +52,7 @@ TEST_ROUTERS = [
|
||||
'name': 'router2',
|
||||
'status': 'ACTIVE',
|
||||
'distributed': False,
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
'project_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
]
|
||||
|
||||
TEST_DVR_ROUTER = [
|
||||
@ -70,7 +70,7 @@ TEST_DVR_ROUTER = [
|
||||
'name': 'router-test',
|
||||
'distributed': True,
|
||||
'status': 'ACTIVE',
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'}]
|
||||
'project_id': '6c5f5d2a1fa2441e88e35422926f48e8'}]
|
||||
|
||||
TEST_ROUTERS_WITH_ONE_RULE = [
|
||||
{'_metering_labels': [
|
||||
@ -87,7 +87,7 @@ TEST_ROUTERS_WITH_ONE_RULE = [
|
||||
'name': 'router1',
|
||||
'status': 'ACTIVE',
|
||||
'distributed': False,
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
'project_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
{'_metering_labels': [
|
||||
{'id': 'eeef45da-c600-4a2a-b2f4-c0fb6df73c83',
|
||||
'rule': {
|
||||
@ -102,7 +102,7 @@ TEST_ROUTERS_WITH_ONE_RULE = [
|
||||
'name': 'router2',
|
||||
'distributed': False,
|
||||
'status': 'ACTIVE',
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
'project_id': '6c5f5d2a1fa2441e88e35422926f48e8'},
|
||||
]
|
||||
|
||||
TEST_ROUTERS_WITH_NEW_LABEL = [
|
||||
@ -119,7 +119,7 @@ TEST_ROUTERS_WITH_NEW_LABEL = [
|
||||
'id': '473ec392-1711-44e3-b008-3251ccfc5099',
|
||||
'name': 'router1',
|
||||
'status': 'ACTIVE',
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'}]
|
||||
'project_id': '6c5f5d2a1fa2441e88e35422926f48e8'}]
|
||||
|
||||
|
||||
class IptablesDriverTestCase(base.BaseTestCase):
|
||||
|
@ -97,8 +97,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
self.uuid_patch = mock.patch(uuid, return_value=self.uuid)
|
||||
self.mock_uuid = self.uuid_patch.start()
|
||||
|
||||
self.tenant_id = 'a7e61382-47b8-4d40-bae3-f95981b5637b'
|
||||
self.ctx = FakeContext('', self.tenant_id, is_admin=True)
|
||||
self.project_id = 'a7e61382-47b8-4d40-bae3-f95981b5637b'
|
||||
self.ctx = FakeContext('', self.project_id, is_admin=True)
|
||||
self.context_patch = mock.patch('neutron_lib.context.Context',
|
||||
return_value=self.ctx)
|
||||
self.mock_context = self.context_patch.start()
|
||||
@ -159,7 +159,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': self.uuid, 'shared': False,
|
||||
@ -171,9 +171,9 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
with self.router(name='router2', tenant_id=tenant_id_2,
|
||||
set_context=True):
|
||||
self.mock_uuid.return_value = self.uuid
|
||||
with self.router(name='router1', tenant_id=self.tenant_id,
|
||||
with self.router(name='router1', tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
self.mock_add.assert_called_with(self.ctx, expected)
|
||||
|
||||
@ -184,7 +184,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': self.uuid, 'shared': False,
|
||||
@ -195,9 +195,9 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'id': self.uuid}]
|
||||
|
||||
tenant_id_2 = '8a268a58-1610-4890-87e0-07abb8231206'
|
||||
with self.router(name='router1', tenant_id=self.tenant_id, shared=True,
|
||||
set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(name='router1', tenant_id=self.project_id,
|
||||
shared=True, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
with self.metering_label(tenant_id=tenant_id_2, shared=True,
|
||||
@ -210,15 +210,15 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': self.uuid, 'shared': False,
|
||||
'name': 'label'}],
|
||||
'id': self.uuid}]
|
||||
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
self.mock_add.assert_called_with(self.ctx, expected)
|
||||
self._delete('metering-labels',
|
||||
@ -232,7 +232,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': self.uuid, 'shared': False,
|
||||
@ -246,18 +246,18 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': second_uuid, 'shared': False,
|
||||
'name': 'label'}],
|
||||
'id': self.uuid}]
|
||||
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
self.mock_add.assert_called_with(self.ctx, expected_add)
|
||||
self._delete('metering-labels',
|
||||
@ -271,7 +271,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'remote_ip_prefix':
|
||||
@ -291,7 +291,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'remote_ip_prefix':
|
||||
@ -307,8 +307,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'id': self.uuid}]
|
||||
|
||||
remote_ip_prefix = {'remote_ip_prefix': '10.0.0.0/24'}
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
@ -326,7 +326,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'source_ip_prefix':
|
||||
@ -346,7 +346,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'source_ip_prefix':
|
||||
@ -362,8 +362,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'id': self.uuid}]
|
||||
|
||||
source_ip_prefix = {'source_ip_prefix': '10.0.0.0/24'}
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
@ -382,7 +382,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'destination_ip_prefix':
|
||||
@ -402,7 +402,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'destination_ip_prefix':
|
||||
@ -418,8 +418,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'id': self.uuid}]
|
||||
|
||||
source_ip_prefix = {'destination_ip_prefix': '10.0.0.0/24'}
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
@ -438,7 +438,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'destination_ip_prefix':
|
||||
@ -459,7 +459,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rule': {
|
||||
'destination_ip_prefix':
|
||||
@ -477,8 +477,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
|
||||
ip_prefixes = {'source_ip_prefix': '10.0.0.0/24',
|
||||
'destination_ip_prefix': '0.0.0.0/0'}
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
@ -491,8 +491,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
expected_del)
|
||||
|
||||
def test_add_and_remove_metering_label_rule_src_and_remote_ip(self):
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
|
||||
@ -514,8 +514,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
"NeutronError"]["message"])
|
||||
|
||||
def test_add_and_remove_metering_label_rule_dest_and_remote_ip(self):
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
|
||||
@ -537,8 +537,8 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
||||
"NeutronError"]["message"])
|
||||
|
||||
def test_add_and_remove_metering_label_rule_no_ip_prefix_entered(self):
|
||||
with self.router(tenant_id=self.tenant_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.router(tenant_id=self.project_id, set_context=True):
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True) as label:
|
||||
la = label['metering_label']
|
||||
|
||||
@ -603,8 +603,8 @@ class TestMeteringPluginL3AgentScheduler(
|
||||
self.uuid_patch = mock.patch(uuid, return_value=self.uuid)
|
||||
self.mock_uuid = self.uuid_patch.start()
|
||||
|
||||
self.tenant_id = 'a7e61382-47b8-4d40-bae3-f95981b5637b'
|
||||
self.ctx = FakeContext('', self.tenant_id, is_admin=True)
|
||||
self.project_id = 'a7e61382-47b8-4d40-bae3-f95981b5637b'
|
||||
self.ctx = FakeContext('', self.project_id, is_admin=True)
|
||||
self.context_patch = mock.patch('neutron_lib.context.Context',
|
||||
return_value=self.ctx)
|
||||
self.mock_context = self.context_patch.start()
|
||||
@ -634,7 +634,7 @@ class TestMeteringPluginL3AgentScheduler(
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': second_uuid, 'shared': False,
|
||||
@ -645,7 +645,7 @@ class TestMeteringPluginL3AgentScheduler(
|
||||
'gw_port_id': None,
|
||||
'admin_state_up': True,
|
||||
'distributed': False,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'_metering_labels': [
|
||||
{'rules': [],
|
||||
'id': second_uuid, 'shared': False,
|
||||
@ -664,12 +664,12 @@ class TestMeteringPluginL3AgentScheduler(
|
||||
|
||||
self.l3routers_mock.side_effect = side_effect
|
||||
|
||||
with self.router(name='router1', tenant_id=self.tenant_id,
|
||||
with self.router(name='router1', tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
self.mock_uuid.return_value = second_uuid
|
||||
with self.router(name='router2', tenant_id=self.tenant_id,
|
||||
with self.router(name='router2', tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
with self.metering_label(tenant_id=self.tenant_id,
|
||||
with self.metering_label(tenant_id=self.project_id,
|
||||
set_context=True):
|
||||
self.mock_add.assert_called_with(
|
||||
self.ctx, tools.UnorderedList(expected))
|
||||
|
Loading…
Reference in New Issue
Block a user