Adding tenant_id to regex_search
In order to allow the creation of clusters templates and node group templates with the same across projects, even when set to public, we need to filter only from the requester's project when creating a new resources. This will narrow the name check to same project only. Change-Id: Icc39c7e680c2fff583069a5522b2a11afb3e239b Closes-bug: #1584680
This commit is contained in:
parent
9aaa975680
commit
e481549c1d
@ -506,7 +506,7 @@ def cluster_template_get(context, cluster_template_id):
|
||||
def cluster_template_get_all(context, regex_search=False,
|
||||
marker=None, limit=None, sort_by=None, **kwargs):
|
||||
|
||||
regex_cols = ['name', 'description', 'plugin_name']
|
||||
regex_cols = ['name', 'description', 'plugin_name', 'tenant_id']
|
||||
sort_by, order = _parse_sorting_args(sort_by)
|
||||
query = model_query(m.ClusterTemplate, context)
|
||||
if regex_search:
|
||||
@ -642,7 +642,7 @@ def node_group_template_get(context, node_group_template_id):
|
||||
def node_group_template_get_all(context, regex_search=False, marker=None,
|
||||
limit=None, sort_by=None, **kwargs):
|
||||
sort_by, order = _parse_sorting_args(sort_by)
|
||||
regex_cols = ['name', 'description', 'plugin_name']
|
||||
regex_cols = ['name', 'description', 'plugin_name', 'tenant_id']
|
||||
limit = int(limit) if limit else None
|
||||
query = model_query(m.NodeGroupTemplate, context)
|
||||
if regex_search:
|
||||
|
@ -295,7 +295,8 @@ def check_network_exists(net_id):
|
||||
# Cluster templates related checks
|
||||
|
||||
def check_cluster_template_unique_name(name):
|
||||
if name in [t.name for t in api.get_cluster_templates()]:
|
||||
if name in [t.name for t in api.get_cluster_templates(
|
||||
tenant_id=context.ctx().tenant_id)]:
|
||||
raise ex.NameAlreadyExistsException(
|
||||
_("Cluster template with name '%s' already exists") % name)
|
||||
|
||||
@ -320,7 +321,8 @@ def check_node_groups_in_cluster_templates(cluster_name, plugin_name,
|
||||
|
||||
|
||||
def check_node_group_template_unique_name(name):
|
||||
if name in [t.name for t in api.get_node_group_templates()]:
|
||||
if name in [t.name for t in api.get_node_group_templates(
|
||||
tenant_id=context.ctx().tenant_id)]:
|
||||
raise ex.NameAlreadyExistsException(
|
||||
_("NodeGroup template with name '%s' already exists") % name)
|
||||
|
||||
|
@ -255,7 +255,8 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
|
||||
self.assertEqual(1, regex_filter.call_count)
|
||||
args, kwargs = regex_filter.call_args
|
||||
self.assertIs(args[1], m.NodeGroupTemplate)
|
||||
self.assertEqual(args[2], ["name", "description", "plugin_name"])
|
||||
self.assertEqual(args[2], ["name", "description", "plugin_name",
|
||||
"tenant_id"])
|
||||
self.assertEqual(args[3], {"name": "fox"})
|
||||
|
||||
def test_ngt_update(self):
|
||||
@ -564,7 +565,8 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
self.assertEqual(1, regex_filter.call_count)
|
||||
args, kwargs = regex_filter.call_args
|
||||
self.assertIs(args[1], m.ClusterTemplate)
|
||||
self.assertEqual(args[2], ["name", "description", "plugin_name"])
|
||||
self.assertEqual(args[2], ["name", "description", "plugin_name",
|
||||
"tenant_id"])
|
||||
self.assertEqual(args[3], {"name": "fox"})
|
||||
|
||||
def test_clt_update(self):
|
||||
|
Loading…
Reference in New Issue
Block a user