From ae80bc92a5886eb759b771ff96bc8f69ba2c6b91 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 10 Feb 2021 11:33:10 -0800 Subject: [PATCH] cloudsdk: Support 'ping' api, add to debug scripts. Easy way to find out what cloud version we are running. Signed-off-by: Ben Greear --- libs/cloudsdk/cloudsdk.py | 4 ++++ tools/debug_nola01.sh | 10 ++++++++-- tools/debug_nola12.sh | 20 ++++++++++++++++---- tools/query_sdk.py | 13 ++++++++++++- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/libs/cloudsdk/cloudsdk.py b/libs/cloudsdk/cloudsdk.py index 01bfb93ff..fb165636a 100755 --- a/libs/cloudsdk/cloudsdk.py +++ b/libs/cloudsdk/cloudsdk.py @@ -436,6 +436,10 @@ class CloudSDK: url_base = cloudSDK_url + "/portal/profile/forCustomer" + "?customerId=" + customer_id return self.get_paged_url(bearer, url_base) + def ping(self, cloudSDK_url, bearer): + url_base = cloudSDK_url + "/ping" + return [self.get_url(bearer, url_base)] + # This is querys all and filters locally. Maybe there is better way to get cloud to # do the filtering? def get_customer_profile_by_name(self, cloudSDK_url, bearer, customer_id, name): diff --git a/tools/debug_nola01.sh b/tools/debug_nola01.sh index 19700762f..1d9644e0e 100755 --- a/tools/debug_nola01.sh +++ b/tools/debug_nola01.sh @@ -12,7 +12,12 @@ APTTY=/dev/ttyAP1 MODEL=ecw5410 # cloud sdk profile dump -./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com --sdk-user-password support --type profile --cmd get > /tmp/nola-$NOLANUM-profiles.txt +./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ + --sdk-user-password support --type profile --cmd get > /tmp/nola-$NOLANUM-profiles.txt + +# cloud version info +./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ + --sdk-user-password support --type ping > /tmp/nola-$NOLANUM-sdk-ping.txt # ovsdb-client dump ./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "ovsdb-client dump" > /tmp/nola-$NOLANUM-ap.txt @@ -20,6 +25,7 @@ MODEL=ecw5410 # interface info ./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "iwinfo && brctl show" > /tmp/nola-$NOLANUM-ap-if.txt + # TODO: Add more things here as we learn what better provides debug info to cloud. -echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt" +echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt /tmp/nola-$NOLANUM-sdk-ping.txt" diff --git a/tools/debug_nola12.sh b/tools/debug_nola12.sh index ebf447258..648b242ef 100755 --- a/tools/debug_nola12.sh +++ b/tools/debug_nola12.sh @@ -5,15 +5,27 @@ set -x +NOLANUM=12 +PORTAL=wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build +APPORT=8823 +APTTY=/dev/ttyAP1 +MODEL=wf188n + # cloud sdk profile dump -./query_sdk.py --testrail-user-id NONE --model ecw5410 --sdk-base-url https://wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build --sdk-user-id support@example.com --sdk-user-password support --type profile --cmd get > /tmp/nola-12-profiles.txt +./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ + --sdk-user-password support --type profile --cmd get > /tmp/nola-$NOLANUM-profiles.txt + +# cloud version info +./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ + --sdk-user-password support --type ping > /tmp/nola-$NOLANUM-sdk-ping.txt # ovsdb-client dump -./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port 8823 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 -m ecw5410 --cmd "ovsdb-client dump" > /tmp/nola-12-ap.txt +./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "ovsdb-client dump" > /tmp/nola-$NOLANUM-ap.txt # interface info -./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port 8823 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 -m ecw5410 --cmd "iwinfo && brctl show" > /tmp/nola-12-ap-if.txt +./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "iwinfo && brctl show" > /tmp/nola-$NOLANUM-ap-if.txt + # TODO: Add more things here as we learn what better provides debug info to cloud. -echo "Grab: /tmp/nola-12-profiles.txt /tmp/nola-12-ap.txt /tmp/nola-12-ap-if.txt" +echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt /tmp/nola-$NOLANUM-sdk-ping.txt" diff --git a/tools/query_sdk.py b/tools/query_sdk.py index b6b2496d5..7246c7200 100755 --- a/tools/query_sdk.py +++ b/tools/query_sdk.py @@ -10,7 +10,7 @@ parser = argparse.ArgumentParser(description="Query SDK Objects", add_help=False parser.add_argument("--type", type=str, help="Type of thing to query", choices=['profile', 'customer', 'location', 'equipment', 'portalUser', 'status', 'client-sessions', 'client-info', 'alarm', 'service-metric', - 'event', 'firmware', 'all'], + 'event', 'firmware', 'ping', 'all'], default = "all") parser.add_argument("--cmd", type=str, help="Operation to do, default is 'get'", choices=['get', 'delete', 'child_of'], @@ -97,6 +97,17 @@ if qtype == 'all' or qtype == 'customer': logging.error(logging.traceback.format_exc()) print("Failed to read Customer %i"%(customer_id)) +if qtype == 'all' or qtype == 'ping': + try: + rv = base.cloud.ping(base.cloudSDK_url, base.bearer) + print("Cloud Ping %s:"%(base.cloudSDK_url)) + #jobj = json.load(ssids) + print(json.dumps(rv, indent=4, sort_keys=True)) + except Exception as ex: + print(ex) + logging.error(logging.traceback.format_exc()) + print("Failed to read Cloud Ping %i"%(base.cloudSDK_url)) + if qtype == 'all' or qtype == 'firmware': try: rv = base.cloud.CloudSDK_images(base.command_line_args.model, base.cloudSDK_url, base.bearer)