[cookbooks/agent] Removed agent cookbook

This commit is contained in:
Vladimir Kozhukalov 2012-07-18 17:20:51 +04:00
parent 410c4f321a
commit c09bf0b2d7
4 changed files with 0 additions and 92 deletions

View File

@ -1,22 +0,0 @@
Agent library sends ohai data to REST service.
Requirements
============
* node["admin"]["URL"] variable defined, which is used as
target REST service for publishing ohai data.
* Packages: chef-solo
* Gems: httplib
License
=======
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.

View File

@ -1,53 +0,0 @@
require 'json'
module NodeAgent
def self.update(node)
mac = node['macaddress'].gsub(':', '')
# Node is booted via PXE from admin node, so we can get IP address
# of admin node from url= param
begin
cmdline = File.read("/proc/cmdline")
admin_ip = cmdline.match(/\burl=http:\/\/((\d{1,3}\.){3}\d{1,3})/)[1]
Chef::Log.info("Found IP address of Nailgun application: #{admin_ip}")
url = "http://#{admin_ip}:8000/api/nodes/#{mac}"
rescue
# If we can't get IP from /proc/cmdline, just set it to localhost for easy testing
Chef::Log.error("Didn't find IP address of Nailgun application, using localhost instead..")
url = "http://localhost:8000/api/nodes/#{mac}"
end
Chef::Log.debug("Sending node info to REST service at #{url}...")
interfaces = node["network"]["interfaces"].inject([]) do |result, elm|
result << { :name => elm[0], :addresses => elm[1]["addresses"] }
end
interfaces << { "default_interface" => node["network"]["default_interface"] }
interfaces << { "default_gateway" => node["network"]["default_gateway"] }
metadata = {
:block_device => node["block_device"].to_hash,
:interfaces => interfaces,
:cpu => node["cpu"].to_hash,
:memory => node["memory"].to_hash
}
data = { :fqdn => node["fqdn"],
:mac => node["macaddress"],
:ip => node["ipaddress"],
:metadata => metadata
}
headers = {"Content-Type" => "application/json"}
cli = HTTPClient.new
begin
res = cli.put(url, data.to_json, headers)
if res.status < 200 or res.status >= 300
Chef::Log.error("HTTP PUT failed: #{res.inspect}")
end
rescue Exception => e
Chef::Log.error("Error in sending node info: #{e.message}")
end
end
end

View File

@ -1,9 +0,0 @@
maintainer "Mirantis, Inc."
maintainer_email "mscherbakov@mirantis.com"
license "Apache 2.0"
description "Sends ohai attrs to admin node"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1"
# depends "apt"
#

View File

@ -1,8 +0,0 @@
# It is assumed that httpclient gem
# already installed by preseed
require 'httpclient'
ruby_block 'update_node_info' do
block { NodeAgent.update(node) }
end