[Pkg-puppet-devel] [facter] 44/180: (FACT-185) Deprecate the old Facter::Util::EC2 API

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit c11263749eb5aa63c3ae4097382dc84fccfd61f4
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Wed Apr 2 17:00:08 2014 -0700

    (FACT-185) Deprecate the old Facter::Util::EC2 API
    
    With commit 5ca456f5 we have a new method of querying the EC2 API; the
    old methods can be deprecated.
---
 lib/facter/util/ec2.rb     | 5 +++++
 spec/unit/util/ec2_spec.rb | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/lib/facter/util/ec2.rb b/lib/facter/util/ec2.rb
index c6e5dca..b81c8fe 100644
--- a/lib/facter/util/ec2.rb
+++ b/lib/facter/util/ec2.rb
@@ -11,6 +11,7 @@ module Facter::Util::EC2
     # The +wait_sec+ parameter provides you with an adjustable timeout.
     #
     def can_connect?(wait_sec=2)
+      Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
       url = "http://169.254.169.254:80/"
       Timeout::timeout(wait_sec) {open(url)}
       return true
@@ -23,6 +24,7 @@ module Facter::Util::EC2
     # Test if this host has a mac address used by Eucalyptus clouds, which
     # normally is +d0:0d+.
     def has_euca_mac?
+      Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
       !!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:})
     end
 
@@ -30,12 +32,14 @@ module Facter::Util::EC2
     # normally starts with FA:16:3E (older versions of OpenStack
     # may generate mac addresses starting with 02:16:3E)
     def has_openstack_mac?
+      Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
       !!(Facter.value(:macaddress) =~ %r{^(02|[fF][aA]):16:3[eE]})
     end
 
     # Test if the host has an arp entry in its cache that matches the EC2 arp,
     # which is normally +fe:ff:ff:ff:ff:ff+.
     def has_ec2_arp?
+      Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
       kernel = Facter.value(:kernel)
 
       mac_address_re = case kernel
@@ -73,6 +77,7 @@ module Facter::Util::EC2
   #
   # @return [String] containing the response body or `nil`
   def self.userdata(version="latest")
+    Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
     uri = "http://169.254.169.254/#{version}/user-data/"
     begin
       read_uri(uri)
diff --git a/spec/unit/util/ec2_spec.rb b/spec/unit/util/ec2_spec.rb
index f963db6..7af59d8 100755
--- a/spec/unit/util/ec2_spec.rb
+++ b/spec/unit/util/ec2_spec.rb
@@ -4,6 +4,10 @@ require 'spec_helper'
 require 'facter/util/ec2'
 
 describe Facter::Util::EC2 do
+  before do
+    # Squelch deprecation notices
+    Facter.stubs(:warnonce)
+  end
   # This is the standard prefix for making an API call in EC2 (or fake)
   # environments.
   let(:api_prefix) { "http://169.254.169.254" }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list