def remove_levels_by_params( reporter, topology_el, level=None, target_type=None, target_value=None, devices=None, ignore_if_missing=False ): """ Remove specified fencing level(s). Raise LibraryError if not found. object reporter -- report processor etree topology_el -- etree element to remove the levels from int|string level -- level (index) of the new fencing level constant target_type -- the new fencing level target value type mixed target_value -- the new fencing level target value Iterable devices -- list of stonith devices for the new fencing level bool ignore_if_missing -- when True, do not raise if level not found """ if target_type: _validate_target_typewise(reporter, target_type) reporter.send() level_el_list = _find_level_elements( topology_el, level, target_type, target_value, devices ) if not level_el_list: if ignore_if_missing: return reporter.process(reports.fencing_level_does_not_exist( level, target_type, target_value, devices )) for el in level_el_list: el.getparent().remove(el)
def remove_levels_by_params(reporter, topology_el, level=None, target_type=None, target_value=None, devices=None, ignore_if_missing=False): """ Remove specified fencing level(s). Raise LibraryError if not found. object reporter -- report processor etree topology_el -- etree element to remove the levels from int|string level -- level (index) of the new fencing level constant target_type -- the new fencing level target value type mixed target_value -- the new fencing level target value Iterable devices -- list of stonith devices for the new fencing level bool ignore_if_missing -- when True, do not raise if level not found """ if target_type: _validate_target_typewise(reporter, target_type) reporter.send() level_el_list = _find_level_elements(topology_el, level, target_type, target_value, devices) if not level_el_list: if ignore_if_missing: return reporter.process( reports.fencing_level_does_not_exist(level, target_type, target_value, devices)) for el in level_el_list: el.getparent().remove(el)
def remove_levels_by_params( topology_el, level=None, target_type=None, target_value=None, devices=None, ignore_if_missing=False, ) -> ReportItemList: """ Remove specified fencing level(s) etree topology_el -- etree element to remove the levels from int|string level -- level (index) of the fencing level to remove constant target_type -- the removed fencing level target value type mixed target_value -- the removed fencing level target value Iterable devices -- list of stonith devices of the removed fencing level bool ignore_if_missing -- when True, do not report if level not found """ # Do not ever remove a fencing-topology element, even if it is empty. There # may be ACLs set in pacemaker which allow "write" for fencing-level # elements (adding, changing and removing) but not fencing-topology # elements. In such a case, removing a fencing-topology element would cause # the whole change to be rejected by pacemaker with a "permission denied" # message. # https://bugzilla.redhat.com/show_bug.cgi?id=1642514 report_list: ReportItemList = [] if target_type: report_list.extend(_validate_target_typewise(target_type)) if has_errors(report_list): return report_list level_el_list = _find_level_elements(topology_el, level, target_type, target_value, devices) if not level_el_list: if ignore_if_missing: return report_list report_list.append( reports.fencing_level_does_not_exist(level, target_type, target_value, devices)) if has_errors(report_list): return report_list for el in level_el_list: el.getparent().remove(el) return report_list