module Proxy::Discovery
Constants
- CREATE_DISCOVERED_HOST_PATH
- PORT
- SCHEME
- VERSION
Public Instance Methods
create_discovered_host(request)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 14 def create_discovered_host(request) foreman_request = Proxy::HttpRequest::ForemanRequest.new() req = foreman_request.request_factory.create_post(CREATE_DISCOVERED_HOST_PATH, request.body.read) response = foreman_request.send_request(req) unless response.is_a? Net::HTTPSuccess msg = JSON.parse(response.body)['message'] rescue "N/A" raise "Discovery failed, code #{response.code}, reason: #{msg}" end end
inventory_facter(ip)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 24 def inventory_facter(ip) client = get_rest_client(generate_url(ip)) client["/inventory/facter"].get() end
kexec(ip, body)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 46 def kexec(ip, body) client = get_rest_client(generate_url(ip)) client["/power/kexec"].put(body) end
reboot(ip)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 41 def reboot(ip) client = get_rest_client(generate_url(ip)) client["/power/reboot"].put({}) end
reboot_legacy(ip)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 34 def reboot_legacy(ip) url = "http://#{ip}:8443" reboot_path = "/bmc/#{ip}/chassis/power/cycle" client = get_rest_client(url) client[reboot_path].put({}) end
refresh_facts_legacy(ip)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 29 def refresh_facts_legacy(ip) client = get_rest_client(generate_url(ip)) client['/facts'].get end
Private Instance Methods
generate_url(ip)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 53 def generate_url(ip) "#{SCHEME}://#{ip}:#{PORT}" end
get_rest_client(url)
click to toggle source
# File lib/smart_proxy_discovery/discovery_main.rb, line 57 def get_rest_client(url) RestClient::Resource.new(url, :verify_ssl => OpenSSL::SSL::VERIFY_NONE) end