mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds uncammelize helper method to put the labels in the expected output format
This commit is contained in:
parent
c6f2b08a60
commit
dbb0304cea
1 changed files with 8 additions and 5 deletions
|
@ -880,19 +880,19 @@ class Ec2Inventory(object):
|
||||||
host_info = {}
|
host_info = {}
|
||||||
for key in describe_dict:
|
for key in describe_dict:
|
||||||
value = describe_dict[key]
|
value = describe_dict[key]
|
||||||
key = self.to_safe('ec2_' + key)
|
key = self.to_safe('ec2_' + self.uncammelize(key))
|
||||||
|
|
||||||
# Handle complex types
|
# Handle complex types
|
||||||
if key == 'ec2_ConfigurationEndpoint' and value:
|
if key == 'ec2_configuration_endpoint' and value:
|
||||||
host_info['ec2_configuration_endpoint_address'] = value['Address']
|
host_info['ec2_configuration_endpoint_address'] = value['Address']
|
||||||
host_info['ec2_configuration_endpoint_port'] = value['Port']
|
host_info['ec2_configuration_endpoint_port'] = value['Port']
|
||||||
if key == 'ec2_Endpoint' and value:
|
if key == 'ec2_endpoint' and value:
|
||||||
host_info['ec2_endpoint_address'] = value['Address']
|
host_info['ec2_endpoint_address'] = value['Address']
|
||||||
host_info['ec2_endpoint_port'] = value['Port']
|
host_info['ec2_endpoint_port'] = value['Port']
|
||||||
elif key == 'ec2_CacheParameterGroup':
|
elif key == 'ec2_cache_parameter_group':
|
||||||
host_info['ec2_cache_parameter_group_name'] = value['CacheParameterGroupName']
|
host_info['ec2_cache_parameter_group_name'] = value['CacheParameterGroupName']
|
||||||
host_info['ec2_cache_parameter_apply_status'] = value['ParameterApplyStatus']
|
host_info['ec2_cache_parameter_apply_status'] = value['ParameterApplyStatus']
|
||||||
elif key == 'ec2_SecurityGroups':
|
elif key == 'ec2_security_groups':
|
||||||
sg_ids = []
|
sg_ids = []
|
||||||
for sg in value:
|
for sg in value:
|
||||||
sg_ids.append(sg['SecurityGroupId'])
|
sg_ids.append(sg['SecurityGroupId'])
|
||||||
|
@ -972,6 +972,9 @@ class Ec2Inventory(object):
|
||||||
cache.write(json_data)
|
cache.write(json_data)
|
||||||
cache.close()
|
cache.close()
|
||||||
|
|
||||||
|
def uncammelize(self, key):
|
||||||
|
temp = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', key)
|
||||||
|
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', temp).lower()
|
||||||
|
|
||||||
def to_safe(self, word):
|
def to_safe(self, word):
|
||||||
''' Converts 'bad' characters in a string to underscores so they can be
|
''' Converts 'bad' characters in a string to underscores so they can be
|
||||||
|
|
Loading…
Reference in a new issue