Merge pull request #50969 from twangboy/fix_lgpo

Fix issue with LGPO when returning empty dict
This commit is contained in:
Daniel Wozniak 2018-12-26 11:41:32 -07:00 committed by GitHub
commit 4faa4b9c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,7 +114,6 @@ import salt.utils.json
# Import 3rd party libs
from salt.ext import six
from requests.structures import CaseInsensitiveDict
log = logging.getLogger(__name__)
__virtualname__ = 'lgpo'
@ -251,14 +250,20 @@ def set_(name,
for policy_section, policy_data in six.iteritems(pol_data):
pol_id = None
if policy_data and policy_data['output_section'] in current_policy:
# Make the subdict keys case insensitive
current_policy[policy_data['output_section']] = CaseInsensitiveDict(
current_policy[policy_data['output_section']])
for policy_name, policy_setting in six.iteritems(policy_data['requested_policy']):
currently_set = False
# Check Case sensitive first (faster)
if policy_name in current_policy[policy_data['output_section']]:
currently_set = True
pol_id = policy_name
# Check case insensitive
elif policy_name.lower() in (k.lower() for k in current_policy[policy_data['output_section']]):
for p_name in current_policy[policy_data['output_section']]:
if policy_name.lower() == p_name.lower():
currently_set = True
pol_id = p_name
break
# Check aliases
else:
for alias in policy_data['policy_lookup'][policy_name]['policy_aliases']:
log.debug('checking alias %s', alias)