Skip to content

Commit 95996b0

Browse files
authored
Merge pull request #67 from hustlzp1981/add_config_option
Add Cfgfile option
2 parents 1b45092 + e0bd7ba commit 95996b0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

redfishtool/redfishtoolMain.py

+12
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ def main(argv):
156156
rft.authToken=rft.token
157157
elif opt in ("-c", "--config"): #read additional options from a file
158158
rft.configFile=arg
159+
try:
160+
with open(arg, 'r') as f:
161+
configdata = json.load(f)
162+
if 'user' in configdata and 'password' in configdata:
163+
rft.user = configdata['user']
164+
rft.password = configdata['password']
165+
rft.printVerbose(1,"Main: get pw from configfile, usr:{}, pw:{}".format(rft.user, rft.password))
166+
else:
167+
rft.printErr("Invalid --config= filedata: {}".format(configdata))
168+
except IOError:
169+
rft.printErr("Invalid: Failed to read configfile")
170+
159171
elif opt in ("-T", "--Timeout"): #Specify http timeout in seconds
160172
timePattern="^([1-9][0-9]*)$"
161173
timeMatch=re.search(timePattern,arg)

0 commit comments

Comments
 (0)