1 | # Copyright (C) 2020-2021 Soleta Networks <info@soleta.eu> |
---|
2 | # |
---|
3 | # This program is free software: you can redistribute it and/or modify it under |
---|
4 | # the terms of the GNU Affero General Public License as published by the |
---|
5 | # Free Software Foundation; either version 3 of the License, or |
---|
6 | # (at your option) any later version. |
---|
7 | |
---|
8 | import argparse |
---|
9 | |
---|
10 | from cli.utils import print_json |
---|
11 | |
---|
12 | |
---|
13 | class OgClient(): |
---|
14 | |
---|
15 | @staticmethod |
---|
16 | def list_clients(rest): |
---|
17 | r = rest.get('/clients') |
---|
18 | print_json(r.text) |
---|
19 | |
---|
20 | @staticmethod |
---|
21 | def list_client_hardware(rest, args): |
---|
22 | parser = argparse.ArgumentParser() |
---|
23 | parser.add_argument('--client-ip', |
---|
24 | nargs=1, |
---|
25 | type=str, |
---|
26 | required=True, |
---|
27 | help='client IP') |
---|
28 | parsed_args = parser.parse_args(args) |
---|
29 | |
---|
30 | payload = {'client': parsed_args.client_ip} |
---|
31 | r = rest.get('/hardware', payload=payload) |
---|
32 | print_json(r.text) |
---|
33 | |
---|
34 | @staticmethod |
---|
35 | def get_client_properties(rest, args): |
---|
36 | parser = argparse.ArgumentParser() |
---|
37 | parser.add_argument('--client-ip', |
---|
38 | nargs=1, |
---|
39 | required=True, |
---|
40 | help='client IP') |
---|
41 | parsed_args = parser.parse_args(args) |
---|
42 | |
---|
43 | payload = {'client': parsed_args.client_ip} |
---|
44 | r = rest.get('/client/info', payload=payload) |
---|
45 | print_json(r.text) |
---|
46 | |
---|
47 | @staticmethod |
---|
48 | def send_refresh(rest, args): |
---|
49 | parser = argparse.ArgumentParser() |
---|
50 | parser.add_argument('--client-ip', |
---|
51 | action='append', |
---|
52 | default=[], |
---|
53 | required=True, |
---|
54 | help='Client IP') |
---|
55 | parsed_args = parser.parse_args(args) |
---|
56 | |
---|
57 | payload = {'clients': parsed_args.client_ip} |
---|
58 | rest.post('/refresh', payload=payload) |
---|