summaryrefslogtreecommitdiff
path: root/network/nxos
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2016-11-17 15:19:14 +0100
committerBrian Coca <bcoca@users.noreply.github.com>2016-11-17 12:33:26 -0500
commitf08ba8c7d6843d6459b471d26289b63d2862d5a5 (patch)
tree4c06b61f8ec60c81f5a14ed52905fd2ee3d23357 /network/nxos
parentc411d518b96f373931119af0c4cd1799fcb86499 (diff)
downloadansible-modules-core-f08ba8c7d6843d6459b471d26289b63d2862d5a5.tar.gz
Performance improvement using in-operator on dicts
Just a small cleanup for the existing occurrences. Using the in-operator for hash lookups is faster than using .keys() http://stackoverflow.com/questions/29314269/why-do-key-in-dict-and-key-in-dict-keys-have-the-same-output
Diffstat (limited to 'network/nxos')
-rw-r--r--network/nxos/nxos_bgp.py2
-rw-r--r--network/nxos/nxos_bgp_af.py2
-rw-r--r--network/nxos/nxos_feature.py4
-rw-r--r--network/nxos/nxos_igmp_interface.py2
-rw-r--r--network/nxos/nxos_ip_interface.py2
-rw-r--r--network/nxos/nxos_static_route.py2
-rw-r--r--network/nxos/nxos_vpc_interface.py2
7 files changed, 8 insertions, 8 deletions
diff --git a/network/nxos/nxos_bgp.py b/network/nxos/nxos_bgp.py
index 5ec5135b..c937fb8d 100644
--- a/network/nxos/nxos_bgp.py
+++ b/network/nxos/nxos_bgp.py
@@ -757,7 +757,7 @@ def state_present(module, existing, proposed, candidate):
elif value is False:
commands.append('no {0}'.format(key))
elif value == 'default':
- if key in PARAM_TO_DEFAULT_KEYMAP.keys():
+ if key in PARAM_TO_DEFAULT_KEYMAP:
commands.append('{0} {1}'.format(key, PARAM_TO_DEFAULT_KEYMAP[key]))
elif existing_commands.get(key):
existing_value = existing_commands.get(key)
diff --git a/network/nxos/nxos_bgp_af.py b/network/nxos/nxos_bgp_af.py
index 0eb920f3..1f02b113 100644
--- a/network/nxos/nxos_bgp_af.py
+++ b/network/nxos/nxos_bgp_af.py
@@ -889,7 +889,7 @@ def state_present(module, existing, proposed, candidate):
commands.append('no {0}'.format(key))
elif value == 'default':
- if key in PARAM_TO_DEFAULT_KEYMAP.keys():
+ if key in PARAM_TO_DEFAULT_KEYMAP:
commands.append('{0} {1}'.format(key, PARAM_TO_DEFAULT_KEYMAP[key]))
elif existing_commands.get(key):
diff --git a/network/nxos/nxos_feature.py b/network/nxos/nxos_feature.py
index 15d49cc7..bdf7980b 100644
--- a/network/nxos/nxos_feature.py
+++ b/network/nxos/nxos_feature.py
@@ -355,7 +355,7 @@ def get_available_features(feature, module):
if 'enabled' in state:
state = 'enabled'
- if feature not in available_features.keys():
+ if feature not in available_features:
available_features[feature] = state
else:
if (available_features[feature] == 'disabled' and
@@ -443,7 +443,7 @@ def main():
state = module.params['state'].lower()
available_features = get_available_features(feature, module)
- if feature not in available_features.keys():
+ if feature not in available_features:
module.fail_json(
msg='Invalid feature name.',
features_currently_supported=available_features,
diff --git a/network/nxos/nxos_igmp_interface.py b/network/nxos/nxos_igmp_interface.py
index 1f5aa5d9..902d5808 100644
--- a/network/nxos/nxos_igmp_interface.py
+++ b/network/nxos/nxos_igmp_interface.py
@@ -823,7 +823,7 @@ def main():
if state == 'absent':
for each in CANNOT_ABSENT:
- if each in proposed.keys():
+ if each in proposed:
module.fail_json(msg='only params: oif_prefix, oif_source, '
'oif_routemap can be used when '
'state=absent')
diff --git a/network/nxos/nxos_ip_interface.py b/network/nxos/nxos_ip_interface.py
index eef79543..25d50cbc 100644
--- a/network/nxos/nxos_ip_interface.py
+++ b/network/nxos/nxos_ip_interface.py
@@ -560,7 +560,7 @@ def get_config_ip_commands(delta, interface, existing, version):
# loop used in the situation that just an IP address or just a
# mask is changing, not both.
for each in ['addr', 'mask']:
- if each not in delta.keys():
+ if each not in delta:
delta[each] = existing[each]
if version == 'v4':
diff --git a/network/nxos/nxos_static_route.py b/network/nxos/nxos_static_route.py
index 10a1f849..a0e2a78b 100644
--- a/network/nxos/nxos_static_route.py
+++ b/network/nxos/nxos_static_route.py
@@ -321,7 +321,7 @@ def get_existing(module, prefix, warnings):
group_route = match_route.groupdict()
for key in key_map:
- if key not in group_route.keys():
+ if key not in group_route:
group_route[key] = ''
group_route['prefix'] = prefix
group_route['vrf'] = module.params['vrf']
diff --git a/network/nxos/nxos_vpc_interface.py b/network/nxos/nxos_vpc_interface.py
index dcc1c213..0f930cac 100644
--- a/network/nxos/nxos_vpc_interface.py
+++ b/network/nxos/nxos_vpc_interface.py
@@ -501,7 +501,7 @@ def main():
if vpc:
mapping = get_existing_portchannel_to_vpc_mappings(module)
- if vpc in mapping.keys() and portchannel != mapping[vpc].strip('Po'):
+ if vpc in mapping and portchannel != mapping[vpc].strip('Po'):
module.fail_json(msg="This vpc is already configured on "
"another portchannel. Remove it first "
"before trying to assign it here. ",