Sha256: d1be3d46b1bdd130a90eb666f03655c4598da003259912d1a8465407dca6eddd
Contents?: true
Size: 1.13 KB
Versions: 11
Compression:
Stored size: 1.13 KB
Contents
module KL def KL.Command_registerNewAgent KL.logger.info '[command] Registering new agent...' agent = KL::Agent.getUUID data = KL.prepare_agent_register_data(agent) uri = "#{KL.config['notifier']['server']}/api/1.0/nodes/register" res = KL.net_post_json(uri, data.to_json) if res.is_a?(Net::HTTPSuccess) response = JSON.parse(res.body) registry = { agent: agent, server: response['code'] } KL.create_registry_file(registry) KL.logger.info '[command] Agent registration has been completed correctly' else KL.logger.info '[command] An error has occurred trying to register agent.' end end def KL.Command_notifyStatus KL.logger.info '[command] Sending instance update...' data = KL.prepare_agent_data uri = "#{KL.config['notifier']['server']}/api/1.0/nodes/data" headers_auth = KL.getAuthorizationHeaders('/api/1.0/nodes/data', data.to_json) res = KL.net_post_json(uri, data.to_json, headers_auth) if res.is_a?(Net::HTTPSuccess) KL.logger.info '[command] Agent notification successfully executed.' else KL.logger.info '[command] An error has occurred trying to notify update.' end end end
Version data entries
11 entries across 11 versions & 1 rubygems