def _convert_agentstore_config(): server_conf_path = os.path.join(config.path, "server_conf") if os.path.exists(server_conf_path): with open(server_conf_path) as f: old_server_conf = json.load(f) set_server_url(old_server_conf.get("url").replace("/agent/", "/")) os.unlink(server_conf_path) else: try: url = config.get("settings", "server").get("url").replace("/agent/", "/") set_server_url(url) config.delete("settings", "server") except (KeyError, TypeError): pass crypto_files = map( lambda x: (os.path.join(config.path, x), os.path.join(ENV_PATH, x)), ["authority.crt", "private.pem", "self.crt"], ) map(lambda x: migrate_file(*x), crypto_files) uuid_re = re.compile( r"[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12}") for entry in os.listdir(config.path): if uuid_re.match(entry): target_conf_path = os.path.join(config.path, entry) with open(target_conf_path) as f: old_target_conf = json.load(f) config.set("targets", entry, old_target_conf) os.unlink(target_conf_path)
def unconfigure_copytool(id): try: # It's OK to do this before unconfiguring, but we should make sure # it always happens regardless. stop_monitored_copytool(id) except Exception as e: # FIXME: do this once the monitoring stuff is complete raise e config.delete("copytools", id) return id
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 deregister_server(): config.delete('settings', 'server') def disable_and_kill(): console_log.info("Disabling chroma-agent service") _disable_service() console_log.info("Terminating") os._exit(0) raise CallbackAfterResponse(None, disable_and_kill)
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)