From ef481c3a12ea5ef8ff3caf6832ca54a6140cdd03 Mon Sep 17 00:00:00 2001 From: asteroide Date: Tue, 15 Sep 2015 11:23:50 +0200 Subject: Correct all the subject commands. Change-Id: I54b29c7cee95b39d55f5bd9a722d5a20f6e5d2e2 --- moonclient/moonclient/subjects.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'moonclient') diff --git a/moonclient/moonclient/subjects.py b/moonclient/moonclient/subjects.py index 21987907..69286343 100644 --- a/moonclient/moonclient/subjects.py +++ b/moonclient/moonclient/subjects.py @@ -28,11 +28,9 @@ class SubjectsList(Lister): parsed_args.intraextension = self.app.intraextension data = self.app.get_url("/v3/OS-MOON/intra_extensions/{}/subjects".format(parsed_args.intraextension), authtoken=True) - if "subjects" not in data: - raise Exception("Error in command {}: {}".format("SubjectsList", data)) return ( - ("subjects",), - ((_uuid, ) for _uuid in data["subjects"]) + ("id", "name", "Keystone ID"), + ((_uuid, data[_uuid]["name"], data[_uuid]["keystone_id"]) for _uuid in data) ) @@ -45,8 +43,8 @@ class SubjectsAdd(Command): parser = super(SubjectsAdd, self).get_parser(prog_name) parser.add_argument( 'subject', - metavar='', - help='Subject UUID', + metavar='', + help='Subject name', ) parser.add_argument( '--intraextension', @@ -59,13 +57,11 @@ class SubjectsAdd(Command): 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), - post_data={"subject_id": parsed_args.subject}, + post_data={"subject_name": parsed_args.subject}, authtoken=True) - if "subjects" not in data: - raise Exception("Error in command {}".format(data)) return ( - ("subjects",), - ((_uuid, ) for _uuid in data["subjects"]) + ("id", "name", "Keystone ID"), + ((_uuid, data[_uuid]["name"], data[_uuid]["keystone_id"]) for _uuid in data) ) -- cgit 1.2.3-korg