summaryrefslogtreecommitdiffstats
path: root/moonclient/moonclient/configuration.py
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2015-09-04 17:12:29 +0200
committerasteroide <thomas.duval@orange.com>2015-09-04 17:12:29 +0200
commit7ecd1573fd6ec625fb89b72ffa428ddf658b62f2 (patch)
tree04dbdaf52ef084a952b8432c6ff4d3af9a6494cc /moonclient/moonclient/configuration.py
parent92fd2dbfb672d7b2b1cdfd5dd5cf89f7716b3e12 (diff)
First modifications of moonclient to comply with the current Moon API.
Change-Id: I8c5e2f6edb17409729d5735f3d49fbdc906a2ca8
Diffstat (limited to 'moonclient/moonclient/configuration.py')
-rw-r--r--moonclient/moonclient/configuration.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/moonclient/moonclient/configuration.py b/moonclient/moonclient/configuration.py
new file mode 100644
index 00000000..df80d71e
--- /dev/null
+++ b/moonclient/moonclient/configuration.py
@@ -0,0 +1,70 @@
+# Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
+# This software is distributed under the terms and conditions of the 'Apache-2.0'
+# license which can be found in the file 'LICENSE' in this package distribution
+# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+
+import logging
+
+from cliff.lister import Lister
+
+
+class TemplatesList(Lister):
+ """List all policy templates."""
+
+ log = logging.getLogger(__name__)
+
+ def get_parser(self, prog_name):
+ parser = super(TemplatesList, self).get_parser(prog_name)
+ return parser
+
+ def take_action(self, parsed_args):
+ templates = self.app.get_url("/v3/OS-MOON/configuration/templates", authtoken=True)
+ self.app.stdout.write(templates)
+ self.app.stdout.write("\n")
+ return (
+ ("id", "name", "description"),
+ ((template_id, templates[template_id]["name"], templates[template_id]["description"])
+ for template_id in templates)
+ )
+
+
+class AggregationAlgorithmsList(Lister):
+ """List all aggregation algorithms."""
+
+ log = logging.getLogger(__name__)
+
+ def get_parser(self, prog_name):
+ parser = super(AggregationAlgorithmsList, self).get_parser(prog_name)
+ return parser
+
+ def take_action(self, parsed_args):
+ templates = self.app.get_url("/v3/OS-MOON/configuration/aggregation_algorithms", authtoken=True)
+ self.app.stdout.write(templates)
+ self.app.stdout.write("\n")
+ return (
+ ("id", "name", "description"),
+ ((template_id, templates[template_id]["name"], templates[template_id]["description"])
+ for template_id in templates)
+ )
+
+
+class SubMetaRuleAlgorithmsList(Lister):
+ """List all aggregation algorithms."""
+
+ log = logging.getLogger(__name__)
+
+ def get_parser(self, prog_name):
+ parser = super(SubMetaRuleAlgorithmsList, self).get_parser(prog_name)
+ return parser
+
+ def take_action(self, parsed_args):
+ templates = self.app.get_url("/v3/OS-MOON/configuration/sub_meta_rule_algorithms", authtoken=True)
+ self.app.stdout.write(templates)
+ self.app.stdout.write("\n")
+ return (
+ ("id", "name", "description"),
+ ((template_id, templates[template_id]["name"], templates[template_id]["description"])
+ for template_id in templates)
+ )
+
+