Sha256: 45f6945d854f55969138dc91be7080244693250a2e0867ed1463e0a50cf3fdcb

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

#
# Author:: Cary Penniman (<cary@rightscale.com>)
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.

provides "cloud"

require_plugin "ec2"
require_plugin "rackspace"

#
# EC2
# 
def on_ec2?
  ec2 != nil
end

def get_ec2_values
  cloud[:instance_uid] = ec2['instance_id']
  cloud[:public_ip] = ec2['public_ipv4']
  cloud[:private_ip] = ec2['local_ipv4']
  cloud[:provider] = "ec2"
end

#
# rackspace
#
def on_rackspace?
  rackspace != nil
end

def get_rackspace_values
  cloud[:instance_uid] = rackspace['instance_uid']
  cloud[:public_ip] = rackspace['public_ip']
  cloud[:private_ip] = rackspace['private_ip']
  cloud[:provider] = "rackspace"
end

if on_ec2?
  cloud Mash.new
  get_ec2_values
end

if on_rackspace?
  cloud Mash.new
  get_rackspace_values
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rightscale-ohai-0.3.3.2 lib/ohai/plugins/cloud.rb
rightscale-ohai-0.3.3.3 lib/ohai/plugins/cloud.rb