diff --git a/cookbooks/agent/README.md b/cookbooks/agent/README.md deleted file mode 100644 index 1e55043b7..000000000 --- a/cookbooks/agent/README.md +++ /dev/null @@ -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. diff --git a/cookbooks/agent/libraries/agent.rb b/cookbooks/agent/libraries/agent.rb deleted file mode 100644 index 2227bba46..000000000 --- a/cookbooks/agent/libraries/agent.rb +++ /dev/null @@ -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 diff --git a/cookbooks/agent/metadata.rb b/cookbooks/agent/metadata.rb deleted file mode 100644 index 95cab460b..000000000 --- a/cookbooks/agent/metadata.rb +++ /dev/null @@ -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" -# diff --git a/cookbooks/agent/recipes/default.rb b/cookbooks/agent/recipes/default.rb deleted file mode 100644 index 8d055fb70..000000000 --- a/cookbooks/agent/recipes/default.rb +++ /dev/null @@ -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 -