def parse_elip_response(response): # results is a list of tuples results = [] elip = aws_lib.extract_response(response, 'Addresses') for e in elip: results.append(('E', e['NetworkInterfaceId'], e['PublicIp'])) return results
def parse_neti_response(response): # results is a list of tuples results = [] neti = aws_lib.extract_response(response, 'NetworkInterfaces') for n in neti: results.append(('N', n['NetworkInterfaceId'], n['PrivateIpAddress'])) return results
def parse_keyp_response(response): # results is a list of tuples results = [] keyp = aws_lib.extract_response(response, 'KeyPairs') for k in keyp: results.append(('K', KEY, k['KeyFingerprint'], k['KeyName'])) return results
def parse_vols_response(response): # results is a list of tuples results = [] vols = aws_lib.extract_response(response, 'Volumes') for v in vols: results.append(('V', DISK, v['VolumeId'], '{}GB'.format(v['Size']), v['VolumeType'])) return results
def parse_secg_response(response): # results is a list of tuples results = [] secg = aws_lib.extract_response(response, 'SecurityGroups') for s in secg: results.append(('S', s['GroupId'], s['GroupName'], s['Description'])) for ip_perm in s['IpPermissions']: if ip_perm['IpProtocol'] != '-1': to_port = str(ip_perm['ToPort']) for cidr_ip in ip_perm['IpRanges']: results.append((to_port, cidr_ip['CidrIp'])) return results
def process_and_parse_resv_response(ec2, response): # results is a list of tuples results = [] resv = aws_lib.extract_response(response, 'Reservations') for r in resv: results.append( ('I', is_API_termination_disabled(ec2, r['Instances'][0]['InstanceId']), r['Instances'][0]['InstanceId'], r['Instances'][0]['ImageId'], r['Instances'][0]['InstanceType'], r['Instances'][0]['PublicDnsName'], r['Instances'][0]['KeyName'])) return results
def parse_vpc_response(response): vpc = aws_lib.extract_response(response, 'Vpcs') return ('\n'.join( ['V {}'.format(v['VpcId']) for v in vpc if not v['IsDefault']]))
def parse_secg_response(response): secg = aws_lib.extract_response(response, 'SecurityGroups') return ('\n'.join([ 'S {} {} {}'.format(s['GroupId'], s['GroupName'], s['Description']) for s in secg if 'VpcId' not in s ]))