"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "salt/states/win_lgpo.py" between
salt-2019.2.0.tar.gz and salt-2019.2.1.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

win_lgpo.py  (salt-2019.2.0):win_lgpo.py  (salt-2019.2.1)
skipping to change at line 128 skipping to change at line 128
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
__virtualname__ = 'lgpo' __virtualname__ = 'lgpo'
__func_alias__ = {'set_': 'set'} __func_alias__ = {'set_': 'set'}
def __virtual__(): def __virtual__():
''' '''
load this state if the win_lgpo module exists load this state if the win_lgpo module exists
''' '''
return __virtualname__ if 'lgpo.set' in __salt__ else False return __virtualname__ if 'lgpo.set' in __salt__ else False
def _compare_policies(new_policy, current_policy):
'''
Helper function that returns ``True`` if the policies are the same,
otherwise ``False``
'''
# Compared dicts, lists, and strings
if isinstance(new_policy, six.string_types):
return new_policy == current_policy
elif isinstance(new_policy, list):
if isinstance(current_policy, list):
return salt.utils.data.compare_lists(new_policy,
current_policy) == {}
else:
return False
elif isinstance(new_policy, dict):
if isinstance(current_policy, dict):
return salt.utils.data.compare_dicts(new_policy,
current_policy) == {}
else:
return False
def set_(name, def set_(name,
setting=None, setting=None,
policy_class=None, policy_class=None,
computer_policy=None, computer_policy=None,
user_policy=None, user_policy=None,
cumulative_rights_assignments=True, cumulative_rights_assignments=True,
adml_language='en-US'): adml_language='en-US'):
''' '''
Ensure the specified policy is set Ensure the specified policy is set
skipping to change at line 279 skipping to change at line 300
currently_set = True currently_set = True
pol_id = alias pol_id = alias
break break
if currently_set: if currently_set:
# compare # compare
log.debug('need to compare %s from ' log.debug('need to compare %s from '
'current/requested policy', policy_name) 'current/requested policy', policy_name)
changes = False changes = False
requested_policy_json = salt.utils.json.dumps(policy_data['r equested_policy'][policy_name], sort_keys=True).lower() requested_policy_json = salt.utils.json.dumps(policy_data['r equested_policy'][policy_name], sort_keys=True).lower()
current_policy_json = salt.utils.json.dumps(current_policy[p olicy_data['output_section']][pol_id], sort_keys=True).lower() current_policy_json = salt.utils.json.dumps(current_policy[p olicy_data['output_section']][pol_id], sort_keys=True).lower()
policies_are_equal = False
requested_policy_check = salt.utils.json.loads(requested_pol icy_json) requested_policy_check = salt.utils.json.loads(requested_pol icy_json)
current_policy_check = salt.utils.json.loads(current_policy_ json) current_policy_check = salt.utils.json.loads(current_policy_ json)
# Compared dicts, lists, and strings # Are the requested and current policies identical
if isinstance(requested_policy_check, six.string_types): policies_are_equal = _compare_policies(
policies_are_equal = requested_policy_check == current_p requested_policy_check, current_policy_check)
olicy_check
elif isinstance(requested_policy_check, list):
policies_are_equal = salt.utils.data.compare_lists(
requested_policy_check,
current_policy_check
) == {}
elif isinstance(requested_policy_check, dict):
policies_are_equal = salt.utils.data.compare_dicts(
requested_policy_check,
current_policy_check
) == {}
if not policies_are_equal: if not policies_are_equal:
additional_policy_comments = [] additional_policy_comments = []
if policy_data['policy_lookup'][policy_name]['rights_ass ignment'] and cumulative_rights_assignments: if policy_data['policy_lookup'][policy_name]['rights_ass ignment'] and cumulative_rights_assignments:
for user in policy_data['requested_policy'][policy_n ame]: for user in policy_data['requested_policy'][policy_n ame]:
if user not in current_policy[policy_data['outpu t_section']][pol_id]: if user not in current_policy[policy_data['outpu t_section']][pol_id]:
changes = True changes = True
else: else:
additional_policy_comments.append('"{0}" is already granted the right'.format(user)) additional_policy_comments.append('"{0}" is already granted the right'.format(user))
else: else:
 End of changes. 3 change blocks. 
15 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)