From e016f5402bf10137f69353c46d1caa06539e1d85 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Tue, 24 Oct 2017 23:51:36 -0700 Subject: [PATCH] NSX|V3: inject X-NSX-EUSER Enable the NSX to know which tenant did the specific opertaion. WIP. Change-Id: If33d69ca1e8751573aca30ee2f3f1535ae44c7c9 Depends-on: I90fa7ea8c7828bf97aec66321e4169588108760e --- vmware_nsx/plugins/nsx_v3/plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index a3b959b5ca..cb74bd84a3 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -68,6 +68,7 @@ from neutron_lib import exceptions as n_exc from neutron_lib.utils import helpers from neutron_lib.utils import net as nlib_net from oslo_config import cfg +from oslo_context import context as context_utils from oslo_db import exception as db_exc from oslo_log import log from oslo_utils import excutils @@ -124,6 +125,13 @@ NSX_V3_EXCLUDED_PORT_NSGROUP_NAME = 'neutron_excluded_port_nsgroup' NSX_V3_NON_VIF_PROFILE = 'nsx-default-switch-security-non-vif-profile' +def inject_headers(): + ctx = context_utils.get_current() + if ctx: + return {'X-NSX-EUSER': ctx.__dict__.get('_project_id')} + return {} + + # NOTE(asarfaty): the order of inheritance here is important. in order for the # QoS notification to work, the AgentScheduler init must be called first # NOTE(arosen): same is true with the ExtendedSecurityGroupPropertiesMixin @@ -182,6 +190,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, router=l3_db_models.Router, floatingip=l3_db_models.FloatingIP) def __init__(self): + nsxlib_utils.set_inject_headers_callback(inject_headers) self._extend_fault_map() self._extension_manager = managers.ExtensionManager() super(NsxV3Plugin, self).__init__()