diff --git a/vmware_nsx/extensions/projectpluginmap.py b/vmware_nsx/extensions/projectpluginmap.py index 4d23f779de..efd43e43c8 100644 --- a/vmware_nsx/extensions/projectpluginmap.py +++ b/vmware_nsx/extensions/projectpluginmap.py @@ -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 diff --git a/vmware_nsx/plugins/nsx/plugin.py b/vmware_nsx/plugins/nsx/plugin.py index dab61be5c5..cf3a01cfcb 100644 --- a/vmware_nsx/plugins/nsx/plugin.py +++ b/vmware_nsx/plugins/nsx/plugin.py @@ -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 "