whitespace cleanup in ec2-get-info.py. consistent 4 space indentation

This commit is contained in:
Scott Moser 2010-01-22 09:30:50 -05:00
parent a43e249584
commit 8be78814be

View File

@ -22,10 +22,10 @@ from optparse import OptionParser
import urllib import urllib
ec2Data = ['ami-id', ec2Data = ['ami-id',
'ami-launch-index', 'ami-launch-index',
'ami-manifest-path', 'ami-manifest-path',
'ancestor-ami-id', 'ancestor-ami-id',
'block-device-mapping', 'block-device-mapping',
'instance-id', 'instance-id',
'instance-type', 'instance-type',
'local-hostname', 'local-hostname',
@ -39,78 +39,78 @@ ec2Data = ['ami-id',
'security-groups'] 'security-groups']
def ec2Version(): def ec2Version():
print file("/etc/ec2_version").read() print file("/etc/ec2_version").read()
def getData(ec2data): def getData(ec2data):
api_ver = '2008-02-01' api_ver = '2008-02-01'
base_url = 'http://169.254.169.254/%s/meta-data' % api_ver base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
print "%s: %s" %(ec2data,urllib.urlopen('%s/%s' %(base_url,ec2data)).read()) print "%s: %s" %(ec2data,urllib.urlopen('%s/%s' %(base_url,ec2data)).read())
def getAllData(ec2Data): def getAllData(ec2Data):
for x in ec2Data: for x in ec2Data:
getData(x) getData(x)
def main(): def main():
usage = "usage: %prog [options]" usage = "usage: %prog [options]"
parser = OptionParser(prog='ec2-get-info', usage=usage) parser = OptionParser(prog='ec2-get-info', usage=usage)
parser.add_option('--ami-id', dest='amiid', action='store_true', help='Display the ami-id.') parser.add_option('--ami-id', dest='amiid', action='store_true', help='Display the ami-id.')
parser.add_option('--launch-index', dest='launch', action='store_true', help='Display the AMI launch index.') parser.add_option('--launch-index', dest='launch', action='store_true', help='Display the AMI launch index.')
parser.add_option('--manifest', dest='manifest', action='store_true', help='Display the AMI manifest path.') parser.add_option('--manifest', dest='manifest', action='store_true', help='Display the AMI manifest path.')
parser.add_option('--ancestor-id', dest='ancestor', action='store_true', help='Display the AMI ancestor id.') parser.add_option('--ancestor-id', dest='ancestor', action='store_true', help='Display the AMI ancestor id.')
parser.add_option('--block-device', dest='block', action='store_true', help='Display the block device id.') parser.add_option('--block-device', dest='block', action='store_true', help='Display the block device id.')
parser.add_option('--instance-id', dest='id', action='store_true', help='Display the instance id.') parser.add_option('--instance-id', dest='id', action='store_true', help='Display the instance id.')
parser.add_option('--instance-type', dest='type', action='store_true', help='Display the instance type.') parser.add_option('--instance-type', dest='type', action='store_true', help='Display the instance type.')
parser.add_option('--local-hostname', dest='lhostname', action='store_true', help='Display the local hostname.') parser.add_option('--local-hostname', dest='lhostname', action='store_true', help='Display the local hostname.')
parser.add_option('--local-ipv4', dest='lipv4', action='store_true', help='Display the local ipv4 IP address.') parser.add_option('--local-ipv4', dest='lipv4', action='store_true', help='Display the local ipv4 IP address.')
parser.add_option('--kernel-id', dest='aki', action='store_true', help='List the AKI.') parser.add_option('--kernel-id', dest='aki', action='store_true', help='List the AKI.')
parser.add_option('--product-codes', dest='code', action='store_true', help='List the product codes associated with thsi AMI.') parser.add_option('--product-codes', dest='code', action='store_true', help='List the product codes associated with thsi AMI.')
parser.add_option('--public-hostname', dest='phostname', action='store_true', help='Show the public hostname.') parser.add_option('--public-hostname', dest='phostname', action='store_true', help='Show the public hostname.')
parser.add_option('--public_ipv4', dest='pipv4', action='store_true', help='Show the public IPV4 IP address.') parser.add_option('--public_ipv4', dest='pipv4', action='store_true', help='Show the public IPV4 IP address.')
parser.add_option('--ramdisk-id', dest='ari', action='store_true', help='Display the ARI.') parser.add_option('--ramdisk-id', dest='ari', action='store_true', help='Display the ARI.')
parser.add_option('--reservation-id', dest='rid', action='store_true', help='Display the reservation id.') parser.add_option('--reservation-id', dest='rid', action='store_true', help='Display the reservation id.')
parser.add_option('--security-groups', dest='security', action='store_true', help='Display the security groups.') parser.add_option('--security-groups', dest='security', action='store_true', help='Display the security groups.')
parser.add_option('--ec2-version', dest='ec2', action='store_true', help='Display the current Ubuntu EC2 version') parser.add_option('--ec2-version', dest='ec2', action='store_true', help='Display the current Ubuntu EC2 version')
parser.add_option('--all',dest='all', action='store_true', help='Display all informantion.') parser.add_option('--all',dest='all', action='store_true', help='Display all informantion.')
options, args = parser.parse_args() options, args = parser.parse_args()
if options.amiid: if options.amiid:
getData(ec2Data[0]) getData(ec2Data[0])
if options.launch: if options.launch:
getData(ec2Data[1]) getData(ec2Data[1])
if options.manifest: if options.manifest:
getData(ec2Data[2]) getData(ec2Data[2])
if options.ancestor: if options.ancestor:
getData(ec2Data[3]) getData(ec2Data[3])
if options.block: if options.block:
getData(ec2Data[4]) getData(ec2Data[4])
if options.id: if options.id:
getData(ec2Data[5]) getData(ec2Data[5])
if options.type: if options.type:
getData(ec2Data[6]) getData(ec2Data[6])
if options.lhostname: if options.lhostname:
getData(ec2Data[7]) getData(ec2Data[7])
if options.lipv4: if options.lipv4:
getData(ec2Data[8]) getData(ec2Data[8])
if options.aki: if options.aki:
getData(ec2Data[9]) getData(ec2Data[9])
if options.code: if options.code:
getData(ec2Data[10]) getData(ec2Data[10])
if options.phostname: if options.phostname:
getData(ec2Data[11]) getData(ec2Data[11])
if options.pipv4: if options.pipv4:
getData(ec2Data[12]) getData(ec2Data[12])
if options.ari: if options.ari:
getData(ec2Data[13]) getData(ec2Data[13])
if options.rid: if options.rid:
getData(ec2Data[14]) getData(ec2Data[14])
if options.security: if options.security:
getData(ec2Data[15]) getData(ec2Data[15])
if options.ec2: if options.ec2:
ec2Version() ec2Version()
if options.all: if options.all:
getAllData(ec2Data) getAllData(ec2Data)
if __name__ == "__main__": if __name__ == "__main__":
main() main()