summaryrefslogtreecommitdiffstats
path: root/cli/objects/client.py
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-07-08 11:47:48 +0200
committerRoberto Hueso Gómez <rhueso@soleta.eu>2020-07-08 13:38:50 +0200
commitf4e1bb767b98ef8370208c79123b6eafac5f4732 (patch)
tree1d616806dbf80468484af8e5e0029eec4ea04364 /cli/objects/client.py
parente3d30d23ff22bebb8e5ebf0e731aab4a14502cea (diff)
Add ogcli list hardware command
This requests GET /hardware by calling something like: ogcli list hardware --scope-id=6 It is important to notice that 'scope-id' must be a "computer" type scope id.
Diffstat (limited to 'cli/objects/client.py')
-rw-r--r--cli/objects/client.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/objects/client.py b/cli/objects/client.py
index 6ae1867..9404635 100644
--- a/cli/objects/client.py
+++ b/cli/objects/client.py
@@ -6,9 +6,25 @@
# Free Software Foundation, version 3.
#
+import argparse
+
class OgClient():
@staticmethod
def list_clients(rest):
r = rest.get('/clients')
print(r.json())
+
+ @staticmethod
+ def list_client_hardware(rest, args):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--scope-id',
+ nargs=1,
+ required=True,
+ help='ID of the computer scope')
+ parsed_args = parser.parse_args(args)
+
+ payload = {'scope': {'id': int(parsed_args.scope_id[0]),
+ 'type': 'computer'}}
+ r = rest.get('/hardware', payload=payload)
+ print(r.json())