summaryrefslogtreecommitdiffstats
path: root/ogcli.py
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-19 12:23:59 +0200
committerRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-19 12:23:59 +0200
commitdbdfc106bfc599ba86c4870b342e684eaf0b2476 (patch)
tree13ac14b82d2b9cb56ae343b656fe56e4fd68b4b0 /ogcli.py
parentd7b54d08bbcd55029daf57f726784950276accb3 (diff)
Rewrite basic structure
This commit: - Adds OgREST class as a wrapper for HTTP REST requests. - Adds objects folder which will contain available functions for each object in the OpenGnsys ecosystem (e.g. client, image, etc.).
Diffstat (limited to 'ogcli.py')
-rwxr-xr-xogcli.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/ogcli.py b/ogcli.py
index b3071f5..09969f5 100755
--- a/ogcli.py
+++ b/ogcli.py
@@ -14,7 +14,7 @@ class CLI():
self.cfg = json.load(json_file)
except json.JSONDecodeError:
sys.exit(f'ERROR: Failed parse malformed JSON file '
- f'{OG_CLI_CFG_PATH}')
+ f'{OG_CLI_CFG_PATH}')
except:
sys.exit(f'ERROR: cannot open {OG_CLI_CFG_PATH}')
@@ -24,20 +24,12 @@ class CLI():
parser.add_argument('command', help='Subcommand to run')
args = parser.parse_args(sys.argv[1:2])
- if not hasattr(self, args.command):
+ if not hasattr(self.ogcli, args.command):
parser.print_help()
sys.exit('Unknown command')
# Call the command with the same name.
- getattr(self, args.command)(sys.argv[2:])
-
- def list(self, args):
- parser = argparse.ArgumentParser()
- parser.add_argument('item', choices=['clients'])
- parser.parse_args(args)
-
- if parser.item == 'clients':
- self.ogcli.client_list()
+ getattr(self.ogcli, args.command)(sys.argv[2:])
if __name__ == "__main__":
CLI()