From 2afd0644452e0dba205dd00611caa6dbe9d08855 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Dec 2023 01:53:33 -0500 Subject: [PATCH] Update CLI to read from pvc.conf --- client-cli/pvc/cli/cli.py | 4 ++-- client-cli/pvc/cli/helpers.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client-cli/pvc/cli/cli.py b/client-cli/pvc/cli/cli.py index 6967cad1..25340996 100644 --- a/client-cli/pvc/cli/cli.py +++ b/client-cli/pvc/cli/cli.py @@ -5960,8 +5960,8 @@ def cli( "PVC_COLOUR": Force colour on the output even if Click determines it is not a console (e.g. with 'watch') If a "-c"/"--connection"/"PVC_CONNECTION" is not specified, the CLI will attempt to read a "local" connection - from the API configuration at "/etc/pvc/pvcapid.yaml". If no such configuration is found, the command will - abort with an error. This applies to all commands except those under "connection". + from the API configuration at "/etc/pvc/pvc.conf". If no such configuration is found, the command will abort + with an error. This applies to all commands except those under "connection". """ global CLI_CONFIG diff --git a/client-cli/pvc/cli/helpers.py b/client-cli/pvc/cli/helpers.py index c7371110..6753a1e4 100644 --- a/client-cli/pvc/cli/helpers.py +++ b/client-cli/pvc/cli/helpers.py @@ -40,7 +40,7 @@ import pvc.lib.vm import pvc.lib.node -DEFAULT_STORE_DATA = {"cfgfile": "/etc/pvc/pvcapid.yaml"} +DEFAULT_STORE_DATA = {"cfgfile": "/etc/pvc/pvc.conf"} DEFAULT_STORE_FILENAME = "pvc.json" DEFAULT_API_PREFIX = "/api/v1" DEFAULT_NODE_HOSTNAME = gethostname().split(".")[0] @@ -88,14 +88,15 @@ def read_config_from_yaml(cfgfile): try: with open(cfgfile) as fh: - api_config = yload(fh, Loader=BaseLoader)["pvc"]["api"] + api_config = yload(fh, Loader=BaseLoader)["api"] - host = api_config["listen_address"] - port = api_config["listen_port"] - scheme = "https" if strtobool(api_config["ssl"]["enabled"]) else "http" + host = api_config["listen"]["address"] + port = api_config["listen"]["port"] + scheme = "https" if api_config["ssl"]["enabled"] else "http" api_key = ( - api_config["authentication"]["tokens"][0]["token"] - if strtobool(api_config["authentication"]["enabled"]) + api_config["token"][0]["token"] + if api_config["authentication"]["enabled"] + and api_config["authentication"]["source"] == "token" else None ) except KeyError: