#NEWLINE# def get_ec2_metadata( self , version ) : #NEWLINE# #INDENT# if ( version == 'latest' ) : #NEWLINE# #INDENT# version = VERSIONS [ ( - 1 ) ] #NEWLINE# #UNINDENT# if ( version not in VERSIONS ) : #NEWLINE# #INDENT# raise InvalidMetadataVersion ( fmt_sgroups ) #NEWLINE# #UNINDENT# hostname = self . _get_hostname ( ) #NEWLINE# floating_ips = self . ip_info [ 'floating_ips' ] #NEWLINE# floating_ip = ( ( floating_ips and floating_ips [ 0 ] ) or '' ) #NEWLINE# fixed_ips = self . ip_info [ 'fixed_ips' ] #NEWLINE# fixed_ip = ( ( fixed_ips and fixed_ips [ 0 ] ) or '' ) #NEWLINE# fmt_sgroups = [ x [ 'name' ] for x in self . security_groups ] #NEWLINE# meta_data = { #NEWLINE# #INDENT# 'ami-id' : self . instance . ec2_ids . ami_id , #NEWLINE# 'ami-launch-index' : self . instance . launch_index , #NEWLINE# 'ami-manifest-path' : 'FIXME' , #NEWLINE# 'instance-id' : self . instance . ec2_ids . instance_id , #NEWLINE# 'hostname' : hostname , #NEWLINE# 'local-ipv4' : ( fixed_ip or self . address ) , #NEWLINE# 'reservation-id' : self . instance . reservation_id , #NEWLINE# 'security-groups' : fmt_sgroups , #NEWLINE# #UNINDENT# } #NEWLINE# if self . instance . key_name : #NEWLINE# #INDENT# meta_data [ 'public-keys' ] = { #NEWLINE# #INDENT# '0' : { #NEWLINE# #INDENT# '_name' : ( '0=' + self . instance . key_name ) , #NEWLINE# 'openssh-key' : self . instance . key_data , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if self . _check_version ( '2007-01-19' , version ) : #NEWLINE# #INDENT# meta_data [ 'local-hostname' ] = hostname #NEWLINE# meta_data [ 'public-hostname' ] = hostname #NEWLINE# meta_data [ 'public-ipv4' ] = floating_ip #NEWLINE# #UNINDENT# if ( False and self . _check_version ( '2007-03-01' , version ) ) : #NEWLINE# #INDENT# meta_data [ 'product-codes' ] = [ ] #NEWLINE# #UNINDENT# if self . _check_version ( '2007-08-29' , version ) : #NEWLINE# #INDENT# instance_type = self . instance . get_flavor ( ) #NEWLINE# meta_data [ 'instance-type' ] = instance_type [ 'name' ] #NEWLINE# #UNINDENT# if ( False and self . _check_version ( '2007-10-10' , version ) ) : #NEWLINE# #INDENT# meta_data [ 'ancestor-ami-ids' ] = [ ] #NEWLINE# #UNINDENT# if self . _check_version ( '2007-12-15' , version ) : #NEWLINE# #INDENT# meta_data [ 'block-device-mapping' ] = self . mappings #NEWLINE# if self . instance . ec2_ids . kernel_id : #NEWLINE# #INDENT# meta_data [ 'kernel-id' ] = self . instance . ec2_ids . kernel_id #NEWLINE# #UNINDENT# if self . instance . ec2_ids . ramdisk_id : #NEWLINE# #INDENT# meta_data [ 'ramdisk-id' ] = self . instance . ec2_ids . ramdisk_id #NEWLINE# #UNINDENT# #UNINDENT# if self . _check_version ( '2008-02-01' , version ) : #NEWLINE# #INDENT# meta_data [ 'placement' ] = { #NEWLINE# #INDENT# 'availability-zone' : self . availability_zone , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if self . _check_version ( '2008-09-01' , version ) : #NEWLINE# #INDENT# meta_data [ 'instance-action' ] = 'none' #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# 'meta-data' : meta_data , #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . userdata_raw is not None ) : #NEWLINE# #INDENT# data [ 'user-data' ] = self . userdata_raw #NEWLINE# #UNINDENT# return data