NSX|TV: validate plugin is available

When admin creates plugin mapping validate that it is available.

Change-Id: If41dc891e8f9a484b85d00d9fff2f7fa3a6f376c
This commit is contained in:
Gary Kotton 2018-01-24 03:35:18 -08:00 committed by garyk
parent 2859a235e6
commit b336b8cc03
2 changed files with 8 additions and 0 deletions

View File

@ -115,6 +115,10 @@ class ProjectPluginIllegalId(nexception.Conflict):
message = _("Project ID %(project_id)s is illegal.")
class ProjectPluginNotAvailable(nexception.NotAuthorized):
message = _("Plugin %(plugin)s is not available.")
class ProjectPluginMapPluginBase(object):
@abc.abstractmethod

View File

@ -756,6 +756,10 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
if not uuidutils.is_uuid_like(data['project']):
raise projectpluginmap.ProjectPluginIllegalId(
project_id=data['project'])
# 4. Check that plugin is available
if data['plugin'] not in self.plugins:
raise projectpluginmap.ProjectPluginNotAvailable(
plugin=data['plugin'])
# Add the entry to the DB and return it
LOG.info("Adding mapping between project %(project)s and plugin "