2
0
mirror of https://opendev.org/x/pyghmi synced 2025-03-19 09:57:43 +00:00

Add password settings to xcc extended attributes

This gives access to the password policy settings to
the xcc, both read and write.

Change-Id: I9a449eee1b46f5cd6856411cc4578ef52fcfcdd4
This commit is contained in:
Jarrod Johnson 2019-08-29 15:46:50 -04:00
parent ee4219766a
commit c711fc5dbe

View File

@ -826,9 +826,29 @@ class XCCClient(IMMClient):
settings['smm']['value'] = 'Enable'
else:
settings['smm']['value'] = None
passrules = self.wc.grab_json_response('/api/dataset/imm_users_global')
passrules = passrules.get('items', [{}])[0]
settings['password_reuse_count'] = {'value': passrules.get('pass_min_resuse')}
settings['password_change_interval'] = {'value': passrules.get('pass_min_resuse')}
settings['password_expiration'] = {'value': passrules.get('pass_expire_days')}
settings['password_login_failures'] = {'value': passrules.get('max_login_failures')}
settings['password_complexity'] = {'value': passrules.get('pass_complex_required')}
settings['password_min_length'] = {'value': passrules.get('pass_min_length')}
settings['password_lockout_period'] = {'value': passrules.get('lockout_period')}
return settings
rulemap = {
'password_change_interval': 'USER_GlobalMinPassChgInt',
'password_reuse_count': 'USER_GlobalMinPassReuseCycle',
'password_expiration': 'USER_GlobalPassExpPeriod',
'password_login_failures': 'USER_GlobalMaxLoginFailures',
'password_complexity': 'USER_GlobalPassComplexRequired',
'password_min_length': 'USER_GlobalMinPassLen',
'password_lockout_period': 'USER_GlobalLockoutPeriod',
}
def set_bmc_configuration(self, changeset):
ruleset = {}
for key in changeset:
if (isinstance(changeset[key], str) or
isinstance(changeset[key], unicode)):
@ -839,9 +859,13 @@ class XCCClient(IMMClient):
self.ipmicmd.xraw_command(0x3a, 0xf1, data=[1])
elif currval == 'Disable':
self.ipmicmd.xraw_command(0x3a, 0xf1, data=[2])
elif key.lower() in self.rulemap:
ruleset[self.rulemap[key.lower()]] = changeset[key]['value']
else:
raise pygexc.InvalidParameterValue(
'{0} not a known setting'.format(key))
if ruleset:
rsp = self.wc.grab_json_response('/api/dataset', ruleset)
def clear_system_configuration(self):
res = self.wc.grab_json_response_with_status(