lib/ohai/mixin/ec2_metadata.rb in ohai-15.0.35 vs lib/ohai/mixin/ec2_metadata.rb in ohai-15.1.3

- old
+ new

@@ -15,11 +15,11 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -require "net/http" +require "net/http" unless defined?(Net::HTTP) module Ohai module Mixin ## # This code parses the EC2 Instance Metadata API to provide details @@ -37,16 +37,16 @@ # # If no compatible version is found, an empty hash is returned. # module Ec2Metadata - EC2_METADATA_ADDR = "169.254.169.254".freeze unless defined?(EC2_METADATA_ADDR) - EC2_SUPPORTED_VERSIONS = %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15 + EC2_METADATA_ADDR ||= "169.254.169.254".freeze + EC2_SUPPORTED_VERSIONS ||= %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }.freeze - EC2_ARRAY_VALUES = %w{security-groups local_ipv4s}.freeze - EC2_ARRAY_DIR = %w{network/interfaces/macs}.freeze - EC2_JSON_DIR = %w{iam}.freeze + EC2_ARRAY_VALUES ||= %w{security-groups local_ipv4s}.freeze + EC2_ARRAY_DIR ||= %w{network/interfaces/macs}.freeze + EC2_JSON_DIR ||= %w{iam}.freeze def best_api_version @api_version ||= begin logger.trace("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}/ to determine the latest supported metadata release") response = http_client.get("/")