mirror of
https://github.com/craigerl/aprsd.git
synced 2025-06-24 21:15:18 -04:00
Change how fetch-stats gets it's defaults
The defaults come from the aprsd.conf CONF attributes now.
This commit is contained in:
parent
cbef93b327
commit
5383b698ea
@ -4,7 +4,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from click_params import IP_ADDRESS
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
@ -25,33 +24,39 @@ CONF = cfg.CONF
|
|||||||
@cli.command()
|
@cli.command()
|
||||||
@cli_helper.add_options(cli_helper.common_options)
|
@cli_helper.add_options(cli_helper.common_options)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--ip-address", type=IP_ADDRESS,
|
"--host", type=str,
|
||||||
default=CONF.rpc_settings.ip,
|
default=None,
|
||||||
help="IP address of the remote aprsd server to fetch stats from.",
|
help="IP address of the remote aprsd server to fetch stats from.",
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--port", type=int,
|
"--port", type=int,
|
||||||
default=CONF.rpc_settings.port,
|
default=None,
|
||||||
help="Port of the remote aprsd server rpc port to fetch stats from.",
|
help="Port of the remote aprsd server rpc port to fetch stats from.",
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--magic-word", type=str,
|
"--magic-word", type=str,
|
||||||
default=CONF.rpc_settings.magic_word,
|
default=None,
|
||||||
help="Magic word of the remote aprsd server rpc port to fetch stats from.",
|
help="Magic word of the remote aprsd server rpc port to fetch stats from.",
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@cli_helper.process_standard_options
|
@cli_helper.process_standard_options
|
||||||
def fetch_stats(ctx, ip_address, port, magic_word):
|
def fetch_stats(ctx, host, port, magic_word):
|
||||||
"""Fetch stats from a remote running instance of aprsd server."""
|
"""Fetch stats from a remote running instance of aprsd server."""
|
||||||
LOG.info(f"APRSD Fetch-Stats started version: {aprsd.__version__}")
|
LOG.info(f"APRSD Fetch-Stats started version: {aprsd.__version__}")
|
||||||
|
|
||||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||||
|
if not host:
|
||||||
|
host = CONF.rpc_settings.ip
|
||||||
|
if not port:
|
||||||
|
port = CONF.rpc_settings.port
|
||||||
|
if not magic_word:
|
||||||
|
magic_word = CONF.rpc_settings.magic_word
|
||||||
|
|
||||||
msg = f"Fetching stats from {ip_address}:{port} with magic word '{magic_word}'"
|
msg = f"Fetching stats from {host}:{port} with magic word '{magic_word}'"
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
|
console.print(msg)
|
||||||
with console.status(msg):
|
with console.status(msg):
|
||||||
client = rpc_client.RPCClient(str(ip_address), port, magic_word)
|
client = rpc_client.RPCClient(host, port, magic_word)
|
||||||
stats = client.get_stats_dict()
|
stats = client.get_stats_dict()
|
||||||
console.print_json(data=stats)
|
console.print_json(data=stats)
|
||||||
aprsd_title = (
|
aprsd_title = (
|
||||||
@ -61,7 +66,7 @@ def fetch_stats(ctx, ip_address, port, magic_word):
|
|||||||
f"Uptime [bold yellow]{stats['aprsd']['uptime']}[/]"
|
f"Uptime [bold yellow]{stats['aprsd']['uptime']}[/]"
|
||||||
)
|
)
|
||||||
|
|
||||||
console.rule(f"Stats from {ip_address}:{port} with magic word '{magic_word}'")
|
console.rule(f"Stats from {host}:{port} with magic word '{magic_word}'")
|
||||||
console.print("\n\n")
|
console.print("\n\n")
|
||||||
console.rule(aprsd_title)
|
console.rule(aprsd_title)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user