def run(self, args): m = MountbrokerUserMgmt(GLUSTERD_VOLFILE) volume = None if args.volume == "." else args.volume user = None if args.user == "." else args.user m.remove(volume=volume, user=user) m.save() node_output_ok()
def run(self, args): # Regenerate if secret.pem.pub not exists if not os.path.exists(SECRET_PEM + ".pub"): # Cleanup old files for f in glob.glob(SECRET_PEM + "*"): os.remove(f) execute(["ssh-keygen", "-N", "", "-f", SECRET_PEM]) # Regenerate if ssh_tar.pem.pub not exists if not os.path.exists(TAR_SSH_PEM + ".pub"): # Cleanup old files for f in glob.glob(TAR_SSH_PEM + "*"): os.remove(f) execute(["ssh-keygen", "-N", "", "-f", TAR_SSH_PEM]) # Add required prefixes if prefix is not "container" prefix_secret_pem_pub = "" prefix_tar_ssh_pem_pub = "" if args.no_prefix != "no-prefix": prefix_secret_pem_pub = GSYNCD_CMD prefix_tar_ssh_pem_pub = TAR_CMD data = {"default_pub": "", "tar_pub": ""} with open(SECRET_PEM + ".pub") as f: data["default_pub"] = prefix_secret_pem_pub + f.read().strip() with open(TAR_SSH_PEM + ".pub") as f: data["tar_pub"] = prefix_tar_ssh_pem_pub + f.read().strip() node_output_ok(data)
def run(self, args): m = MountbrokerUserMgmt(GLUSTERD_VOLFILE) grp = m.get_group() if grp is None: node_output_notok("Group is not available") m.add(args.volume, args.user) m.save() node_output_ok()
def run(self, args): http_headers = {} hashval = "" if args.bearer_token != ".": hashval = args.bearer_token if args.secret != ".": hashval = get_jwt_token(args.secret, "TEST", int(time.time())) if hashval: http_headers["Authorization"] = "Bearer " + hashval urldata = requests.utils.urlparse(args.url) parts = urldata.netloc.split(":") domain = parts[0] # Default https port if not specified port = 443 if len(parts) == 2: port = int(parts[1]) cert_path = os.path.join(CERTS_DIR, args.url.replace("/", "_").strip()) verify = True while True: try: resp = requests.post(args.url, headers=http_headers, verify=verify) # Successful webhook push break except requests.exceptions.SSLError as e: # If verify is equal to cert path, but still failed with # SSLError, Looks like some issue with custom downloaded # certificate, Try with verify = false if verify == cert_path: verify = False continue # If verify is instance of bool and True, then custom cert # is required, download the cert and retry try: save_https_cert(domain, port, cert_path) verify = cert_path except Exception: verify = False # Done with collecting cert, continue continue except Exception as e: node_output_notok("{0}".format(e)) break if resp.status_code != 200: node_output_notok("{0}".format(resp.status_code)) node_output_ok()
def run(self, args): http_headers = {} if args.bearer_token != ".": http_headers["Authorization"] = "Bearer " + args.bearer_token try: resp = requests.post(args.url, headers=http_headers) except requests.ConnectionError as e: node_output_notok("{0}".format(e)) if resp.status_code != 200: node_output_notok("{0}".format(resp.status_code)) node_output_ok()
def run(self, args): m = MountbrokerUserMgmt(GLUSTERD_VOLFILE) data = m.info() data["group_exists"] = False data["path_exists"] = False rc, out, err = execute( ["getent", "group", data["geo-replication-log-group"]]) if rc == 0: data["group_exists"] = True if os.path.exists(data["mountbroker-root"]): data["path_exists"] = True node_output_ok(data)
def run(self, args): m = MountbrokerUserMgmt(GLUSTERD_VOLFILE) try: os.makedirs(args.mount_root) except OSError as e: if e.errno == EEXIST: pass else: node_output_notok("Unable to Create {0}".format( args.mount_root)) execute(["chmod", "0711", args.mount_root]) try: execute( ["semanage", "fcontext", "-a", "-e", "/home", args.mount_root]) except OSError as e: if e.errno == ENOENT: pass else: node_output_notok("Unable to run semanage: {0}".format(e)) try: execute(["restorecon", "-Rv", args.mount_root]) except OSError as e: if e.errno == ENOENT: pass else: node_output_notok("Unable to run restorecon: {0}".format(e)) rc, out, err = execute(["getent", "group", args.group]) if rc != 0: node_output_notok("User Group not exists") execute(["chgrp", "-R", args.group, GEOREP_DIR]) execute(["chgrp", "-R", args.group, LOG_DIR]) execute(["chmod", "-R", "770", GEOREP_DIR]) execute(["chmod", "-R", "770", args.group, LOG_DIR]) m.set_mount_root_and_group(args.mount_root, args.group) m.save() node_output_ok()
def run(self, args): http_headers = {} hashval = "" if args.bearer_token != ".": hashval = args.bearer_token if args.secret != ".": hashval = get_jwt_token(args.secret, "TEST", int(time.time())) if hashval: http_headers["Authorization"] = "Bearer " + hashval try: resp = requests.post(args.url, headers=http_headers) except requests.ConnectionError as e: node_output_notok("{0}".format(e)) except requests.exceptions.InvalidSchema as e: node_output_notok("{0}".format(e)) if resp.status_code != 200: node_output_notok("{0}".format(resp.status_code)) node_output_ok()
def run(self, args): node_output_ok("UP" if is_active() else "DOWN")
def node_output_handle(resp): rc, out, err = resp if rc == 0: node_output_ok(out) else: node_output_notok(err)