Skip to content

Commit

Permalink
Dev: Remove 'master' and 'ms' terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxin1300 committed Jan 12, 2025
1 parent 51967e0 commit 2363162
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 55 deletions.
19 changes: 8 additions & 11 deletions crmsh/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .utils import run_ptest, is_id_valid, edit_file, get_boolean, filter_string
from .xmlutil import is_child_rsc, rsc_constraint, sanitize_cib, rename_id, get_interesting_nodes
from .xmlutil import is_pref_location, get_topnode, new_cib, get_rscop_defaults_meta_node
from .xmlutil import rename_rscref, is_ms_or_promotable_clone, silly_constraint, is_container, fix_comments
from .xmlutil import rename_rscref, is_promotable_clone, silly_constraint, is_container, fix_comments
from .xmlutil import sanity_check_nvpairs, merge_nodes, op2list, mk_rsc_type, is_resource
from .xmlutil import stuff_comments, is_comment, is_constraint, read_cib, processing_sort_cli
from .xmlutil import find_operation, get_rsc_children_ids, is_primitive, referenced_resources
Expand Down Expand Up @@ -940,7 +940,7 @@ def _repr_cli_xml(self, format_mode):
return "%s %s" % (h, cli_format(l, break_lines=(format_mode > 0), xml=True))

def _gv_rsc_id(self):
if self.parent and self.parent.obj_type in constants.clonems_tags:
if self.parent and self.parent.obj_type in constants.clone_tags:
return "%s:%s" % (self.parent.obj_type, self.obj_id)
return self.obj_id

Expand Down Expand Up @@ -1644,7 +1644,7 @@ def repr_gv(self, gv_obj, from_grp=False):
self._set_gv_attrs(gv_obj)
self._set_gv_attrs(gv_obj, "class:%s" % ra_class)
# if it's clone/ms, then get parent graph attributes
if self.parent and self.parent.obj_type in constants.clonems_tags:
if self.parent and self.parent.obj_type in constants.clone_tags:
self._set_gv_attrs(gv_obj, self.parent.obj_type)

template_ref = self.node.get("template")
Expand All @@ -1669,7 +1669,7 @@ def repr_gv(self, gv_obj, from_grp=False):
self._set_gv_attrs(gv_obj)
self._set_gv_attrs(gv_obj, "class:%s" % ra_class)
# if it's clone/ms, then get parent graph attributes
if self.parent and self.parent.obj_type in constants.clonems_tags:
if self.parent and self.parent.obj_type in constants.clone_tags:
self._set_gv_attrs(gv_obj, self.parent.obj_type)


