def cli(ctx): """View Ultron8 node information.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("View Ultron8 node information")
def setup(ctx, cluster_url): """Cmd to setup workspace etc for ultron8.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("cluster setup subcommand")
def cli(ctx): """cluster cmds for ultron8.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("cluster subcommand called from cli")
def list(ctx, output): """list command for users""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() ctx.obj["user"]["output"] = output click.secho("user list subcommand", fg=colors.COLOR_SUCCESS) # Run API call response = ctx.obj["client"]._get_users() # Output values click.secho("response: \n\n", fg=colors.COLOR_SUCCESS) if ctx.obj["user"]["output"] == "table": data = [user_results_to_list(i) for i in response] tt.print( data, header=TERMTABLES_HEADER, style=tt.styles.double, ) else: pp.pprint(response) click.secho("\n\n", fg=colors.COLOR_SUCCESS)
def show(ctx): """Show Ultron8 node information""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("node show subcommand")
def cli(ctx): """Interact with workspace for ultron8.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("workspace subcommand called from cli") ctx.obj["workspace"].setup()
def cli(ctx): """Get version of running Ultron8 process.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("info subcommand called from cli") _version()
def tree(ctx): """Tree command for Workspace""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("tree show subcommand") ctx.obj["workspace"].tree()
def cli(ctx, fact: Tuple[str]): """Get info on running Ultron8 process.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("info subcommand called from cli") set_fact_flags(fact) _info()
def cli(ctx): """init cmd to setup workspace etc for ultron8.""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("init subcommand called from cli") ctx.obj["workspace"].setup()
def show(ctx): """show command for connecting to a cluster""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() click.secho("metrics show subcommand", fg=colors.COLOR_SUCCESS) response = ctx.obj["client"]._get_metrics() click.secho("response: {}\n".format(response), fg=colors.COLOR_SUCCESS)
def token(ctx): """token command for connecting to a cluster""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() click.secho("login token subcommand", fg=colors.COLOR_SUCCESS) response = ctx.obj["client"]._post_login_access_token( ctx.obj["login"]["email"], ctx.obj["login"]["password"] ) click.secho("response: {}\n".format(response), fg=colors.COLOR_SUCCESS)
def info(ctx): """Info on workspace""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() logger.debug("workspace infosubcommand") click.echo("--------------------------------") click.echo("-------[Workspace Info]---------") click.echo("--------------------------------") click.echo("Root: {}".format(ctx.obj["workspace"]._root)) click.echo("Api: {}".format(ctx.obj["workspace"].api)) click.echo("Workdir: {}".format(ctx.obj["workspace"]._wdir)) click.echo("Libdir: {}".format(ctx.obj["workspace"]._lib_dir)) click.echo("Templatedir: {}".format(ctx.obj["workspace"]._template_dir))
def cli(ctx): """ Dummy command, doesn't do anything. """ if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() if ctx.obj["debug"]: click.echo("[DUMP ctx]: ") for k, v in ctx.obj.items(): click.echo(f" {k} -> {v}") click.echo("Dummy command, doesn't do anything.") if ctx.obj["verbose"] > 0: click.echo("Ran [{}]| test".format(sys._getframe().f_code.co_name))
def create(ctx, payload, output): """create user from payload""" if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() click.secho("user create subcommand", fg=colors.COLOR_SUCCESS) ctx.obj["user"]["output"] = output source = json.load(payload) click.secho("Data loaded: \n\n", fg=colors.COLOR_SUCCESS) click.secho("{}".format(source), fg=colors.COLOR_SUCCESS) # data = UserCreate(email=source["email"], password=source["password"]) data = {"email": source["email"], "password": source["password"]} json_compatible_data = jsonable_encoder(data) click.secho("data: \n\n", fg=colors.COLOR_SUCCESS) click.secho("{}".format(data), fg=colors.COLOR_SUCCESS) # Run API call response = ctx.obj["client"]._post_create_user(json_compatible_data) # Output values click.secho("response: \n\n", fg=colors.COLOR_SUCCESS) if ctx.obj["user"]["output"] == "table": data = [user_results_to_list(i) for i in response] tt.print( data, header=TERMTABLES_HEADER, style=tt.styles.double, ) else: pp.pprint(response) click.secho("\n\n", fg=colors.COLOR_SUCCESS)
def cli(ctx, cluster): """ Metrics CLI. Used to interact with ultron8 api. """ if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() args = {} ctx.obj["metrics"] = args ctx.obj["metrics"]["cluster"] = cluster.lower() ctx.obj["client"].set_api_endpoint( ctx.obj["configmanager"].data["clusters"]["instances"][ ctx.obj["metrics"]["cluster"]]["url"]) ctx.obj["client"].jwt_token = ctx.obj["configmanager"].data["clusters"][ "instances"][ctx.obj["metrics"]["cluster"]]["token"] click.secho( "Client endpoints: {}\n".format(ctx.obj["client"].endpoints), fg=colors.COLOR_SUCCESS, ) if ctx.obj["debug"]: click.secho( "Cluster: {}\n".format(ctx.obj["metrics"]["cluster"]), fg=colors.COLOR_SUCCESS, ) click.secho( "Cluster url: {}\n".format(ctx.obj["client"].api_endpoint), fg=colors.COLOR_SUCCESS, ) click.secho( "Token: {}\n".format(ctx.obj["client"].jwt_token), fg=colors.COLOR_SUCCESS, )
def cli(ctx, cluster, email, password): """ Login CLI. Used to interact with ultron8 api. """ if ctx.obj["debug"]: click.echo("Debug mode initiated") set_trace() args = {} ctx.obj["login"] = args ctx.obj["login"]["cluster"] = cluster ctx.obj["login"]["email"] = email ctx.obj["login"]["password"] = password ctx.obj["client"].set_api_endpoint( ctx.obj["configmanager"].data["clusters"]["instances"][ ctx.obj["login"]["cluster"] ]["url"] ) click.secho( "Client endpoints: {}\n".format(ctx.obj["client"].endpoints), fg=colors.COLOR_SUCCESS, ) if ctx.obj["debug"]: click.secho( "User: {}\n".format(ctx.obj["login"]["email"]), fg=colors.COLOR_SUCCESS ) click.secho( "Cluster: {}\n".format(ctx.obj["login"]["cluster"]), fg=colors.COLOR_SUCCESS ) click.secho( "Cluster url: {}\n".format(ctx.obj["client"].api_endpoint), fg=colors.COLOR_SUCCESS, )