Class: Cloudscale::Benchmark::Init
- Inherits:
-
Object
- Object
- Cloudscale::Benchmark::Init
- Defined in:
- lib/cloudscale/benchmark/agent/init.rb
Instance Attribute Summary collapse
-
#agentInstanceId ⇒ Object
Returns the value of attribute agentInstanceId.
-
#client ⇒ Object
Returns the value of attribute client.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#log ⇒ Object
Returns the value of attribute log.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #agent_instance_id ⇒ Object
-
#initialize ⇒ Init
constructor
A new instance of Init.
Constructor Details
#initialize ⇒ Init
Returns a new instance of Init.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 17 def initialize() @log = Logger.new(STDOUT) @customer = 60 @server = Socket.gethostname @agentInstanceId = SecureRandom.hex @client = RestClientWrapper.instance puts " " puts "Running preflight verification for cloudscale benchmarking agent" stored_agent_instance = Constants::AgentInstance.load stored_agent = Constants::Agent.load if (stored_agent == nil) raise "You did not provide any valid Agent file under /store/agent/agent.store." end agent = client.searchOne('benchmarkAgents', 'findByAgentId', { :agentId => stored_agent["agentId"] }) if (agent == nil) raise "No agent registered yet. It is not allowed to connect this agent instance to cloudscale monitoring." end if (stored_agent_instance && stored_agent_instance != nil) agent_instance = client.searchOne('benchmarkAgentInstances', 'findByAgentInstanceId', { :id => stored_agent_instance["agentInstanceId"] }) end if (agent_instance == nil) puts "No Instance of this agent was started previously, starting cloudscale benchmarking agent for the first, registering..." agent_instance = Benchmarking::BenchmarkAgentInstance.new(RestClientWrapper.load_entity_ref(agent)["href"], agentInstanceId, customer, server, Time.now.to_i * 1000) client.post('benchmarkAgentInstances', agent_instance) Constants::AgentInstance.create(agent_instance.to_h) else puts " Instance has been started previously, loading settings and existing data... \n\n" @agentInstanceId = agent_instance["agentInstanceId"] agent_instance["lastInitialization"] = Time.now.to_i * 1000 agent_instance["benchmarkAgent"] = RestClientWrapper.load_entity_ref(agent)["href"] client.put('benchmarkAgentInstances', RestClientWrapper.load_entity_id(agent_instance), agent_instance) end end |
Instance Attribute Details
#agentInstanceId ⇒ Object
Returns the value of attribute agentInstanceId.
16 17 18 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 16 def agentInstanceId @agentInstanceId end |
#client ⇒ Object
Returns the value of attribute client.
16 17 18 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 16 def client @client end |
#customer ⇒ Object
Returns the value of attribute customer.
16 17 18 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 16 def customer @customer end |
#log ⇒ Object
Returns the value of attribute log.
16 17 18 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 16 def log @log end |
#server ⇒ Object
Returns the value of attribute server.
16 17 18 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 16 def server @server end |
Instance Method Details
#agent_instance_id ⇒ Object
67 68 69 |
# File 'lib/cloudscale/benchmark/agent/init.rb', line 67 def agent_instance_id return agentInstanceId end |