Path: | lib/ohai/plugins/rackspace.rb |
Last Update: | Thu Jan 17 19:03:16 +0000 2013 |
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
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.
Names rackspace ipv6 address for interface
name<Symbol>: | Use :public_ip or :private_ip |
eth<Symbol>: | Interface name of public or private ip |
# File lib/ohai/plugins/rackspace.rb, line 73 73: def get_global_ipv6_address(name, eth) 74: network[:interfaces][eth][:addresses].each do |key, info| 75: # check if we got an ipv6 address and if its in global scope 76: if info['family'] == 'inet6' && info['scope'] == 'Global' 77: rackspace[name] = key 78: break # break when we found an address 79: end 80: end 81: end
Names rackspace ip address
name<Symbol>: | Use :public_ip or :private_ip |
eth<Symbol>: | Interface name of public or private ip |
# File lib/ohai/plugins/rackspace.rb, line 59 59: def get_ip_address(name, eth) 60: network[:interfaces][eth][:addresses].each do |key, info| 61: if info['family'] == 'inet' 62: rackspace[name] = key 63: break # break when we found an address 64: end 65: end 66: end
Get the rackspace region
# File lib/ohai/plugins/rackspace.rb, line 85 85: def get_region() 86: status, stdout, stderr = run_command(:no_status_check => true, :command => "xenstore-ls vm-data/provider_data") 87: if status == 0 88: stdout.split("\n").each do |line| 89: rackspace[:region] = line.split[2].delete('\"') if line =~ /^region/ 90: end 91: end 92: rescue Ohai::Exceptions::Exec 93: Ohai::Log.debug("Unable to find xenstore-ls, cannot capture region information for Rackspace cloud") 94: end
Checks for matching rackspace kernel name
true: | If kernel name matches |
false: | Otherwise |
# File lib/ohai/plugins/rackspace.rb, line 27 27: def has_rackspace_kernel? 28: kernel[:release].split('-').last.eql?("rscloud") 29: end
Checks for matching rackspace arp mac
true: | If mac address matches |
false: | Otherwise |
# File lib/ohai/plugins/rackspace.rb, line 36 36: def has_rackspace_mac? 37: network[:interfaces].values.each do |iface| 38: unless iface[:arp].nil? 39: return true if iface[:arp].value?("00:00:0c:07:ac:01") or iface[:arp].value?("00:00:0c:9f:f0:01") 40: end 41: end 42: false 43: end