Created
November 30, 2011 19:26
-
-
Save Drewzar/1410418 to your computer and use it in GitHub Desktop.
cloudkick handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_node_id | |
resp, data = @ckclient.access_token.get("/2.0/nodes?query=node:#{node[:hostname]}") | |
puts node[:hostname] | |
puts resp.inspect | |
puts data.inspect | |
if not resp.code =~ /^2/ | |
reset | |
return nil | |
end | |
parsed = JSON::parse(data) | |
if parsed['items'].first['name'].to_s == node[:hostname].to_s | |
return parsed['items'].first['id'] | |
end | |
return nil | |
end | |
def connect | |
@ckclient = Cloudkick::Base.new(@oauth_key, @oauth_secret) | |
@cknode_id = get_node_id | |
@check_id = get_check_id | |
end | |
ck_handler = CloudkickHandler.new('sxSGVVhqNneRwzWK', 'RghRTe5Nv7GgMyZJ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment