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) 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 node_output_handle(resp): rc, out, err = resp if rc == 0: node_output_ok(out) else: node_output_notok(err)