diff options
Diffstat (limited to 'moonclient')
-rw-r--r-- | moonclient/moonclient/action_assignments.py | 10 | ||||
-rw-r--r-- | moonclient/moonclient/action_categories.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/action_scopes.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/actions.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/configuration.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/intraextension.py | 12 | ||||
-rw-r--r-- | moonclient/moonclient/logs.py | 4 | ||||
-rw-r--r-- | moonclient/moonclient/metarules.py | 18 | ||||
-rw-r--r-- | moonclient/moonclient/object_assignments.py | 10 | ||||
-rw-r--r-- | moonclient/moonclient/object_categories.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/object_scopes.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/objects.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/rules.py | 28 | ||||
-rw-r--r-- | moonclient/moonclient/shell.py | 13 | ||||
-rw-r--r-- | moonclient/moonclient/subject_assignments.py | 10 | ||||
-rw-r--r-- | moonclient/moonclient/subject_categories.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/subject_scopes.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/subjects.py | 6 | ||||
-rw-r--r-- | moonclient/moonclient/tenants.py | 10 |
19 files changed, 89 insertions, 86 deletions
diff --git a/moonclient/moonclient/action_assignments.py b/moonclient/moonclient/action_assignments.py index be2a66da..5625a2f2 100644 --- a/moonclient/moonclient/action_assignments.py +++ b/moonclient/moonclient/action_assignments.py @@ -34,7 +34,7 @@ class ActionAssignmentsList(Lister): return parser def __get_scope_from_id(self, intraextension_id, action_category_id, action_scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}".format( intraextension_id, action_category_id), authtoken=True) if action_scope_id in data: @@ -43,7 +43,7 @@ class ActionAssignmentsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_assignments/{}/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_assignments/{}/{}".format( parsed_args.intraextension, parsed_args.action_id, parsed_args.action_category_id), authtoken=True) return ( @@ -84,7 +84,7 @@ class ActionAssignmentsAdd(Command): return parser def __get_scope_from_id(self, intraextension_id, action_category_id, action_scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}".format( intraextension_id, action_category_id), authtoken=True) if action_scope_id in data: @@ -93,7 +93,7 @@ class ActionAssignmentsAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_assignments".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_assignments".format(parsed_args.intraextension), post_data={ "action_id": parsed_args.action_id, "action_category_id": parsed_args.action_category_id, @@ -139,7 +139,7 @@ class ActionAssignmentsDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_assignments/{}/{}/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_assignments/{}/{}/{}".format( parsed_args.intraextension, parsed_args.action_id, parsed_args.action_category_id, diff --git a/moonclient/moonclient/action_categories.py b/moonclient/moonclient/action_categories.py index f4400c79..bf7cb7e1 100644 --- a/moonclient/moonclient/action_categories.py +++ b/moonclient/moonclient/action_categories.py @@ -26,7 +26,7 @@ class ActionCategoriesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_categories".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_categories".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "description"), @@ -61,7 +61,7 @@ class ActionCategoriesAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_categories".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_categories".format(parsed_args.intraextension), post_data={ "action_category_name": parsed_args.action_category_name, "action_category_description": parsed_args.description}, @@ -94,7 +94,7 @@ class ActionCategoriesDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_categories/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_categories/{}".format( parsed_args.intraextension, parsed_args.action_category_id), method="DELETE", diff --git a/moonclient/moonclient/action_scopes.py b/moonclient/moonclient/action_scopes.py index 53ed2604..9ddf8d4e 100644 --- a/moonclient/moonclient/action_scopes.py +++ b/moonclient/moonclient/action_scopes.py @@ -31,7 +31,7 @@ class ActionScopesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}".format( parsed_args.intraextension, parsed_args.action_category_id), authtoken=True) self.log.debug(data) @@ -73,7 +73,7 @@ class ActionScopesAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}".format( parsed_args.intraextension, parsed_args.action_category_id), post_data={ "action_scope_name": parsed_args.action_scope_name, @@ -113,7 +113,7 @@ class ActionScopesDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}/{}".format( parsed_args.intraextension, parsed_args.action_category_id, parsed_args.action_scope_id diff --git a/moonclient/moonclient/actions.py b/moonclient/moonclient/actions.py index f2550579..9fbad13a 100644 --- a/moonclient/moonclient/actions.py +++ b/moonclient/moonclient/actions.py @@ -26,7 +26,7 @@ class ActionsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/actions".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/actions".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "description"), @@ -61,7 +61,7 @@ class ActionsAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/actions".format(parsed_args.intraextension), # TODO: check method POST? + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/actions".format(parsed_args.intraextension), # TODO: check method POST? post_data={ "action_name": parsed_args.action_name, "action_description": parsed_args.description}, @@ -94,7 +94,7 @@ class ActionsDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/actions/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/actions/{}".format( parsed_args.intraextension, parsed_args.action_id), method="DELETE", diff --git a/moonclient/moonclient/configuration.py b/moonclient/moonclient/configuration.py index 3a77723c..a05d7151 100644 --- a/moonclient/moonclient/configuration.py +++ b/moonclient/moonclient/configuration.py @@ -18,7 +18,7 @@ class TemplatesList(Lister): return parser def take_action(self, parsed_args): - templates = self.app.get_url("/v3/OS-MOON/configuration/templates", authtoken=True) + templates = self.app.get_url(self.app.url_prefix+"/configuration/templates", authtoken=True) return ( ("id", "name", "description"), ((template_id, templates[template_id]["name"], templates[template_id]["description"]) @@ -36,7 +36,7 @@ class AggregationAlgorithmsList(Lister): return parser def take_action(self, parsed_args): - templates = self.app.get_url("/v3/OS-MOON/configuration/aggregation_algorithms", authtoken=True) + templates = self.app.get_url(self.app.url_prefix+"/configuration/aggregation_algorithms", authtoken=True) return ( ("id", "name", "description"), ((template_id, templates[template_id]["name"], templates[template_id]["description"]) @@ -54,7 +54,7 @@ class SubMetaRuleAlgorithmsList(Lister): return parser def take_action(self, parsed_args): - templates = self.app.get_url("/v3/OS-MOON/configuration/sub_meta_rule_algorithms", authtoken=True) + templates = self.app.get_url(self.app.url_prefix+"/configuration/sub_meta_rule_algorithms", authtoken=True) return ( ("id", "name", "description"), ((template_id, templates[template_id]["name"], templates[template_id]["description"]) diff --git a/moonclient/moonclient/intraextension.py b/moonclient/moonclient/intraextension.py index 24286dd9..f66aabbc 100644 --- a/moonclient/moonclient/intraextension.py +++ b/moonclient/moonclient/intraextension.py @@ -26,7 +26,7 @@ class IntraExtensionSelect(Command): return parser def take_action(self, parsed_args): - ie = self.app.get_url("/v3/OS-MOON/intra_extensions", authtoken=True) + ie = self.app.get_url(self.app.url_prefix+"/intra_extensions", authtoken=True) if parsed_args.id in ie.keys(): self.app.intraextension = parsed_args.id self.app.stdout.write("Select {} IntraExtension.\n".format(self.app.intraextension)) @@ -66,7 +66,7 @@ class IntraExtensionCreate(Command): "intra_extension_model": parsed_args.policy_model, "intra_extension_description": parsed_args.description } - ie = self.app.get_url("/v3/OS-MOON/intra_extensions", post_data=post_data, authtoken=True) + ie = self.app.get_url(self.app.url_prefix+"/intra_extensions", post_data=post_data, authtoken=True) if "id" not in ie: raise Exception("Error in command {}".format(ie)) self.app.stdout.write("IntraExtension created: {}\n".format(ie["id"])) @@ -83,7 +83,7 @@ class IntraExtensionList(Lister): return parser def take_action(self, parsed_args): - ie = self.app.get_url("/v3/OS-MOON/intra_extensions", authtoken=True) + ie = self.app.get_url(self.app.url_prefix+"/intra_extensions", authtoken=True) return ( ("id", "name", "model"), ((_id, ie[_id]["name"], ie[_id]["model"]) for _id in ie.keys()) @@ -105,7 +105,7 @@ class IntraExtensionDelete(Command): return parser def take_action(self, parsed_args): - self.app.get_url("/v3/OS-MOON/intra_extensions/{}".format(parsed_args.uuid), + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}".format(parsed_args.uuid), method="DELETE", authtoken=True) @@ -120,7 +120,7 @@ class IntraExtensionInit(Command): return parser def take_action(self, parsed_args): - self.app.get_url("/v3/OS-MOON/intra_extensions/init", + self.app.get_url(self.app.url_prefix+"/intra_extensions/init", method="GET", authtoken=True) @@ -145,7 +145,7 @@ class IntraExtensionShow(ShowOne): if parsed_args.uuid == "selected": intra_extension_id = self.app.intraextension self.log.debug("self.app.intraextension={}".format(intra_extension_id)) - ie = self.app.get_url("/v3/OS-MOON/intra_extensions/{}".format(intra_extension_id), authtoken=True) + ie = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}".format(intra_extension_id), authtoken=True) self.log.debug("ie={}".format(ie)) if "id" not in ie: self.log.error("Unknown intraextension {}".format(intra_extension_id)) diff --git a/moonclient/moonclient/logs.py b/moonclient/moonclient/logs.py index 36437786..e65a530d 100644 --- a/moonclient/moonclient/logs.py +++ b/moonclient/moonclient/logs.py @@ -85,9 +85,9 @@ class LogsList(Lister): if number: options.append("event_number={}".format(number)) if len(options) > 0: - url = "/v3/OS-MOON/logs/{}".format(",".join(options)) + url = self.app.url_prefix+"/logs/{}".format(",".join(options)) else: - url = "/v3/OS-MOON/logs" + url = self.app.url_prefix+"/logs" data = self.app.get_url(url, authtoken=True) return ( ("Time", "Message",), diff --git a/moonclient/moonclient/metarules.py b/moonclient/moonclient/metarules.py index 8938f890..6727711e 100644 --- a/moonclient/moonclient/metarules.py +++ b/moonclient/moonclient/metarules.py @@ -16,7 +16,7 @@ class AggregationAlgorithmsList(Lister): log = logging.getLogger(__name__) def __get_aggregation_algorithm_from_id(self, algorithm_id): - algorithms = self.app.get_url("/v3/OS-MOON/configuration/aggregation_algorithms", authtoken=True) + algorithms = self.app.get_url(self.app.url_prefix+"/configuration/aggregation_algorithms", authtoken=True) if algorithm_id in algorithms: return algorithms[algorithm_id] return dict() @@ -33,7 +33,7 @@ class AggregationAlgorithmsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/aggregation_algorithm".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/aggregation_algorithm".format( parsed_args.intraextension), authtoken=True) algorithm = self.__get_aggregation_algorithm_from_id(data['aggregation_algorithm']) @@ -49,7 +49,7 @@ class AggregationAlgorithmSet(Command): log = logging.getLogger(__name__) def __get_aggregation_algorithm_from_id(self, algorithm_id): - algorithms = self.app.get_url("/v3/OS-MOON/configuration/aggregation_algorithms", authtoken=True) + algorithms = self.app.get_url(self.app.url_prefix+"/configuration/aggregation_algorithms", authtoken=True) if algorithm_id in algorithms: return algorithms[algorithm_id] return dict() @@ -76,7 +76,7 @@ class AggregationAlgorithmSet(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/aggregation_algorithm".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/aggregation_algorithm".format( parsed_args.intraextension), post_data={ "aggregation_algorithm_id": parsed_args.aggregation_algorithm_id, @@ -104,19 +104,19 @@ class SubMetaRuleShow(Lister): return parser def __get_subject_category_name(self, intraextension, subject_category_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_categories".format(intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_categories".format(intraextension), authtoken=True) if subject_category_id in data: return data[subject_category_id]["name"] def __get_object_category_name(self, intraextension, object_category_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_categories".format(intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_categories".format(intraextension), authtoken=True) if object_category_id in data: return data[object_category_id]["name"] def __get_action_category_name(self, intraextension, action_category_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_categories".format(intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_categories".format(intraextension), authtoken=True) if action_category_id in data: return data[action_category_id]["name"] @@ -124,7 +124,7 @@ class SubMetaRuleShow(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/sub_meta_rules".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/sub_meta_rules".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "algorithm", "subject categories", "object categories", "action categories"), @@ -205,7 +205,7 @@ class SubMetaRuleSet(Command): post_data["sub_meta_rule_subject_categories"] = filter(lambda x: x, subject_category_id) post_data["sub_meta_rule_object_categories"] = filter(lambda x: x, object_category_id) post_data["sub_meta_rule_action_categories"] = filter(lambda x: x, action_category_id) - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/sub_meta_rules/{}".format(parsed_args.intraextension, + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/sub_meta_rules/{}".format(parsed_args.intraextension, sub_meta_rule_id), post_data=post_data, method="POST", diff --git a/moonclient/moonclient/object_assignments.py b/moonclient/moonclient/object_assignments.py index b5f89002..0942aa6f 100644 --- a/moonclient/moonclient/object_assignments.py +++ b/moonclient/moonclient/object_assignments.py @@ -34,7 +34,7 @@ class ObjectAssignmentsList(Lister): return parser def __get_scope_from_id(self, intraextension_id, object_category_id, object_scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}".format( intraextension_id, object_category_id), authtoken=True) if object_scope_id in data: @@ -43,7 +43,7 @@ class ObjectAssignmentsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_assignments/{}/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_assignments/{}/{}".format( parsed_args.intraextension, parsed_args.object_id, parsed_args.object_category_id), authtoken=True) return ( @@ -84,7 +84,7 @@ class ObjectAssignmentsAdd(Command): return parser def __get_scope_from_id(self, intraextension_id, object_category_id, object_scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}".format( intraextension_id, object_category_id), authtoken=True) if object_scope_id in data: @@ -93,7 +93,7 @@ class ObjectAssignmentsAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_assignments".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_assignments".format(parsed_args.intraextension), post_data={ "object_id": parsed_args.object_id, "object_category_id": parsed_args.object_category_id, @@ -139,7 +139,7 @@ class ObjectAssignmentsDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_assignments/{}/{}/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_assignments/{}/{}/{}".format( parsed_args.intraextension, parsed_args.object_id, parsed_args.object_category_id, diff --git a/moonclient/moonclient/object_categories.py b/moonclient/moonclient/object_categories.py index c86586f3..5641f4bf 100644 --- a/moonclient/moonclient/object_categories.py +++ b/moonclient/moonclient/object_categories.py @@ -26,7 +26,7 @@ class ObjectCategoriesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_categories".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_categories".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "description"), @@ -61,7 +61,7 @@ class ObjectCategoriesAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_categories".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_categories".format(parsed_args.intraextension), post_data={ "object_category_name": parsed_args.object_category_name, "object_category_description": parsed_args.description}, @@ -94,7 +94,7 @@ class ObjectCategoriesDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_categories/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_categories/{}".format( parsed_args.intraextension, parsed_args.object_category_id), method="DELETE", diff --git a/moonclient/moonclient/object_scopes.py b/moonclient/moonclient/object_scopes.py index 0fbd757d..41b9aef6 100644 --- a/moonclient/moonclient/object_scopes.py +++ b/moonclient/moonclient/object_scopes.py @@ -31,7 +31,7 @@ class ObjectScopesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}".format( parsed_args.intraextension, parsed_args.object_category_id), authtoken=True) self.log.debug(data) # TODO: why log here? @@ -73,7 +73,7 @@ class ObjectScopesAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}".format( parsed_args.intraextension, parsed_args.object_category_id), post_data={ "object_scope_name": parsed_args.object_scope_name, @@ -113,7 +113,7 @@ class ObjectScopesDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}/{}".format( parsed_args.intraextension, parsed_args.object_category_id, parsed_args.object_scope_id diff --git a/moonclient/moonclient/objects.py b/moonclient/moonclient/objects.py index 0f6fef06..0fc04ab8 100644 --- a/moonclient/moonclient/objects.py +++ b/moonclient/moonclient/objects.py @@ -26,7 +26,7 @@ class ObjectsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/objects".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/objects".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "description"), @@ -61,7 +61,7 @@ class ObjectsAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/objects".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/objects".format(parsed_args.intraextension), post_data={ "object_name": parsed_args.object_name, "object_description": parsed_args.description}, @@ -94,7 +94,7 @@ class ObjectsDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/objects/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/objects/{}".format( parsed_args.intraextension, parsed_args.object_id), method="DELETE", diff --git a/moonclient/moonclient/rules.py b/moonclient/moonclient/rules.py index 682c830d..207533a8 100644 --- a/moonclient/moonclient/rules.py +++ b/moonclient/moonclient/rules.py @@ -30,39 +30,39 @@ class RulesList(Lister): return parser def __get_subject_category_name(self, intraextension, category_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_categories".format(intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_categories".format(intraextension), authtoken=True) if category_id in data: return data[category_id]["name"] def __get_object_category_name(self, intraextension, category_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_categories".format(intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_categories".format(intraextension), authtoken=True) if category_id in data: return data[category_id]["name"] def __get_action_category_name(self, intraextension, category_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_categories".format(intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_categories".format(intraextension), authtoken=True) if category_id in data: return data[category_id]["name"] def __get_subject_scope_name(self, intraextension, category_id, scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}".format(intraextension, category_id), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}".format(intraextension, category_id), authtoken=True) if scope_id in data: return data[scope_id]["name"] return scope_id def __get_object_scope_name(self, intraextension, category_id, scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}".format(intraextension, category_id), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}".format(intraextension, category_id), authtoken=True) if scope_id in data: return data[scope_id]["name"] return scope_id def __get_action_scope_name(self, intraextension, category_id, scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}".format(intraextension, category_id), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}".format(intraextension, category_id), authtoken=True) if scope_id in data: return data[scope_id]["name"] @@ -72,7 +72,7 @@ class RulesList(Lister): headers = list() headers.append("") headers.append("id") - self.sub_meta_rules = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/sub_meta_rules".format(intraextension), + self.sub_meta_rules = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/sub_meta_rules".format(intraextension), authtoken=True) for cat in self.sub_meta_rules[submetarule_id]["subject_categories"]: headers.append("s:" + self.__get_subject_category_name(intraextension, cat)) @@ -105,7 +105,7 @@ class RulesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/rule/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/rule/{}".format( parsed_args.intraextension, parsed_args.submetarule_id, ), @@ -144,7 +144,7 @@ class RuleAdd(Command): return parser def __get_subject_scope_id(self, intraextension, category_id, scope_name): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}".format(intraextension, category_id), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}".format(intraextension, category_id), authtoken=True) self.log.debug("__get_subject_scope_id {}".format(data)) for scope_id in data: @@ -153,7 +153,7 @@ class RuleAdd(Command): return scope_name def __get_object_scope_id(self, intraextension, category_id, scope_name): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/object_scopes/{}".format(intraextension, category_id), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/object_scopes/{}".format(intraextension, category_id), authtoken=True) self.log.debug("__get_action_scope_id {}".format(data)) for scope_id in data: @@ -162,7 +162,7 @@ class RuleAdd(Command): return scope_name def __get_action_scope_id(self, intraextension, category_id, scope_name): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/action_scopes/{}".format(intraextension, category_id), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/action_scopes/{}".format(intraextension, category_id), authtoken=True) self.log.debug("__get_object_scope_id {}".format(data)) for scope_id in data: @@ -173,7 +173,7 @@ class RuleAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.sub_meta_rules = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/sub_meta_rules".format( + self.sub_meta_rules = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/sub_meta_rules".format( parsed_args.intraextension), authtoken=True) new_rule = map(lambda x: x.strip(), parsed_args.rule.split(",")) @@ -198,7 +198,7 @@ class RuleAdd(Command): post["object_categories"].append(self.__get_object_scope_id( parsed_args.intraextension, cat, new_rule.pop(0)) ) - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/rule/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/rule/{}".format( parsed_args.intraextension, parsed_args.submetarule_id), post_data=post, authtoken=True) @@ -232,7 +232,7 @@ class RuleDelete(Command): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension self.app.get_url( - "/v3/OS-MOON/intra_extensions/{intra_extensions_id}/rule/{submetarule_id}/{rule_id}".format( + self.app.url_prefix+"/intra_extensions/{intra_extensions_id}/rule/{submetarule_id}/{rule_id}".format( intra_extensions_id=parsed_args.intraextension, submetarule_id=parsed_args.submetarule_id, rule_id=parsed_args.rule_id diff --git a/moonclient/moonclient/shell.py b/moonclient/moonclient/shell.py index 1be1a42a..ce2b0102 100644 --- a/moonclient/moonclient/shell.py +++ b/moonclient/moonclient/shell.py @@ -32,13 +32,14 @@ class MoonClient(App): log = logging.getLogger(__name__) x_subject_token = None host = "localhost" - port = "35357" + port = "35358" tenant = None _intraextension = None _tenant_id = None _tenant_name = None secureprotocol = False user_saving_file = ".moonclient" + url_prefix = "/moon" post = { "auth": { "identity": { @@ -112,7 +113,7 @@ class MoonClient(App): def tenant_id(self): if not self._tenant_id: self._tenant_id = self.get_url("/v3/projects?name={}".format(self._tenant_name), - authtoken=True)["projects"][0]["id"] + authtoken=True, port=5000)["projects"][0]["id"] return self._tenant_id @property @@ -129,16 +130,18 @@ class MoonClient(App): open(os.path.join(os.getenv('HOME'), self.user_saving_file), "w").write(value) def get_tenant_uuid(self, tenant_name): - return self.get_url("/v3/projects?name={}".format(tenant_name), authtoken=True)["projects"][0]["id"] + return self.get_url("/v3/projects?name={}".format(tenant_name), authtoken=True, port=5000)["projects"][0]["id"] - def get_url(self, url, post_data=None, delete_data=None, method="GET", authtoken=None): + def get_url(self, url, post_data=None, delete_data=None, method="GET", authtoken=None, port=None): if post_data: method = "POST" if delete_data: method = "DELETE" self.log.debug("\033[32m{} {}\033[m".format(method, url)) # TODO: we must manage authentication and requests with secure protocol (ie. HTTPS) - conn = httplib.HTTPConnection(self.host, self.port) + if not port: + port = self.port + conn = httplib.HTTPConnection(self.host, port) self.log.debug("Host: {}:{}".format(self.host, self.port)) headers = { "Content-type": "application/x-www-form-urlencoded", diff --git a/moonclient/moonclient/subject_assignments.py b/moonclient/moonclient/subject_assignments.py index 5ca31291..ec5e9549 100644 --- a/moonclient/moonclient/subject_assignments.py +++ b/moonclient/moonclient/subject_assignments.py @@ -34,7 +34,7 @@ class SubjectAssignmentsList(Lister): return parser def __get_scope_from_id(self, intraextension_id, subject_category_id, subject_scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}".format( intraextension_id, subject_category_id), authtoken=True) if subject_scope_id in data: @@ -43,7 +43,7 @@ class SubjectAssignmentsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_assignments/{}/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_assignments/{}/{}".format( parsed_args.intraextension, parsed_args.subject_id, parsed_args.subject_category_id), authtoken=True) return ( @@ -84,7 +84,7 @@ class SubjectAssignmentsAdd(Command): return parser def __get_scope_from_id(self, intraextension_id, subject_category_id, subject_scope_id): - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}".format( intraextension_id, subject_category_id), authtoken=True) if subject_scope_id in data: @@ -93,7 +93,7 @@ class SubjectAssignmentsAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_assignments".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_assignments".format(parsed_args.intraextension), post_data={ "subject_id": parsed_args.subject_id, "subject_category_id": parsed_args.subject_category_id, @@ -139,7 +139,7 @@ class SubjectAssignmentsDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_assignments/{}/{}/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_assignments/{}/{}/{}".format( parsed_args.intraextension, parsed_args.subject_id, parsed_args.subject_category_id, diff --git a/moonclient/moonclient/subject_categories.py b/moonclient/moonclient/subject_categories.py index e7ecfe6a..810b0b5f 100644 --- a/moonclient/moonclient/subject_categories.py +++ b/moonclient/moonclient/subject_categories.py @@ -26,7 +26,7 @@ class SubjectCategoriesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_categories".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_categories".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "description"), @@ -61,7 +61,7 @@ class SubjectCategoriesAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_categories".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_categories".format(parsed_args.intraextension), post_data={ "subject_category_name": parsed_args.subject_category_name, "subject_category_description": parsed_args.description}, @@ -94,7 +94,7 @@ class SubjectCategoriesDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_categories/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_categories/{}".format( parsed_args.intraextension, parsed_args.subject_category_id), method="DELETE", diff --git a/moonclient/moonclient/subject_scopes.py b/moonclient/moonclient/subject_scopes.py index f960a1d0..90cc5dcc 100644 --- a/moonclient/moonclient/subject_scopes.py +++ b/moonclient/moonclient/subject_scopes.py @@ -31,7 +31,7 @@ class SubjectScopesList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}".format( parsed_args.intraextension, parsed_args.subject_category_id), authtoken=True) @@ -73,7 +73,7 @@ class SubjectScopesAdd(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}".format( + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}".format( parsed_args.intraextension, parsed_args.subject_category_id), post_data={ "subject_scope_name": parsed_args.subject_scope_name, @@ -113,7 +113,7 @@ class SubjectScopesDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subject_scopes/{}/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subject_scopes/{}/{}".format( parsed_args.intraextension, parsed_args.subject_category_id, parsed_args.subject_scope_id diff --git a/moonclient/moonclient/subjects.py b/moonclient/moonclient/subjects.py index 29ce745d..8203cd92 100644 --- a/moonclient/moonclient/subjects.py +++ b/moonclient/moonclient/subjects.py @@ -27,7 +27,7 @@ class SubjectsList(Lister): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subjects".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subjects".format(parsed_args.intraextension), authtoken=True) return ( ("id", "name", "Keystone ID"), @@ -74,7 +74,7 @@ class SubjectsAdd(Command): parsed_args.intraextension = self.app.intraextension if not parsed_args.password: parsed_args.password = getpass.getpass("Password for user {}:".format(parsed_args.subject_name)) - data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subjects".format(parsed_args.intraextension), + data = self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subjects".format(parsed_args.intraextension), post_data={ "subject_name": parsed_args.subject_name, "subject_description": parsed_args.description, @@ -110,7 +110,7 @@ class SubjectsDelete(Command): def take_action(self, parsed_args): if not parsed_args.intraextension: parsed_args.intraextension = self.app.intraextension - self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subjects/{}".format( + self.app.get_url(self.app.url_prefix+"/intra_extensions/{}/subjects/{}".format( parsed_args.intraextension, parsed_args.subject_id ), diff --git a/moonclient/moonclient/tenants.py b/moonclient/moonclient/tenants.py index b2e0aafa..99c6e501 100644 --- a/moonclient/moonclient/tenants.py +++ b/moonclient/moonclient/tenants.py @@ -19,7 +19,7 @@ class TenantList(Lister): return parser def take_action(self, parsed_args): - tenants = self.app.get_url("/v3/OS-MOON/tenants", authtoken=True) + tenants = self.app.get_url(self.app.url_prefix+"/tenants", authtoken=True) self.log.debug(tenants) return ( ("id", "name", "description", "intra_authz_extension_id", "intra_admin_extension_id"), @@ -72,7 +72,7 @@ class TenantAdd(Command): post_data["tenant_intra_admin_extension_id"] = parsed_args.admin if parsed_args.desc: post_data["tenant_description"] = parsed_args.desc - tenants = self.app.get_url("/v3/OS-MOON/tenants", + tenants = self.app.get_url(self.app.url_prefix+"/tenants", post_data=post_data, authtoken=True) return ( @@ -103,7 +103,7 @@ class TenantShow(Command): return parser def take_action(self, parsed_args): - tenants = self.app.get_url("/v3/OS-MOON/tenants/{}".format(parsed_args.tenant_name), + tenants = self.app.get_url(self.app.url_prefix+"/tenants/{}".format(parsed_args.tenant_name), authtoken=True) return ( ("id", "name", "description", "intra_authz_extension_id", "intra_admin_extension_id"), @@ -164,7 +164,7 @@ class TenantSet(Command): post_data["tenant_intra_admin_extension_id"] = parsed_args.admin if parsed_args.desc is not None: post_data["tenant_description"] = parsed_args.desc - tenants = self.app.get_url("/v3/OS-MOON/tenants/{}".format(post_data["tenant_id"]), + tenants = self.app.get_url(self.app.url_prefix+"/tenants/{}".format(post_data["tenant_id"]), post_data=post_data, authtoken=True) return ( @@ -195,6 +195,6 @@ class TenantDelete(Command): return parser def take_action(self, parsed_args): - self.app.get_url("/v3/OS-MOON/tenants/{}".format(parsed_args.tenant_id), + self.app.get_url(self.app.url_prefix+"/tenants/{}".format(parsed_args.tenant_id), method="DELETE", authtoken=True) |