|
|
@@ -2,12 +2,14 @@ from . import Mu5001Tool
|
|
|
|
from .prometheus_exporter import prometheus_exporter
|
|
|
|
from .prometheus_exporter import prometheus_exporter
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from pprint import pprint
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(prog="mu5001tool")
|
|
|
|
parser = argparse.ArgumentParser(prog="mu5001tool")
|
|
|
|
|
|
|
|
|
|
|
|
parser.add_argument("--stok", dest="stok", help="Initial session token to use for commands")
|
|
|
|
parser.add_argument("--stok", dest="stok", help="Initial session token to use for commands")
|
|
|
|
parser.add_argument("--password", dest="password", help="Password for authentication against the device")
|
|
|
|
parser.add_argument("--password", dest="password", help="Password for authentication against the device")
|
|
|
|
|
|
|
|
parser.add_argument("--password-file", dest="password_file", type=Path, help="Password for authentication against the device, passed as path to file")
|
|
|
|
|
|
|
|
|
|
|
|
subparsers = parser.add_subparsers()
|
|
|
|
subparsers = parser.add_subparsers()
|
|
|
|
|
|
|
|
|
|
|
@@ -28,11 +30,12 @@ def run_status(m):
|
|
|
|
sp_status = subparsers.add_parser("status", help="General modem status information")
|
|
|
|
sp_status = subparsers.add_parser("status", help="General modem status information")
|
|
|
|
sp_status.set_defaults(func=run_status)
|
|
|
|
sp_status.set_defaults(func=run_status)
|
|
|
|
|
|
|
|
|
|
|
|
def run_prometheus_exporter(m):
|
|
|
|
def run_prometheus_exporter(m, listen_port):
|
|
|
|
prometheus_exporter(m)
|
|
|
|
prometheus_exporter(m, listen_port)
|
|
|
|
|
|
|
|
|
|
|
|
sp_prometheus_exporter = subparsers.add_parser("prometheus-exporter", help="Serve metrics as prometheus exporter")
|
|
|
|
sp_prometheus_exporter = subparsers.add_parser("prometheus-exporter", help="Serve metrics as prometheus exporter")
|
|
|
|
sp_prometheus_exporter.set_defaults(func=run_prometheus_exporter)
|
|
|
|
sp_prometheus_exporter.set_defaults(func=run_prometheus_exporter)
|
|
|
|
|
|
|
|
sp_prometheus_exporter.add_argument("--listen-port", dest="listen_port", type=int, default=9242, help="Port for service webserver")
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
|
@@ -47,6 +50,7 @@ def main():
|
|
|
|
function_arguments.pop("func")
|
|
|
|
function_arguments.pop("func")
|
|
|
|
function_arguments.pop("stok")
|
|
|
|
function_arguments.pop("stok")
|
|
|
|
function_arguments.pop("password")
|
|
|
|
function_arguments.pop("password")
|
|
|
|
|
|
|
|
function_arguments.pop("password_file")
|
|
|
|
|
|
|
|
|
|
|
|
m = Mu5001Tool()
|
|
|
|
m = Mu5001Tool()
|
|
|
|
|
|
|
|
|
|
|
@@ -55,6 +59,12 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
if args.password is not None:
|
|
|
|
if args.password is not None:
|
|
|
|
m.set_password(args.password)
|
|
|
|
m.set_password(args.password)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.password_file is not None:
|
|
|
|
|
|
|
|
password = args.password_file.read_text()
|
|
|
|
|
|
|
|
m.set_password(password)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.password is not None or args.password_file is not None:
|
|
|
|
m.login()
|
|
|
|
m.login()
|
|
|
|
|
|
|
|
|
|
|
|
args.func(m=m, **function_arguments)
|
|
|
|
args.func(m=m, **function_arguments)
|
|
|
|