Skip to content

Commit 9ca80bc

Browse files
author
Kevin Sweeney
committed
Added --interactive option to hpilo_cli.
1 parent d7298f8 commit 9ca80bc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

hpilo_cli

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ try:
1212
except NameError:
1313
basestring = str
1414
import hpilo
15+
try:
16+
input = raw_input
17+
except NameError:
18+
pass
19+
import getpass
1520
import optparse
1621
import os
1722
from pprint import pprint
@@ -27,6 +32,8 @@ def main():
2732
help="Username to access the iLO")
2833
p.add_option("-p", "--password", dest="password", default=None,
2934
help="Password to access the iLO")
35+
p.add_option("-i", "--interactive", action="store_true", default=False,
36+
help="Prompt for username and/or password if they are not specified.")
3037
p.add_option("-c", "--config", dest="config", default="~/.ilo.conf",
3138
help="File containing authentication and config details", metavar="FILE")
3239
p.add_option("-t", "--timeout", dest="timeout", type="int", default=60,
@@ -119,7 +126,13 @@ def main():
119126
if opts.password:
120127
password = opts.password
121128
if not login or not password:
122-
p.error("No login details provided")
129+
if opts.interactive:
130+
while not login:
131+
login = input('Login for iLO at %s: ' % hostname)
132+
while not password:
133+
password = getpass.getpass('Password for %s@%s:' % (login, hostname))
134+
else:
135+
p.error("No login details provided")
123136

124137
opts.protocol = {
125138
'http': hpilo.ILO_HTTP,

0 commit comments

Comments
 (0)