def unconfigure_target_store(uuid): try: target = _get_target_config(uuid) os.rmdir(target['mntpt']) except KeyError: console_log.warn("Cannot retrieve target information") except IOError: console_log.warn("Cannot remove target mount folder: %s" % target['mntpt']) config.delete('targets', uuid)
def unconfigure_target_store(uuid): """ Remove target directory and config store for given uuid. :param uuid: UUID identifying target """ try: target = _get_target_config(uuid) os.rmdir(target["mntpt"]) except KeyError: console_log.warn("Cannot retrieve target information") except IOError: console_log.warn("Cannot remove target mount folder: %s", target["mntpt"]) config.delete("targets", uuid)
def _configure_target_priority(primary, ha_label, node): if primary: score = "20" else: score = "10" name = _constraint(ha_label, primary) result = AgentShell.run( ['pcs', 'constraint', 'location', 'add', name, ha_label, node, score]) if result.rc == 76: console_log.warn("A constraint with the name %s already exists", name) result.rc = 0 return result
def _configure_target_priority(primary, ha_label, node): if primary: score = "20" else: score = "10" name = _constraint(ha_label, primary) constraint = ET.Element( "rsc_location", {"id": name, "node": node, "rsc": ha_label, "score": score} ) result = cibcreate("constraints", ET.tostring(constraint)) if result.rc == errno.ENOTUNIQ: console_log.warn("A constraint with the name %s already exists", name) result = AgentShell.RunResult(0, result.stdout, result.stderr, result.timeout) return result
def clear_targets(force=False): if not force: from os import _exit import textwrap warning = """ clear-targets will forcibly unmount and unconfigure all Lustre targets on EVERY node in this HA domain. This is an irreversible and potentially very destructive operation. Data loss may occur. Please do not use it unless you fully understand the consequences! If you are sure that this command does what you intend to do, then you must supply the --force flag to avoid seeing this message. """ console_log.warn(textwrap.fill(textwrap.dedent(warning))) _exit(1) for resource, attrs in _query_ha_targets().items(): console_log.info("Stopping %s" % resource) stop_target(attrs['ha_label']) console_log.info("Unconfiguring %s" % resource) unconfigure_target_ha(True, attrs['ha_label'], attrs['uuid'])