mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
No need to call .keys()
when iterating a dictionary
This commit is contained in:
parent
0da3c1f808
commit
7dc6b64689
53 changed files with 96 additions and 96 deletions
|
@ -215,7 +215,7 @@ class Batch(object):
|
|||
print_cli('minion {0} was already deleted from tracker, probably a duplicate key'.format(part['id']))
|
||||
else:
|
||||
parts.update(part)
|
||||
for id in part.keys():
|
||||
for id in part:
|
||||
if id in minion_tracker[queue]['minions']:
|
||||
minion_tracker[queue]['minions'].remove(id)
|
||||
else:
|
||||
|
|
|
@ -721,7 +721,7 @@ class LocalClient(object):
|
|||
ret[mid] = (data if full_return
|
||||
else data.get('ret', {}))
|
||||
|
||||
for failed in list(set(pub_data['minions']) ^ set(ret.keys())):
|
||||
for failed in list(set(pub_data['minions']) ^ set(ret)):
|
||||
ret[failed] = False
|
||||
return ret
|
||||
finally:
|
||||
|
@ -943,7 +943,7 @@ class LocalClient(object):
|
|||
block=False,
|
||||
**kwargs):
|
||||
if fn_ret and any([show_jid, verbose]):
|
||||
for minion in fn_ret.keys():
|
||||
for minion in fn_ret:
|
||||
fn_ret[minion]['jid'] = pub_data['jid']
|
||||
yield fn_ret
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ class CloudClient(object):
|
|||
if a.get('provider', '')]
|
||||
if providers:
|
||||
_providers = opts.get('providers', {})
|
||||
for provider in _providers.keys():
|
||||
for provider in _providers:
|
||||
if provider not in providers:
|
||||
_providers.pop(provider)
|
||||
return opts
|
||||
|
|
|
@ -1104,7 +1104,7 @@ def list_nodes(call=None, **kwargs):
|
|||
public = []
|
||||
if 'addresses' not in server_tmp:
|
||||
server_tmp['addresses'] = {}
|
||||
for network in server_tmp['addresses'].keys():
|
||||
for network in server_tmp['addresses']:
|
||||
for address in server_tmp['addresses'][network]:
|
||||
if salt.utils.cloud.is_public_ip(address.get('addr', '')):
|
||||
public.append(address['addr'])
|
||||
|
|
|
@ -508,7 +508,7 @@ def get_devices_by_token():
|
|||
|
||||
devices = []
|
||||
|
||||
for profile_name in vm_['profiles'].keys():
|
||||
for profile_name in vm_['profiles']:
|
||||
profile = vm_['profiles'][profile_name]
|
||||
|
||||
devices.extend(manager.list_devices(profile['project_id']))
|
||||
|
|
|
@ -170,7 +170,7 @@ def update_employee(emp_id, key=None, value=None, items=None):
|
|||
items = yaml.safe_load(items)
|
||||
|
||||
xml_items = ''
|
||||
for pair in items.keys():
|
||||
for pair in items:
|
||||
xml_items += '<field id="{0}">{1}</field>'.format(pair, items[pair])
|
||||
xml_items = '<employee>{0}</employee>'.format(xml_items)
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ def config_(dev=None, **kwargs):
|
|||
if key in data:
|
||||
del data[key]
|
||||
|
||||
for key in data.keys():
|
||||
for key in data:
|
||||
result.update(data[key])
|
||||
|
||||
return result
|
||||
|
@ -441,7 +441,7 @@ def status(stats=False, config=False, internals=False, superblock=False, alldevs
|
|||
cdev = _bdev()
|
||||
if cdev:
|
||||
count = 0
|
||||
for dev in statii.keys():
|
||||
for dev in statii:
|
||||
if dev != cdev:
|
||||
# it's a backing dev
|
||||
if statii[dev]['cache'] == cuuid:
|
||||
|
@ -519,7 +519,7 @@ def device(dev, stats=False, config=False, internals=False, superblock=False):
|
|||
if 'stats' in result:
|
||||
replre = r'(stats|cache)_'
|
||||
statres = result['stats']
|
||||
for attr in result['stats'].keys():
|
||||
for attr in result['stats']:
|
||||
if '/' not in attr:
|
||||
key = re.sub(replre, '', attr)
|
||||
statres[key] = statres.pop(attr)
|
||||
|
@ -537,7 +537,7 @@ def device(dev, stats=False, config=False, internals=False, superblock=False):
|
|||
interres = result.pop('inter_ro', {})
|
||||
interres.update(result.pop('inter_rw', {}))
|
||||
if len(interres):
|
||||
for key in interres.keys():
|
||||
for key in interres:
|
||||
if key.startswith('internal'):
|
||||
nkey = re.sub(r'internal[s/]*', '', key)
|
||||
interres[nkey] = interres.pop(key)
|
||||
|
@ -552,7 +552,7 @@ def device(dev, stats=False, config=False, internals=False, superblock=False):
|
|||
# ---------------- Config ----------------
|
||||
if config:
|
||||
configres = result['config']
|
||||
for key in configres.keys():
|
||||
for key in configres:
|
||||
if key.startswith('writeback'):
|
||||
mkey, skey = re.split(r'_', key, maxsplit=1)
|
||||
if mkey not in configres:
|
||||
|
@ -767,7 +767,7 @@ def _sysfs_parse(path, base_attr=None, stats=False, config=False, internals=Fals
|
|||
bintf[key].append(intf)
|
||||
|
||||
if base_attr is not None:
|
||||
for intf in bintf.keys():
|
||||
for intf in bintf:
|
||||
bintf[intf] = [sintf for sintf in bintf[intf] if sintf not in base_attr]
|
||||
bintf['base'] = base_attr
|
||||
|
||||
|
|
|
@ -984,7 +984,7 @@ def replace_pool_members(hostname, username, password, name, members):
|
|||
member['state'] = member.pop('member_state')
|
||||
|
||||
#replace underscore with dash
|
||||
for key in member.keys():
|
||||
for key in member:
|
||||
new_key = key.replace('_', '-')
|
||||
member[new_key] = member.pop(key)
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ def add_pool_member(hostname, username, password, name, member):
|
|||
member['state'] = member.pop('member_state')
|
||||
|
||||
#replace underscore with dash
|
||||
for key in member.keys():
|
||||
for key in member:
|
||||
new_key = key.replace('_', '-')
|
||||
member[new_key] = member.pop(key)
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ def _proxy_cmd(command, *args, **kwargs):
|
|||
proxy_cmd = '.'.join([proxy_prefix, command])
|
||||
if proxy_cmd not in __proxy__:
|
||||
return False
|
||||
for k in kwargs.keys():
|
||||
for k in kwargs:
|
||||
if k.startswith('__pub_'):
|
||||
kwargs.pop(k)
|
||||
return __proxy__[proxy_cmd](*args, **kwargs)
|
||||
|
|
|
@ -700,7 +700,7 @@ def smart_attributes(dev, attributes=None, values=None):
|
|||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
|
||||
for field in data.keys():
|
||||
for field in data:
|
||||
val = data[field]
|
||||
try:
|
||||
val = int(val)
|
||||
|
|
|
@ -358,7 +358,7 @@ def image_show(id=None, name=None, profile=None): # pylint: disable=C0103
|
|||
schema = image_schema(profile=profile)
|
||||
if len(schema.keys()) == 1:
|
||||
schema = schema['image']
|
||||
for key in schema.keys():
|
||||
for key in schema:
|
||||
if key in image:
|
||||
ret[key] = image[key]
|
||||
return ret
|
||||
|
|
|
@ -163,7 +163,7 @@ def _restore_ownership(func):
|
|||
__salt__['file.chown'](path, run_user['name'], group)
|
||||
|
||||
# Filter special kwargs
|
||||
for key in kwargs.keys():
|
||||
for key in kwargs:
|
||||
if key.startswith('__'):
|
||||
del kwargs[key]
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ def get_network(network_name,
|
|||
log.debug('Infoblox record returned: {0}'.format(entry))
|
||||
tEntry = {}
|
||||
data = _parse_record_data(entry)
|
||||
for key in data.keys():
|
||||
for key in data:
|
||||
tEntry[key] = data[key]
|
||||
records.append(tEntry)
|
||||
return records
|
||||
|
@ -467,7 +467,7 @@ def get_record(record_name,
|
|||
log.debug('Infoblox record returned: {0}'.format(entry))
|
||||
tEntry = {}
|
||||
data = _parse_record_data(entry)
|
||||
for key in data.keys():
|
||||
for key in data:
|
||||
tEntry[key] = data[key]
|
||||
records.append(tEntry)
|
||||
return records
|
||||
|
|
|
@ -64,7 +64,7 @@ def _get_config(**kwargs):
|
|||
if '__salt__' in globals():
|
||||
config_key = '{0}.config'.format(__virtualname__)
|
||||
config.update(__salt__['config.get'](config_key, {}))
|
||||
for k in set(config.keys()) & set(kwargs.keys()):
|
||||
for k in set(config) & set(kwargs):
|
||||
config[k] = kwargs[k]
|
||||
return config
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ def _route_flags(rflags):
|
|||
0x01000000: 'C', # RTF_CACHE, cache entry
|
||||
0x0200: '!', # RTF_REJECT, reject route
|
||||
}
|
||||
for item in fmap.keys():
|
||||
for item in fmap:
|
||||
if rflags & item:
|
||||
flags += fmap[item]
|
||||
return flags
|
||||
|
|
|
@ -135,7 +135,7 @@ def _get_config(**kwargs):
|
|||
}
|
||||
config_key = '{0}.config'.format(__virtualname__)
|
||||
config.update(__salt__['config.get'](config_key, {}))
|
||||
for k in set(config.keys()) & set(kwargs.keys()):
|
||||
for k in set(config) & set(kwargs):
|
||||
config[k] = kwargs[k]
|
||||
return config
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ def cmd(command, *args, **kwargs):
|
|||
proxy_cmd = '.'.join([proxy_prefix, command])
|
||||
if proxy_cmd not in __proxy__:
|
||||
return False
|
||||
for k in kwargs.keys():
|
||||
for k in kwargs:
|
||||
if k.startswith('__pub_'):
|
||||
kwargs.pop(k)
|
||||
return __proxy__[proxy_cmd](*args, **kwargs)
|
||||
|
|
|
@ -619,7 +619,7 @@ def file_dict(*packages):
|
|||
continue # unexpected string
|
||||
|
||||
ret = {'errors': errors, 'files': files}
|
||||
for field in ret.keys():
|
||||
for field in ret:
|
||||
if not ret[field] or ret[field] == '':
|
||||
del ret[field]
|
||||
return ret
|
||||
|
|
|
@ -82,7 +82,7 @@ def _get_proxy_windows(types=None):
|
|||
if len(types) == 1:
|
||||
return ret[types[0]]
|
||||
else:
|
||||
for key in ret.keys():
|
||||
for key in ret:
|
||||
if key not in types:
|
||||
del ret[key]
|
||||
|
||||
|
|
|
@ -392,7 +392,7 @@ def restartcheck(ignorelist=None, blacklist=None, excludepid=None, verbose=True)
|
|||
if len(packages) == 0 and not kernel_restart:
|
||||
return 'No packages seem to need to be restarted.'
|
||||
|
||||
for package in packages.keys():
|
||||
for package in packages:
|
||||
cmd = cmd_pkg_query + package
|
||||
paths = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
|
||||
|
||||
|
@ -427,7 +427,7 @@ def restartcheck(ignorelist=None, blacklist=None, excludepid=None, verbose=True)
|
|||
paths.stdout.close()
|
||||
|
||||
# Alternatively, find init.d script or service that match the process name
|
||||
for package in packages.keys():
|
||||
for package in packages:
|
||||
if len(packages[package]['systemdservice']) == 0 and len(packages[package]['initscripts']) == 0:
|
||||
service = __salt__['service.available'](packages[package]['process_name'])
|
||||
|
||||
|
@ -442,7 +442,7 @@ def restartcheck(ignorelist=None, blacklist=None, excludepid=None, verbose=True)
|
|||
restartinitcommands = []
|
||||
restartservicecommands = []
|
||||
|
||||
for package in packages.keys():
|
||||
for package in packages:
|
||||
if len(packages[package]['initscripts']) > 0:
|
||||
restartable.append(package)
|
||||
restartinitcommands.extend(['service ' + s + ' restart' for s in packages[package]['initscripts']])
|
||||
|
|
|
@ -514,7 +514,7 @@ def fcontext_apply_policy(name, recursive=False):
|
|||
for key, value in six.iteritems(old):
|
||||
if new.get(key) == value:
|
||||
intersect.update({key: value})
|
||||
for key in intersect.keys():
|
||||
for key in intersect:
|
||||
del old[key]
|
||||
del new[key]
|
||||
ret['changes'].update({filespec: {'old': old, 'new': new}})
|
||||
|
|
|
@ -879,7 +879,7 @@ def netdev():
|
|||
'''
|
||||
ret = {}
|
||||
##NOTE: we cannot use hwaddr_interfaces here, so we grab both ip4 and ip6
|
||||
for dev in __grains__['ip4_interfaces'].keys() + __grains__['ip6_interfaces'].keys():
|
||||
for dev in __grains__['ip4_interfaces'].keys() + __grains__['ip6_interfaces']:
|
||||
# fetch device info
|
||||
netstat_ipv4 = __salt__['cmd.run']('netstat -i -I {dev} -n -f inet'.format(dev=dev)).splitlines()
|
||||
netstat_ipv6 = __salt__['cmd.run']('netstat -i -I {dev} -n -f inet6'.format(dev=dev)).splitlines()
|
||||
|
|
|
@ -235,7 +235,7 @@ def _copy_function(module_name, name=None):
|
|||
return success, pass_msgs, fail_msgs
|
||||
if hasattr(inspect, 'signature'):
|
||||
mod_sig = inspect.signature(mod)
|
||||
parameters = mod_sig.parameters.keys()
|
||||
parameters = mod_sig.parameters
|
||||
else:
|
||||
if isinstance(mod.__init__, types.MethodType):
|
||||
mod_sig = inspect.getargspec(mod.__init__)
|
||||
|
@ -243,7 +243,7 @@ def _copy_function(module_name, name=None):
|
|||
mod_sig = inspect.getargspec(mod.__call__)
|
||||
parameters = mod_sig.args
|
||||
additional_args = {}
|
||||
for arg in set(parameters).intersection(set(methods.keys())):
|
||||
for arg in set(parameters).intersection(set(methods)):
|
||||
additional_args[arg] = methods.pop(arg)
|
||||
try:
|
||||
if len(parameters) > 1:
|
||||
|
|
|
@ -3820,7 +3820,7 @@ def _checkAllAdmxPolicies(policy_class,
|
|||
if policy_vals and return_full_policy_names and not hierarchical_return:
|
||||
unpathed_dict = {}
|
||||
pathed_dict = {}
|
||||
for policy_item in policy_vals.keys():
|
||||
for policy_item in policy_vals:
|
||||
if full_names[policy_item] in policy_vals:
|
||||
# add this item with the path'd full name
|
||||
full_path_list = hierarchy[policy_item]
|
||||
|
@ -3832,7 +3832,7 @@ def _checkAllAdmxPolicies(policy_class,
|
|||
policy_vals[full_names[policy_item]] = policy_vals.pop(policy_item)
|
||||
unpathed_dict[full_names[policy_item]] = policy_item
|
||||
# go back and remove any "unpathed" policies that need a full path
|
||||
for path_needed in unpathed_dict.keys():
|
||||
for path_needed in unpathed_dict:
|
||||
# remove the item with the same full name and re-add it w/a path'd version
|
||||
full_path_list = hierarchy[unpathed_dict[path_needed]]
|
||||
full_path_list.reverse()
|
||||
|
@ -3841,7 +3841,7 @@ def _checkAllAdmxPolicies(policy_class,
|
|||
policy_vals['\\'.join(full_path_list)] = policy_vals.pop(path_needed)
|
||||
if policy_vals and hierarchical_return:
|
||||
if hierarchy:
|
||||
for hierarchy_item in hierarchy.keys():
|
||||
for hierarchy_item in hierarchy:
|
||||
if hierarchy_item in policy_vals:
|
||||
tdict = {}
|
||||
first_item = True
|
||||
|
@ -4151,14 +4151,14 @@ def _writeAdminTemplateRegPolFile(admtemplate_data,
|
|||
hierarchical_return=False,
|
||||
return_not_configured=False)
|
||||
log.debug('preparing to loop through policies requested to be configured')
|
||||
for adm_policy in admtemplate_data.keys():
|
||||
for adm_policy in admtemplate_data:
|
||||
if str(admtemplate_data[adm_policy]).lower() == 'not configured':
|
||||
if adm_policy in base_policy_settings:
|
||||
base_policy_settings.pop(adm_policy)
|
||||
else:
|
||||
log.debug('adding {0} to base_policy_settings'.format(adm_policy))
|
||||
base_policy_settings[adm_policy] = admtemplate_data[adm_policy]
|
||||
for admPolicy in base_policy_settings.keys():
|
||||
for admPolicy in base_policy_settings:
|
||||
log.debug('working on admPolicy {0}'.format(admPolicy))
|
||||
explicit_enable_disable_value_setting = False
|
||||
this_key = None
|
||||
|
@ -4225,7 +4225,7 @@ def _writeAdminTemplateRegPolFile(admtemplate_data,
|
|||
# WARNING: no OOB adm files use true/falseList items
|
||||
# this has not been fully vetted
|
||||
temp_dict = {'trueList': TRUE_LIST_XPATH, 'falseList': FALSE_LIST_XPATH}
|
||||
for this_list in temp_dict.keys():
|
||||
for this_list in temp_dict:
|
||||
disabled_list_strings = _checkListItem(
|
||||
child_item,
|
||||
admPolicy,
|
||||
|
@ -4731,7 +4731,7 @@ def get_policy_info(policy_name,
|
|||
ret['rights_assignment'] = True
|
||||
return ret
|
||||
else:
|
||||
for pol in policy_data.policies[policy_class]['policies'].keys():
|
||||
for pol in policy_data.policies[policy_class]['policies']:
|
||||
if policy_data.policies[policy_class]['policies'][pol]['Policy'].lower() == policy_name.lower():
|
||||
ret['policy_aliases'].append(pol)
|
||||
ret['policy_found'] = True
|
||||
|
@ -4833,7 +4833,7 @@ def get(policy_class=None, return_full_policy_names=True,
|
|||
if policy_name in _policydata.policies[p_class]['policies']:
|
||||
_pol = _policydata.policies[p_class]['policies'][policy_name]
|
||||
else:
|
||||
for policy in _policydata.policies[p_class]['policies'].keys():
|
||||
for policy in _policydata.policies[p_class]['policies']:
|
||||
if _policydata.policies[p_class]['policies'][policy]['Policy'].upper() == policy_name.upper():
|
||||
_pol = _policydata.policies[p_class]['policies'][policy]
|
||||
policy_name = policy
|
||||
|
@ -5072,7 +5072,7 @@ def set_(computer_policy=None, user_policy=None,
|
|||
policies['User'] = user_policy
|
||||
policies['Machine'] = computer_policy
|
||||
if policies:
|
||||
for p_class in policies.keys():
|
||||
for p_class in policies:
|
||||
_secedits = {}
|
||||
_modal_sets = {}
|
||||
_admTemplateData = {}
|
||||
|
@ -5081,13 +5081,13 @@ def set_(computer_policy=None, user_policy=None,
|
|||
_policydata = _policy_info()
|
||||
admxPolicyDefinitions, admlPolicyResources = _processPolicyDefinitions(display_language=adml_language)
|
||||
if policies[p_class]:
|
||||
for policy_name in policies[p_class].keys():
|
||||
for policy_name in policies[p_class]:
|
||||
_pol = None
|
||||
policy_key_name = policy_name
|
||||
if policy_name in _policydata.policies[p_class]['policies']:
|
||||
_pol = _policydata.policies[p_class]['policies'][policy_name]
|
||||
else:
|
||||
for policy in _policydata.policies[p_class]['policies'].keys():
|
||||
for policy in _policydata.policies[p_class]['policies']:
|
||||
if _policydata.policies[p_class]['policies'][policy]['Policy'].upper() == \
|
||||
policy_name.upper():
|
||||
_pol = _policydata.policies[p_class]['policies'][policy]
|
||||
|
@ -5237,7 +5237,7 @@ def set_(computer_policy=None, user_policy=None,
|
|||
msg = msg.format(policy_name)
|
||||
raise SaltInvocationError(msg)
|
||||
if _regedits:
|
||||
for regedit in _regedits.keys():
|
||||
for regedit in _regedits:
|
||||
log.debug('{0} is a Registry policy'.format(regedit))
|
||||
# if the value setting is None or "(value not set)", we will delete the value from the registry
|
||||
if _regedits[regedit]['value'] is not None and _regedits[regedit]['value'] != '(value not set)':
|
||||
|
@ -5257,7 +5257,7 @@ def set_(computer_policy=None, user_policy=None,
|
|||
' Some changes may not be applied as expected')
|
||||
raise CommandExecutionError(msg.format(regedit))
|
||||
if _lsarights:
|
||||
for lsaright in _lsarights.keys():
|
||||
for lsaright in _lsarights:
|
||||
_existingUsers = None
|
||||
if not cumulative_rights_assignments:
|
||||
_existingUsers = _getRightsAssignments(
|
||||
|
@ -5296,7 +5296,7 @@ def set_(computer_policy=None, user_policy=None,
|
|||
if _modal_sets:
|
||||
# we've got modalsets to make
|
||||
log.debug(_modal_sets)
|
||||
for _modal_set in _modal_sets.keys():
|
||||
for _modal_set in _modal_sets:
|
||||
try:
|
||||
_existingModalData = win32net.NetUserModalsGet(None, _modal_set)
|
||||
_newModalSetData = dictupdate.update(_existingModalData, _modal_sets[_modal_set])
|
||||
|
|
|
@ -338,7 +338,7 @@ def list_pkgs(versions_as_list=False, **kwargs):
|
|||
pkg_info = _get_package_info(key, saltenv=saltenv)
|
||||
if not pkg_info:
|
||||
continue
|
||||
for pkg_ver in pkg_info.keys():
|
||||
for pkg_ver in pkg_info:
|
||||
if pkg_info[pkg_ver]['full_name'] == pkg_name:
|
||||
val = pkg_ver
|
||||
else:
|
||||
|
@ -1570,7 +1570,7 @@ def _get_name_map(saltenv='base'):
|
|||
'''
|
||||
u_name_map = {}
|
||||
name_map = get_repo_data(saltenv).get('name_map', {})
|
||||
for k in name_map.keys():
|
||||
for k in name_map:
|
||||
u_name_map[k.decode('utf-8')] = name_map[k]
|
||||
return u_name_map
|
||||
|
||||
|
|
|
@ -2365,7 +2365,7 @@ def list_repos(basedir=None):
|
|||
if not repofile.endswith('.repo'):
|
||||
continue
|
||||
filerepos = _parse_repo_file(repopath)[1]
|
||||
for reponame in filerepos.keys():
|
||||
for reponame in filerepos:
|
||||
repo = filerepos[reponame]
|
||||
repo['file'] = repopath
|
||||
repos[reponame] = repo
|
||||
|
|
|
@ -191,7 +191,7 @@ def _params_extend(params, _ignore_name=False, **kwargs):
|
|||
|
||||
'''
|
||||
# extend params value by optional zabbix API parameters
|
||||
for key in kwargs.keys():
|
||||
for key in kwargs:
|
||||
if not key.startswith('_'):
|
||||
params.setdefault(key, kwargs[key])
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ def create(name, **kwargs):
|
|||
# create "-o property=value" pairs
|
||||
if properties:
|
||||
optlist = []
|
||||
for prop in properties.keys():
|
||||
for prop in properties:
|
||||
if isinstance(properties[prop], bool): # salt breaks the on/off/yes/no properties :(
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
|
||||
|
@ -685,7 +685,7 @@ def clone(name_a, name_b, **kwargs):
|
|||
# create "-o property=value" pairs
|
||||
if properties:
|
||||
optlist = []
|
||||
for prop in properties.keys():
|
||||
for prop in properties:
|
||||
if isinstance(properties[prop], bool): # salt breaks the on/off/yes/no properties :(
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
optlist.append('-o {0}={1}'.format(prop, properties[prop]))
|
||||
|
@ -1063,7 +1063,7 @@ def snapshot(*snapshot, **kwargs):
|
|||
# create "-o property=value" pairs
|
||||
if properties:
|
||||
optlist = []
|
||||
for prop in properties.keys():
|
||||
for prop in properties:
|
||||
if isinstance(properties[prop], bool): # salt breaks the on/off/yes/no properties :(
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
optlist.append('-o {0}={1}'.format(prop, properties[prop]))
|
||||
|
@ -1153,7 +1153,7 @@ def set(*dataset, **kwargs):
|
|||
|
||||
# for better error handling we don't do one big set command
|
||||
for ds in dataset:
|
||||
for prop in properties.keys():
|
||||
for prop in properties:
|
||||
|
||||
if isinstance(properties[prop], bool): # salt breaks the on/off/yes/no properties :(
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
|
|
|
@ -1332,7 +1332,7 @@ class Jobs(LowDataAdapter):
|
|||
ret['info'] = [job_ret_info[0]]
|
||||
minion_ret = {}
|
||||
returns = job_ret_info[0].get('Result')
|
||||
for minion in returns.keys():
|
||||
for minion in returns:
|
||||
if u'return' in returns[minion]:
|
||||
minion_ret[minion] = returns[minion].get(u'return')
|
||||
else:
|
||||
|
|
|
@ -502,7 +502,7 @@ def _crawl_attribute(this_data, this_attr):
|
|||
else:
|
||||
if isinstance(this_attr, dict):
|
||||
t_dict = {}
|
||||
for k in this_attr.keys():
|
||||
for k in this_attr:
|
||||
if hasattr(this_data, k):
|
||||
t_dict[k] = _crawl_attribute(getattr(this_data, k, None), this_attr[k])
|
||||
return t_dict
|
||||
|
|
|
@ -406,7 +406,7 @@ def ch_config(cmd, *args, **kwargs):
|
|||
|
||||
'''
|
||||
# Strip the __pub_ keys...is there a better way to do this?
|
||||
for k in kwargs.keys():
|
||||
for k in kwargs:
|
||||
if k.startswith('__pub_'):
|
||||
kwargs.pop(k)
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ def chconfig(cmd, *args, **kwargs):
|
|||
|
||||
'''
|
||||
# Strip the __pub_ keys...is there a better way to do this?
|
||||
for k in kwargs.keys():
|
||||
for k in kwargs:
|
||||
if k.startswith('__pub_'):
|
||||
kwargs.pop(k)
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ def _get_config(**kwargs):
|
|||
}
|
||||
config_key = '{0}.config'.format(__virtualname__)
|
||||
config.update(__opts__.get(config_key, {}))
|
||||
for k in set(config.keys()) & set(kwargs.keys()):
|
||||
for k in set(config) & set(kwargs):
|
||||
config[k] = kwargs[k]
|
||||
return config
|
||||
|
||||
|
|
|
@ -563,7 +563,7 @@ def _update_global_secondary_indexes(ret, changes_old, changes_new, comments, ex
|
|||
if success:
|
||||
comments.append(
|
||||
'Updated GSIs with new throughputs {0}'.format(str(index_updates)))
|
||||
for index_name in index_updates.keys():
|
||||
for index_name in index_updates:
|
||||
changes_old['global_indexes'][index_name] = provisioned_throughputs[index_name]
|
||||
changes_new['global_indexes'][index_name] = index_updates[index_name]
|
||||
else:
|
||||
|
|
|
@ -1435,7 +1435,7 @@ def _tags_present(name,
|
|||
tags_to_update = {}
|
||||
tags_to_remove = []
|
||||
if lb['tags']:
|
||||
for _tag in lb['tags'].keys():
|
||||
for _tag in lb['tags']:
|
||||
if _tag not in tags.keys():
|
||||
if _tag not in tags_to_remove:
|
||||
tags_to_remove.append(_tag)
|
||||
|
|
|
@ -638,7 +638,7 @@ def _tags_present(name, tags, vpc_id=None, vpc_name=None, region=None,
|
|||
tags_to_update = {}
|
||||
tags_to_remove = []
|
||||
if sg.get('tags'):
|
||||
for existing_tag in sg['tags'].keys():
|
||||
for existing_tag in sg['tags']:
|
||||
if existing_tag not in tags:
|
||||
if existing_tag not in tags_to_remove:
|
||||
tags_to_remove.append(existing_tag)
|
||||
|
|
|
@ -499,7 +499,7 @@ def chassis(name, chassis_name=None, password=None, datacenter=None,
|
|||
pw_single = True
|
||||
if __salt__[chassis_cmd]('change_password', username='root', uid=1,
|
||||
password=password):
|
||||
for blade in inventory['server'].keys():
|
||||
for blade in inventory['server']:
|
||||
pw_single = __salt__[chassis_cmd]('deploy_password',
|
||||
username='root',
|
||||
password=password,
|
||||
|
|
|
@ -235,7 +235,7 @@ def user_present(name,
|
|||
ret['changes']['Password'] = 'Updated'
|
||||
|
||||
if roles:
|
||||
for tenant in roles.keys():
|
||||
for tenant in roles:
|
||||
args = dict({'user_name': name, 'tenant_name':
|
||||
tenant, 'profile': profile}, **connection_args)
|
||||
tenant_roles = __salt__['keystone.user_role_list'](**args)
|
||||
|
@ -284,7 +284,7 @@ def user_present(name,
|
|||
profile=profile,
|
||||
**connection_args)
|
||||
if roles:
|
||||
for tenant in roles.keys():
|
||||
for tenant in roles:
|
||||
for role in roles[tenant]:
|
||||
__salt__['keystone.user_role_add'](user=name,
|
||||
role=role,
|
||||
|
|
|
@ -161,7 +161,7 @@ def _parse_vmconfig(config, instances):
|
|||
|
||||
if isinstance(config, (salt.utils.odict.OrderedDict)):
|
||||
vmconfig = OrderedDict()
|
||||
for prop in config.keys():
|
||||
for prop in config:
|
||||
if prop not in instances:
|
||||
vmconfig[prop] = config[prop]
|
||||
else:
|
||||
|
@ -188,7 +188,7 @@ def _get_instance_changes(current, state):
|
|||
|
||||
# compare configs
|
||||
changed = salt.utils.compare_dicts(current, state)
|
||||
for change in changed.keys():
|
||||
for change in changed:
|
||||
if change in changed and changed[change]['old'] == "":
|
||||
del changed[change]
|
||||
if change in changed and changed[change]['new'] == "":
|
||||
|
|
|
@ -83,7 +83,7 @@ def present(name, **kwargs):
|
|||
pass
|
||||
needs_update = {}
|
||||
if info.get('email', False):
|
||||
for field in kwargs.keys():
|
||||
for field in kwargs:
|
||||
if info.get(field, None) != kwargs[field]:
|
||||
needs_update[field] = kwargs[field]
|
||||
del needs_update['directory_id']
|
||||
|
|
|
@ -352,7 +352,7 @@ def filesystem_present(name, create_parent=False, properties=None, cloned_from=N
|
|||
log.debug('zfs.filesystem_present::{0}::config::cloned_from = {1}'.format(name, cloned_from))
|
||||
log.debug('zfs.filesystem_present::{0}::config::properties = {1}'.format(name, properties))
|
||||
|
||||
for prop in properties.keys(): # salt breaks the on/off/yes/no properties
|
||||
for prop in properties: # salt breaks the on/off/yes/no properties
|
||||
if isinstance(properties[prop], bool):
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
|
||||
|
@ -378,7 +378,7 @@ def filesystem_present(name, create_parent=False, properties=None, cloned_from=N
|
|||
if len(properties) > 0:
|
||||
result = __salt__['zfs.get'](name, **{'properties': ','.join(properties.keys()), 'fields': 'value', 'depth': 1})
|
||||
|
||||
for prop in properties.keys():
|
||||
for prop in properties:
|
||||
if properties[prop] != result[name][prop]['value']:
|
||||
if name not in ret['changes']:
|
||||
ret['changes'][name] = {}
|
||||
|
@ -390,7 +390,7 @@ def filesystem_present(name, create_parent=False, properties=None, cloned_from=N
|
|||
if name not in result:
|
||||
ret['result'] = False
|
||||
else:
|
||||
for prop in result[name].keys():
|
||||
for prop in result[name]:
|
||||
if result[name][prop] != 'set':
|
||||
ret['result'] = False
|
||||
|
||||
|
@ -470,7 +470,7 @@ def volume_present(name, volume_size, sparse=False, create_parent=False, propert
|
|||
log.debug('zfs.volume_present::{0}::config::cloned_from = {1}'.format(name, cloned_from))
|
||||
log.debug('zfs.volume_present::{0}::config::properties = {1}'.format(name, properties))
|
||||
|
||||
for prop in properties.keys(): # salt breaks the on/off/yes/no properties
|
||||
for prop in properties: # salt breaks the on/off/yes/no properties
|
||||
if isinstance(properties[prop], bool):
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
|
||||
|
@ -495,7 +495,7 @@ def volume_present(name, volume_size, sparse=False, create_parent=False, propert
|
|||
properties['volsize'] = volume_size # add volume_size to properties
|
||||
result = __salt__['zfs.get'](name, **{'properties': ','.join(properties.keys()), 'fields': 'value', 'depth': 1})
|
||||
|
||||
for prop in properties.keys():
|
||||
for prop in properties:
|
||||
if properties[prop] != result[name][prop]['value']:
|
||||
if name not in ret['changes']:
|
||||
ret['changes'][name] = {}
|
||||
|
@ -507,7 +507,7 @@ def volume_present(name, volume_size, sparse=False, create_parent=False, propert
|
|||
if name not in result:
|
||||
ret['result'] = False
|
||||
else:
|
||||
for prop in result[name].keys():
|
||||
for prop in result[name]:
|
||||
if result[name][prop] != 'set':
|
||||
ret['result'] = False
|
||||
|
||||
|
@ -616,7 +616,7 @@ def snapshot_present(name, recursive=False, properties=None):
|
|||
log.debug('zfs.snapshot_present::{0}::config::recursive = {1}'.format(name, recursive))
|
||||
log.debug('zfs.snapshot_present::{0}::config::properties = {1}'.format(name, properties))
|
||||
|
||||
for prop in properties.keys(): # salt breaks the on/off/yes/no properties
|
||||
for prop in properties: # salt breaks the on/off/yes/no properties
|
||||
if isinstance(properties[prop], bool):
|
||||
properties[prop] = 'on' if properties[prop] else 'off'
|
||||
|
||||
|
@ -733,7 +733,7 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
|
|||
'month': 0,
|
||||
'year': 0,
|
||||
}
|
||||
for hold in state_schedule.keys():
|
||||
for hold in state_schedule:
|
||||
if hold not in schedule:
|
||||
del state_schedule[hold]
|
||||
schedule.update(state_schedule)
|
||||
|
@ -747,7 +747,7 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
|
|||
ret['result'] = False
|
||||
# check schedule
|
||||
snap_count = 0
|
||||
for hold in schedule.keys():
|
||||
for hold in schedule:
|
||||
if not isinstance(schedule[hold], int):
|
||||
ret['comment'] = 'schedule values must be integers'
|
||||
ret['result'] = False
|
||||
|
@ -767,7 +767,7 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
|
|||
# retreive snapshots
|
||||
prunable = []
|
||||
snapshots = {}
|
||||
for key in schedule.keys():
|
||||
for key in schedule:
|
||||
snapshots[key] = []
|
||||
|
||||
for snap in sorted(__salt__['zfs.list'](name, **{'recursive': True, 'depth': 1, 'type': 'snapshot'}).keys()):
|
||||
|
@ -780,7 +780,7 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
|
|||
if snap not in holds or holds[snap] == 'no holds':
|
||||
prunable.append(snap)
|
||||
continue
|
||||
for hold in holds[snap].keys():
|
||||
for hold in holds[snap]:
|
||||
hold = hold.strip()
|
||||
if hold not in snapshots.keys():
|
||||
continue
|
||||
|
@ -790,7 +790,7 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
|
|||
# create snapshot
|
||||
needed_holds = []
|
||||
current_timestamp = gmtime()
|
||||
for hold in snapshots.keys():
|
||||
for hold in snapshots:
|
||||
# check if we need need to consider hold
|
||||
if schedule[hold] == 0:
|
||||
continue
|
||||
|
@ -862,7 +862,7 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
|
|||
ret['changes']['pruned'] = []
|
||||
|
||||
# prune snapshots
|
||||
for hold in schedule.keys():
|
||||
for hold in schedule:
|
||||
if hold not in snapshots.keys():
|
||||
continue
|
||||
while len(snapshots[hold]) > schedule[hold]:
|
||||
|
|
|
@ -1493,7 +1493,7 @@ def subdict_match(data,
|
|||
exact_match=exact_match):
|
||||
return True
|
||||
if wildcard:
|
||||
for key in target.keys():
|
||||
for key in target:
|
||||
if _match(key,
|
||||
pattern,
|
||||
regex_match=regex_match,
|
||||
|
|
|
@ -145,7 +145,7 @@ class CacheDisk(CacheDict):
|
|||
else: # old format
|
||||
self._dict = cache
|
||||
timestamp = os.path.getmtime(self._path)
|
||||
for key in self._dict.keys():
|
||||
for key in self._dict:
|
||||
self._key_cache_time[key] = timestamp
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
log.debug('Disk cache retrieved: {0}'.format(cache))
|
||||
|
|
|
@ -58,7 +58,7 @@ def update(dest, upd, recursive_update=True, merge_lists=False):
|
|||
return dest
|
||||
else:
|
||||
try:
|
||||
for k in upd.keys():
|
||||
for k in upd:
|
||||
dest[k] = upd[k]
|
||||
except AttributeError:
|
||||
# this mapping is not a dict
|
||||
|
|
|
@ -838,7 +838,7 @@ def parse_cookie_header(header):
|
|||
for cookie in cookies:
|
||||
name = None
|
||||
value = None
|
||||
for item in cookie.keys():
|
||||
for item in cookie:
|
||||
if item in attribs:
|
||||
continue
|
||||
name = item
|
||||
|
|
|
@ -16,7 +16,7 @@ def clean_args(args):
|
|||
'''
|
||||
Cleans up the args that weren't passed in
|
||||
'''
|
||||
for arg in args.keys():
|
||||
for arg in args:
|
||||
if not args[arg]:
|
||||
del args[arg]
|
||||
return args
|
||||
|
@ -1138,7 +1138,7 @@ def mksls(src, dst=None):
|
|||
sls[device]['ipv6'] = {'enabled': False}
|
||||
del interface['noipv6']
|
||||
|
||||
for option in interface.keys():
|
||||
for option in interface:
|
||||
if type(interface[option]) is bool:
|
||||
sls[device][option] = {'enabled': [interface[option]]}
|
||||
else:
|
||||
|
|
|
@ -816,7 +816,7 @@ class CkMinions(object):
|
|||
log.info('Malformed ACL: {0}'.format(auth_list_entry))
|
||||
continue
|
||||
allowed_minions.update(set(auth_list_entry.keys()))
|
||||
for key in auth_list_entry.keys():
|
||||
for key in auth_list_entry:
|
||||
for match in self._expand_matching(key):
|
||||
if match in auth_dictionary:
|
||||
auth_dictionary[match].extend(auth_list_entry[key])
|
||||
|
|
|
@ -538,7 +538,7 @@ class Schedule(object):
|
|||
|
||||
# if enabled is not included in the job,
|
||||
# assume job is enabled.
|
||||
for job in data.keys():
|
||||
for job in data:
|
||||
if 'enabled' not in data[job]:
|
||||
data[job]['enabled'] = True
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ class BaseSchemaItemMeta(six.with_metaclass(Prepareable, type)):
|
|||
'Please pass all arguments as named arguments. Un-named '
|
||||
'arguments are not supported'
|
||||
)
|
||||
for key in kwargs.copy().keys():
|
||||
for key in kwargs.copy():
|
||||
# Store the kwarg keys as the instance attributes for the
|
||||
# serialization step
|
||||
if key == 'name':
|
||||
|
|
|
@ -195,7 +195,7 @@ class GrainsAppendTestCase(integration.ModuleCase):
|
|||
# Now make sure the grain doesn't show up twice.
|
||||
grains = self.run_function('grains.items')
|
||||
count = 0
|
||||
for grain in grains.keys():
|
||||
for grain in grains:
|
||||
if grain == self.GRAIN_KEY:
|
||||
count += 1
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ tcpdump "tcp[tcpflags] & tcp-syn != 0" and port 4506 and "tcp[tcpflags] & tcp-ac
|
|||
from __future__ import absolute_import, print_function
|
||||
import socket
|
||||
from struct import unpack
|
||||
import pcapy
|
||||
import pcapy # pylint: disable=import-error,3rd-party-module-not-gated
|
||||
import sys
|
||||
import argparse # pylint: disable=minimum-python-version
|
||||
import time
|
||||
|
|
|
@ -38,7 +38,7 @@ try:
|
|||
current_module_names = sys.modules.keys()
|
||||
import salt # pylint: disable=unused-import
|
||||
|
||||
for name in sys.modules.keys():
|
||||
for name in sys.modules:
|
||||
if name not in current_module_names:
|
||||
del sys.modules[name]
|
||||
except ImportError:
|
||||
|
|
|
@ -36,7 +36,7 @@ from tests.support.case import TestCase
|
|||
|
||||
# Import 3rd-party libs
|
||||
# pylint: disable=import-error
|
||||
import cherrypy
|
||||
import cherrypy # pylint: disable=3rd-party-module-not-gated
|
||||
import salt.ext.six as six
|
||||
from salt.ext.six.moves import StringIO
|
||||
# pylint: enable=import-error
|
||||
|
|
Loading…
Add table
Reference in a new issue