Skip to content

Commit

Permalink
Dev: ui_resource: Add warning if detect maintenance-mode is true whil…
Browse files Browse the repository at this point in the history
…e start/stop/add RA
  • Loading branch information
liangxin1300 committed Aug 6, 2021
1 parent 18f9a8c commit e7bdd8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crmsh/ui_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,8 @@ def do_primitive(self, context, *args):
tmp.remove(item)
tmp.insert(idx, "monitor")
tmp.insert(idx+1, "role=%s" % item.split('_')[1])
if utils.is_in_maintenance():
context.warning("Cluster now is in maintenance mode")
return self.__conf_object(context.get_command_name(), *tuple(tmp))

@command.completers_repeating(compl.attr_id, _container_type, container_complete_complex)
Expand Down
2 changes: 2 additions & 0 deletions crmsh/ui_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def _commit_meta_attrs(self, context, resources, name, value):
commit = not cib_factory.has_cib_changed()
if not commit:
context.info("Currently editing the CIB, changes will not be committed")
if utils.is_in_maintenance():
context.warning("Cluster now is in maintenance mode")

rc = True
for rsc in resources:
Expand Down
8 changes: 8 additions & 0 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2896,4 +2896,12 @@ def detect_virt():
"""
rc, _, _ = get_stdout_stderr("systemd-detect-virt")
return rc == 0


def is_in_maintenance():
"""
Detect if maintenance-mode is true
"""
from .cibconfig import cib_factory
return is_boolean_true(cib_factory.get_property_w_default("maintenance-mode"))
# vim:ts=4:sw=4:et:

0 comments on commit e7bdd8b

Please sign in to comment.