mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Removed dict.iteritems() in modules. (#18859)
This is for py3 compatibility, addressed in #18506
This commit is contained in:
parent
4b27d08643
commit
ef391a11ec
99 changed files with 251 additions and 250 deletions
|
@ -274,14 +274,14 @@ def update_dynamo_table(table, throughput=None, check_mode=False, global_indexes
|
||||||
removed_indexes, added_indexes, index_throughput_changes = get_changed_global_indexes(table, global_indexes)
|
removed_indexes, added_indexes, index_throughput_changes = get_changed_global_indexes(table, global_indexes)
|
||||||
if removed_indexes:
|
if removed_indexes:
|
||||||
if not check_mode:
|
if not check_mode:
|
||||||
for name, index in removed_indexes.iteritems():
|
for name, index in removed_indexes.items():
|
||||||
global_indexes_changed = table.delete_global_secondary_index(name) or global_indexes_changed
|
global_indexes_changed = table.delete_global_secondary_index(name) or global_indexes_changed
|
||||||
else:
|
else:
|
||||||
global_indexes_changed = True
|
global_indexes_changed = True
|
||||||
|
|
||||||
if added_indexes:
|
if added_indexes:
|
||||||
if not check_mode:
|
if not check_mode:
|
||||||
for name, index in added_indexes.iteritems():
|
for name, index in added_indexes.items():
|
||||||
global_indexes_changed = table.create_global_secondary_index(global_index=index) or global_indexes_changed
|
global_indexes_changed = table.create_global_secondary_index(global_index=index) or global_indexes_changed
|
||||||
else:
|
else:
|
||||||
global_indexes_changed = True
|
global_indexes_changed = True
|
||||||
|
@ -328,18 +328,18 @@ def get_changed_global_indexes(table, global_indexes):
|
||||||
set_index_info = dict((index.name, index.schema()) for index in global_indexes)
|
set_index_info = dict((index.name, index.schema()) for index in global_indexes)
|
||||||
set_index_objects = dict((index.name, index) for index in global_indexes)
|
set_index_objects = dict((index.name, index) for index in global_indexes)
|
||||||
|
|
||||||
removed_indexes = dict((name, index) for name, index in table_index_info.iteritems() if name not in set_index_info)
|
removed_indexes = dict((name, index) for name, index in table_index_info.items() if name not in set_index_info)
|
||||||
added_indexes = dict((name, set_index_objects[name]) for name, index in set_index_info.iteritems() if name not in table_index_info)
|
added_indexes = dict((name, set_index_objects[name]) for name, index in set_index_info.items() if name not in table_index_info)
|
||||||
# todo: uncomment once boto has https://github.com/boto/boto/pull/3447 fixed
|
# todo: uncomment once boto has https://github.com/boto/boto/pull/3447 fixed
|
||||||
# index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.iteritems() if name not in added_indexes and (index.throughput['read'] != str(table_index_objects[name].throughput['read']) or index.throughput['write'] != str(table_index_objects[name].throughput['write'])))
|
# index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.items() if name not in added_indexes and (index.throughput['read'] != str(table_index_objects[name].throughput['read']) or index.throughput['write'] != str(table_index_objects[name].throughput['write'])))
|
||||||
# todo: remove once boto has https://github.com/boto/boto/pull/3447 fixed
|
# todo: remove once boto has https://github.com/boto/boto/pull/3447 fixed
|
||||||
index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.iteritems() if name not in added_indexes)
|
index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.items() if name not in added_indexes)
|
||||||
|
|
||||||
return removed_indexes, added_indexes, index_throughput_changes
|
return removed_indexes, added_indexes, index_throughput_changes
|
||||||
|
|
||||||
|
|
||||||
def validate_index(index, module):
|
def validate_index(index, module):
|
||||||
for key, val in index.iteritems():
|
for key, val in index.items():
|
||||||
if key not in INDEX_OPTIONS:
|
if key not in INDEX_OPTIONS:
|
||||||
module.fail_json(msg='%s is not a valid option for an index' % key)
|
module.fail_json(msg='%s is not a valid option for an index' % key)
|
||||||
for required_option in INDEX_REQUIRED_OPTIONS:
|
for required_option in INDEX_REQUIRED_OPTIONS:
|
||||||
|
|
|
@ -458,7 +458,7 @@ def create_autoscaling_group(connection, module):
|
||||||
|
|
||||||
asg_tags = []
|
asg_tags = []
|
||||||
for tag in set_tags:
|
for tag in set_tags:
|
||||||
for k,v in tag.iteritems():
|
for k,v in tag.items():
|
||||||
if k !='propagate_at_launch':
|
if k !='propagate_at_launch':
|
||||||
asg_tags.append(Tag(key=k,
|
asg_tags.append(Tag(key=k,
|
||||||
value=v,
|
value=v,
|
||||||
|
|
|
@ -206,7 +206,7 @@ except ImportError:
|
||||||
HAS_BOTO3 = False
|
HAS_BOTO3 = False
|
||||||
|
|
||||||
def match_asg_tags(tags_to_match, asg):
|
def match_asg_tags(tags_to_match, asg):
|
||||||
for key, value in tags_to_match.iteritems():
|
for key, value in tags_to_match.items():
|
||||||
for tag in asg['Tags']:
|
for tag in asg['Tags']:
|
||||||
if key == tag['Key'] and value == tag['Value']:
|
if key == tag['Key'] and value == tag['Value']:
|
||||||
break
|
break
|
||||||
|
|
|
@ -911,7 +911,7 @@ class ElbManager(object):
|
||||||
if not self.elb.health_check:
|
if not self.elb.health_check:
|
||||||
self.elb.health_check = HealthCheck()
|
self.elb.health_check = HealthCheck()
|
||||||
|
|
||||||
for attr, desired_value in health_check_config.iteritems():
|
for attr, desired_value in health_check_config.items():
|
||||||
if getattr(self.elb.health_check, attr) != desired_value:
|
if getattr(self.elb.health_check, attr) != desired_value:
|
||||||
setattr(self.elb.health_check, attr, desired_value)
|
setattr(self.elb.health_check, attr, desired_value)
|
||||||
update_health_check = True
|
update_health_check = True
|
||||||
|
@ -950,7 +950,7 @@ class ElbManager(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
update_access_logs_config = False
|
update_access_logs_config = False
|
||||||
for attr, desired_value in access_logs_config.iteritems():
|
for attr, desired_value in access_logs_config.items():
|
||||||
if getattr(attributes.access_log, attr) != desired_value:
|
if getattr(attributes.access_log, attr) != desired_value:
|
||||||
setattr(attributes.access_log, attr, desired_value)
|
setattr(attributes.access_log, attr, desired_value)
|
||||||
update_access_logs_config = True
|
update_access_logs_config = True
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Ec2Metadata(object):
|
||||||
|
|
||||||
def _mangle_fields(self, fields, uri, filter_patterns=['public-keys-0']):
|
def _mangle_fields(self, fields, uri, filter_patterns=['public-keys-0']):
|
||||||
new_fields = {}
|
new_fields = {}
|
||||||
for key, value in fields.iteritems():
|
for key, value in fields.items():
|
||||||
split_fields = key[len(uri):].split('/')
|
split_fields = key[len(uri):].split('/')
|
||||||
if len(split_fields) > 1 and split_fields[1]:
|
if len(split_fields) > 1 and split_fields[1]:
|
||||||
new_key = "-".join(split_fields)
|
new_key = "-".join(split_fields)
|
||||||
|
|
|
@ -106,7 +106,7 @@ def list_dhcp_options(client, module):
|
||||||
|
|
||||||
if module.params.get('filters'):
|
if module.params.get('filters'):
|
||||||
params['Filters'] = []
|
params['Filters'] = []
|
||||||
for key, value in module.params.get('filters').iteritems():
|
for key, value in module.params.get('filters').items():
|
||||||
temp_dict = dict()
|
temp_dict = dict()
|
||||||
temp_dict['Name'] = key
|
temp_dict['Name'] = key
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
|
|
|
@ -161,7 +161,7 @@ def icmp_present(entry):
|
||||||
def load_tags(module):
|
def load_tags(module):
|
||||||
tags = []
|
tags = []
|
||||||
if module.params.get('tags'):
|
if module.params.get('tags'):
|
||||||
for name, value in module.params.get('tags').iteritems():
|
for name, value in module.params.get('tags').items():
|
||||||
tags.append({'Key': name, 'Value': str(value)})
|
tags.append({'Key': name, 'Value': str(value)})
|
||||||
tags.append({'Key': "Name", 'Value': module.params.get('name')})
|
tags.append({'Key': "Name", 'Value': module.params.get('name')})
|
||||||
else:
|
else:
|
||||||
|
@ -239,7 +239,7 @@ def tags_changed(nacl_id, client, module):
|
||||||
if nacl['NetworkAcls']:
|
if nacl['NetworkAcls']:
|
||||||
nacl_values = [t.values() for t in nacl['NetworkAcls'][0]['Tags']]
|
nacl_values = [t.values() for t in nacl['NetworkAcls'][0]['Tags']]
|
||||||
nacl_tags = [item for sublist in nacl_values for item in sublist]
|
nacl_tags = [item for sublist in nacl_values for item in sublist]
|
||||||
tag_values = [[key, str(value)] for key, value in tags.iteritems()]
|
tag_values = [[key, str(value)] for key, value in tags.items()]
|
||||||
tags = [item for sublist in tag_values for item in sublist]
|
tags = [item for sublist in tag_values for item in sublist]
|
||||||
if sorted(nacl_tags) == sorted(tags):
|
if sorted(nacl_tags) == sorted(tags):
|
||||||
changed = False
|
changed = False
|
||||||
|
|
|
@ -210,7 +210,7 @@ def tags_changed(pcx_id, client, module):
|
||||||
if pcx['VpcPeeringConnections']:
|
if pcx['VpcPeeringConnections']:
|
||||||
pcx_values = [t.values() for t in pcx['VpcPeeringConnections'][0]['Tags']]
|
pcx_values = [t.values() for t in pcx['VpcPeeringConnections'][0]['Tags']]
|
||||||
pcx_tags = [item for sublist in pcx_values for item in sublist]
|
pcx_tags = [item for sublist in pcx_values for item in sublist]
|
||||||
tag_values = [[key, str(value)] for key, value in tags.iteritems()]
|
tag_values = [[key, str(value)] for key, value in tags.items()]
|
||||||
tags = [item for sublist in tag_values for item in sublist]
|
tags = [item for sublist in tag_values for item in sublist]
|
||||||
if sorted(pcx_tags) == sorted(tags):
|
if sorted(pcx_tags) == sorted(tags):
|
||||||
changed = False
|
changed = False
|
||||||
|
@ -305,7 +305,7 @@ def accept_reject_delete(state, client, module):
|
||||||
def load_tags(module):
|
def load_tags(module):
|
||||||
tags = []
|
tags = []
|
||||||
if module.params.get('tags'):
|
if module.params.get('tags'):
|
||||||
for name, value in module.params.get('tags').iteritems():
|
for name, value in module.params.get('tags').items():
|
||||||
tags.append({'Key': name, 'Value': str(value)})
|
tags.append({'Key': name, 'Value': str(value)})
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ def get_resource_tags(vpc_conn, resource_id):
|
||||||
|
|
||||||
def tags_match(match_tags, candidate_tags):
|
def tags_match(match_tags, candidate_tags):
|
||||||
return all((k in candidate_tags and candidate_tags[k] == v
|
return all((k in candidate_tags and candidate_tags[k] == v
|
||||||
for k, v in match_tags.iteritems()))
|
for k, v in match_tags.items()))
|
||||||
|
|
||||||
|
|
||||||
def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode):
|
def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode):
|
||||||
|
|
|
@ -276,7 +276,7 @@ def load_tags(module):
|
||||||
tags = []
|
tags = []
|
||||||
|
|
||||||
if module.params.get('tags'):
|
if module.params.get('tags'):
|
||||||
for name, value in module.params.get('tags').iteritems():
|
for name, value in module.params.get('tags').items():
|
||||||
tags.append({'Key': name, 'Value': str(value)})
|
tags.append({'Key': name, 'Value': str(value)})
|
||||||
tags.append({'Key': "Name", 'Value': module.params.get('name')})
|
tags.append({'Key': "Name", 'Value': module.params.get('name')})
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -244,7 +244,7 @@ def main():
|
||||||
|
|
||||||
def _right_has_values_of_left(left, right):
|
def _right_has_values_of_left(left, right):
|
||||||
# Make sure the values are equivalent for everything left has
|
# Make sure the values are equivalent for everything left has
|
||||||
for k, v in left.iteritems():
|
for k, v in left.items():
|
||||||
if not ((not v and (k not in right or not right[k])) or (k in right and v == right[k])):
|
if not ((not v and (k not in right or not right[k])) or (k in right and v == right[k])):
|
||||||
# We don't care about list ordering because ECS can change things
|
# We don't care about list ordering because ECS can change things
|
||||||
if isinstance(v, list) and k in right:
|
if isinstance(v, list) and k in right:
|
||||||
|
@ -261,7 +261,7 @@ def main():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Make sure right doesn't have anything that left doesn't
|
# Make sure right doesn't have anything that left doesn't
|
||||||
for k, v in right.iteritems():
|
for k, v in right.items():
|
||||||
if v and k not in left:
|
if v and k not in left:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -385,7 +385,7 @@ class ElastiCacheManager(object):
|
||||||
'NumCacheNodes': self.num_nodes,
|
'NumCacheNodes': self.num_nodes,
|
||||||
'EngineVersion': self.cache_engine_version
|
'EngineVersion': self.cache_engine_version
|
||||||
}
|
}
|
||||||
for key, value in modifiable_data.iteritems():
|
for key, value in modifiable_data.items():
|
||||||
if value is not None and self.data[key] != value:
|
if value is not None and self.data[key] != value:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ class ElastiCacheManager(object):
|
||||||
# Only check for modifications if zone is specified
|
# Only check for modifications if zone is specified
|
||||||
if self.zone is not None:
|
if self.zone is not None:
|
||||||
unmodifiable_data['zone'] = self.data['PreferredAvailabilityZone']
|
unmodifiable_data['zone'] = self.data['PreferredAvailabilityZone']
|
||||||
for key, value in unmodifiable_data.iteritems():
|
for key, value in unmodifiable_data.items():
|
||||||
if getattr(self, key) is not None and getattr(self, key) != value:
|
if getattr(self, key) is not None and getattr(self, key) != value:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -141,7 +141,7 @@ def create_tags_container(tags):
|
||||||
|
|
||||||
tag_set = TagSet()
|
tag_set = TagSet()
|
||||||
tags_obj = Tags()
|
tags_obj = Tags()
|
||||||
for key, val in tags.iteritems():
|
for key, val in tags.items():
|
||||||
tag_set.add_tag(key, val)
|
tag_set.add_tag(key, val)
|
||||||
|
|
||||||
tags_obj.add_tag_set(tag_set)
|
tags_obj.add_tag_set(tag_set)
|
||||||
|
|
|
@ -132,7 +132,7 @@ class CloudStackFacts(object):
|
||||||
result = {}
|
result = {}
|
||||||
filter = module.params.get('filter')
|
filter = module.params.get('filter')
|
||||||
if not filter:
|
if not filter:
|
||||||
for key,path in self.fact_paths.iteritems():
|
for key,path in self.fact_paths.items():
|
||||||
result[key] = self._fetch(CS_METADATA_BASE_URL + "/" + path)
|
result[key] = self._fetch(CS_METADATA_BASE_URL + "/" + path)
|
||||||
result['cloudstack_user_data'] = self._get_user_data_json()
|
result['cloudstack_user_data'] = self._get_user_data_json()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -334,7 +334,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
|
||||||
super(AnsibleCloudStackPortforwarding, self).get_result(portforwarding_rule)
|
super(AnsibleCloudStackPortforwarding, self).get_result(portforwarding_rule)
|
||||||
if portforwarding_rule:
|
if portforwarding_rule:
|
||||||
# Bad bad API does not always return int when it should.
|
# Bad bad API does not always return int when it should.
|
||||||
for search_key, return_key in self.returns_to_int.iteritems():
|
for search_key, return_key in self.returns_to_int.items():
|
||||||
if search_key in portforwarding_rule:
|
if search_key in portforwarding_rule:
|
||||||
self.result[return_key] = int(portforwarding_rule[search_key])
|
self.result[return_key] = int(portforwarding_rule[search_key])
|
||||||
return self.result
|
return self.result
|
||||||
|
|
|
@ -231,7 +231,7 @@ class Droplet(JsonfyMixIn):
|
||||||
|
|
||||||
def update_attr(self, attrs=None):
|
def update_attr(self, attrs=None):
|
||||||
if attrs:
|
if attrs:
|
||||||
for k, v in attrs.iteritems():
|
for k, v in attrs.items():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
else:
|
else:
|
||||||
json = self.manager.show_droplet(self.id)
|
json = self.manager.show_droplet(self.id)
|
||||||
|
|
|
@ -902,11 +902,11 @@ class DockerManager(object):
|
||||||
self.ensure_capability('env_file')
|
self.ensure_capability('env_file')
|
||||||
parsed_env_file = docker.utils.parse_env_file(env_file)
|
parsed_env_file = docker.utils.parse_env_file(env_file)
|
||||||
|
|
||||||
for name, value in parsed_env_file.iteritems():
|
for name, value in parsed_env_file.items():
|
||||||
final_env[name] = str(value)
|
final_env[name] = str(value)
|
||||||
|
|
||||||
if env:
|
if env:
|
||||||
for name, value in env.iteritems():
|
for name, value in env.items():
|
||||||
final_env[name] = str(value)
|
final_env[name] = str(value)
|
||||||
|
|
||||||
return final_env
|
return final_env
|
||||||
|
@ -998,7 +998,7 @@ class DockerManager(object):
|
||||||
self.ensure_capability('log_driver')
|
self.ensure_capability('log_driver')
|
||||||
log_config = docker.utils.LogConfig(type=docker.utils.LogConfig.types.JSON)
|
log_config = docker.utils.LogConfig(type=docker.utils.LogConfig.types.JSON)
|
||||||
if optionals['log_opt'] is not None:
|
if optionals['log_opt'] is not None:
|
||||||
for k, v in optionals['log_opt'].iteritems():
|
for k, v in optionals['log_opt'].items():
|
||||||
log_config.set_config_value(k, v)
|
log_config.set_config_value(k, v)
|
||||||
log_config.type = optionals['log_driver']
|
log_config.type = optionals['log_driver']
|
||||||
params['log_config'] = log_config
|
params['log_config'] = log_config
|
||||||
|
@ -1073,7 +1073,7 @@ class DockerManager(object):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
parts = []
|
parts = []
|
||||||
for k, v in self.counters.iteritems():
|
for k, v in self.counters.items():
|
||||||
if v == 0:
|
if v == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ class DockerManager(object):
|
||||||
|
|
||||||
def get_summary_counters_msg(self):
|
def get_summary_counters_msg(self):
|
||||||
msg = ""
|
msg = ""
|
||||||
for k, v in self.counters.iteritems():
|
for k, v in self.counters.items():
|
||||||
msg = msg + "%s %d " % (k, v)
|
msg = msg + "%s %d " % (k, v)
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
@ -1109,7 +1109,7 @@ class DockerManager(object):
|
||||||
self.counters[name] = self.counters[name] + 1
|
self.counters[name] = self.counters[name] + 1
|
||||||
|
|
||||||
def has_changed(self):
|
def has_changed(self):
|
||||||
for k, v in self.counters.iteritems():
|
for k, v in self.counters.items():
|
||||||
if v > 0:
|
if v > 0:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -1287,7 +1287,7 @@ class DockerManager(object):
|
||||||
expected_env[name] = value
|
expected_env[name] = value
|
||||||
|
|
||||||
if self.environment:
|
if self.environment:
|
||||||
for name, value in self.environment.iteritems():
|
for name, value in self.environment.items():
|
||||||
expected_env[name] = str(value)
|
expected_env[name] = str(value)
|
||||||
|
|
||||||
actual_env = {}
|
actual_env = {}
|
||||||
|
@ -1304,7 +1304,7 @@ class DockerManager(object):
|
||||||
# LABELS
|
# LABELS
|
||||||
|
|
||||||
expected_labels = {}
|
expected_labels = {}
|
||||||
for name, value in self.module.params.get('labels').iteritems():
|
for name, value in self.module.params.get('labels').items():
|
||||||
expected_labels[name] = str(value)
|
expected_labels[name] = str(value)
|
||||||
|
|
||||||
if isinstance(container['Config']['Labels'], dict):
|
if isinstance(container['Config']['Labels'], dict):
|
||||||
|
@ -1401,7 +1401,7 @@ class DockerManager(object):
|
||||||
|
|
||||||
expected_bound_ports = {}
|
expected_bound_ports = {}
|
||||||
if self.port_bindings:
|
if self.port_bindings:
|
||||||
for container_port, config in self.port_bindings.iteritems():
|
for container_port, config in self.port_bindings.items():
|
||||||
if isinstance(container_port, int):
|
if isinstance(container_port, int):
|
||||||
container_port = "{0}/tcp".format(container_port)
|
container_port = "{0}/tcp".format(container_port)
|
||||||
if len(config) == 1:
|
if len(config) == 1:
|
||||||
|
@ -1437,7 +1437,7 @@ class DockerManager(object):
|
||||||
# LINKS
|
# LINKS
|
||||||
|
|
||||||
expected_links = set()
|
expected_links = set()
|
||||||
for link, alias in (self.links or {}).iteritems():
|
for link, alias in (self.links or {}).items():
|
||||||
expected_links.add("/{0}:{1}/{2}".format(link, container["Name"], alias))
|
expected_links.add("/{0}:{1}/{2}".format(link, container["Name"], alias))
|
||||||
|
|
||||||
actual_links = set(container['HostConfig']['Links'] or [])
|
actual_links = set(container['HostConfig']['Links'] or [])
|
||||||
|
|
|
@ -815,7 +815,7 @@ class TaskParameters(DockerBaseClass):
|
||||||
kernel_memory='kernel_memory'
|
kernel_memory='kernel_memory'
|
||||||
)
|
)
|
||||||
result = dict()
|
result = dict()
|
||||||
for key, value in update_parameters.iteritems():
|
for key, value in update_parameters.items():
|
||||||
if getattr(self, value, None) is not None:
|
if getattr(self, value, None) is not None:
|
||||||
result[key] = getattr(self, value)
|
result[key] = getattr(self, value)
|
||||||
return result
|
return result
|
||||||
|
@ -927,7 +927,7 @@ class TaskParameters(DockerBaseClass):
|
||||||
pid_mode='pid_mode'
|
pid_mode='pid_mode'
|
||||||
)
|
)
|
||||||
params = dict()
|
params = dict()
|
||||||
for key, value in host_config_params.iteritems():
|
for key, value in host_config_params.items():
|
||||||
if getattr(self, value, None) is not None:
|
if getattr(self, value, None) is not None:
|
||||||
params[key] = getattr(self, value)
|
params[key] = getattr(self, value)
|
||||||
|
|
||||||
|
@ -1116,10 +1116,10 @@ class TaskParameters(DockerBaseClass):
|
||||||
final_env = {}
|
final_env = {}
|
||||||
if self.env_file:
|
if self.env_file:
|
||||||
parsed_env_file = utils.parse_env_file(self.env_file)
|
parsed_env_file = utils.parse_env_file(self.env_file)
|
||||||
for name, value in parsed_env_file.iteritems():
|
for name, value in parsed_env_file.items():
|
||||||
final_env[name] = str(value)
|
final_env[name] = str(value)
|
||||||
if self.env:
|
if self.env:
|
||||||
for name, value in self.env.iteritems():
|
for name, value in self.env.items():
|
||||||
final_env[name] = str(value)
|
final_env[name] = str(value)
|
||||||
return final_env
|
return final_env
|
||||||
|
|
||||||
|
@ -1258,7 +1258,7 @@ class Container(DockerBaseClass):
|
||||||
)
|
)
|
||||||
|
|
||||||
differences = []
|
differences = []
|
||||||
for key, value in config_mapping.iteritems():
|
for key, value in config_mapping.items():
|
||||||
self.log('check differences %s %s vs %s' % (key, getattr(self.parameters, key), str(value)))
|
self.log('check differences %s %s vs %s' % (key, getattr(self.parameters, key), str(value)))
|
||||||
if getattr(self.parameters, key, None) is not None:
|
if getattr(self.parameters, key, None) is not None:
|
||||||
if isinstance(getattr(self.parameters, key), list) and isinstance(value, list):
|
if isinstance(getattr(self.parameters, key), list) and isinstance(value, list):
|
||||||
|
@ -1314,7 +1314,7 @@ class Container(DockerBaseClass):
|
||||||
'''
|
'''
|
||||||
if not isinstance(dict_a, dict) or not isinstance(dict_b, dict):
|
if not isinstance(dict_a, dict) or not isinstance(dict_b, dict):
|
||||||
return False
|
return False
|
||||||
for key, value in dict_a.iteritems():
|
for key, value in dict_a.items():
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
match = self._compare_dicts(value, dict_b.get(key))
|
match = self._compare_dicts(value, dict_b.get(key))
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
|
@ -1353,7 +1353,7 @@ class Container(DockerBaseClass):
|
||||||
)
|
)
|
||||||
|
|
||||||
differences = []
|
differences = []
|
||||||
for key, value in config_mapping.iteritems():
|
for key, value in config_mapping.items():
|
||||||
if getattr(self.parameters, key, None) and getattr(self.parameters, key) != value:
|
if getattr(self.parameters, key, None) and getattr(self.parameters, key) != value:
|
||||||
# no match. record the differences
|
# no match. record the differences
|
||||||
item = dict()
|
item = dict()
|
||||||
|
@ -1402,7 +1402,7 @@ class Container(DockerBaseClass):
|
||||||
diff = True
|
diff = True
|
||||||
if network.get('links') and connected_networks[network['name']].get('Links'):
|
if network.get('links') and connected_networks[network['name']].get('Links'):
|
||||||
expected_links = []
|
expected_links = []
|
||||||
for link, alias in network['links'].iteritems():
|
for link, alias in network['links'].items():
|
||||||
expected_links.append("%s:%s" % (link, alias))
|
expected_links.append("%s:%s" % (link, alias))
|
||||||
for link in expected_links:
|
for link in expected_links:
|
||||||
if link not in connected_networks[network['name']].get('Links', []):
|
if link not in connected_networks[network['name']].get('Links', []):
|
||||||
|
@ -1433,7 +1433,7 @@ class Container(DockerBaseClass):
|
||||||
|
|
||||||
connected_networks = self.container['NetworkSettings'].get('Networks')
|
connected_networks = self.container['NetworkSettings'].get('Networks')
|
||||||
if connected_networks:
|
if connected_networks:
|
||||||
for network, network_config in connected_networks.iteritems():
|
for network, network_config in connected_networks.items():
|
||||||
keep = False
|
keep = False
|
||||||
if self.parameters.networks:
|
if self.parameters.networks:
|
||||||
for expected_network in self.parameters.networks:
|
for expected_network in self.parameters.networks:
|
||||||
|
@ -1485,7 +1485,7 @@ class Container(DockerBaseClass):
|
||||||
if not self.parameters.published_ports:
|
if not self.parameters.published_ports:
|
||||||
return None
|
return None
|
||||||
expected_bound_ports = {}
|
expected_bound_ports = {}
|
||||||
for container_port, config in self.parameters.published_ports.iteritems():
|
for container_port, config in self.parameters.published_ports.items():
|
||||||
if isinstance(container_port, int):
|
if isinstance(container_port, int):
|
||||||
container_port = "%s/tcp" % container_port
|
container_port = "%s/tcp" % container_port
|
||||||
if len(config) == 1:
|
if len(config) == 1:
|
||||||
|
@ -1504,7 +1504,7 @@ class Container(DockerBaseClass):
|
||||||
self.log('parameter links:')
|
self.log('parameter links:')
|
||||||
self.log(self.parameters.links, pretty_print=True)
|
self.log(self.parameters.links, pretty_print=True)
|
||||||
exp_links = []
|
exp_links = []
|
||||||
for link, alias in self.parameters.links.iteritems():
|
for link, alias in self.parameters.links.items():
|
||||||
exp_links.append("/%s:%s/%s" % (link, ('/' + self.parameters.name), alias))
|
exp_links.append("/%s:%s/%s" % (link, ('/' + self.parameters.name), alias))
|
||||||
return exp_links
|
return exp_links
|
||||||
|
|
||||||
|
@ -1635,7 +1635,7 @@ class Container(DockerBaseClass):
|
||||||
if getattr(self.parameters, param_name, None) is None:
|
if getattr(self.parameters, param_name, None) is None:
|
||||||
return None
|
return None
|
||||||
results = []
|
results = []
|
||||||
for key, value in getattr(self.parameters, param_name).iteritems():
|
for key, value in getattr(self.parameters, param_name).items():
|
||||||
results.append("%s%s%s" % (key, join_with, value))
|
results.append("%s%s%s" % (key, join_with, value))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ class ImageManager(DockerBaseClass):
|
||||||
if self.container_limits:
|
if self.container_limits:
|
||||||
params['container_limits'] = self.container_limits
|
params['container_limits'] = self.container_limits
|
||||||
if self.buildargs:
|
if self.buildargs:
|
||||||
for key, value in self.buildargs.iteritems():
|
for key, value in self.buildargs.items():
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, basestring):
|
||||||
self.buildargs[key] = str(value)
|
self.buildargs[key] = str(value)
|
||||||
params['buildargs'] = self.buildargs
|
params['buildargs'] = self.buildargs
|
||||||
|
|
|
@ -242,7 +242,7 @@ class DockerNetworkManager(object):
|
||||||
different = True
|
different = True
|
||||||
differences.append('driver_options')
|
differences.append('driver_options')
|
||||||
else:
|
else:
|
||||||
for key, value in self.parameters.driver_options.iteritems():
|
for key, value in self.parameters.driver_options.items():
|
||||||
if not net['Options'].get(key) or value != net['Options'][key]:
|
if not net['Options'].get(key) or value != net['Options'][key]:
|
||||||
different = True
|
different = True
|
||||||
differences.append('driver_options.%s' % key)
|
differences.append('driver_options.%s' % key)
|
||||||
|
@ -255,7 +255,7 @@ class DockerNetworkManager(object):
|
||||||
different = True
|
different = True
|
||||||
differences.append('ipam_options')
|
differences.append('ipam_options')
|
||||||
else:
|
else:
|
||||||
for key, value in self.parameters.ipam_options.iteritems():
|
for key, value in self.parameters.ipam_options.items():
|
||||||
camelkey = None
|
camelkey = None
|
||||||
for net_key in net['IPAM']['Config'][0]:
|
for net_key in net['IPAM']['Config'][0]:
|
||||||
if key == net_key.lower():
|
if key == net_key.lower():
|
||||||
|
|
|
@ -284,7 +284,7 @@ class LXDProfileManagement(object):
|
||||||
|
|
||||||
def _apply_profile_configs(self):
|
def _apply_profile_configs(self):
|
||||||
config = self.old_profile_json.copy()
|
config = self.old_profile_json.copy()
|
||||||
for k, v in self.config.iteritems():
|
for k, v in self.config.items():
|
||||||
config[k] = v
|
config[k] = v
|
||||||
self.client.do('PUT', '/1.0/profiles/{}'.format(self.name), config)
|
self.client.do('PUT', '/1.0/profiles/{}'.format(self.name), config)
|
||||||
self.actions.append('apply_profile_configs')
|
self.actions.append('apply_profile_configs')
|
||||||
|
|
|
@ -328,7 +328,7 @@ def node_check(proxmox, node):
|
||||||
|
|
||||||
def create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, swap, timeout, **kwargs):
|
def create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, swap, timeout, **kwargs):
|
||||||
proxmox_node = proxmox.nodes(node)
|
proxmox_node = proxmox.nodes(node)
|
||||||
kwargs = dict((k,v) for k, v in kwargs.iteritems() if v is not None)
|
kwargs = dict((k,v) for k, v in kwargs.items() if v is not None)
|
||||||
if VZ_TYPE =='lxc':
|
if VZ_TYPE =='lxc':
|
||||||
kwargs['cpulimit']=cpus
|
kwargs['cpulimit']=cpus
|
||||||
kwargs['rootfs']=disk
|
kwargs['rootfs']=disk
|
||||||
|
|
|
@ -689,7 +689,7 @@ def get_vminfo(module, proxmox, node, vmid, **kwargs):
|
||||||
module.fail_json(msg='Getting information for VM with vmid = %s failed with exception: %s' % (vmid, e))
|
module.fail_json(msg='Getting information for VM with vmid = %s failed with exception: %s' % (vmid, e))
|
||||||
|
|
||||||
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
||||||
kwargs = dict((k,v) for k, v in kwargs.iteritems() if v is not None)
|
kwargs = dict((k,v) for k, v in kwargs.items() if v is not None)
|
||||||
|
|
||||||
# Convert all dict in kwargs to elements. For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n]
|
# Convert all dict in kwargs to elements. For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n]
|
||||||
for k in kwargs.keys():
|
for k in kwargs.keys():
|
||||||
|
@ -698,7 +698,7 @@ def get_vminfo(module, proxmox, node, vmid, **kwargs):
|
||||||
del kwargs[k]
|
del kwargs[k]
|
||||||
|
|
||||||
# Split information by type
|
# Split information by type
|
||||||
for k, v in kwargs.iteritems():
|
for k, v in kwargs.items():
|
||||||
if re.match(r'net[0-9]', k) is not None:
|
if re.match(r'net[0-9]', k) is not None:
|
||||||
interface = k
|
interface = k
|
||||||
k = vm[k]
|
k = vm[k]
|
||||||
|
@ -723,8 +723,8 @@ def create_vm(module, proxmox, vmid, node, name, memory, cpu, cores, sockets, ti
|
||||||
proxmox_node = proxmox.nodes(node)
|
proxmox_node = proxmox.nodes(node)
|
||||||
|
|
||||||
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
||||||
kwargs = dict((k,v) for k, v in kwargs.iteritems() if v is not None)
|
kwargs = dict((k,v) for k, v in kwargs.items() if v is not None)
|
||||||
kwargs.update(dict([k, int(v)] for k, v in kwargs.iteritems() if isinstance(v, bool)))
|
kwargs.update(dict([k, int(v)] for k, v in kwargs.items() if isinstance(v, bool)))
|
||||||
|
|
||||||
# The features work only on PVE 4
|
# The features work only on PVE 4
|
||||||
if PVE_MAJOR_VERSION < 4:
|
if PVE_MAJOR_VERSION < 4:
|
||||||
|
|
|
@ -129,7 +129,7 @@ def change_keys(recs, key='uuid', filter_func=None):
|
||||||
"""
|
"""
|
||||||
new_recs = {}
|
new_recs = {}
|
||||||
|
|
||||||
for ref, rec in recs.iteritems():
|
for ref, rec in recs.items():
|
||||||
if filter_func is not None and not filter_func(rec):
|
if filter_func is not None and not filter_func(rec):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -484,7 +484,7 @@ def cloudservers(module, state=None, name=None, flavor=None, image=None,
|
||||||
if not boot_from_volume and not boot_volume and not image:
|
if not boot_from_volume and not boot_volume and not image:
|
||||||
module.fail_json(msg='image is required for the "rax" module')
|
module.fail_json(msg='image is required for the "rax" module')
|
||||||
|
|
||||||
for arg, value in dict(name=name, flavor=flavor).iteritems():
|
for arg, value in dict(name=name, flavor=flavor).items():
|
||||||
if not value:
|
if not value:
|
||||||
module.fail_json(msg='%s is required for the "rax" module' %
|
module.fail_json(msg='%s is required for the "rax" module' %
|
||||||
arg)
|
arg)
|
||||||
|
|
|
@ -129,7 +129,7 @@ def cloud_block_storage_attachments(module, state, volume, server, device,
|
||||||
|
|
||||||
volume.get()
|
volume.get()
|
||||||
|
|
||||||
for key, value in vars(volume).iteritems():
|
for key, value in vars(volume).items():
|
||||||
if (isinstance(value, NON_CALLABLES) and
|
if (isinstance(value, NON_CALLABLES) and
|
||||||
not key.startswith('_')):
|
not key.startswith('_')):
|
||||||
instance[key] = value
|
instance[key] = value
|
||||||
|
|
|
@ -114,7 +114,7 @@ def save_instance(module, name, flavor, volume, cdb_type, cdb_version, wait,
|
||||||
|
|
||||||
for arg, value in dict(name=name, flavor=flavor,
|
for arg, value in dict(name=name, flavor=flavor,
|
||||||
volume=volume, type=cdb_type, version=cdb_version
|
volume=volume, type=cdb_type, version=cdb_version
|
||||||
).iteritems():
|
).items():
|
||||||
if not value:
|
if not value:
|
||||||
module.fail_json(msg='%s is required for the "rax_cdb"'
|
module.fail_json(msg='%s is required for the "rax_cdb"'
|
||||||
' module' % arg)
|
' module' % arg)
|
||||||
|
|
|
@ -93,7 +93,7 @@ def find_user(instance, name):
|
||||||
|
|
||||||
def save_user(module, cdb_id, name, password, databases, host):
|
def save_user(module, cdb_id, name, password, databases, host):
|
||||||
|
|
||||||
for arg, value in dict(cdb_id=cdb_id, name=name).iteritems():
|
for arg, value in dict(cdb_id=cdb_id, name=name).items():
|
||||||
if not value:
|
if not value:
|
||||||
module.fail_json(msg='%s is required for the "rax_cdb_user" '
|
module.fail_json(msg='%s is required for the "rax_cdb_user" '
|
||||||
'module' % arg)
|
'module' % arg)
|
||||||
|
@ -148,7 +148,7 @@ def save_user(module, cdb_id, name, password, databases, host):
|
||||||
|
|
||||||
def delete_user(module, cdb_id, name):
|
def delete_user(module, cdb_id, name):
|
||||||
|
|
||||||
for arg, value in dict(cdb_id=cdb_id, name=name).iteritems():
|
for arg, value in dict(cdb_id=cdb_id, name=name).items():
|
||||||
if not value:
|
if not value:
|
||||||
module.fail_json(msg='%s is required for the "rax_cdb_user"'
|
module.fail_json(msg='%s is required for the "rax_cdb_user"'
|
||||||
' module' % arg)
|
' module' % arg)
|
||||||
|
|
|
@ -200,7 +200,7 @@ def cloud_load_balancer(module, state, name, meta, algorithm, port, protocol,
|
||||||
'protocol': protocol,
|
'protocol': protocol,
|
||||||
'timeout': timeout
|
'timeout': timeout
|
||||||
}
|
}
|
||||||
for att, value in atts.iteritems():
|
for att, value in atts.items():
|
||||||
current = getattr(balancer, att)
|
current = getattr(balancer, att)
|
||||||
if current != value:
|
if current != value:
|
||||||
changed = True
|
changed = True
|
||||||
|
|
|
@ -143,7 +143,7 @@ def cloud_load_balancer_ssl(module, loadbalancer, state, enabled, private_key,
|
||||||
needs_change = False
|
needs_change = False
|
||||||
|
|
||||||
if existing_ssl:
|
if existing_ssl:
|
||||||
for ssl_attr, value in ssl_attrs.iteritems():
|
for ssl_attr, value in ssl_attrs.items():
|
||||||
if ssl_attr == 'privatekey':
|
if ssl_attr == 'privatekey':
|
||||||
# The private key is not included in get_ssl_termination's
|
# The private key is not included in get_ssl_termination's
|
||||||
# output (as it shouldn't be). Also, if you're changing the
|
# output (as it shouldn't be). Also, if you're changing the
|
||||||
|
|
|
@ -191,7 +191,7 @@ def cloud_check(module, state, entity_id, label, check_type,
|
||||||
# Only force a recreation of the check if one of the *specified*
|
# Only force a recreation of the check if one of the *specified*
|
||||||
# keys is missing or has a different value.
|
# keys is missing or has a different value.
|
||||||
if details:
|
if details:
|
||||||
for (key, value) in details.iteritems():
|
for (key, value) in details.items():
|
||||||
if key not in check.details:
|
if key not in check.details:
|
||||||
should_delete = should_create = True
|
should_delete = should_create = True
|
||||||
elif value != check.details[key]:
|
elif value != check.details[key]:
|
||||||
|
|
|
@ -594,7 +594,7 @@ class PyVmomiHelper(object):
|
||||||
mac = device.macAddress
|
mac = device.macAddress
|
||||||
ips = list(device.ipAddress)
|
ips = list(device.ipAddress)
|
||||||
netDict[mac] = ips
|
netDict[mac] = ips
|
||||||
for k,v in netDict.iteritems():
|
for k,v in netDict.items():
|
||||||
for ipaddress in v:
|
for ipaddress in v:
|
||||||
if ipaddress:
|
if ipaddress:
|
||||||
if '::' in ipaddress:
|
if '::' in ipaddress:
|
||||||
|
@ -979,7 +979,7 @@ class PyVmomiHelper(object):
|
||||||
timeout=10, headers=None)
|
timeout=10, headers=None)
|
||||||
|
|
||||||
# save all of the transfer data
|
# save all of the transfer data
|
||||||
for k,v in info.iteritems():
|
for k,v in info.items():
|
||||||
result[k] = v
|
result[k] = v
|
||||||
|
|
||||||
# exit early if xfer failed
|
# exit early if xfer failed
|
||||||
|
@ -1045,7 +1045,7 @@ class PyVmomiHelper(object):
|
||||||
result['msg'] = str(rsp.read())
|
result['msg'] = str(rsp.read())
|
||||||
|
|
||||||
# save all of the transfer data
|
# save all of the transfer data
|
||||||
for k,v in info.iteritems():
|
for k,v in info.items():
|
||||||
result[k] = v
|
result[k] = v
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -863,7 +863,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
if vm_extra_config:
|
if vm_extra_config:
|
||||||
spec = spec_singleton(spec, request, vm)
|
spec = spec_singleton(spec, request, vm)
|
||||||
extra_config = []
|
extra_config = []
|
||||||
for k,v in vm_extra_config.iteritems():
|
for k,v in vm_extra_config.items():
|
||||||
ec = spec.new_extraConfig()
|
ec = spec.new_extraConfig()
|
||||||
ec.set_element_key(str(k))
|
ec.set_element_key(str(k))
|
||||||
ec.set_element_value(str(v))
|
ec.set_element_value(str(v))
|
||||||
|
@ -1085,7 +1085,7 @@ def reconfigure_net(vsphere_client, vm, module, esxi, resource_pool, guest, vm_n
|
||||||
module.fail_json(msg="Cannot find datacenter named: %s" % datacenter)
|
module.fail_json(msg="Cannot find datacenter named: %s" % datacenter)
|
||||||
dcprops = VIProperty(vsphere_client, dcmor)
|
dcprops = VIProperty(vsphere_client, dcmor)
|
||||||
nfmor = dcprops.networkFolder._obj
|
nfmor = dcprops.networkFolder._obj
|
||||||
for k,v in vm_nic.iteritems():
|
for k,v in vm_nic.items():
|
||||||
nicNum = k[len(k) -1]
|
nicNum = k[len(k) -1]
|
||||||
if vm_nic[k]['network_type'] == 'dvs':
|
if vm_nic[k]['network_type'] == 'dvs':
|
||||||
portgroupKey = find_portgroup_key(module, s, nfmor, vm_nic[k]['network'])
|
portgroupKey = find_portgroup_key(module, s, nfmor, vm_nic[k]['network'])
|
||||||
|
@ -1116,7 +1116,7 @@ def reconfigure_net(vsphere_client, vm, module, esxi, resource_pool, guest, vm_n
|
||||||
module.exit_json()
|
module.exit_json()
|
||||||
|
|
||||||
if len(nics) > 0:
|
if len(nics) > 0:
|
||||||
for nic, obj in nics.iteritems():
|
for nic, obj in nics.items():
|
||||||
"""
|
"""
|
||||||
1,2 and 3 are used to mark which action should be taken
|
1,2 and 3 are used to mark which action should be taken
|
||||||
1 = from a distributed switch to a distributed switch
|
1 = from a distributed switch to a distributed switch
|
||||||
|
@ -1145,7 +1145,7 @@ def reconfigure_net(vsphere_client, vm, module, esxi, resource_pool, guest, vm_n
|
||||||
"nic_backing").pyclass()
|
"nic_backing").pyclass()
|
||||||
nic_backing.set_element_deviceName(vm_nic[nic]['network'])
|
nic_backing.set_element_deviceName(vm_nic[nic]['network'])
|
||||||
dev._obj.set_element_backing(nic_backing)
|
dev._obj.set_element_backing(nic_backing)
|
||||||
for nic, obj in nics.iteritems():
|
for nic, obj in nics.items():
|
||||||
dev = obj[0]
|
dev = obj[0]
|
||||||
spec = request.new_spec()
|
spec = request.new_spec()
|
||||||
nic_change = spec.new_deviceChange()
|
nic_change = spec.new_deviceChange()
|
||||||
|
@ -1178,7 +1178,7 @@ def _build_folder_tree(nodes, parent):
|
||||||
|
|
||||||
|
|
||||||
def _find_path_in_tree(tree, path):
|
def _find_path_in_tree(tree, path):
|
||||||
for name, o in tree.iteritems():
|
for name, o in tree.items():
|
||||||
if name == path[0]:
|
if name == path[0]:
|
||||||
if len(path) == 1:
|
if len(path) == 1:
|
||||||
return o
|
return o
|
||||||
|
@ -1231,7 +1231,7 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest,
|
||||||
|
|
||||||
# try the legacy behaviour of just matching the folder name, so 'lamp' alone matches 'production/customerA/lamp'
|
# try the legacy behaviour of just matching the folder name, so 'lamp' alone matches 'production/customerA/lamp'
|
||||||
if vmfmor is None:
|
if vmfmor is None:
|
||||||
for mor, name in vsphere_client._get_managed_objects(MORTypes.Folder).iteritems():
|
for mor, name in vsphere_client._get_managed_objects(MORTypes.Folder).items():
|
||||||
if name == vm_extra_config['folder']:
|
if name == vm_extra_config['folder']:
|
||||||
vmfmor = mor
|
vmfmor = mor
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ def get_consul_api(module, token=None):
|
||||||
|
|
||||||
def get_service_by_id_or_name(consul_api, service_id_or_name):
|
def get_service_by_id_or_name(consul_api, service_id_or_name):
|
||||||
''' iterate the registered services and find one with the given id '''
|
''' iterate the registered services and find one with the given id '''
|
||||||
for name, service in consul_api.agent.services().iteritems():
|
for name, service in consul_api.agent.services().items():
|
||||||
if service['ID'] == service_id_or_name or service['Service'] == service_id_or_name:
|
if service['ID'] == service_id_or_name or service['Service'] == service_id_or_name:
|
||||||
return ConsulService(loaded=service)
|
return ConsulService(loaded=service)
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ def load_rules_for_token(module, consul_api, token):
|
||||||
if info and info['Rules']:
|
if info and info['Rules']:
|
||||||
rule_set = hcl.loads(to_ascii(info['Rules']))
|
rule_set = hcl.loads(to_ascii(info['Rules']))
|
||||||
for rule_type in rule_set:
|
for rule_type in rule_set:
|
||||||
for pattern, policy in rule_set[rule_type].iteritems():
|
for pattern, policy in rule_set[rule_type].items():
|
||||||
rules.add_rule(rule_type, Rule(pattern, policy['policy']))
|
rules.add_rule(rule_type, Rule(pattern, policy['policy']))
|
||||||
return rules
|
return rules
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -272,7 +272,7 @@ class Rules:
|
||||||
|
|
||||||
rules = ""
|
rules = ""
|
||||||
for rule_type in RULE_TYPES:
|
for rule_type in RULE_TYPES:
|
||||||
for pattern, rule in self.rules[rule_type].iteritems():
|
for pattern, rule in self.rules[rule_type].items():
|
||||||
rules += template % (rule_type, pattern, rule.policy)
|
rules += template % (rule_type, pattern, rule.policy)
|
||||||
return to_ascii(rules)
|
return to_ascii(rules)
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ class Rules:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for rule_type in RULE_TYPES:
|
for rule_type in RULE_TYPES:
|
||||||
for name, other_rule in other.rules[rule_type].iteritems():
|
for name, other_rule in other.rules[rule_type].items():
|
||||||
if not name in self.rules[rule_type]:
|
if not name in self.rules[rule_type]:
|
||||||
return False
|
return False
|
||||||
rule = self.rules[rule_type][name]
|
rule = self.rules[rule_type][name]
|
||||||
|
|
|
@ -146,7 +146,7 @@ def main():
|
||||||
echo = module.params['echo']
|
echo = module.params['echo']
|
||||||
|
|
||||||
events = dict()
|
events = dict()
|
||||||
for key, value in responses.iteritems():
|
for key, value in responses.items():
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
response = response_closure(module, key, value)
|
response = response_closure(module, key, value)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -152,7 +152,7 @@ def main():
|
||||||
"login_password":"password",
|
"login_password":"password",
|
||||||
"port":"port"
|
"port":"port"
|
||||||
}
|
}
|
||||||
kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems()
|
kw = dict( (params_map[k], v) for (k, v) in module.params.items()
|
||||||
if k in params_map and v != '' )
|
if k in params_map and v != '' )
|
||||||
try:
|
try:
|
||||||
db_connection = psycopg2.connect(database=db, **kw)
|
db_connection = psycopg2.connect(database=db, **kw)
|
||||||
|
|
|
@ -237,7 +237,7 @@ def main():
|
||||||
"port":"port",
|
"port":"port",
|
||||||
"db":"database"
|
"db":"database"
|
||||||
}
|
}
|
||||||
kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems()
|
kw = dict( (params_map[k], v) for (k, v) in module.params.items()
|
||||||
if k in params_map and v != "" )
|
if k in params_map and v != "" )
|
||||||
try:
|
try:
|
||||||
db_connection = psycopg2.connect(**kw)
|
db_connection = psycopg2.connect(**kw)
|
||||||
|
|
|
@ -210,7 +210,7 @@ def main():
|
||||||
"login_password":"password",
|
"login_password":"password",
|
||||||
"port":"port"
|
"port":"port"
|
||||||
}
|
}
|
||||||
kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems()
|
kw = dict( (params_map[k], v) for (k, v) in module.params.items()
|
||||||
if k in params_map and v != '' )
|
if k in params_map and v != '' )
|
||||||
|
|
||||||
# If a login_unix_socket is specified, incorporate it here.
|
# If a login_unix_socket is specified, incorporate it here.
|
||||||
|
|
|
@ -1557,7 +1557,7 @@ class Host(LogicMonitor):
|
||||||
if properties is not None and properties is not {}:
|
if properties is not None and properties is not {}:
|
||||||
self.module.debug("Properties hash exists")
|
self.module.debug("Properties hash exists")
|
||||||
propnum = 0
|
propnum = 0
|
||||||
for key, value in properties.iteritems():
|
for key, value in properties.items():
|
||||||
h["propName" + str(propnum)] = key
|
h["propName" + str(propnum)] = key
|
||||||
h["propValue" + str(propnum)] = value
|
h["propValue" + str(propnum)] = value
|
||||||
propnum = propnum + 1
|
propnum = propnum + 1
|
||||||
|
@ -2049,7 +2049,7 @@ class Hostgroup(LogicMonitor):
|
||||||
if properties != {}:
|
if properties != {}:
|
||||||
self.module.debug("Properties hash exists")
|
self.module.debug("Properties hash exists")
|
||||||
propnum = 0
|
propnum = 0
|
||||||
for key, value in properties.iteritems():
|
for key, value in properties.items():
|
||||||
h["propName" + str(propnum)] = key
|
h["propName" + str(propnum)] = key
|
||||||
h["propValue" + str(propnum)] = value
|
h["propValue" + str(propnum)] = value
|
||||||
propnum = propnum + 1
|
propnum = propnum + 1
|
||||||
|
|
|
@ -459,7 +459,7 @@ def main():
|
||||||
# checks all lists and removes it, so that functions expecting
|
# checks all lists and removes it, so that functions expecting
|
||||||
# an empty list, get this result. May upstream this fix into
|
# an empty list, get this result. May upstream this fix into
|
||||||
# the AnsibleModule code to have it check for this.
|
# the AnsibleModule code to have it check for this.
|
||||||
for k, _param in module.params.iteritems():
|
for k, _param in module.params.items():
|
||||||
if isinstance(_param, list):
|
if isinstance(_param, list):
|
||||||
module.params[k] = [x for x in _param if x]
|
module.params[k] = [x for x in _param if x]
|
||||||
|
|
||||||
|
|
|
@ -385,7 +385,7 @@ def main():
|
||||||
# checks all lists and removes it, so that functions expecting
|
# checks all lists and removes it, so that functions expecting
|
||||||
# an empty list, get this result. May upstream this fix into
|
# an empty list, get this result. May upstream this fix into
|
||||||
# the AnsibleModule code to have it check for this.
|
# the AnsibleModule code to have it check for this.
|
||||||
for k, _param in module.params.iteritems():
|
for k, _param in module.params.items():
|
||||||
if isinstance(_param, list):
|
if isinstance(_param, list):
|
||||||
module.params[k] = [x for x in _param if x]
|
module.params[k] = [x for x in _param if x]
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ def main():
|
||||||
# checks all lists and removes it, so that functions expecting
|
# checks all lists and removes it, so that functions expecting
|
||||||
# an empty list, get this result. May upstream this fix into
|
# an empty list, get this result. May upstream this fix into
|
||||||
# the AnsibleModule code to have it check for this.
|
# the AnsibleModule code to have it check for this.
|
||||||
for k, _param in module.params.iteritems():
|
for k, _param in module.params.items():
|
||||||
if isinstance(_param, list):
|
if isinstance(_param, list):
|
||||||
module.params[k] = [x for x in _param if x]
|
module.params[k] = [x for x in _param if x]
|
||||||
|
|
||||||
|
|
|
@ -443,7 +443,7 @@ def main():
|
||||||
module.exit_json(out=module.from_json(runner.items))
|
module.exit_json(out=module.from_json(runner.items))
|
||||||
|
|
||||||
ansible_facts = dict()
|
ansible_facts = dict()
|
||||||
for key, value in facts.iteritems():
|
for key, value in facts.items():
|
||||||
key = 'ansible_net_%s' % key
|
key = 'ansible_net_%s' % key
|
||||||
ansible_facts[key] = value
|
ansible_facts[key] = value
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ class Interfaces(FactsBase):
|
||||||
|
|
||||||
def populate_interfaces(self, interfaces, desc, properties):
|
def populate_interfaces(self, interfaces, desc, properties):
|
||||||
facts = dict()
|
facts = dict()
|
||||||
for key, value in interfaces.iteritems():
|
for key, value in interfaces.items():
|
||||||
intf = dict()
|
intf = dict()
|
||||||
intf['description'] = self.parse_description(key,desc)
|
intf['description'] = self.parse_description(key,desc)
|
||||||
intf['macaddress'] = self.parse_macaddress(value)
|
intf['macaddress'] = self.parse_macaddress(value)
|
||||||
|
@ -433,7 +433,7 @@ def main():
|
||||||
module.exit_json(out=module.from_json(runner.items))
|
module.exit_json(out=module.from_json(runner.items))
|
||||||
|
|
||||||
ansible_facts = dict()
|
ansible_facts = dict()
|
||||||
for key, value in facts.iteritems():
|
for key, value in facts.items():
|
||||||
key = 'ansible_net_%s' % key
|
key = 'ansible_net_%s' % key
|
||||||
ansible_facts[key] = value
|
ansible_facts[key] = value
|
||||||
|
|
||||||
|
|
|
@ -286,7 +286,7 @@ class Interfaces(FactsBase):
|
||||||
|
|
||||||
def populate_interfaces(self, interfaces):
|
def populate_interfaces(self, interfaces):
|
||||||
facts = dict()
|
facts = dict()
|
||||||
for key, value in interfaces.iteritems():
|
for key, value in interfaces.items():
|
||||||
intf = dict()
|
intf = dict()
|
||||||
intf['description'] = self.parse_description(value)
|
intf['description'] = self.parse_description(value)
|
||||||
intf['macaddress'] = self.parse_macaddress(value)
|
intf['macaddress'] = self.parse_macaddress(value)
|
||||||
|
@ -307,7 +307,7 @@ class Interfaces(FactsBase):
|
||||||
return facts
|
return facts
|
||||||
|
|
||||||
def populate_ipv6_interfaces(self, data):
|
def populate_ipv6_interfaces(self, data):
|
||||||
for key, value in data.iteritems():
|
for key, value in data.items():
|
||||||
self.facts['interfaces'][key]['ipv6'] = list()
|
self.facts['interfaces'][key]['ipv6'] = list()
|
||||||
addresses = re.findall(r'\s+(.+), subnet', value, re.M)
|
addresses = re.findall(r'\s+(.+), subnet', value, re.M)
|
||||||
subnets = re.findall(r', subnet is (\S+)', value, re.M)
|
subnets = re.findall(r', subnet is (\S+)', value, re.M)
|
||||||
|
@ -556,7 +556,7 @@ def main():
|
||||||
module.exit_json(out=module.from_json(runner.items))
|
module.exit_json(out=module.from_json(runner.items))
|
||||||
|
|
||||||
ansible_facts = dict()
|
ansible_facts = dict()
|
||||||
for key, value in facts.iteritems():
|
for key, value in facts.items():
|
||||||
key = 'ansible_net_%s' % key
|
key = 'ansible_net_%s' % key
|
||||||
ansible_facts[key] = value
|
ansible_facts[key] = value
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ def get_instance(module):
|
||||||
def started(module, instance, commands):
|
def started(module, instance, commands):
|
||||||
commands.append('no shutdown')
|
commands.append('no shutdown')
|
||||||
setters = set()
|
setters = set()
|
||||||
for key, value in module.argument_spec.iteritems():
|
for key, value in module.argument_spec.items():
|
||||||
if module.params[key] is not None:
|
if module.params[key] is not None:
|
||||||
setter = value.get('setter') or 'set_%s' % key
|
setter = value.get('setter') or 'set_%s' % key
|
||||||
if setter not in setters:
|
if setter not in setters:
|
||||||
|
|
|
@ -227,7 +227,7 @@ class BigIpGtmFactsCommon(object):
|
||||||
result = dict()
|
result = dict()
|
||||||
for attribute in self.attributes_to_remove:
|
for attribute in self.attributes_to_remove:
|
||||||
parameters.pop(attribute, None)
|
parameters.pop(attribute, None)
|
||||||
for key, val in parameters.iteritems():
|
for key, val in parameters.items():
|
||||||
result[key] = str(val)
|
result[key] = str(val)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ class BigIpGtmFactsPools(BigIpGtmFactsCommon):
|
||||||
|
|
||||||
def get_facts_with_types(self):
|
def get_facts_with_types(self):
|
||||||
result = []
|
result = []
|
||||||
for key, type in self.gtm_types.iteritems():
|
for key, type in self.gtm_types.items():
|
||||||
facts = self.get_all_facts_by_type(key, type)
|
facts = self.get_all_facts_by_type(key, type)
|
||||||
if facts:
|
if facts:
|
||||||
result.append(facts)
|
result.append(facts)
|
||||||
|
@ -330,7 +330,7 @@ class BigIpGtmFactsWideIps(BigIpGtmFactsCommon):
|
||||||
|
|
||||||
def get_facts_with_types(self):
|
def get_facts_with_types(self):
|
||||||
result = []
|
result = []
|
||||||
for key, type in self.gtm_types.iteritems():
|
for key, type in self.gtm_types.items():
|
||||||
facts = self.get_all_facts_by_type(key, type)
|
facts = self.get_all_facts_by_type(key, type)
|
||||||
if facts:
|
if facts:
|
||||||
result.append(facts)
|
result.append(facts)
|
||||||
|
|
|
@ -164,6 +164,7 @@ import re
|
||||||
from ansible.module_utils.basic import get_exception
|
from ansible.module_utils.basic import get_exception
|
||||||
from ansible.module_utils.netcfg import NetworkConfig, ConfigLine
|
from ansible.module_utils.netcfg import NetworkConfig, ConfigLine
|
||||||
from ansible.module_utils.shell import ShellError
|
from ansible.module_utils.shell import ShellError
|
||||||
|
from ansible.module_utils.six import iteritems
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.nxos import get_module
|
from ansible.module_utils.nxos import get_module
|
||||||
|
@ -508,7 +509,7 @@ def main():
|
||||||
server_timeout=server_timeout, directed_request=directed_request)
|
server_timeout=server_timeout, directed_request=directed_request)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
existing = get_aaa_server_info(server_type, module)
|
existing = get_aaa_server_info(server_type, module)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
@ -531,15 +532,15 @@ def main():
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg='server_timeout must be an integer between 1 and 60')
|
msg='server_timeout must be an integer between 1 and 60')
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(
|
delta = dict(set(proposed.items()).difference(
|
||||||
existing.iteritems()))
|
existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = config_aaa_server(delta, server_type)
|
command = config_aaa_server(delta, server_type)
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
elif state == 'default':
|
elif state == 'default':
|
||||||
for key, value in proposed.iteritems():
|
for key, value in proposed.items():
|
||||||
if key != 'server_type' and value != 'default':
|
if key != 'server_type' and value != 'default':
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg='Parameters must be set to "default"'
|
msg='Parameters must be set to "default"'
|
||||||
|
|
|
@ -513,7 +513,7 @@ def main():
|
||||||
auth_port=auth_port, acct_port=acct_port,
|
auth_port=auth_port, acct_port=acct_port,
|
||||||
tacacs_port=tacacs_port)
|
tacacs_port=tacacs_port)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
if encrypt_type and not key:
|
if encrypt_type and not key:
|
||||||
|
@ -543,7 +543,7 @@ def main():
|
||||||
msg='host_timeout must be an integer between 1 and 60')
|
msg='host_timeout must be an integer between 1 and 60')
|
||||||
|
|
||||||
delta = dict(
|
delta = dict(
|
||||||
set(proposed.iteritems()).difference(existing.iteritems()))
|
set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
union = existing.copy()
|
union = existing.copy()
|
||||||
union.update(delta)
|
union.update(delta)
|
||||||
|
@ -553,7 +553,7 @@ def main():
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
intersect = dict(
|
intersect = dict(
|
||||||
set(proposed.iteritems()).intersection(existing.iteritems()))
|
set(proposed.items()).intersection(existing.items()))
|
||||||
if intersect.get('address') and intersect.get('server_type'):
|
if intersect.get('address') and intersect.get('server_type'):
|
||||||
command = 'no {0}-server host {1}'.format(
|
command = 'no {0}-server host {1}'.format(
|
||||||
intersect.get('server_type'), intersect.get('address'))
|
intersect.get('server_type'), intersect.get('address'))
|
||||||
|
|
|
@ -525,13 +525,13 @@ def get_acl(module, acl_name, seq_number):
|
||||||
options['time_range'] = each.get('timerange')
|
options['time_range'] = each.get('timerange')
|
||||||
|
|
||||||
options_no_null = {}
|
options_no_null = {}
|
||||||
for key, value in options.iteritems():
|
for key, value in options.items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
options_no_null[key] = value
|
options_no_null[key] = value
|
||||||
|
|
||||||
keep['options'] = options_no_null
|
keep['options'] = options_no_null
|
||||||
|
|
||||||
for key, value in temp.iteritems():
|
for key, value in temp.items():
|
||||||
if value:
|
if value:
|
||||||
keep[key] = value
|
keep[key] = value
|
||||||
# ensure options is always in the dict
|
# ensure options is always in the dict
|
||||||
|
@ -600,7 +600,7 @@ def config_acl_options(options):
|
||||||
options.pop('time_range')
|
options.pop('time_range')
|
||||||
|
|
||||||
command = ''
|
command = ''
|
||||||
for option, value in options.iteritems():
|
for option, value in options.items():
|
||||||
if option in ENABLE_ONLY:
|
if option in ENABLE_ONLY:
|
||||||
if value == 'enable':
|
if value == 'enable':
|
||||||
command += ' ' + option
|
command += ' ' + option
|
||||||
|
@ -733,11 +733,11 @@ def main():
|
||||||
'dest_port1', 'dest_port2', 'remark']
|
'dest_port1', 'dest_port2', 'remark']
|
||||||
|
|
||||||
proposed_core = dict((param, value) for (param, value) in
|
proposed_core = dict((param, value) for (param, value) in
|
||||||
module.params.iteritems()
|
module.params.items()
|
||||||
if param in CORE and value is not None)
|
if param in CORE and value is not None)
|
||||||
|
|
||||||
proposed_options = dict((param, value) for (param, value) in
|
proposed_options = dict((param, value) for (param, value) in
|
||||||
module.params.iteritems()
|
module.params.items()
|
||||||
if param in OPTIONS_NAMES and value is not None)
|
if param in OPTIONS_NAMES and value is not None)
|
||||||
proposed = {}
|
proposed = {}
|
||||||
proposed.update(proposed_core)
|
proposed.update(proposed_core)
|
||||||
|
@ -759,12 +759,12 @@ def main():
|
||||||
|
|
||||||
if not existing_core.get('remark'):
|
if not existing_core.get('remark'):
|
||||||
delta_core = dict(
|
delta_core = dict(
|
||||||
set(proposed_core.iteritems()).difference(
|
set(proposed_core.items()).difference(
|
||||||
existing_core.iteritems())
|
existing_core.items())
|
||||||
)
|
)
|
||||||
delta_options = dict(
|
delta_options = dict(
|
||||||
set(proposed_options.iteritems()).difference(
|
set(proposed_options.items()).difference(
|
||||||
existing_options.iteritems())
|
existing_options.items())
|
||||||
)
|
)
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
|
|
@ -755,7 +755,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
elif value is False:
|
elif value is False:
|
||||||
|
@ -951,7 +951,7 @@ def main():
|
||||||
]
|
]
|
||||||
|
|
||||||
if module.params['vrf'] != 'default':
|
if module.params['vrf'] != 'default':
|
||||||
for param, inserted_value in module.params.iteritems():
|
for param, inserted_value in module.params.items():
|
||||||
if param in GLOBAL_PARAMS and inserted_value:
|
if param in GLOBAL_PARAMS and inserted_value:
|
||||||
module.fail_json(msg='Global params can be modified only'
|
module.fail_json(msg='Global params can be modified only'
|
||||||
' under "default" VRF.',
|
' under "default" VRF.',
|
||||||
|
@ -968,10 +968,10 @@ def main():
|
||||||
existing_asn=existing.get('asn'))
|
existing_asn=existing.get('asn'))
|
||||||
|
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'asn' and key != 'vrf':
|
if key != 'asn' and key != 'vrf':
|
||||||
if str(value).lower() == 'default':
|
if str(value).lower() == 'default':
|
||||||
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
||||||
|
|
|
@ -736,7 +736,7 @@ def fix_proposed(module, proposed, existing):
|
||||||
commands = list()
|
commands = list()
|
||||||
command = ''
|
command = ''
|
||||||
fixed_proposed = {}
|
fixed_proposed = {}
|
||||||
for key, value in proposed.iteritems():
|
for key, value in proposed.items():
|
||||||
if key in DAMPENING_PARAMS:
|
if key in DAMPENING_PARAMS:
|
||||||
if value != 'default':
|
if value != 'default':
|
||||||
command = 'dampening {0} {1} {2} {3}'.format(
|
command = 'dampening {0} {1} {2} {3}'.format(
|
||||||
|
@ -874,7 +874,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
fixed_proposed, commands = fix_proposed(module, proposed, existing)
|
fixed_proposed, commands = fix_proposed(module, proposed, existing)
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, fixed_proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, fixed_proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if key == 'address-family':
|
if key == 'address-family':
|
||||||
addr_family_command = "address-family {0} {1}".format(
|
addr_family_command = "address-family {0} {1}".format(
|
||||||
module.params['afi'], module.params['safi'])
|
module.params['afi'], module.params['safi'])
|
||||||
|
@ -1060,7 +1060,7 @@ def main():
|
||||||
existing_asn=existing.get('asn'))
|
existing_asn=existing.get('asn'))
|
||||||
|
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
if proposed_args.get('networks'):
|
if proposed_args.get('networks'):
|
||||||
|
@ -1071,7 +1071,7 @@ def main():
|
||||||
proposed_args['inject_map'] = 'default'
|
proposed_args['inject_map'] = 'default'
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key not in ['asn', 'vrf']:
|
if key not in ['asn', 'vrf']:
|
||||||
if str(value).lower() == 'default':
|
if str(value).lower() == 'default':
|
||||||
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
||||||
|
|
|
@ -576,7 +576,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
|
|
||||||
|
@ -725,11 +725,11 @@ def main():
|
||||||
existing_asn=existing.get('asn'))
|
existing_asn=existing.get('asn'))
|
||||||
|
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key not in ['asn', 'vrf', 'neighbor', 'pwd_type']:
|
if key not in ['asn', 'vrf', 'neighbor', 'pwd_type']:
|
||||||
if str(value).lower() == 'default':
|
if str(value).lower() == 'default':
|
||||||
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
||||||
|
|
|
@ -895,7 +895,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
'route-map out',
|
'route-map out',
|
||||||
'soft-reconfiguration inbound'
|
'soft-reconfiguration inbound'
|
||||||
]
|
]
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if key == 'send-community' and value == 'none':
|
if key == 'send-community' and value == 'none':
|
||||||
commands.append('{0}'.format(key))
|
commands.append('{0}'.format(key))
|
||||||
|
|
||||||
|
@ -1070,11 +1070,11 @@ def main():
|
||||||
module.params['advertise_map_non_exist'] = 'default'
|
module.params['advertise_map_non_exist'] = 'default'
|
||||||
|
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key not in ['asn', 'vrf', 'neighbor']:
|
if key not in ['asn', 'vrf', 'neighbor']:
|
||||||
if not isinstance(value, list):
|
if not isinstance(value, list):
|
||||||
if str(value).lower() == 'true':
|
if str(value).lower() == 'true':
|
||||||
|
|
|
@ -269,7 +269,7 @@ def get_commands(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
elif value is False:
|
elif value is False:
|
||||||
|
|
|
@ -330,7 +330,7 @@ def get_existing(module, args):
|
||||||
else:
|
else:
|
||||||
existing[arg] = get_route_target_value(arg, config, module)
|
existing[arg] = get_route_target_value(arg, config, module)
|
||||||
|
|
||||||
existing_fix = dict((k, v) for k, v in existing.iteritems() if v)
|
existing_fix = dict((k, v) for k, v in existing.items() if v)
|
||||||
if existing_fix:
|
if existing_fix:
|
||||||
existing['vni'] = module.params['vni']
|
existing['vni'] = module.params['vni']
|
||||||
else:
|
else:
|
||||||
|
@ -358,7 +358,7 @@ def state_present(module, existing, proposed):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if key.startswith('route-target'):
|
if key.startswith('route-target'):
|
||||||
if value == ['default']:
|
if value == ['default']:
|
||||||
existing_value = existing_commands.get(key)
|
existing_value = existing_commands.get(key)
|
||||||
|
@ -434,11 +434,11 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'vni':
|
if key != 'vni':
|
||||||
if value == 'true':
|
if value == 'true':
|
||||||
value = True
|
value = True
|
||||||
|
|
|
@ -512,7 +512,7 @@ def get_commands_config_hsrp(delta, interface, args):
|
||||||
elif preempt == 'disabled':
|
elif preempt == 'disabled':
|
||||||
delta['preempt'] = 'no preempt'
|
delta['preempt'] = 'no preempt'
|
||||||
|
|
||||||
for key, value in delta.iteritems():
|
for key, value in delta.items():
|
||||||
command = config_args.get(key, 'DNE').format(**delta)
|
command = config_args.get(key, 'DNE').format(**delta)
|
||||||
if command and command != 'DNE':
|
if command and command != 'DNE':
|
||||||
if key == 'group':
|
if key == 'group':
|
||||||
|
@ -664,7 +664,7 @@ def main():
|
||||||
preempt=preempt, vip=vip, auth_type=auth_type,
|
preempt=preempt, vip=vip, auth_type=auth_type,
|
||||||
auth_string=auth_string)
|
auth_string=auth_string)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
existing = get_hsrp_group(group, interface, module)
|
existing = get_hsrp_group(group, interface, module)
|
||||||
|
|
||||||
|
@ -685,7 +685,7 @@ def main():
|
||||||
commands = []
|
commands = []
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
delta = dict(
|
delta = dict(
|
||||||
set(proposed.iteritems()).difference(existing.iteritems()))
|
set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = get_commands_config_hsrp(delta, interface, args)
|
command = get_commands_config_hsrp(delta, interface, args)
|
||||||
commands.extend(command)
|
commands.extend(command)
|
||||||
|
|
|
@ -301,11 +301,11 @@ def get_commands(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
if module.params['state'] == 'default':
|
if module.params['state'] == 'default':
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if existing_commands.get(key):
|
if existing_commands.get(key):
|
||||||
commands.append('no {0}'.format(key))
|
commands.append('no {0}'.format(key))
|
||||||
else:
|
else:
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
else:
|
else:
|
||||||
|
@ -361,7 +361,7 @@ def main():
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems()
|
proposed = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed_args = proposed.copy()
|
proposed_args = proposed.copy()
|
||||||
|
|
|
@ -624,7 +624,7 @@ def config_igmp_interface(delta, found_both, found_prefix):
|
||||||
commands = []
|
commands = []
|
||||||
command = None
|
command = None
|
||||||
|
|
||||||
for key, value in delta.iteritems():
|
for key, value in delta.items():
|
||||||
if key == 'oif_source' or found_both or found_prefix:
|
if key == 'oif_source' or found_both or found_prefix:
|
||||||
pass
|
pass
|
||||||
elif key == 'oif_prefix':
|
elif key == 'oif_prefix':
|
||||||
|
@ -669,7 +669,7 @@ def get_igmp_interface_defaults():
|
||||||
group_timeout=group_timeout, report_llg=report_llg,
|
group_timeout=group_timeout, report_llg=report_llg,
|
||||||
immediate_leave=immediate_leave)
|
immediate_leave=immediate_leave)
|
||||||
|
|
||||||
default = dict((param, value) for (param, value) in args.iteritems()
|
default = dict((param, value) for (param, value) in args.items()
|
||||||
if value is not None)
|
if value is not None)
|
||||||
|
|
||||||
return default
|
return default
|
||||||
|
@ -678,7 +678,7 @@ def get_igmp_interface_defaults():
|
||||||
def config_default_igmp_interface(existing, delta, found_both, found_prefix):
|
def config_default_igmp_interface(existing, delta, found_both, found_prefix):
|
||||||
commands = []
|
commands = []
|
||||||
proposed = get_igmp_interface_defaults()
|
proposed = get_igmp_interface_defaults()
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = config_igmp_interface(delta, found_both, found_prefix)
|
command = config_igmp_interface(delta, found_both, found_prefix)
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ def main():
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
commands = []
|
commands = []
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems()
|
proposed = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
CANNOT_ABSENT = ['version', 'startup_query_interval',
|
CANNOT_ABSENT = ['version', 'startup_query_interval',
|
||||||
|
@ -833,7 +833,7 @@ def main():
|
||||||
'state=absent')
|
'state=absent')
|
||||||
|
|
||||||
# delta check for all params except oif_prefix and oif_source
|
# delta check for all params except oif_prefix and oif_source
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
# now check to see there is a delta for prefix and source command option
|
# now check to see there is a delta for prefix and source command option
|
||||||
found_both = False
|
found_both = False
|
||||||
|
|
|
@ -449,7 +449,7 @@ def config_igmp_snooping(delta, existing, default=False):
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
command = None
|
command = None
|
||||||
for key, value in delta.iteritems():
|
for key, value in delta.items():
|
||||||
if value:
|
if value:
|
||||||
if default and key == 'group_timeout':
|
if default and key == 'group_timeout':
|
||||||
if existing.get(key):
|
if existing.get(key):
|
||||||
|
@ -477,7 +477,7 @@ def get_igmp_snooping_defaults():
|
||||||
report_supp=report_supp, v3_report_supp=v3_report_supp,
|
report_supp=report_supp, v3_report_supp=v3_report_supp,
|
||||||
group_timeout=group_timeout)
|
group_timeout=group_timeout)
|
||||||
|
|
||||||
default = dict((param, value) for (param, value) in args.iteritems()
|
default = dict((param, value) for (param, value) in args.items()
|
||||||
if value is not None)
|
if value is not None)
|
||||||
|
|
||||||
return default
|
return default
|
||||||
|
@ -506,7 +506,7 @@ def main():
|
||||||
report_supp=report_supp, v3_report_supp=v3_report_supp,
|
report_supp=report_supp, v3_report_supp=v3_report_supp,
|
||||||
group_timeout=group_timeout)
|
group_timeout=group_timeout)
|
||||||
|
|
||||||
proposed = dict((param, value) for (param, value) in args.iteritems()
|
proposed = dict((param, value) for (param, value) in args.items()
|
||||||
if value is not None)
|
if value is not None)
|
||||||
|
|
||||||
existing = get_igmp_snooping(module)
|
existing = get_igmp_snooping(module)
|
||||||
|
@ -516,7 +516,7 @@ def main():
|
||||||
commands = []
|
commands = []
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
delta = dict(
|
delta = dict(
|
||||||
set(proposed.iteritems()).difference(existing.iteritems())
|
set(proposed.items()).difference(existing.items())
|
||||||
)
|
)
|
||||||
if delta:
|
if delta:
|
||||||
command = config_igmp_snooping(delta, existing)
|
command = config_igmp_snooping(delta, existing)
|
||||||
|
@ -525,7 +525,7 @@ def main():
|
||||||
elif state == 'default':
|
elif state == 'default':
|
||||||
proposed = get_igmp_snooping_defaults()
|
proposed = get_igmp_snooping_defaults()
|
||||||
delta = dict(
|
delta = dict(
|
||||||
set(proposed.iteritems()).difference(existing.iteritems())
|
set(proposed.items()).difference(existing.items())
|
||||||
)
|
)
|
||||||
if delta:
|
if delta:
|
||||||
command = config_igmp_snooping(delta, existing, default=True)
|
command = config_igmp_snooping(delta, existing, default=True)
|
||||||
|
|
|
@ -907,8 +907,8 @@ def main():
|
||||||
existing)
|
existing)
|
||||||
commands.append(cmds)
|
commands.append(cmds)
|
||||||
else:
|
else:
|
||||||
delta = dict(set(proposed.iteritems()).difference(
|
delta = dict(set(proposed.items()).difference(
|
||||||
existing.iteritems()))
|
existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
cmds = get_interface_config_commands(delta,
|
cmds = get_interface_config_commands(delta,
|
||||||
normalized_interface,
|
normalized_interface,
|
||||||
|
|
|
@ -507,7 +507,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
elif value is False:
|
elif value is False:
|
||||||
|
@ -536,7 +536,7 @@ def state_absent(module, existing, proposed, candidate):
|
||||||
parents = ['interface {0}'.format(module.params['interface'].capitalize())]
|
parents = ['interface {0}'.format(module.params['interface'].capitalize())]
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in existing_commands.iteritems():
|
for key, value in existing_commands.items():
|
||||||
if value:
|
if value:
|
||||||
if key.startswith('ip ospf message-digest-key'):
|
if key.startswith('ip ospf message-digest-key'):
|
||||||
if 'options' not in key:
|
if 'options' not in key:
|
||||||
|
@ -632,11 +632,11 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'interface':
|
if key != 'interface':
|
||||||
if str(value).lower() == 'true':
|
if str(value).lower() == 'true':
|
||||||
value = True
|
value = True
|
||||||
|
|
|
@ -660,7 +660,7 @@ def main():
|
||||||
existing, address_list = get_ip_interface(interface, version, module)
|
existing, address_list = get_ip_interface(interface, version, module)
|
||||||
|
|
||||||
args = dict(addr=addr, mask=mask, interface=interface)
|
args = dict(addr=addr, mask=mask, interface=interface)
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
commands = []
|
commands = []
|
||||||
changed = False
|
changed = False
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
|
@ -411,7 +411,7 @@ def get_commands_config_mtu(delta, interface):
|
||||||
}
|
}
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
for param, value in delta.iteritems():
|
for param, value in delta.items():
|
||||||
command = CONFIG_ARGS.get(param, 'DNE').format(**delta)
|
command = CONFIG_ARGS.get(param, 'DNE').format(**delta)
|
||||||
if command and command != 'DNE':
|
if command and command != 'DNE':
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
@ -428,7 +428,7 @@ def get_commands_remove_mtu(delta, interface):
|
||||||
'sysmtu': 'no system jumbomtu {sysmtu}',
|
'sysmtu': 'no system jumbomtu {sysmtu}',
|
||||||
}
|
}
|
||||||
commands = []
|
commands = []
|
||||||
for param, value in delta.iteritems():
|
for param, value in delta.items():
|
||||||
command = CONFIG_ARGS.get(param, 'DNE').format(**delta)
|
command = CONFIG_ARGS.get(param, 'DNE').format(**delta)
|
||||||
if command and command != 'DNE':
|
if command and command != 'DNE':
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
@ -552,8 +552,8 @@ def main():
|
||||||
'number between 576 and 9216')
|
'number between 576 and 9216')
|
||||||
|
|
||||||
args = dict(mtu=mtu, sysmtu=sysmtu)
|
args = dict(mtu=mtu, sysmtu=sysmtu)
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
@ -565,7 +565,7 @@ def main():
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
common = set(proposed.iteritems()).intersection(existing.iteritems())
|
common = set(proposed.items()).intersection(existing.items())
|
||||||
if common:
|
if common:
|
||||||
command = get_commands_remove_mtu(dict(common), interface)
|
command = get_commands_remove_mtu(dict(common), interface)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
|
@ -439,7 +439,7 @@ def get_ntp_peer(module):
|
||||||
args = dict(peer_type=peer_type, address=address, prefer=prefer,
|
args = dict(peer_type=peer_type, address=address, prefer=prefer,
|
||||||
vrf_name=vrf_name, key_id=key_id)
|
vrf_name=vrf_name, key_id=key_id)
|
||||||
|
|
||||||
ntp_peer = dict((k, v) for k, v in args.iteritems())
|
ntp_peer = dict((k, v) for k, v in args.items())
|
||||||
ntp_peer_list.append(ntp_peer)
|
ntp_peer_list.append(ntp_peer)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
ntp_peer_list = []
|
ntp_peer_list = []
|
||||||
|
@ -573,7 +573,7 @@ def main():
|
||||||
prefer=prefer, vrf_name=vrf_name, source_type=source_type,
|
prefer=prefer, vrf_name=vrf_name, source_type=source_type,
|
||||||
source=source)
|
source=source)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
existing, peer_server_list = get_ntp_existing(address, peer_type, module)
|
existing, peer_server_list = get_ntp_existing(address, peer_type, module)
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ def main():
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = config_ntp(delta, existing)
|
command = config_ntp(delta, existing)
|
||||||
if command:
|
if command:
|
||||||
|
|
|
@ -518,12 +518,12 @@ def main():
|
||||||
authentication=authentication)
|
authentication=authentication)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
existing = get_ntp_auth_info(key_id, module)
|
existing = get_ntp_auth_info(key_id, module)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
@ -553,7 +553,7 @@ def main():
|
||||||
clie = get_exception()
|
clie = get_exception()
|
||||||
module.fail_json(msg=str(clie) + ": " + cmds)
|
module.fail_json(msg=str(clie) + ": " + cmds)
|
||||||
end_state = get_ntp_auth_info(key_id, module)
|
end_state = get_ntp_auth_info(key_id, module)
|
||||||
delta = dict(set(end_state.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(end_state.items()).difference(existing.items()))
|
||||||
if delta or (len(existing) != len(end_state)):
|
if delta or (len(existing) != len(end_state)):
|
||||||
changed = True
|
changed = True
|
||||||
if 'configure' in cmds:
|
if 'configure' in cmds:
|
||||||
|
|
|
@ -468,13 +468,13 @@ def main():
|
||||||
args = dict(master=master, stratum=stratum, logging=logging)
|
args = dict(master=master, stratum=stratum, logging=logging)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
if master is False:
|
if master is False:
|
||||||
proposed['stratum'] = None
|
proposed['stratum'] = None
|
||||||
stratum = None
|
stratum = None
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
delta_stratum = delta.get('stratum')
|
delta_stratum = delta.get('stratum')
|
||||||
|
|
||||||
if delta_stratum:
|
if delta_stratum:
|
||||||
|
@ -488,8 +488,8 @@ def main():
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
if existing:
|
if existing:
|
||||||
isection = dict(set(proposed.iteritems()).intersection(
|
isection = dict(set(proposed.items()).intersection(
|
||||||
existing.iteritems()))
|
existing.items()))
|
||||||
command = config_ntp_options(isection, flip=True)
|
command = config_ntp_options(isection, flip=True)
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
|
@ -177,7 +177,7 @@ def get_instance(module):
|
||||||
def present(module, instance, commands):
|
def present(module, instance, commands):
|
||||||
commands.append('feature nxapi')
|
commands.append('feature nxapi')
|
||||||
setters = set()
|
setters = set()
|
||||||
for key, value in module.argument_spec.iteritems():
|
for key, value in module.argument_spec.items():
|
||||||
setter = value.get('setter') or 'set_%s' % key
|
setter = value.get('setter') or 'set_%s' % key
|
||||||
if setter not in setters:
|
if setter not in setters:
|
||||||
setters.add(setter)
|
setters.add(setter)
|
||||||
|
|
|
@ -427,7 +427,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ def state_absent(module, existing, proposed, candidate):
|
||||||
parents = ['router ospf {0}'.format(module.params['ospf'])]
|
parents = ['router ospf {0}'.format(module.params['ospf'])]
|
||||||
if module.params['vrf'] == 'default':
|
if module.params['vrf'] == 'default':
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
for key, value in existing_commands.iteritems():
|
for key, value in existing_commands.items():
|
||||||
if value:
|
if value:
|
||||||
if key == 'timers throttle lsa':
|
if key == 'timers throttle lsa':
|
||||||
command = 'no {0} {1} {2} {3}'.format(
|
command = 'no {0} {1} {2} {3}'.format(
|
||||||
|
@ -548,11 +548,11 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'interface':
|
if key != 'interface':
|
||||||
if str(value).lower() == 'true':
|
if str(value).lower() == 'true':
|
||||||
value = True
|
value = True
|
||||||
|
|
|
@ -309,7 +309,7 @@ def get_commands(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value == 'default':
|
if value == 'default':
|
||||||
existing_value = existing_commands.get(key)
|
existing_value = existing_commands.get(key)
|
||||||
if existing_value:
|
if existing_value:
|
||||||
|
@ -385,7 +385,7 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems()
|
proposed = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
|
@ -275,7 +275,7 @@ def get_commands(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
command = '{0} {1}'.format(key, value)
|
command = '{0} {1}'.format(key, value)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems()
|
proposed = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
|
@ -661,7 +661,7 @@ def config_pim_interface(delta, existing, jp_bidir, isauth):
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
for k, v in delta.iteritems():
|
for k, v in delta.items():
|
||||||
if k in ['dr_prio', 'hello_interval', 'hello_auth_key', 'border',
|
if k in ['dr_prio', 'hello_interval', 'hello_auth_key', 'border',
|
||||||
'sparse']:
|
'sparse']:
|
||||||
if v:
|
if v:
|
||||||
|
@ -726,7 +726,7 @@ def get_pim_interface_defaults():
|
||||||
hello_interval=hello_interval,
|
hello_interval=hello_interval,
|
||||||
hello_auth_key=hello_auth_key)
|
hello_auth_key=hello_auth_key)
|
||||||
|
|
||||||
default = dict((param, value) for (param, value) in args.iteritems()
|
default = dict((param, value) for (param, value) in args.items()
|
||||||
if value is not None)
|
if value is not None)
|
||||||
|
|
||||||
return default
|
return default
|
||||||
|
@ -746,7 +746,7 @@ def default_pim_interface_policies(existing, jp_bidir):
|
||||||
|
|
||||||
elif not jp_bidir:
|
elif not jp_bidir:
|
||||||
command = None
|
command = None
|
||||||
for k, v in existing.iteritems():
|
for k, v in existing.items():
|
||||||
if k == 'jp_policy_in':
|
if k == 'jp_policy_in':
|
||||||
if existing.get('jp_policy_in'):
|
if existing.get('jp_policy_in'):
|
||||||
if existing.get('jp_type_in') == 'prefix':
|
if existing.get('jp_type_in') == 'prefix':
|
||||||
|
@ -783,8 +783,8 @@ def config_pim_interface_defaults(existing, jp_bidir, isauth):
|
||||||
|
|
||||||
# returns a dict
|
# returns a dict
|
||||||
defaults = get_pim_interface_defaults()
|
defaults = get_pim_interface_defaults()
|
||||||
delta = dict(set(defaults.iteritems()).difference(
|
delta = dict(set(defaults.items()).difference(
|
||||||
existing.iteritems()))
|
existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
# returns a list
|
# returns a list
|
||||||
command = config_pim_interface(delta, existing,
|
command = config_pim_interface(delta, existing,
|
||||||
|
@ -866,7 +866,7 @@ def main():
|
||||||
'neighbor_type',
|
'neighbor_type',
|
||||||
'neighbor_policy'
|
'neighbor_policy'
|
||||||
]
|
]
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems()
|
proposed = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -879,7 +879,7 @@ def main():
|
||||||
if hello_interval:
|
if hello_interval:
|
||||||
proposed['hello_interval'] = str(proposed['hello_interval'] * 1000)
|
proposed['hello_interval'] = str(proposed['hello_interval'] * 1000)
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if delta:
|
if delta:
|
||||||
|
|
|
@ -375,11 +375,11 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if str(value).lower() == 'true':
|
if str(value).lower() == 'true':
|
||||||
value = True
|
value = True
|
||||||
elif str(value).lower() == 'false':
|
elif str(value).lower() == 'false':
|
||||||
|
|
|
@ -412,7 +412,7 @@ def main():
|
||||||
}
|
}
|
||||||
|
|
||||||
ping_command = 'ping {0}'.format(destination)
|
ping_command = 'ping {0}'.format(destination)
|
||||||
for command, arg in OPTIONS.iteritems():
|
for command, arg in OPTIONS.items():
|
||||||
if arg:
|
if arg:
|
||||||
ping_command += ' {0} {1}'.format(command, arg)
|
ping_command += ' {0} {1}'.format(command, arg)
|
||||||
|
|
||||||
|
|
|
@ -475,7 +475,7 @@ def get_portchannel(module, netcfg=None):
|
||||||
|
|
||||||
# Ensure each member have the same mode.
|
# Ensure each member have the same mode.
|
||||||
modes = set()
|
modes = set()
|
||||||
for each, value in member_dictionary.iteritems():
|
for each, value in member_dictionary.items():
|
||||||
modes.update([value['mode']])
|
modes.update([value['mode']])
|
||||||
if len(modes) == 1:
|
if len(modes) == 1:
|
||||||
portchannel['mode'] = value['mode']
|
portchannel['mode'] = value['mode']
|
||||||
|
@ -597,7 +597,7 @@ def get_commands_if_mode_change(proposed, existing, group, mode, module):
|
||||||
members_to_remove = set(existing_members).difference(proposed_members)
|
members_to_remove = set(existing_members).difference(proposed_members)
|
||||||
members_with_mode_change = []
|
members_with_mode_change = []
|
||||||
if members_dict:
|
if members_dict:
|
||||||
for interface, values in members_dict.iteritems():
|
for interface, values in members_dict.items():
|
||||||
if (interface in proposed_members and
|
if (interface in proposed_members and
|
||||||
(interface not in members_to_remove)):
|
(interface not in members_to_remove)):
|
||||||
if values['mode'] != mode:
|
if values['mode'] != mode:
|
||||||
|
@ -683,7 +683,7 @@ def main():
|
||||||
|
|
||||||
existing, interface_exist = invoke('get_existing', module, args)
|
existing, interface_exist = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems()
|
proposed = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
|
@ -405,7 +405,7 @@ def get_snmp_community(module, find_filter=None):
|
||||||
return {}
|
return {}
|
||||||
else:
|
else:
|
||||||
fix_find = {}
|
fix_find = {}
|
||||||
for (key, value) in find.iteritems():
|
for (key, value) in find.items():
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
fix_find[key] = value.strip()
|
fix_find[key] = value.strip()
|
||||||
else:
|
else:
|
||||||
|
@ -419,7 +419,7 @@ def config_snmp_community(delta, community):
|
||||||
'acl': 'snmp-server community {0} use-acl {acl}'
|
'acl': 'snmp-server community {0} use-acl {acl}'
|
||||||
}
|
}
|
||||||
commands = []
|
commands = []
|
||||||
for k, v in delta.iteritems():
|
for k, v in delta.items():
|
||||||
cmd = CMDS.get(k).format(community, **delta)
|
cmd = CMDS.get(k).format(community, **delta)
|
||||||
if cmd:
|
if cmd:
|
||||||
commands.append(cmd)
|
commands.append(cmd)
|
||||||
|
@ -461,8 +461,8 @@ def main():
|
||||||
|
|
||||||
existing = get_snmp_community(module, community)
|
existing = get_snmp_community(module, community)
|
||||||
args = dict(group=group, acl=acl)
|
args = dict(group=group, acl=acl)
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
|
@ -432,7 +432,7 @@ def get_snmp_host(host, module):
|
||||||
|
|
||||||
if find:
|
if find:
|
||||||
fix_find = {}
|
fix_find = {}
|
||||||
for (key, value) in find.iteritems():
|
for (key, value) in find.items():
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
fix_find[key] = value.strip()
|
fix_find[key] = value.strip()
|
||||||
else:
|
else:
|
||||||
|
@ -507,7 +507,7 @@ def config_snmp_host(delta, proposed, existing, module):
|
||||||
'src_intf': 'snmp-server host {0} source-interface {src_intf}'
|
'src_intf': 'snmp-server host {0} source-interface {src_intf}'
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value in delta.iteritems():
|
for key, value in delta.items():
|
||||||
if key in ['vrf_filter', 'vrf', 'udp', 'src_intf']:
|
if key in ['vrf_filter', 'vrf', 'udp', 'src_intf']:
|
||||||
command = CMDS.get(key, None)
|
command = CMDS.get(key, None)
|
||||||
if command:
|
if command:
|
||||||
|
@ -597,9 +597,9 @@ def main():
|
||||||
snmp_type=snmp_type
|
snmp_type=snmp_type
|
||||||
)
|
)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
commands = []
|
commands = []
|
||||||
|
|
|
@ -506,7 +506,7 @@ def main():
|
||||||
|
|
||||||
args = dict(user=user, pwd=pwd, group=group, privacy=privacy,
|
args = dict(user=user, pwd=pwd, group=group, privacy=privacy,
|
||||||
encrypt=encrypt, authentication=authentication)
|
encrypt=encrypt, authentication=authentication)
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
if not existing:
|
if not existing:
|
||||||
if encrypt:
|
if encrypt:
|
||||||
|
@ -522,7 +522,7 @@ def main():
|
||||||
proposed['encrypt'] = 'aes-128'
|
proposed['encrypt'] = 'aes-128'
|
||||||
|
|
||||||
delta = dict(
|
delta = dict(
|
||||||
set(proposed.iteritems()).difference(existing.iteritems()))
|
set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
if delta.get('pwd'):
|
if delta.get('pwd'):
|
||||||
delta['authentication'] = authentication
|
delta['authentication'] = authentication
|
||||||
|
|
|
@ -442,7 +442,7 @@ def main():
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
||||||
args = ['route_name', 'vrf', 'pref', 'tag', 'next_hop', 'prefix']
|
args = ['route_name', 'vrf', 'pref', 'tag', 'next_hop', 'prefix']
|
||||||
proposed = dict((k, v) for k, v in module.params.iteritems() if v is not None and k in args)
|
proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args)
|
||||||
|
|
||||||
if state == 'present' or (state == 'absent' and existing):
|
if state == 'present' or (state == 'absent' and existing):
|
||||||
candidate = CustomNetworkConfig(indent=3)
|
candidate = CustomNetworkConfig(indent=3)
|
||||||
|
|
|
@ -729,7 +729,7 @@ def main():
|
||||||
native_vlan=native_vlan, trunk_vlans=trunk_vlans,
|
native_vlan=native_vlan, trunk_vlans=trunk_vlans,
|
||||||
trunk_allowed_vlans=trunk_allowed_vlans)
|
trunk_allowed_vlans=trunk_allowed_vlans)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
interface = interface.lower()
|
interface = interface.lower()
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ def get_commands_config_udld_global(delta, reset):
|
||||||
'msg_time': 'udld message-time {msg_time}'
|
'msg_time': 'udld message-time {msg_time}'
|
||||||
}
|
}
|
||||||
commands = []
|
commands = []
|
||||||
for param, value in delta.iteritems():
|
for param, value in delta.items():
|
||||||
if param == 'aggressive':
|
if param == 'aggressive':
|
||||||
if value == 'enabled':
|
if value == 'enabled':
|
||||||
command = 'udld aggressive'
|
command = 'udld aggressive'
|
||||||
|
@ -404,7 +404,7 @@ def get_commands_remove_udld_global(delta):
|
||||||
'msg_time': 'no udld message-time {msg_time}',
|
'msg_time': 'no udld message-time {msg_time}',
|
||||||
}
|
}
|
||||||
commands = []
|
commands = []
|
||||||
for param, value in delta.iteritems():
|
for param, value in delta.items():
|
||||||
command = config_args.get(param, 'DNE').format(**delta)
|
command = config_args.get(param, 'DNE').format(**delta)
|
||||||
if command and command != 'DNE':
|
if command and command != 'DNE':
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
@ -460,12 +460,12 @@ def main():
|
||||||
'between 7 and 90')
|
'between 7 and 90')
|
||||||
|
|
||||||
args = dict(aggressive=aggressive, msg_time=msg_time, reset=reset)
|
args = dict(aggressive=aggressive, msg_time=msg_time, reset=reset)
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
existing = get_udld_global(module)
|
existing = get_udld_global(module)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
||||||
delta = set(proposed.iteritems()).difference(existing.iteritems())
|
delta = set(proposed.items()).difference(existing.items())
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
|
@ -475,7 +475,7 @@ def main():
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
common = set(proposed.iteritems()).intersection(existing.iteritems())
|
common = set(proposed.items()).intersection(existing.items())
|
||||||
if common:
|
if common:
|
||||||
command = get_commands_remove_udld_global(dict(common))
|
command = get_commands_remove_udld_global(dict(common))
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
|
@ -477,7 +477,7 @@ def main():
|
||||||
existing = get_udld_interface(module, interface)
|
existing = get_udld_interface(module, interface)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
commands = []
|
commands = []
|
||||||
|
@ -487,7 +487,7 @@ def main():
|
||||||
module, existing)
|
module, existing)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
common = set(proposed.iteritems()).intersection(existing.iteritems())
|
common = set(proposed.items()).intersection(existing.items())
|
||||||
if common:
|
if common:
|
||||||
command = get_commands_remove_udld_interface(
|
command = get_commands_remove_udld_interface(
|
||||||
dict(common), interface, module, existing
|
dict(common), interface, module, existing
|
||||||
|
|
|
@ -381,7 +381,7 @@ def get_vlan_config_commands(vlan, vid):
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
for param, value in vlan.iteritems():
|
for param, value in vlan.items():
|
||||||
if param == 'mapped_vni' and value == 'default':
|
if param == 'mapped_vni' and value == 'default':
|
||||||
command = 'no vn-segment'
|
command = 'no vn-segment'
|
||||||
else:
|
else:
|
||||||
|
@ -589,7 +589,7 @@ def main():
|
||||||
args = dict(name=name, vlan_state=vlan_state,
|
args = dict(name=name, vlan_state=vlan_state,
|
||||||
admin_state=admin_state, mapped_vni=mapped_vni)
|
admin_state=admin_state, mapped_vni=mapped_vni)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
proposed_vlans_list = numerical_sort(vlan_range_to_list(
|
proposed_vlans_list = numerical_sort(vlan_range_to_list(
|
||||||
vlan_id or vlan_range))
|
vlan_id or vlan_range))
|
||||||
|
@ -620,7 +620,7 @@ def main():
|
||||||
proposed.get('mapped_vni') == 'default'):
|
proposed.get('mapped_vni') == 'default'):
|
||||||
proposed.pop('mapped_vni')
|
proposed.pop('mapped_vni')
|
||||||
delta = dict(set(
|
delta = dict(set(
|
||||||
proposed.iteritems()).difference(existing.iteritems()))
|
proposed.items()).difference(existing.items()))
|
||||||
if delta or not existing:
|
if delta or not existing:
|
||||||
commands = get_vlan_config_commands(delta, vlan_id)
|
commands = get_vlan_config_commands(delta, vlan_id)
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,7 @@ def get_commands_to_config_vpc(module, vpc, domain, existing):
|
||||||
'auto_recovery': '{auto_recovery} auto-recovery',
|
'auto_recovery': '{auto_recovery} auto-recovery',
|
||||||
}
|
}
|
||||||
|
|
||||||
for param, value in vpc.iteritems():
|
for param, value in vpc.items():
|
||||||
command = CONFIG_ARGS.get(param, 'DNE').format(**vpc)
|
command = CONFIG_ARGS.get(param, 'DNE').format(**vpc)
|
||||||
if command and command != 'DNE':
|
if command and command != 'DNE':
|
||||||
commands.append(command.strip())
|
commands.append(command.strip())
|
||||||
|
@ -614,14 +614,14 @@ def main():
|
||||||
module.fail_json(msg='The VRF you are trying to use for the peer '
|
module.fail_json(msg='The VRF you are trying to use for the peer '
|
||||||
'keepalive link is not on device yet. Add it'
|
'keepalive link is not on device yet. Add it'
|
||||||
' first, please.')
|
' first, please.')
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
changed = False
|
changed = False
|
||||||
existing = get_vpc(module)
|
existing = get_vpc(module)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
delta = set(proposed.iteritems()).difference(existing.iteritems())
|
delta = set(proposed.items()).difference(existing.items())
|
||||||
if delta:
|
if delta:
|
||||||
command = get_commands_to_config_vpc(module, delta, domain, existing)
|
command = get_commands_to_config_vpc(module, delta, domain, existing)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
|
@ -446,7 +446,7 @@ def get_portchannel_vpc_config(module, portchannel):
|
||||||
|
|
||||||
mapping = get_existing_portchannel_to_vpc_mappings(module)
|
mapping = get_existing_portchannel_to_vpc_mappings(module)
|
||||||
|
|
||||||
for existing_vpc, port_channel in mapping.iteritems():
|
for existing_vpc, port_channel in mapping.items():
|
||||||
port_ch = str(port_channel[2:])
|
port_ch = str(port_channel[2:])
|
||||||
if port_ch == portchannel:
|
if port_ch == portchannel:
|
||||||
pc = port_ch
|
pc = port_ch
|
||||||
|
@ -511,7 +511,7 @@ def main():
|
||||||
"before trying to assign it here. ",
|
"before trying to assign it here. ",
|
||||||
existing_portchannel=mapping[vpc])
|
existing_portchannel=mapping[vpc])
|
||||||
|
|
||||||
for vpcid, existing_pc in mapping.iteritems():
|
for vpcid, existing_pc in mapping.items():
|
||||||
if portchannel == existing_pc.strip('Po') and vpcid != vpc:
|
if portchannel == existing_pc.strip('Po') and vpcid != vpc:
|
||||||
module.fail_json(msg="This portchannel already has another"
|
module.fail_json(msg="This portchannel already has another"
|
||||||
" VPC configured. Remove it first "
|
" VPC configured. Remove it first "
|
||||||
|
@ -538,13 +538,13 @@ def main():
|
||||||
config_value = 'peer-link'
|
config_value = 'peer-link'
|
||||||
|
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
existing = get_portchannel_vpc_config(module, portchannel)
|
existing = get_portchannel_vpc_config(module, portchannel)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = get_commands_to_config_vpc_interface(
|
command = get_commands_to_config_vpc_interface(
|
||||||
portchannel,
|
portchannel,
|
||||||
|
|
|
@ -367,7 +367,7 @@ def apply_key_map(key_map, table):
|
||||||
|
|
||||||
def get_commands_to_config_vrf(delta, vrf):
|
def get_commands_to_config_vrf(delta, vrf):
|
||||||
commands = []
|
commands = []
|
||||||
for param, value in delta.iteritems():
|
for param, value in delta.items():
|
||||||
command = ''
|
command = ''
|
||||||
if param == 'description':
|
if param == 'description':
|
||||||
command = 'description {0}'.format(value)
|
command = 'description {0}'.format(value)
|
||||||
|
@ -479,7 +479,7 @@ def main():
|
||||||
|
|
||||||
end_state = existing
|
end_state = existing
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
|
|
||||||
"""Since 'admin_state' is either 'Up' or 'Down' from outputs,
|
"""Since 'admin_state' is either 'Up' or 'Down' from outputs,
|
||||||
we use the following to make sure right letter case is used so that delta
|
we use the following to make sure right letter case is used so that delta
|
||||||
|
@ -488,7 +488,7 @@ def main():
|
||||||
if existing['admin_state'].lower() == admin_state:
|
if existing['admin_state'].lower() == admin_state:
|
||||||
proposed['admin_state'] = existing['admin_state']
|
proposed['admin_state'] = existing['admin_state']
|
||||||
|
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
changed = False
|
changed = False
|
||||||
end_state = existing
|
end_state = existing
|
||||||
commands = []
|
commands = []
|
||||||
|
|
|
@ -335,7 +335,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
|
|
||||||
|
@ -392,11 +392,11 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'interface':
|
if key != 'interface':
|
||||||
if str(value).lower() == 'default':
|
if str(value).lower() == 'default':
|
||||||
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
||||||
|
|
|
@ -622,7 +622,7 @@ def main():
|
||||||
vip=vip, authentication=authentication,
|
vip=vip, authentication=authentication,
|
||||||
admin_state=admin_state)
|
admin_state=admin_state)
|
||||||
|
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
existing = get_existing_vrrp(interface, group, module, name)
|
existing = get_existing_vrrp(interface, group, module, name)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
@ -631,7 +631,7 @@ def main():
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
delta = dict(
|
delta = dict(
|
||||||
set(proposed.iteritems()).difference(existing.iteritems()))
|
set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = get_commands_config_vrrp(delta, group)
|
command = get_commands_config_vrrp(delta, group)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
|
@ -391,8 +391,8 @@ def main():
|
||||||
args = dict(domain=domain)
|
args = dict(domain=domain)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
if delta:
|
if delta:
|
||||||
|
|
|
@ -424,8 +424,8 @@ def main():
|
||||||
args = dict(vtp_password=vtp_password)
|
args = dict(vtp_password=vtp_password)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
|
|
|
@ -386,8 +386,8 @@ def main():
|
||||||
args = dict(version=version)
|
args = dict(version=version)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
proposed = dict((k, v) for k, v in args.iteritems() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
delta = dict(set(proposed.iteritems()).difference(existing.iteritems()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
if delta:
|
if delta:
|
||||||
|
|
|
@ -409,7 +409,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
commands = list()
|
commands = list()
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
commands.append(key)
|
commands.append(key)
|
||||||
|
|
||||||
|
@ -475,11 +475,11 @@ def main():
|
||||||
|
|
||||||
existing = invoke('get_existing', module, args)
|
existing = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'interface':
|
if key != 'interface':
|
||||||
if str(value).lower() == 'true':
|
if str(value).lower() == 'true':
|
||||||
value = True
|
value = True
|
||||||
|
|
|
@ -417,7 +417,7 @@ def state_present(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.iteritems():
|
for key, value in proposed_commands.items():
|
||||||
if key == 'associate-vrf':
|
if key == 'associate-vrf':
|
||||||
command = 'member vni {0} {1}'.format(module.params['vni'], key)
|
command = 'member vni {0} {1}'.format(module.params['vni'], key)
|
||||||
|
|
||||||
|
@ -532,11 +532,11 @@ def main():
|
||||||
|
|
||||||
existing, interface_exist = invoke('get_existing', module, args)
|
existing, interface_exist = invoke('get_existing', module, args)
|
||||||
end_state = existing
|
end_state = existing
|
||||||
proposed_args = dict((k, v) for k, v in module.params.iteritems()
|
proposed_args = dict((k, v) for k, v in module.params.items()
|
||||||
if v is not None and k in args)
|
if v is not None and k in args)
|
||||||
|
|
||||||
proposed = {}
|
proposed = {}
|
||||||
for key, value in proposed_args.iteritems():
|
for key, value in proposed_args.items():
|
||||||
if key != 'interface':
|
if key != 'interface':
|
||||||
if str(value).lower() == 'default':
|
if str(value).lower() == 'default':
|
||||||
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
|
||||||
|
|
|
@ -125,7 +125,7 @@ def sanitize_config(lines):
|
||||||
|
|
||||||
def present(module, commands):
|
def present(module, commands):
|
||||||
setters = set()
|
setters = set()
|
||||||
for key, value in module.argument_spec.iteritems():
|
for key, value in module.argument_spec.items():
|
||||||
if module.params[key] is not None:
|
if module.params[key] is not None:
|
||||||
setter = value.get('setter') or 'set_%s' % key
|
setter = value.get('setter') or 'set_%s' % key
|
||||||
if setter not in setters:
|
if setter not in setters:
|
||||||
|
|
|
@ -215,7 +215,7 @@ def main():
|
||||||
'ignore_platform_reqs': 'ignore-platform-reqs',
|
'ignore_platform_reqs': 'ignore-platform-reqs',
|
||||||
}
|
}
|
||||||
|
|
||||||
for param, option in option_params.iteritems():
|
for param, option in option_params.items():
|
||||||
if module.params.get(param) and option in available_options:
|
if module.params.get(param) and option in available_options:
|
||||||
option = "--%s" % option
|
option = "--%s" % option
|
||||||
options.append(option)
|
options.append(option)
|
||||||
|
|
|
@ -137,7 +137,7 @@ class OSXDefaults(object):
|
||||||
self.current_value = None
|
self.current_value = None
|
||||||
|
|
||||||
# Just set all given parameters
|
# Just set all given parameters
|
||||||
for key, val in kwargs.iteritems():
|
for key, val in kwargs.items():
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
|
|
||||||
# Try to find the defaults executable
|
# Try to find the defaults executable
|
||||||
|
|
|
@ -286,7 +286,7 @@ def main():
|
||||||
(_, pre_rules, _) = module.run_command("grep '^### tuple' /lib/ufw/user*.rules")
|
(_, pre_rules, _) = module.run_command("grep '^### tuple' /lib/ufw/user*.rules")
|
||||||
|
|
||||||
# Execute commands
|
# Execute commands
|
||||||
for (command, value) in commands.iteritems():
|
for (command, value) in commands.items():
|
||||||
cmd = [[ufw_bin], [module.check_mode, '--dry-run']]
|
cmd = [[ufw_bin], [module.check_mode, '--dry-run']]
|
||||||
|
|
||||||
if command == 'state':
|
if command == 'state':
|
||||||
|
|
|
@ -168,7 +168,7 @@ class Zfs(object):
|
||||||
if volblocksize:
|
if volblocksize:
|
||||||
cmd += ['-b', 'volblocksize']
|
cmd += ['-b', 'volblocksize']
|
||||||
if properties:
|
if properties:
|
||||||
for prop, value in properties.iteritems():
|
for prop, value in properties.items():
|
||||||
cmd += ['-o', '%s="%s"' % (prop, value)]
|
cmd += ['-o', '%s="%s"' % (prop, value)]
|
||||||
if origin:
|
if origin:
|
||||||
cmd.append(origin)
|
cmd.append(origin)
|
||||||
|
@ -203,7 +203,7 @@ class Zfs(object):
|
||||||
|
|
||||||
def set_properties_if_changed(self):
|
def set_properties_if_changed(self):
|
||||||
current_properties = self.get_current_properties()
|
current_properties = self.get_current_properties()
|
||||||
for prop, value in self.properties.iteritems():
|
for prop, value in self.properties.items():
|
||||||
if current_properties.get(prop, None) != value:
|
if current_properties.get(prop, None) != value:
|
||||||
self.set_property(prop, value)
|
self.set_property(prop, value)
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ def main():
|
||||||
|
|
||||||
# Get all valid zfs-properties
|
# Get all valid zfs-properties
|
||||||
properties = dict()
|
properties = dict()
|
||||||
for prop, value in module.params.iteritems():
|
for prop, value in module.params.items():
|
||||||
# All freestyle params are zfs properties
|
# All freestyle params are zfs properties
|
||||||
if prop not in module.argument_spec:
|
if prop not in module.argument_spec:
|
||||||
# Reverse the boolification of freestyle zfs properties
|
# Reverse the boolification of freestyle zfs properties
|
||||||
|
|
Loading…
Reference in a new issue