Change 'ignore_default' to 'ignore_prot_on_def'
With the change of semantics for templates with 'is_default' and 'is_protected' set, this flag should be changed everywhere to have a more appropriate name. Change-Id: Ifc913e34e94dc59604f733c991858e7011bd728f Partial-implements: blueprint replace-is-default
This commit is contained in:
parent
85c101cd22
commit
1613f2b143
@ -181,18 +181,18 @@ class LocalApi(object):
|
||||
return self._manager.cluster_template_create(context, values)
|
||||
|
||||
def cluster_template_destroy(self, context, cluster_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Destroy the cluster template or raise if it does not exist.
|
||||
|
||||
:returns: None
|
||||
"""
|
||||
self._manager.cluster_template_destroy(context,
|
||||
_get_id(cluster_template),
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
@r.wrap(r.ClusterTemplateResource)
|
||||
def cluster_template_update(self, context, id, cluster_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Update the cluster template or raise if it does not exist.
|
||||
|
||||
:returns: the updated cluster template
|
||||
@ -200,7 +200,7 @@ class LocalApi(object):
|
||||
return self._manager.cluster_template_update(context,
|
||||
id,
|
||||
cluster_template,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
# Node Group Template ops
|
||||
|
||||
@ -228,24 +228,24 @@ class LocalApi(object):
|
||||
return self._manager.node_group_template_create(context, values)
|
||||
|
||||
def node_group_template_destroy(self, context, node_group_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Destroy the node group template or raise if it does not exist.
|
||||
|
||||
:returns: None
|
||||
"""
|
||||
self._manager.node_group_template_destroy(context,
|
||||
_get_id(node_group_template),
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
@r.wrap(r.NodeGroupTemplateResource)
|
||||
def node_group_template_update(self, context, id, values,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Update a node group template from the values dictionary.
|
||||
|
||||
:returns: the updated node group template
|
||||
"""
|
||||
return self._manager.node_group_template_update(context, id, values,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
# Data Source ops
|
||||
|
||||
|
@ -308,13 +308,13 @@ class ConductorManager(db_base.Base):
|
||||
return self.db.cluster_template_create(context, values)
|
||||
|
||||
def cluster_template_destroy(self, context, cluster_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Destroy the cluster_template or raise if it does not exist."""
|
||||
self.db.cluster_template_destroy(context, cluster_template,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
def cluster_template_update(self, context, id, values,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Update a cluster_template from the values dictionary."""
|
||||
values = copy.deepcopy(values)
|
||||
values['tenant_id'] = context.tenant_id
|
||||
@ -323,7 +323,8 @@ class ConductorManager(db_base.Base):
|
||||
if 'node_groups' in values:
|
||||
values['node_groups'] = self._populate_node_groups(context, values)
|
||||
|
||||
return self.db.cluster_template_update(context, values, ignore_default)
|
||||
return self.db.cluster_template_update(context, values,
|
||||
ignore_prot_on_def)
|
||||
|
||||
# Node Group Template ops
|
||||
|
||||
@ -348,20 +349,20 @@ class ConductorManager(db_base.Base):
|
||||
return self.db.node_group_template_create(context, values)
|
||||
|
||||
def node_group_template_destroy(self, context, node_group_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Destroy the Node Group Template or raise if it does not exist."""
|
||||
self.db.node_group_template_destroy(context, node_group_template,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
def node_group_template_update(self, context, id, values,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Update a Node Group Template from the values dictionary."""
|
||||
values = copy.deepcopy(values)
|
||||
values['tenant_id'] = context.tenant_id
|
||||
values['id'] = id
|
||||
|
||||
return self.db.node_group_template_update(context, values,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
# Data Source ops
|
||||
|
||||
|
@ -217,15 +217,16 @@ def cluster_template_create(context, values):
|
||||
|
||||
def cluster_template_destroy(context,
|
||||
cluster_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Destroy the cluster_template or raise if it does not exist."""
|
||||
IMPL.cluster_template_destroy(context, cluster_template, ignore_default)
|
||||
IMPL.cluster_template_destroy(context, cluster_template,
|
||||
ignore_prot_on_def)
|
||||
|
||||
|
||||
@to_dict
|
||||
def cluster_template_update(context, values, ignore_default=False):
|
||||
def cluster_template_update(context, values, ignore_prot_on_def=False):
|
||||
"""Update a cluster_template from the values dictionary."""
|
||||
return IMPL.cluster_template_update(context, values, ignore_default)
|
||||
return IMPL.cluster_template_update(context, values, ignore_prot_on_def)
|
||||
|
||||
|
||||
# Node Group Template ops
|
||||
@ -254,18 +255,18 @@ def node_group_template_create(context, values):
|
||||
|
||||
def node_group_template_destroy(context,
|
||||
node_group_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Destroy the Node Group Template or raise if it does not exist."""
|
||||
IMPL.node_group_template_destroy(context, node_group_template,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
|
||||
@to_dict
|
||||
def node_group_template_update(context, node_group_template,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
"""Update a Node Group Template from the values in a dictionary."""
|
||||
return IMPL.node_group_template_update(context, node_group_template,
|
||||
ignore_default)
|
||||
ignore_prot_on_def)
|
||||
|
||||
|
||||
# Data Source ops
|
||||
|
@ -430,7 +430,7 @@ def cluster_template_create(context, values):
|
||||
|
||||
|
||||
def cluster_template_destroy(context, cluster_template_id,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
cluster_template = _cluster_template_get(context, session,
|
||||
@ -441,13 +441,13 @@ def cluster_template_destroy(context, cluster_template_id,
|
||||
_("Cluster Template id '%s' not found!"))
|
||||
|
||||
validate.check_tenant_for_delete(context, cluster_template)
|
||||
if not (cluster_template.is_default and ignore_default):
|
||||
if not (cluster_template.is_default and ignore_prot_on_def):
|
||||
validate.check_protected_from_delete(cluster_template)
|
||||
|
||||
session.delete(cluster_template)
|
||||
|
||||
|
||||
def cluster_template_update(context, values, ignore_default=False):
|
||||
def cluster_template_update(context, values, ignore_prot_on_def=False):
|
||||
explicit_node_groups = "node_groups" in values
|
||||
if explicit_node_groups:
|
||||
node_groups = values.pop("node_groups")
|
||||
@ -466,7 +466,7 @@ def cluster_template_update(context, values, ignore_default=False):
|
||||
_("Cluster Template id '%s' not found!"))
|
||||
|
||||
validate.check_tenant_for_update(context, cluster_template)
|
||||
if not (cluster_template.is_default and ignore_default):
|
||||
if not (cluster_template.is_default and ignore_prot_on_def):
|
||||
validate.check_protected_from_update(cluster_template, values)
|
||||
|
||||
if len(cluster_template.clusters) > 0:
|
||||
@ -535,7 +535,7 @@ def node_group_template_create(context, values):
|
||||
|
||||
|
||||
def node_group_template_destroy(context, node_group_template_id,
|
||||
ignore_default=False):
|
||||
ignore_prot_on_def=False):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
node_group_template = _node_group_template_get(context, session,
|
||||
@ -546,13 +546,13 @@ def node_group_template_destroy(context, node_group_template_id,
|
||||
_("Node Group Template id '%s' not found!"))
|
||||
|
||||
validate.check_tenant_for_delete(context, node_group_template)
|
||||
if not (node_group_template.is_default and ignore_default):
|
||||
if not (node_group_template.is_default and ignore_prot_on_def):
|
||||
validate.check_protected_from_delete(node_group_template)
|
||||
|
||||
session.delete(node_group_template)
|
||||
|
||||
|
||||
def node_group_template_update(context, values, ignore_default=False):
|
||||
def node_group_template_update(context, values, ignore_prot_on_def=False):
|
||||
session = get_session()
|
||||
try:
|
||||
with session.begin():
|
||||
@ -563,7 +563,7 @@ def node_group_template_update(context, values, ignore_default=False):
|
||||
ngt_id, _("NodeGroupTemplate id '%s' not found"))
|
||||
|
||||
validate.check_tenant_for_update(context, ngt)
|
||||
if not (ngt.is_default and ignore_default):
|
||||
if not (ngt.is_default and ignore_prot_on_def):
|
||||
validate.check_protected_from_update(ngt, values)
|
||||
|
||||
# Check to see that the node group template to be updated is not in
|
||||
|
@ -388,7 +388,7 @@ def delete_node_group_template(ctx, template, rollback=False):
|
||||
|
||||
try:
|
||||
conductor.API.node_group_template_destroy(ctx, template["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
except Exception as e:
|
||||
LOG.warning("Deletion of node group template {info} failed{rollback}"
|
||||
", {reason}".format(info=u.name_and_id(template),
|
||||
@ -410,7 +410,7 @@ def reverse_node_group_template_updates(ctx, update_info):
|
||||
try:
|
||||
conductor.API.node_group_template_update(ctx,
|
||||
template["id"], values,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
except Exception as e:
|
||||
LOG.warning("Rollback of update for node group "
|
||||
"template {info} failed, {reason}".format(
|
||||
@ -454,7 +454,7 @@ def add_node_group_templates(ctx, node_groups):
|
||||
# mark it as updated.
|
||||
try:
|
||||
template = conductor.API.node_group_template_update(
|
||||
ctx, current['id'], template, ignore_default=True)
|
||||
ctx, current['id'], template, ignore_prot_on_def=True)
|
||||
except Exception as e:
|
||||
LOG.warning("Update of node group template {info} "
|
||||
"failed, {reason}".format(
|
||||
@ -526,7 +526,7 @@ def delete_cluster_template(ctx, template, rollback=False):
|
||||
|
||||
try:
|
||||
conductor.API.cluster_template_destroy(ctx, template["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
except Exception as e:
|
||||
LOG.warning("Deletion of cluster template {info} failed{rollback}"
|
||||
", {reason}".format(info=u.name_and_id(template),
|
||||
@ -548,7 +548,7 @@ def reverse_cluster_template_updates(ctx, update_info):
|
||||
try:
|
||||
conductor.API.cluster_template_update(ctx,
|
||||
template["id"], values,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
except Exception as e:
|
||||
LOG.warning("Rollback of update for cluster "
|
||||
"template {info} failed, {reason}".format(
|
||||
@ -617,7 +617,7 @@ def add_cluster_templates(ctx, clusters, ng_dict):
|
||||
# Probably a bug
|
||||
try:
|
||||
template = conductor.API.cluster_template_update(
|
||||
ctx, current['id'], template, ignore_default=True)
|
||||
ctx, current['id'], template, ignore_prot_on_def=True)
|
||||
except Exception as e:
|
||||
LOG.warning("Update of cluster template {info} "
|
||||
"failed, {reason}".format(
|
||||
|
@ -175,13 +175,13 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
|
||||
ngt_prot_def_id = ngt_prot_def['id']
|
||||
|
||||
# We should not be able to delete ngt_prot until we remove
|
||||
# the protected flag, even if we pass ignore_default
|
||||
# the protected flag, even if we pass ignore_prot_on_def
|
||||
with testtools.ExpectedException(ex.DeletionFailed):
|
||||
self.api.node_group_template_destroy(ctx, ngt_prot_id)
|
||||
|
||||
with testtools.ExpectedException(ex.DeletionFailed):
|
||||
self.api.node_group_template_destroy(ctx, ngt_prot_id,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
update_values = {"is_protected": False}
|
||||
self.api.node_group_template_update(ctx,
|
||||
@ -193,12 +193,12 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
|
||||
self.api.node_group_template_destroy(ctx, ngt_prot_id)
|
||||
|
||||
# However, for the protected_default we should be able to
|
||||
# override the protected check by passing ignore_default
|
||||
# override the protected check by passing ignore_prot_on_def
|
||||
with testtools.ExpectedException(ex.DeletionFailed):
|
||||
self.api.node_group_template_destroy(ctx, ngt_prot_def_id)
|
||||
|
||||
self.api.node_group_template_destroy(ctx, ngt_prot_def_id,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
with testtools.ExpectedException(ex.NotFoundException):
|
||||
self.api.node_group_template_destroy(ctx, ngt_prot_def_id)
|
||||
@ -263,7 +263,7 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
|
||||
ngt_prot_def_id = ngt_prot_def["id"]
|
||||
|
||||
# We should not be able to update ngt_prot until we remove
|
||||
# the is_protected flag, even if we pass ignore_default
|
||||
# the is_protected flag, even if we pass ignore_prot_on_def
|
||||
UPDATE_NAME = "UpdatedSampleNGTName"
|
||||
update_values = {"name": UPDATE_NAME}
|
||||
with testtools.ExpectedException(ex.UpdateFailedException):
|
||||
@ -275,7 +275,7 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
|
||||
self.api.node_group_template_update(ctx,
|
||||
ngt_prot_id,
|
||||
update_values,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
update_values["is_protected"] = False
|
||||
updated_ngt = self.api.node_group_template_update(ctx,
|
||||
ngt_prot_id,
|
||||
@ -283,17 +283,16 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
|
||||
self.assertEqual(UPDATE_NAME, updated_ngt["name"])
|
||||
|
||||
# However, for the ngt_prot_def we should be able to
|
||||
# override the is_protected check by passing ignore_default
|
||||
# override the is_protected check by passing ignore_prot_on_def
|
||||
update_values = {"name": UPDATE_NAME+"default"}
|
||||
with testtools.ExpectedException(ex.UpdateFailedException):
|
||||
self.api.node_group_template_update(ctx,
|
||||
ngt_prot_def_id,
|
||||
update_values)
|
||||
|
||||
updated_ngt = self.api.node_group_template_update(ctx,
|
||||
ngt_prot_def_id,
|
||||
update_values,
|
||||
ignore_default=True)
|
||||
updated_ngt = self.api.node_group_template_update(
|
||||
ctx, ngt_prot_def_id, update_values, ignore_prot_on_def=True)
|
||||
|
||||
self.assertEqual(UPDATE_NAME+"default", updated_ngt["name"])
|
||||
self.assertTrue(updated_ngt["is_protected"])
|
||||
self.assertTrue(updated_ngt["is_default"])
|
||||
@ -455,13 +454,13 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
clt_prot_def_id = clt_prot_def['id']
|
||||
|
||||
# We should not be able to delete clt_prot until we remove
|
||||
# the is_protected flag, even if we pass ignore_default
|
||||
# the is_protected flag, even if we pass ignore_prot_on_def
|
||||
with testtools.ExpectedException(ex.DeletionFailed):
|
||||
self.api.cluster_template_destroy(ctx, clt_prot_id)
|
||||
|
||||
with testtools.ExpectedException(ex.DeletionFailed):
|
||||
self.api.cluster_template_destroy(ctx, clt_prot_id,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
update_values = {"is_protected": False}
|
||||
self.api.cluster_template_update(ctx,
|
||||
@ -473,12 +472,12 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
self.api.cluster_template_destroy(ctx, clt_prot_id)
|
||||
|
||||
# However, for clt_prot_def we should be able to override
|
||||
# the is_protected check by passing ignore_default
|
||||
# the is_protected check by passing ignore_prot_on_def
|
||||
with testtools.ExpectedException(ex.DeletionFailed):
|
||||
self.api.cluster_template_destroy(ctx, clt_prot_def_id)
|
||||
|
||||
self.api.cluster_template_destroy(ctx, clt_prot_def_id,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
with testtools.ExpectedException(ex.NotFoundException):
|
||||
self.api.cluster_template_destroy(ctx, clt_prot_def_id)
|
||||
@ -555,7 +554,7 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
clt_prot_def_id = clt_prot_def["id"]
|
||||
|
||||
# We should not be able to update clt_prot until we remove
|
||||
# the is_protected flag, even if we pass ignore_default
|
||||
# the is_protected flag, even if we pass ignore_prot_on_def
|
||||
UPDATE_NAME = "UpdatedClusterTemplate"
|
||||
update_values = {"name": UPDATE_NAME}
|
||||
with testtools.ExpectedException(ex.UpdateFailedException):
|
||||
@ -567,7 +566,7 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
self.api.cluster_template_update(ctx,
|
||||
clt_prot_id,
|
||||
update_values,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
update_values["is_protected"] = False
|
||||
updated_clt = self.api.cluster_template_update(ctx,
|
||||
clt_prot_id,
|
||||
@ -575,7 +574,7 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
self.assertEqual(UPDATE_NAME, updated_clt["name"])
|
||||
|
||||
# However, for the clt_prot_def we should be able to
|
||||
# override the is_protected check by passing ignore_default
|
||||
# override the is_protected check by passing ignore_prot_on_def
|
||||
update_values = {"name": UPDATE_NAME+"default"}
|
||||
with testtools.ExpectedException(ex.UpdateFailedException):
|
||||
self.api.cluster_template_update(ctx,
|
||||
@ -585,7 +584,7 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
|
||||
updated_clt = self.api.cluster_template_update(ctx,
|
||||
clt_prot_def_id,
|
||||
update_values,
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
self.assertEqual(UPDATE_NAME+"default", updated_clt["name"])
|
||||
self.assertTrue(updated_clt["is_default"])
|
||||
self.assertTrue(updated_clt["is_protected"])
|
||||
|
@ -387,9 +387,9 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
|
||||
self.assertIn(msg, self.logger.infos)
|
||||
|
||||
self.api.node_group_template_destroy(ctx, new["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
self.api.node_group_template_destroy(ctx, existing["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
@mock.patch("sahara.conductor.API.node_group_template_update")
|
||||
@mock.patch("sahara.db.templates.api.reverse_node_group_template_creates")
|
||||
@ -432,9 +432,9 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
|
||||
self.assertIn(msg, self.logger.warnings)
|
||||
|
||||
self.api.node_group_template_destroy(ctx, new["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
self.api.node_group_template_destroy(ctx, existing["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
@mock.patch("sahara.conductor.API.node_group_template_create")
|
||||
@mock.patch("sahara.db.templates.api.reverse_node_group_template_creates")
|
||||
@ -476,7 +476,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
|
||||
self.assertIn(msg, self.logger.warnings)
|
||||
|
||||
self.api.node_group_template_destroy(ctx, existing["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
def test_add_cluster_templates(self):
|
||||
self.logger.clear_log()
|
||||
@ -512,9 +512,9 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
|
||||
self.assertIn(msg, self.logger.infos)
|
||||
|
||||
self.api.cluster_template_destroy(ctx, new["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
self.api.cluster_template_destroy(ctx, existing["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
@mock.patch("sahara.conductor.API.cluster_template_update")
|
||||
@mock.patch("sahara.db.templates.api.reverse_cluster_template_creates")
|
||||
@ -557,9 +557,9 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
|
||||
self.assertIn(msg, self.logger.warnings)
|
||||
|
||||
self.api.cluster_template_destroy(ctx, new["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
self.api.cluster_template_destroy(ctx, existing["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
@mock.patch("sahara.conductor.API.cluster_template_create")
|
||||
@mock.patch("sahara.db.templates.api.reverse_cluster_template_creates")
|
||||
@ -605,7 +605,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
|
||||
self.assertIn(msg, self.logger.warnings)
|
||||
|
||||
self.api.cluster_template_destroy(ctx, existing["id"],
|
||||
ignore_default=True)
|
||||
ignore_prot_on_def=True)
|
||||
|
||||
@mock.patch("sahara.db.templates.api.get_configs")
|
||||
@mock.patch("sahara.db.templates.api.add_config_section_for_template")
|
||||
|
Loading…
Reference in New Issue
Block a user