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 ab11ccf
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 72 deletions.
26 changes: 11 additions & 15 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 @@ -676,7 +676,6 @@ def fix_node_ids(node, oldnode):
'node': 'node',
'primitive': 'rsc',
'template': 'rsc',
'master': 'grp',
'group': 'grp',
'clone': 'grp',
'rsc_location': 'location',
Expand Down Expand Up @@ -940,7 +939,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 +1643,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 +1668,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 +1687,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 +1703,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 +1719,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 +2280,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 @@ -2966,7 +2962,7 @@ def fence_id_list_without_pcmk_delay(self):
return [_id for _id in self.fence_id_list() if _id not in self.fence_id_list_with_pcmk_delay()]

def children_id_list(self):
"List of child ids (for clone/master completion)."
"List of child ids (for clone completion)."
return [x.obj_id for x in self.cib_objects if x.obj_type in constants.children_tags]

def rsc_id_list(self):
Expand Down Expand Up @@ -3006,7 +3002,7 @@ def rsc_template_list(self):
if x.obj_type == "rsc_template"]

def f_children_id_list(self):
"List of possible child ids (for clone/master completion)."
"List of possible child ids (for clone completion)."
return [x.obj_id for x in self.cib_objects
if x.obj_type in constants.children_tags and not x.parent]

Expand Down Expand Up @@ -3086,7 +3082,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 +3096,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 Expand Up @@ -3789,7 +3785,7 @@ def _add_element(self, obj, node):
def _add_children(self, obj_type, node):
"""
Called from create_from_node
In case this is a clone/group/master create from XML,
In case this is a clone/group create from XML,
and the child node(s) haven't been added as a separate objects.
"""
if obj_type not in constants.container_tags:
Expand Down
6 changes: 2 additions & 4 deletions crmsh/cmd_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
'Stopped',
'standby',
'WITHOUT quorum']
_OKS = ['Masters', 'Slaves', 'Started', 'Master', 'Slave', 'Online', 'online', 'ok', 'master',
'with quorum']
_OKS = ['Masters', 'Slaves', 'Started', 'Master', 'Slave', 'Online', 'online', 'ok', 'with quorum']
_ERRORS = ['not running',
'unknown error',
'invalid parameter',
Expand All @@ -30,13 +29,12 @@
'not installed',
'not configured',
'not running',
r'master \(failed\)',
'OCF_SIGNAL',
'OCF_NOT_SUPPORTED',
'OCF_TIMEOUT',
'OCF_OTHER_ERROR',
'OCF_DEGRADED',
'OCF_DEGRADED_MASTER',
'OCF_DEGRADED_PROMOTED',
'unknown',
'Unknown',
'OFFLINE',
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
22 changes: 7 additions & 15 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 @@ -114,8 +113,8 @@
"installed": "5",
"configured": "6",
"not_running": "7",
"master": "8",
"failed_master": "9",
"promoted": "8",
"failed_promoted": "9",
}
lrm_status_codes = {
"pending": "-1",
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
2 changes: 1 addition & 1 deletion crmsh/logparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def __init__(self, report_path):
for grp in cib_elem.xpath("/cib/configuration/resources/group"):
self.groups[grp.get("id")] = xmlutil.get_rsc_children_ids(grp)

for cln in cib_elem.xpath("/cib/configuration/resources/*[self::clone or self::master]"):
for cln in cib_elem.xpath("/cib/configuration/resources/*[self::clone]"):
self.clones[cln.get("id")] = xmlutil.get_prim_children_ids(cln)
self.cloned_resources.union(self.clones[cln.get("id")])

Expand Down
30 changes: 13 additions & 17 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 @@ -45,7 +45,7 @@ def __init__(self, rsc_node, nodes):
self.ec_l = {}
self.ec_ok = self.unused
self.ec_stopped = self.unused
self.ec_master = self.unused
self.ec_promoted = self.unused
self.last_op = None
self.last_rec = {}
self.timeout = 20000
Expand All @@ -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 All @@ -251,14 +247,14 @@ class RAOCF(RADriver):
OCF_ERR_INSTALLED = 5
OCF_ERR_CONFIGURED = 6
OCF_NOT_RUNNING = 7
OCF_RUNNING_MASTER = 8
OCF_FAILED_MASTER = 9
OCF_RUNNING_PROMOTED = 8
OCF_FAILED_PROMOTED = 9

def __init__(self, *args):
RADriver.__init__(self, *args)
self.ec_ok = self.OCF_SUCCESS
self.ec_stopped = self.OCF_NOT_RUNNING
self.ec_master = self.OCF_RUNNING_MASTER
self.ec_promoted = self.OCF_RUNNING_PROMOTED

def set_rscenv(self, op):
RADriver.set_rscenv(self, op)
Expand Down Expand Up @@ -295,7 +291,7 @@ def __init__(self, *args):
RADriver.__init__(self, *args)
self.ec_ok = self.LSB_OK
self.ec_stopped = self.LSB_STATUS_NOT_RUNNING
self.ec_master = self.unused
self.ec_promoted = self.unused

def set_rscenv(self, op):
RADriver.set_rscenv(self, op)
Expand Down Expand Up @@ -323,7 +319,7 @@ def __init__(self, *args):
RADriver.__init__(self, *args)
self.ec_ok = self.SYSD_OK
self.ec_stopped = self.SYSD_NOT_RUNNING
self.ec_master = self.unused
self.ec_promoted = self.unused

def set_rscenv(self, op):
RADriver.set_rscenv(self, op)
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
Loading

0 comments on commit ab11ccf

Please sign in to comment.