diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-05 16:56:35 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-05 16:56:35 +0000 |
| commit | 222330898300676dbadd82d8c000a02ad964d35c (patch) | |
| tree | 2cf8eb5f0e3ca61c29a9fb762f166183f4eb6c11 /openstackclient | |
| parent | fd1b11856587167829f51c728066238d64a93e0e (diff) | |
| parent | 39da32b3a5d31a022e958c7b2ca752a1b6fbd3a2 (diff) | |
| download | python-openstackclient-222330898300676dbadd82d8c000a02ad964d35c.tar.gz | |
Merge "If no password in env or command line, try prompting."
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/shell.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py index 14b4f80a..3d0adf99 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -19,6 +19,7 @@ Command-line interface to the OpenStack APIs """ +import getpass import logging import os import sys @@ -149,9 +150,20 @@ class OpenStackShell(App): " either --os-username or env[OS_USERNAME]") if not self.options.os_password: - raise exc.CommandError( - "You must provide a password via" - " either --os-password or env[OS_PASSWORD]") + # No password, if we've got a tty, try prompting for it + if hasattr(sys.stdin, 'isatty') and sys.stdin.isatty(): + # Check for Ctl-D + try: + self.options.os_password = getpass.getpass() + except EOFError: + pass + # No password because we did't have a tty or the + # user Ctl-D when prompted? + if not self.options.os_password: + raise exc.CommandError( + "You must provide a password via" + " either --os-password, or env[OS_PASSWORD], " + " or prompted response") if not (self.options.os_tenant_id or self.options.os_tenant_name): raise exc.CommandError( |
