def stop(role=None, cli=False, pause=False, unmap=False, **kwargs): if role: try: p = peers[role] except KeyError: raise Error("Invalid peer %s" % role) return stop_peer(p, cli) # check devices if cli: print "====================" print "Stoping archipelago" print "====================" print "" if config["BLKTAP_ENABLED"] and loaded_module('blktap'): mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: if not pause: vlmc_showmapped() print "" if unmap: print red("Mapped volumes exist, unmapping...") try: for m in mapped: vlmc_unmap_volume(m.device) except Error as e: raise Error("Error while umapping volume, during " "shutdown: %s" % e) else: raise Error("Found mapped volumes, cannot stop " "Archipelago") else: for m in mapped: if not VlmcTapdisk.is_paused(m.device): VlmcTapdisk.pause(m.device) mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: vlmc_showmapped() print "" if pause: import operator if not reduce( operator.and_, [VlmcTapdisk.is_paused(m.device) for m in mapped], True): raise Error("Found unpaused volume, cannot stop " "Archipelago") else: raise Error("Found more mapped volumes, cannot stop " "Archipelago") stop_peers(peers, cli) time.sleep(0.5) get_segment().destroy()
def stop(role=None, cli=False, pause=False, unmap=False, **kwargs): if role: try: p = peers[role] except KeyError: raise Error("Invalid peer %s" % role) return stop_peer(p, cli) # check devices if cli: print "====================" print "Stoping archipelago" print "====================" print "" if config["BLKTAP_ENABLED"] and loaded_module('blktap'): mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: if not pause: vlmc_showmapped() print "" if unmap: print red("Mapped volumes exist, unmapping...") try: for m in mapped: vlmc_unmap_volume(m.device) except Error as e: raise Error("Error while umapping volume, during " "shutdown: %s" % e) else: raise Error("Found mapped volumes, cannot stop " "Archipelago") else: for m in mapped: if not VlmcTapdisk.is_paused(m.device): VlmcTapdisk.pause(m.device) mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: vlmc_showmapped() print "" if pause: import operator if not reduce(operator.and_, [VlmcTapdisk.is_paused(m.device) for m in mapped], True): raise Error("Found unpaused volume, cannot stop " "Archipelago") else: raise Error("Found more mapped volumes, cannot stop " "Archipelago") stop_peers(peers, cli) time.sleep(0.5) get_segment().destroy()
def stop(role=None, cli=False, force=False, **kwargs): try: if config['BLKTAP_ENABLED'] is False and vlmc_get_mapped(): vlmc_showmapped() raise Error("Cannot stop archipelago. Mapped volumes exist") except VlmcTapdiskException: pass if role: try: p = peers[role] except KeyError: raise Error("Invalid peer %s" % role) return stop_peer(p, cli) #check devices if cli: print "====================" print "Stoping archipelago" print "====================" print "" if config["BLKTAP_ENABLED"] and loaded_module('blktap'): mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: if not force: vlmc_showmapped() raise Error("Cannot stop archipelago. Mapped volumes exist") for m in mapped: if not VlmcTapdisk.is_paused(m.device): VlmcTapdisk.pause(m.device) stop_peers(peers, cli) time.sleep(0.5) get_segment().destroy()
def start(role=None, cli=False, **kwargs): if role: try: p = peers[role] except KeyError: raise Error("Invalid peer %s" % role) return start_peer(p, cli) if status() > 0: raise Error("Cannot start. Try stopping first") if cli: print "====================" print "Starting archipelago" print "====================" print "" try: #get_segment().create() #time.sleep(0.5) create_posixfd_dirs() start_peers(peers, cli) if config["BLKTAP_ENABLED"]: load_module("blktap", None) mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: for m in mapped: if VlmcTapdisk.is_paused(m.device): VlmcTapdisk.unpause(m.device) except Exception as e: if cli: print red(e) stop(role, cli, force=True)
def status(cli=False, **kwargs): r = 0 if config["BLKTAP_ENABLED"]: if not loaded_module("blktap"): for role, _ in reversed(config['roles']): p = peers[role] if peer_running(p, cli): r += 1 if cli: pretty_print("blktap", red('Not loaded')) return r if cli: if vlmc_showmapped() > 0: r += 1 else: mapped = vlmc_get_mapped() if mapped and len(mapped) > 0: for m in mapped: if not VlmcTapdisk.is_paused(m.device): r += 1 if loaded_module("blktap"): if cli: pretty_print("blktap", green('Loaded')) #r += 1 else: if cli: pretty_print("blktap", red('Not loaded')) for role, _ in reversed(config['roles']): p = peers[role] if peer_running(p, cli): r += 1 try: if config['BLKTAP_ENABLED'] is False and vlmc_get_mapped(): print red("Mapped volumes exist while blktap module is disabled.") vlmc_showmapped() r += 1 except VlmcTapdiskException: pass return r