Populate plugin directory to fix port operation in nsxadmin v3
Following I7331e914234c5f0b7abe836604fdd7e4067551cf, nsxadmin command "nsxadmin -o list-mismatches -r ports" failed due to absence of core plugin in plugin directory. Fix this by adding core plugin from the admin code Change-Id: I4edbe0b413a66c65c7061dee2b478a9db4a13bdb
This commit is contained in:
parent
27a908ef16
commit
47cd93baaf
@ -39,6 +39,7 @@ from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import portsecurity_db
|
||||
from neutron.extensions import allowedaddresspairs
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -46,7 +47,12 @@ LOG = logging.getLogger(__name__)
|
||||
class PortsPlugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
portsecurity_db.PortSecurityDbMixin,
|
||||
addr_pair_db.AllowedAddressPairsMixin):
|
||||
pass
|
||||
def __enter__(self):
|
||||
directory.add_plugin(const.CORE, self)
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
directory.add_plugin(const.CORE, None)
|
||||
|
||||
|
||||
def get_port_nsx_id(session, neutron_id):
|
||||
@ -109,8 +115,9 @@ def list_missing_ports(resource, event, trigger, **kwargs):
|
||||
"""List neutron ports that are missing the NSX backend port
|
||||
And ports with wrong switch profiles
|
||||
"""
|
||||
plugin = PortsPlugin()
|
||||
admin_cxt = neutron_context.get_admin_context()
|
||||
|
||||
with PortsPlugin() as plugin:
|
||||
neutron_ports = plugin.get_ports(admin_cxt)
|
||||
port_client, profile_client = get_port_and_profile_clients()
|
||||
|
||||
@ -217,9 +224,9 @@ def migrate_compute_ports_vms(resource, event, trigger, **kwargs):
|
||||
return
|
||||
|
||||
# Go over all the compute ports from the plugin
|
||||
plugin = PortsPlugin()
|
||||
admin_cxt = neutron_context.get_admin_context()
|
||||
port_filters = {'device_owner': ['compute:None']}
|
||||
with PortsPlugin() as plugin:
|
||||
neutron_ports = plugin.get_ports(admin_cxt, filters=port_filters)
|
||||
|
||||
for port in neutron_ports:
|
||||
|
Loading…
x
Reference in New Issue
Block a user