Exemple #1
0
def main(args):
    """ Create, remove user or enable authentication for etcd - depending on the input argument """
    eis_integ.init_logger()

    os.environ[
        "ETCDCTL_ENDPOINTS"] = "https://" + eis_integ.extract_etcd_endpoint()

    eis_integ.check_path_variable("ETCDCTL_CACERT",
                                  os.environ.get("ETCDCTL_CACERT"))
    eis_integ.check_path_variable("ETCDCTL_CERT",
                                  os.environ.get("ETCDCTL_CERT"))
    eis_integ.check_path_variable("ETCDCTL_KEY", os.environ.get("ETCDCTL_KEY"))

    if args.auth:
        print(
            "Enable authentication for etcd. Create root user with root role.")
        eis_integ.enable_etcd_auth(args.auth)
    elif args.create:
        print("Create etcd {} user and role for application.".format(
            args.create))
        eis_integ.create_etcd_users(args.create)
    elif args.remove:
        print("Remove the {} role and user from the etcd.".format(args.remove))
        eis_integ.remove_user_privilege(args.remove)
        eis_integ.remove_user(args.remove)

    return eis_integ.CODES.NO_ERROR
Exemple #2
0
def main(args):
    """ Calls the eis_integ.etcd_put_json function to add the contents of the json file
        to the etcd database """
    eis_integ.init_logger()

    os.environ["ETCDCTL_ENDPOINTS"] = "https://" + eis_integ.extract_etcd_endpoint()

    eis_integ.check_path_variable("ETCDCTL_CACERT", os.environ.get("ETCDCTL_CACERT"))
    eis_integ.check_path_variable("ETCDCTL_CERT", os.environ.get("ETCDCTL_CERT"))
    eis_integ.check_path_variable("ETCDCTL_KEY", os.environ.get("ETCDCTL_KEY"))

    print("Update the etcd database or add {} file contents to the etcd database".format(args.arg))
    eis_integ.etcd_put_json(eis_integ.load_json(args.arg))
    return eis_integ.CODES.NO_ERROR
Exemple #3
0
def main(args):
    eis_integ.init_logger()

    os.environ[
        "ETCDCTL_ENDPOINTS"] = "https://" + eis_integ.extract_etcd_endpoint()

    eis_integ.check_path_variable("ETCDCTL_CACERT",
                                  os.environ.get("ETCDCTL_CACERT"))
    eis_integ.check_path_variable("ETCDCTL_CERT",
                                  os.environ.get("ETCDCTL_CERT"))
    eis_integ.check_path_variable("ETCDCTL_KEY", os.environ.get("ETCDCTL_KEY"))

    print("Remove all {} app related content from etcd database".format(
        args.arg))
    eis_integ.remove_eis_app(args.app, args.delete_keys)
    return eis_integ.CODES.NO_ERROR
Exemple #4
0
def main(args):
    """ Calls the eis_integ.etcd_put_json function to add the contents of the json file
        to the etcd database """
    eis_integ.init_logger()

    os.environ["ETCDCTL_ENDPOINTS"] = "https://" + \
        eis_integ.extract_etcd_endpoint()

    eis_integ.check_path_variable("ETCDCTL_CACERT",
                                  os.environ.get("ETCDCTL_CACERT"))
    eis_integ.check_path_variable("ETCDCTL_CERT",
                                  os.environ.get("ETCDCTL_CERT"))
    eis_integ.check_path_variable("ETCDCTL_KEY", os.environ.get("ETCDCTL_KEY"))

    logging.info(
        "Generate ZMQ pair keys for {} and put them to the etcd database".
        format(args.app))

    eis_integ.put_zmqkeys(args.app)
    return eis_integ.CODES.NO_ERROR