Merge "If no password in env or command line, try prompting."
This commit is contained in:
commit
2223308983
@ -19,6 +19,7 @@
|
|||||||
Command-line interface to the OpenStack APIs
|
Command-line interface to the OpenStack APIs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -149,9 +150,20 @@ class OpenStackShell(App):
|
|||||||
" either --os-username or env[OS_USERNAME]")
|
" either --os-username or env[OS_USERNAME]")
|
||||||
|
|
||||||
if not self.options.os_password:
|
if not self.options.os_password:
|
||||||
raise exc.CommandError(
|
# No password, if we've got a tty, try prompting for it
|
||||||
"You must provide a password via"
|
if hasattr(sys.stdin, 'isatty') and sys.stdin.isatty():
|
||||||
" either --os-password or env[OS_PASSWORD]")
|
# 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):
|
if not (self.options.os_tenant_id or self.options.os_tenant_name):
|
||||||
raise exc.CommandError(
|
raise exc.CommandError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user