Martin Sivák has uploaded a new change for review. Change subject: Lockspace reset tool support ......................................................................
Lockspace reset tool support Change-Id: I1c9d1c329ad56f288aac50077411778f99d194f0 Signed-off-by: Martin Sivak <[email protected]> --- M ovirt_hosted_engine_ha/client/client.py 1 file changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha refs/changes/94/38494/1 diff --git a/ovirt_hosted_engine_ha/client/client.py b/ovirt_hosted_engine_ha/client/client.py index 8fce979..c418888 100644 --- a/ovirt_hosted_engine_ha/client/client.py +++ b/ovirt_hosted_engine_ha/client/client.py @@ -18,6 +18,8 @@ # import logging +import os.path +import sanlock from ..agent import constants as agent_constants from ..env import config @@ -256,3 +258,48 @@ else: raise Exception("Invalid maintenance mode: {0}".format(mode)) + + def reset_lockspace(self, force=False): + # Lockspace file + lockspace_file = None + + # Service names + lockspace = (constants.SERVICE_TYPE + + agent_constants.LOCKSPACE_EXTENSION) + service = (constants.SERVICE_TYPE + + agent_constants.MD_EXTENSION) + + # Connect to a broker and read all stats + if self._config is None: + self._config = config.Config() + broker = brokerlink.BrokerLink() + + with broker.connection(): + self._configure_broker_conn(broker) + stats = broker.get_stats_from_storage(service) + lockspace_file = broker.get_service_path(lockspace) + + # Process raw stats + try: + all_stats = self._parse_stats(stats, self.StatModes.ALL) + self._check_liveness_for_stats(all_stats, broker) + except Exception as ex: + self._log.exception(ex) + all_stats = {} + + # Check whether it is safe to perform lockfile reset + for id, stats in all_stats.iteritems(): + if id == 0: + if (not force and + not stats.get(self.GlobalMdFlags.MAINTENANCE, False)): + raise Exception("Lockfile reset can be performed in" + " global maintenance mode only.") + else: + if not force and not stats.get("stopped", False): + raise Exception("Lockfile reset cannot be performed with" + " an active agent.") + + if os.path.exists(lockspace_file): + sanlock.write_lockspace(lockspace=constants.SERVICE_TYPE, + path=lockspace_file, + offset=0) -- To view, visit https://gerrit.ovirt.org/38494 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1c9d1c329ad56f288aac50077411778f99d194f0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-ha Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