Expand All @@ -1688,7 +1688,7 @@ def _repr_cli_head(self, format_mode):
if (self.obj_type == "group" and is_primitive(c)) or \
is_child_rsc(c):
children.append(clidisplay.rscref(c.get("id")))
elif self.obj_type in constants.clonems_tags and is_child_rsc(c):
elif self.obj_type in constants.clone_tags and is_child_rsc(c):
children.append(clidisplay.rscref(c.get("id")))
s = clidisplay.keyword(self.obj_type)
ident = clidisplay.ident(self.obj_id)
Expand All @@ -1704,8 +1704,6 @@ def check_sanity(self):
l = get_resource_meta_list()
if self.obj_type == "clone":
l += constants.clone_meta_attributes
elif self.obj_type == "ms":
l += constants.clone_meta_attributes + constants.ms_meta_attributes
elif self.obj_type == "group":
l += constants.group_meta_attributes
rc = sanity_check_meta(self.obj_id, self.node, l)
Expand All @@ -1722,7 +1720,7 @@ def repr_gv(self, gv_obj, from_grp=False):
"cluster_%s" % self.obj_id)
sg_obj.new_graph_attr('label', self._gv_rsc_id())
self._set_sg_attrs(sg_obj, self.obj_type)
if self.parent and self.parent.obj_type in constants.clonems_tags:
if self.parent and self.parent.obj_type in constants.clone_tags:
self._set_sg_attrs(sg_obj, self.parent.obj_type)
for child_rsc in self.children:
child_rsc.repr_gv(sg_obj, from_grp=True)
Expand Down Expand Up @@ -2283,7 +2281,6 @@ def get_default_timeout():
"primitive": ("primitive", CibPrimitive, "resources"),
"group": ("group", CibContainer, "resources"),
"clone": ("clone", CibContainer, "resources"),
"master": ("ms", CibContainer, "resources"),
"template": ("rsc_template", CibPrimitive, "resources"),
"bundle": ("bundle", CibBundle, "resources"),
"rsc_location": ("location", CibLocation, "constraints"),
Expand Down Expand Up @@ -3086,7 +3083,7 @@ def default_timeouts(self, *args):
implied_actions.remove(op)
elif can_migrate(r_node) and op in implied_migrate_actions:
implied_migrate_actions.remove(op)
elif is_ms_or_promotable_clone(obj.node.getparent()) and op in implied_ms_actions:
elif is_promotable_clone(obj.node.getparent()) and op in implied_ms_actions:
implied_ms_actions.remove(op)
elif op not in other_actions:
continue
Expand All @@ -3100,7 +3097,7 @@ def default_timeouts(self, *args):
l = implied_actions
if can_migrate(r_node):
l += implied_migrate_actions
if is_ms_or_promotable_clone(obj.node.getparent()):
if is_promotable_clone(obj.node.getparent()):
l += implied_ms_actions
for op in l:
adv_timeout = ra.get_op_attr_value(op, "timeout")
Expand Down
2 changes: 1 addition & 1 deletion crmsh/completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def resources(args=None):
rsc_id_list = [x.get("id") for x in nodes if xmlutil.is_resource(x)]
if args:
if args[0] in ('promote', 'demote'):
rsc_id_list = [item for item in rsc_id_list if xmlutil.RscState().is_ms_or_promotable_clone(item)]
rsc_id_list = [item for item in rsc_id_list if xmlutil.RscState().is_promotable_clone(item)]
elif args[0] == "start":
rsc_id_list = [item for item in rsc_id_list if not xmlutil.RscState().is_running(item)]
elif args[0] == "stop":
Expand Down
18 changes: 5 additions & 13 deletions crmsh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"primitive": "primitive",
"group": "group",
"clone": "clone",
"master": "ms",
"bundle": "bundle",
"rsc_location": "location",
"rsc_colocation": "colocation",
Expand All @@ -23,15 +22,15 @@
"tag": "tag",
"alert": "alert",
}
container_tags = ("group", "clone", "ms", "master", "bundle")
clonems_tags = ("clone", "ms", "master")
resource_tags = ("primitive", "group", "clone", "ms", "master", "template", "bundle")
container_tags = ("group", "clone", "bundle")
clone_tags = ("clone", )
resource_tags = ("primitive", "group", "clone", "template", "bundle")
constraint_tags = ("rsc_location", "rsc_colocation", "rsc_order", "rsc_ticket")
constraint_rsc_refs = ("rsc", "with-rsc", "first", "then")
children_tags = ("group", "primitive")
nvpairs_tags = ("meta_attributes", "instance_attributes", "utilization")
defaults_tags = ("rsc_defaults", "op_defaults")
resource_cli_names = ("primitive", "group", "clone", "ms", "master", "rsc_template", "bundle")
resource_cli_names = ("primitive", "group", "clone", "rsc_template", "bundle")
constraint_cli_names = ("location", "colocation", "collocation", "order", "rsc_ticket")
nvset_cli_names = ("property", "rsc_defaults", "op_defaults")
op_cli_names = ("monitor",
Expand Down Expand Up @@ -144,10 +143,6 @@
"clone-max", "clone-node-max", "clone-state", "description",
"clone-min", "promotable", "promoted-max", "promoted-node-max",
)
ms_meta_attributes = common_meta_attributes + (
"clone-max", "clone-node-max", "notify", "globally-unique", "ordered",
"interleave", "master-max", "master-node-max", "description",
)
bundle_meta_attributes = common_meta_attributes
alert_meta_attributes = (
"timeout", "timestamp-format"
Expand Down Expand Up @@ -219,9 +214,6 @@
"clone": {
"color": "#ec008c",
},
"ms": {
"color": "#f8981d",
},
"bundle": {
"color": "#00aeef",
"style": "rounded",
Expand Down Expand Up @@ -447,7 +439,7 @@
DLM_PORT = 21064

# Commands that are deprecated and hidden from UI
HIDDEN_COMMANDS = {'ms'}
HIDDEN_COMMANDS = {}

NO_SSH_ERROR_MSG = "ssh-related operations are disabled. crmsh works in local mode."

Expand Down
18 changes: 7 additions & 11 deletions crmsh/rsctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import sys
from .utils import rmdir_r, quote, this_node, ext_cmd
from .xmlutil import get_topmost_rsc, get_op_timeout, get_child_nvset_node, is_ms_or_promotable_clone, is_cloned
from .xmlutil import get_topmost_rsc, get_op_timeout, get_child_nvset_node, is_promotable_clone, is_cloned
from . import log


Expand Down Expand Up @@ -69,8 +69,8 @@ def info(self, s):
def debug(self, s):
logger.debug("%s: %s", self.id_str(), s)

def is_ms_or_promotable_clone(self):
return is_ms_or_promotable_clone(get_topmost_rsc(self.rscdef_node))
def is_promotable_clone(self):
return is_promotable_clone(get_topmost_rsc(self.rscdef_node))

def nvset2env(self, set_n):
if set_n is None:
Expand Down Expand Up @@ -123,10 +123,6 @@ def is_ok(self, host):
'Was last op successful?'
return self.op_status(host) == self.ec_ok

def is_master(self, host):
'Only if last op was probe/monitor.'
return self.op_status(host) == self.ec_master

def is_stopped(self, host):
'Only if last op was probe/monitor.'
return self.op_status(host) == self.ec_stopped
Expand Down Expand Up @@ -198,7 +194,7 @@ def stop(self, node):
"""
Make sure resource is stopped on node.
"""
if self.is_ms_or_promotable_clone():
if self.is_promotable_clone():
self.runop("demote", (node,))
self.runop("stop", (node,))
ok = self.is_ok(node)
Expand All @@ -212,7 +208,7 @@ def test_resource(self, node):
Perform test of resource on node.
"""
self.runop("start", (node,))
if self.is_ms_or_promotable_clone() and self.is_ok(node):
if self.is_promotable_clone() and self.is_ok(node):
self.runop("promote", (node,))
return self.is_ok(node)

Expand All @@ -230,8 +226,8 @@ def verify_stopped(self, node):
if not stopped:
if self.is_ok(node):
self.warn("resource running at %s" % (node))
elif self.is_ms_or_promotable_clone() and self.is_master(node):
self.warn("resource is master at %s" % (node))
elif self.is_promotable_clone():
self.warn("resource is promoted at %s" % (node))
else:
self.warn("resource not clean at %s" % (node))
self.show_log(node)
Expand Down
2 changes: 0 additions & 2 deletions crmsh/ui_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ def _advanced_completer(args):
return_list = utils.filter_keys(constants.group_meta_attributes, args)
if resource_type == "clone":
return_list = utils.filter_keys(constants.clone_meta_attributes, args)
if resource_type in ["ms", "master"]:
return_list = utils.filter_keys(constants.ms_meta_attributes, args)
return return_list + key_words


Expand Down
6 changes: 3 additions & 3 deletions crmsh/ui_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def do_promote(self, context, rsc):
"usage: promote <rsc>"
if not utils.is_name_sane(rsc):
return False
if not xmlutil.RscState().is_ms_or_promotable_clone(rsc):
if not xmlutil.RscState().is_promotable_clone(rsc):
logger.error("%s is not a promotable resource", rsc)
return False
role = utils.handle_role_for_ocf_1_1(constants.RSC_ROLE_PROMOTED)
Expand Down Expand Up @@ -367,7 +367,7 @@ def do_demote(self, context, rsc):
"usage: demote <rsc>"
if not utils.is_name_sane(rsc):
return False
if not xmlutil.RscState().is_ms_or_promotable_clone(rsc):
if not xmlutil.RscState().is_promotable_clone(rsc):
logger.error("%s is not a promotable resource", rsc)
return False
role = utils.handle_role_for_ocf_1_1(constants.RSC_ROLE_UNPROMOTED)
Expand Down Expand Up @@ -667,7 +667,7 @@ def trace(name):
context.fatal_error("Failed to add trace for %s:%s" % (rsc_id, name))
trace('start')
trace('stop')
if xmlutil.is_ms_or_promotable_clone(rsc.node):
if xmlutil.is_promotable_clone(rsc.node):
trace('promote')
trace('demote')
for op_node in op_nodes:
Expand Down
25 changes: 11 additions & 14 deletions crmsh/xmlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ def rsc2node(self, ident):
except (IndexError, AttributeError):
return None

def is_ms_or_promotable_clone(self, ident):
def is_promotable_clone(self, ident):
'''
Test if the resource is master-slave.
Test if the resource is promotable.
'''
rsc_node = self.rsc2node(ident)
if rsc_node is None:
return False
return is_ms_or_promotable_clone(rsc_node)
return is_promotable_clone(rsc_node)

def rsc_clone(self, ident):
'''
Expand Down Expand Up @@ -560,24 +560,22 @@ def is_attr_set(node, attr):
return get_attr_value(get_child_nvset_node(node), attr) is not None


def is_ms_or_promotable_clone(node):
is_promotable_type = is_boolean_true(is_attr_set(node, "promotable"))
is_ms_type = node.tag in ("master", "ms")
return is_ms_type or is_promotable_type
def is_promotable_clone(node):
return is_boolean_true(is_attr_set(node, "promotable"))


def is_clone(node):
return node.tag == "clone"


def is_clonems(node):
return node.tag in constants.clonems_tags
return node.tag in constants.clone_tags


def is_cloned(node):
return (node.getparent().tag in constants.clonems_tags or
return (node.getparent().tag in constants.clone_tags or
(node.getparent().tag == "group" and
node.getparent().getparent().tag in constants.clonems_tags))
node.getparent().getparent().tag in constants.clone_tags))


def is_container(node):
Expand Down Expand Up @@ -632,7 +630,7 @@ def is_related(rsc_id, node):
return True
return False
if is_container(node):
for tag in ('primitive', 'group', 'clone', 'master'):
for tag in ('primitive', 'group', 'clone'):
if len(node.xpath('.//%s[@id="%s"]' % (tag, rsc_id))) > 0:
return True
return False
Expand Down Expand Up @@ -869,8 +867,7 @@ def make_sort_map(*order):


_sort_xml_order = make_sort_map('node',
'template', 'primitive', 'bundle', 'group', 'master', 'clone', 'op',
'tag',
'template', 'primitive', 'bundle', 'group', 'clone', 'op', 'tag',
['rsc_location', 'rsc_colocation', 'rsc_order'],
['rsc_ticket', 'fencing-topology'],
'cluster_property_set', 'rsc_defaults', 'op_defaults',
Expand All @@ -879,7 +876,7 @@ def make_sort_map(*order):

_sort_cli_order = make_sort_map('node',
'rsc_template', 'primitive', 'bundle', 'group',
['ms', 'master'], 'clone', 'op',
'clone', 'op',
'tag',
['location', 'colocation', 'collocation', 'order'],
['rsc_ticket', 'fencing_topology'],
Expand Down

0 comments on commit 2363162

Please sign in to comment.