[perl-Net-Amazon-EC2-Metadata] Import Net::Amazon::EC2::Metadata

Lubomir Rintel lkundrak at fedoraproject.org
Wed Feb 15 15:17:11 UTC 2012


commit b6063d106ebfa77234f80a899892e745eb582a4f
Author: Lubomir Rintel <lubo.rintel at gooddata.com>
Date:   Wed Feb 15 16:17:06 2012 +0100

    Import Net::Amazon::EC2::Metadata

 .gitignore                                  |    1 +
 net-amazon-ec2-metadata.diff                |  179 +++++++++++++++++++++++++++
 perl-Net-Amazon-EC2-Metadata-0.10-say.patch |   75 +++++++++++
 perl-Net-Amazon-EC2-Metadata.spec           |   79 ++++++++++++
 sources                                     |    1 +
 5 files changed, 335 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..3843867 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/Net-Amazon-EC2-Metadata-0.10.tar.gz
diff --git a/net-amazon-ec2-metadata.diff b/net-amazon-ec2-metadata.diff
new file mode 100644
index 0000000..3f0c955
--- /dev/null
+++ b/net-amazon-ec2-metadata.diff
@@ -0,0 +1,179 @@
+Subject: Add support for few new metadata types
+From: Vlastimil Holer <vlastimil.holer at GOODDATA.COM>
+
+diff -pur Net-Amazon-EC2-Metadata-0.10/lib/Net/Amazon/EC2/Metadata.pm Net-Amazon-EC2-Metadata-0.10a/lib/Net/Amazon/EC2/Metadata.pm
+--- Net-Amazon-EC2-Metadata-0.10/lib/Net/Amazon/EC2/Metadata.pm	2008-01-22 20:28:59.000000000 +0100
++++ Net-Amazon-EC2-Metadata-0.10a/lib/Net/Amazon/EC2/Metadata.pm	2009-04-20 10:38:06.000000000 +0200
+@@ -9,27 +9,27 @@ use LWP::Simple;
+ # http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1085&categoryID=100
+ 
+ #Docs
+-#http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.html
+-
++#http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?AESDG-chapter-instancedata.html
+ 
+ ### Metadata
+-# ami-id	The AMI ID used to launch the instance.	1.0
+-# ami-manifest-path	The manifest path of the AMI with which the instance was launched.	1.0
+-# ami-launch-index	The index of this instance in the reservation (per AMI).	1.0
+-# ancestor-ami-ids	The AMI IDs of any instances that were rebundled to create this AMI.	2007-10-10
+-# instance-id	The ID of this instance.	1.0
+-# instance-type	The type of instance to launch. For more information, see Selecting Instance Types.	2007-08-29
+-# local-hostname	The local hostname of the instance.	2007-01-19
+-# public-hostname	The public hostname of the instance.	2007-01-19
+-# local-ipv4	Public IP address if launched with direct addressing; private IP address if launched with public addressing.	1.0
+-# public-ipv4	NATted public IP Address	2007-01-19
+-# public-keys/	Public keys. Only available if supplied at instance launch time	1.0
+-# reservation-id	ID of the reservation.	1.0
+-# security-groups	Names of the security groups the instance is launched in. Only available if supplied at instance launch time	1.0
+-# product-codes	 Product codes associated with this instance.	2007-03-01
+-
+-
+-
++# ami-id                  The AMI ID used to launch the instance.                                         1.0
++# ami-launch-index        The index of this instance in the reservation (per AMI).                        1.0
++# ami-manifest-path       The manifest path of the AMI with which the instance was launched.              1.0
++# ancestor-ami-ids        The AMI IDs of any instances that were rebundled to create this AMI.            2007-10-10
++# block-device-mapping    Defines native device names to use when exposing virtual devices.               2007-10-10
++# instance-id             The ID of this instance.                                                        1.0
++# instance-type           The type of instance to launch. For more information, see Instance Types.       2007-08-29
++# local-hostname          The local hostname of the instance.                                             2007-01-19
++# local-ipv4              Public IP address if launched with direct addressing; private IP address if launched with public addressing.    1.0
++# kernel-id               The ID of the kernel launched with this instance, if applicable.                2008-02-01
++# placement/availability-zone     The Availability Zone in which the instance launched.                   2008-02-01
++# product-codes           Product codes associated with this instance.                                    2007-03-01
++# public-hostname         The public hostname of the instance.                                            2007-01-19
++# public-ipv4             The public IP address                                                           2007-01-19
++# public-keys/            Public keys. Only available if supplied at instance launch time                 1.0
++# ramdisk-id              The ID of the RAM disk launched with this instance, if applicable.              2008-02-01
++# reservation-id          ID of the reservation.                                                          1.0
++# security-groups         Names of the security groups the instance is launched in. Only available if supplied at instance launch time    1.0
+ 
+ my $data = {};
+ my $baseurl='http://169.254.169.254/latest/';
+@@ -40,21 +40,19 @@ my @data = qw(ami_id ami_manifest_path a
+                   ancestor_ami_ids instance_id  instance_type
+                   local_hostname public_hostname
+                   local_ipv4 public_ipv4
++                  kernel_id ramdisk_id
+                   reservation_id
+                   security_groups
+-                  product_codes	
++                  product_codes 
+                );
+ 
+ 
+-
+-
+-
+ for my $item (@data)  {
+     no strict 'refs';
+     *{"$item"} = sub {
+         return $data->{$item}  if $data->{$item};
+         my $path = $item;
+-        $path =~ s/_/-/;
++        $path =~ s/_/-/g;
+         $data->{$item} = get($metaurl.$path);
+         return $data->{$item};
+     }
+@@ -71,26 +69,24 @@ sub new{
+ # returns a hash of all the data
+ #
+ sub available_data{
+-    return [@data, 'user_data', 'public_keys'];
++    return [@data, 'user_data', 'public_keys', 'placement', 'block_device_mapping'];
+ }
+ 
+ sub all_data{
+     my $data={};
+-    for  (@data, 'user_data', 'public_keys' )      {
++    for  (@data, 'user_data', 'public_keys', 'placement', 'block_device_mapping' )      {
+         no strict 'refs';        
+         $data->{$_}= $_->();
+     }
+     return $data;
+ }
+ 
+-
+-
+ sub public_keys{
+     my $self = shift;
+     my $key  = shift;
+     my $item = 'public_keys';    
+     my $path = $item;
+-    $path =~ s/_/-/;
++    $path =~ s/_/-/g;
+     if ($key)     {
+         $path .=  "/$key";
+         $item .=  "/$key";
+@@ -113,24 +109,38 @@ sub user_data{
+     return $data->{$item};
+ }
+ 
++sub placement {
++    my $self = shift;
++    my $item = 'placement';
+ 
++    for ('availability_zone') {
++        my $path = $item.'/'.$_;
++        $path =~ s/_/-/g;
++        $data->{$item}->{$_} = get($metaurl.$path);
++    }
+ 
++    return $data->{$item};
++}
+ 
++sub block_device_mapping {
++    my $self = shift;
++    my $item = 'block_device_mapping';
++    my $path = $item;
++    $path =~ s/_/-/g;
+ 
++	$data->{$item}={};
++    my $devs = get($metaurl.$path);
++    for my $dev (split(/\n/,$devs)) {
++        $data->{$item}->{$dev} = get($metaurl.$path.'/'.$dev);
++    }
+ 
+-
+-
+-
+-
+-
++    return $data->{$item};
++}
+ 
+ 1;
+ 
+  # Magic true value required at end of module
+ 
+-
+-
+-
+ __END__
+ 
+ 
+@@ -193,6 +203,14 @@ A listing of all the meta_data and user_
+ 
+ =item instance_type
+ 
++=item kernel_id
++
++=item ramdisk_id
++
++=item placement
++
++=item block_device_mapping
++
+ =item local_hostname 
+ 
+ =item public_hostname
+@@ -238,6 +256,6 @@ Copyright (c) 2008 Nathan McFarland. Thi
+ =head1 SEE ALSO
+ 
+ 
+- Amazon EC2 Documentation: L<http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/>
+- Amazon EC2 Metadata Documentation: L<http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.html>
++ Amazon EC2 Documentation: Lhttp://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html>
++ Amazon EC2 Metadata Documentation: L<http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?AESDG-chapter-instancedata.html>
+  Amazon Tutorial on EC2 Metadata: L<http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1085&categoryID=100>
diff --git a/perl-Net-Amazon-EC2-Metadata-0.10-say.patch b/perl-Net-Amazon-EC2-Metadata-0.10-say.patch
new file mode 100644
index 0000000..a422486
--- /dev/null
+++ b/perl-Net-Amazon-EC2-Metadata-0.10-say.patch
@@ -0,0 +1,75 @@
+Replace say with print, so that we don't drop otherwise useless
+Perl6::Say dependency.
+
+Lubomir Rintel <lkundrak at v3.sk>
+
+diff -urp Net-Amazon-EC2-Metadata-0.10.orig/bin/ec2meta Net-Amazon-EC2-Metadata-0.10/bin/ec2meta
+--- Net-Amazon-EC2-Metadata-0.10.orig/bin/ec2meta	2008-01-21 19:06:21.000000000 +0100
++++ Net-Amazon-EC2-Metadata-0.10/bin/ec2meta	2008-07-14 10:51:55.000000000 +0200
+@@ -5,7 +5,6 @@ use strict;
+ use Data::Dumper;
+ use Getopt::Long;
+ use Pod::Usage;
+-use Perl6::Say;
+ use Net::Amazon::EC2::Metadata;
+ my $DEBUGGING;
+ my $help;
+@@ -15,16 +14,16 @@ if ( $ARGV[0]  )  {
+     no strict 'refs';
+     no warnings 'uninitialized';
+     if ($DEBUGGING)      {
+-        say "$ARGV[0]: ". eval("Net::Amazon::EC2::Metadata->$ARGV[0]") ;    
++        print "$ARGV[0]: ". eval("Net::Amazon::EC2::Metadata->$ARGV[0]\n") ;    
+     }else      {
+-        say  eval("Net::Amazon::EC2::Metadata->$ARGV[0]") ;         
++        print  eval("Net::Amazon::EC2::Metadata->$ARGV[0]\n") ;         
+     }
+ 
+ }else  {
+     no warnings 'uninitialized';
+     my $data = Net::Amazon::EC2::Metadata->all_data;
+     for (sort keys %$data)      {
+-        say "$_: $data->{$_}";
++        print "$_: $data->{$_}\n";
+     }
+ }
+ 
+diff -urp Net-Amazon-EC2-Metadata-0.10.orig/lib/Net/Amazon/EC2/Metadata.pm Net-Amazon-EC2-Metadata-0.10/lib/Net/Amazon/EC2/Metadata.pm
+--- Net-Amazon-EC2-Metadata-0.10.orig/lib/Net/Amazon/EC2/Metadata.pm	2008-01-22 20:28:59.000000000 +0100
++++ Net-Amazon-EC2-Metadata-0.10/lib/Net/Amazon/EC2/Metadata.pm	2008-07-14 10:51:02.000000000 +0200
+@@ -145,12 +145,11 @@ This document describes Net::Amazon::EC2
+ =head1 SYNOPSIS
+     
+     #  running on an EC2 instance.
+-    use Perl6::Say;
+     use Net::Amazon::EC2::Metadata;
+     no warnings 'uninitialized';
+     my $data = Net::Amazon::EC2::Metadata->all_data;
+     for (sort keys %$data)      {
+-        say "$_: $data->{$_}";
++        print "$_: $data->{$_}\n";
+     }
+ 
+     ###############
+diff -urp Net-Amazon-EC2-Metadata-0.10.orig/Makefile.PL Net-Amazon-EC2-Metadata-0.10/Makefile.PL
+--- Net-Amazon-EC2-Metadata-0.10.orig/Makefile.PL	2008-01-21 19:06:21.000000000 +0100
++++ Net-Amazon-EC2-Metadata-0.10/Makefile.PL	2008-07-14 10:51:09.000000000 +0200
+@@ -12,7 +12,6 @@ WriteMakefile(
+ 
+     PREREQ_PM => {
+         'Test::More'    => 0,
+-        'Perl6::Say'    => 0,
+         'Pod::Usage'    => 0,
+         'LWP::Simple'   => 0,
+     },
+diff -urp Net-Amazon-EC2-Metadata-0.10.orig/META.yml Net-Amazon-EC2-Metadata-0.10/META.yml
+--- Net-Amazon-EC2-Metadata-0.10.orig/META.yml	2008-01-22 20:37:41.000000000 +0100
++++ Net-Amazon-EC2-Metadata-0.10/META.yml	2008-07-14 10:50:38.000000000 +0200
+@@ -6,7 +6,6 @@ version_from: lib/Net/Amazon/EC2/Metadat
+ installdirs:  site
+ requires:
+     LWP::Simple:                   0
+-    Perl6::Say:                    0
+     Pod::Usage:                    0
+     Test::More:                    0
+ 
diff --git a/perl-Net-Amazon-EC2-Metadata.spec b/perl-Net-Amazon-EC2-Metadata.spec
new file mode 100644
index 0000000..08ba42c
--- /dev/null
+++ b/perl-Net-Amazon-EC2-Metadata.spec
@@ -0,0 +1,79 @@
+Name:           perl-Net-Amazon-EC2-Metadata
+Version:        0.10
+Release:        4%{?dist}
+Summary:        Retrieves data from EC2 Metadata service
+License:        GPL+ or Artistic
+Group:          Development/Libraries
+URL:            http://search.cpan.org/dist/Net-Amazon-EC2-Metadata/
+Source0:        http://www.cpan.org/authors/id/N/NM/NMCFARL/Net-Amazon-EC2-Metadata-%{version}.tar.gz
+Patch0:         perl-Net-Amazon-EC2-Metadata-0.10-say.patch
+# https://rt.cpan.org/Public/Bug/Display.html?id=74949
+Patch1:         net-amazon-ec2-metadata.diff
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch:      noarch
+BuildRequires:  perl(LWP::Simple)
+BuildRequires:  perl(Module::Build)
+BuildRequires:  perl(Test::More)
+BuildRequires:  perl(Test::Pod)
+BuildRequires:  perl(Test::Pod::Coverage)
+Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+
+%description
+This module queries Amazon's Elastic Compute Cloud Metadata service.
+It also fetches 'user_data' which follows the same API but is often no
+considered part of the metadata service by Amazons documentation. The
+module also ships with a command line tool ec2meta that provides the same
+data.
+
+
+%prep
+%setup -q -n Net-Amazon-EC2-Metadata-%{version}
+%patch0 -p1
+%patch1 -p1
+
+
+%build
+%{__perl} Build.PL installdirs=vendor
+./Build
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+./Build install destdir=$RPM_BUILD_ROOT create_packlist=0
+find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \;
+
+%{_fixperms} $RPM_BUILD_ROOT/*
+
+
+%check
+./Build test
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root,-)
+%doc Changes README
+%{perl_vendorlib}/*
+%{_mandir}/man3/*
+%{_mandir}/man1/*
+%{_bindir}/*
+
+
+%changelog
+* Mon Feb 13 2012 Lubomir Rintel (GoodData) <lubo.rintel at gooddata.com> 0.10-4
+- Fix issues from review (Petr Pisar, #657518)
+
+* Mon Nov 22 2010 Lubomir Rintel (GoodData) <lubo.rintel at gooddata.com> 0.10-3
+- Pull Test::More
+
+* Fri Jul 24 2009 Lubomir Rintel (Good Data) <lubo.rintel at gooddata.com> 0.10-2
+- Patch to support more metadata (Vlastimil Holer, gdc#4395)
+
+* Mon Jul 14 2008 Lubomir Rintel (Good Data) <lubo.rintel at gooddata.com> 0.10-1
+- Specfile autogenerated by cpanspec 1.75.
+- Patch away Perl6::Say dependency
+- Adjust plist and License tag
diff --git a/sources b/sources
index e69de29..2491263 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+653a74d6a1bce303cbc1a303e60ef2f4  Net-Amazon-EC2-Metadata-0.10.tar.gz


More information about the scm-commits mailing list