diff options
author | asteroide <thomas.duval@orange.com> | 2015-11-09 10:04:27 +0100 |
---|---|---|
committer | asteroide <thomas.duval@orange.com> | 2015-11-09 10:04:27 +0100 |
commit | 7e98b5d8b90f18d433fabc34733030ba69e8d584 (patch) | |
tree | 741d858a919c94f3a54f9ad980882052f9f7eeae /moonclient | |
parent | 1057fe45ef39844e7ad64fafbc3aba2ea8999b26 (diff) |
Add username and tenant parameters to Moonclient
Change-Id: Ie96e7b579a5fe6e1cae4198cbd7ca59d7e39fb21
Diffstat (limited to 'moonclient')
-rw-r--r-- | moonclient/moonclient/shell.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/moonclient/moonclient/shell.py b/moonclient/moonclient/shell.py index 60a5355f..ce59b3c6 100644 --- a/moonclient/moonclient/shell.py +++ b/moonclient/moonclient/shell.py @@ -78,6 +78,18 @@ class MoonClient(App): self.host = creds["auth_url"].replace("https://", "").replace("http://", "").split("/")[0].split(":")[0] self.port = creds["auth_url"].replace("https://", "").replace("http://", "").split("/")[0].split(":")[1] self._tenant_name = creds["tenant_name"] + self.parser.add_argument( + '--username', + metavar='<username-str>', + help='Force OpenStack username', + default=None + ) + self.parser.add_argument( + '--tenant', + metavar='<tenantname-str>', + help='Force OpenStack tenant', + default=None + ) @property def tenant_id(self): @@ -144,7 +156,13 @@ class MoonClient(App): def initialize_app(self, argv): self.log.debug('initialize_app: {}'.format(argv)) - # TODO: get credentials from OS env + if self.options.username: + self.post["auth"]["identity"]["password"]["user"]["name"] = self.options.username + self.log.debug("change username {}".format(self.options.username)) + if self.options.tenant: + self.post["auth"]["scope"]["project"]["name"] = self.options.tenant + self._tenant_name = self.options.tenant + self.log.debug("change tenant {}".format(self.options.tenant)) data = self.get_url("/v3/auth/tokens", post_data=self.post) if "token" not in data: raise Exception("Authentication problem ({})".format(data)) |