cloudscale 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07c3a384bcb365307be67e2390acb8ca9ab27cc0
4
- data.tar.gz: 874fffa112bfdcb158f02339a7cf4cdbbd1cc8c2
3
+ metadata.gz: 07a34393d2ffd100908ce523865bc2110c3d3f36
4
+ data.tar.gz: 352f6af0a202322466cf411ff34357a4eececc67
5
5
  SHA512:
6
- metadata.gz: 2b28c28ed9a347c008ca6bb7cdcc3334bf4f6e54dbc7aea82dd94c7cfee7ee0ef8c399fd6750c9bce26ca190ceb2e1864b57d4eb17ee1bb083fb0a35fca887ee
7
- data.tar.gz: b24d86fff46bc0c31b5fe19bd05cca0970f185a89543d2f67917e0b75dbb56d93619f9f8587706e8ca50dc4816d4b5da0ed0de8800adc73476c72d414e238af2
6
+ metadata.gz: 426faf03ecdcc811bda61727dd8143a24d3c10700946138bb1414223d1a07b06ff408f88cf2151d23545072ca8264eb026dae952a1414cdbd2c743a7185aea89
7
+ data.tar.gz: 184c0f8e96e05e61ec362eeda9658f2e66782a51d33c1beb052f67329f37814150deea184fea17ff533b8f611647dda36d60030f5319f37ec1137af77cdcc9e1
data/lib/cloudscale.rb CHANGED
@@ -7,6 +7,7 @@ require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/init"
7
7
  require "#{File.dirname(__FILE__)}/cloudscale/schedule"
8
8
  require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/preops/general_preop"
9
9
  require "#{File.dirname(__FILE__)}/cloudscale/plugins/plugin"
10
+ require "#{File.dirname(__FILE__)}/cloudscale/monitor/model/constants/agent_store"
10
11
  Dir["#{File.dirname(__FILE__)}/cloudscale/plugins/*/*.rb"].each { | f | require f }
11
12
 
12
13
  ##
@@ -93,6 +94,16 @@ module Cloudscale
93
94
  puts parser
94
95
  exit
95
96
  end
97
+
98
+ begin
99
+ host = GeneralPreop.instance.get_option_value("host")
100
+ port = GeneralPreop.instance.get_option_value("port")
101
+
102
+ config = Constants::Agent.load()
103
+ if (port != nil) then config["port"] = port end
104
+ if (host != nil) then config["host"] = host end
105
+ Constants::Agent.save(config)
106
+ end
96
107
 
97
108
  agent_instance = Monitor::Init.new(GeneralPreop.instance.get_option_value("token"))
98
109
  agent_instance_id = registry = Monitor::Registry.instance.agent_instance_id
@@ -51,7 +51,7 @@ module Cloudscale
51
51
  Constants::AgentInstance.create(agent_instance.to_h)
52
52
  else
53
53
  puts " Instance has been started previously, loading settings and existing data... \n\n"
54
-
54
+
55
55
  agent_instance["lastInitialization"] = Time.now.to_i * 1000
56
56
 
57
57
  client.patch('agentInstances', RestClientWrapper.load_entity_id(agent_instance), agent_instance)
@@ -19,6 +19,18 @@ module Cloudscale
19
19
  :required => true,
20
20
  :value => nil
21
21
  },
22
+ :host => {
23
+ :argument => "--host",
24
+ :description => "The host endpoint for the agent registration",
25
+ :required => false,
26
+ :value => nil
27
+ },
28
+ :port => {
29
+ :argument => "--port",
30
+ :description => "The port of the endpoint for the agent registration",
31
+ :required => false,
32
+ :value => nil
33
+ }
22
34
  }
23
35
 
24
36
  def options
@@ -28,7 +28,11 @@ module Cloudscale
28
28
  end
29
29
 
30
30
  def get_option_value(key)
31
- options[key.to_sym][:value] #|| @plugin_settings_db[key.to_s]
31
+ if (options[key.to_sym] != nil)
32
+ options[key.to_sym][:value] #|| @plugin_settings_db[key.to_s]
33
+ else
34
+ nil
35
+ end
32
36
  end
33
37
 
34
38
  def init_options
@@ -8,16 +8,28 @@ require "yaml/store"
8
8
  module Cloudscale
9
9
  module Constants
10
10
  class Agent
11
-
11
+
12
12
  @@AGENT_STORE = "#{File.dirname(__FILE__)}/../../../store/agent/agent.store"
13
-
13
+
14
14
  def self.load
15
15
  begin
16
- YAML.load(File.read(@@AGENT_STORE))
16
+ YAML.load_file(@@AGENT_STORE)
17
17
  rescue
18
18
  return nil
19
19
  end
20
- end
20
+ end
21
+
22
+ def self.save(config)
23
+ puts config
24
+ begin
25
+ File.open(@@AGENT_STORE, 'w') do | h |
26
+ h.write config.to_yaml
27
+ end
28
+ rescue Exception
29
+ return nil
30
+ end
31
+ puts load()
32
+ end
21
33
  end
22
34
  end
23
35
  end
@@ -1,8 +1,9 @@
1
1
  require "yaml"
2
2
  require "json"
3
- require "rest_client"
3
+ require "rest-client"
4
4
  require "singleton"
5
5
  require "#{File.dirname(__FILE__)}/rest_client_helper"
6
+ require "#{File.dirname(__FILE__)}/../monitor/model/constants/agent_store"
6
7
 
7
8
  ##
8
9
  #
@@ -12,21 +13,15 @@ require "#{File.dirname(__FILE__)}/rest_client_helper"
12
13
  class RestClientWrapper < RestClientHelper
13
14
  include Singleton
14
15
 
15
- attr_accessor :endpoint, :key, :token, :header
16
-
17
- def load_hash()
18
- begin
19
- YAML.load(File.read("#{File.dirname(__FILE__)}/../store/agent/agent.store"))
20
- rescue
21
- return nil
22
- end
23
- end
16
+ attr_accessor :endpoint, :host, :port, :key, :token, :header
24
17
 
25
18
  def initialize
26
- if (endpoint == nil && key == nil && token == nil)
27
- hash = load_hash()
19
+ if (key == nil && token == nil)
20
+ hash = Cloudscale::Constants::Agent.load()
28
21
  end
22
+
29
23
  @endpoint = hash["host"] + ":" + hash["port"].to_s + hash["path"].to_s
24
+
30
25
  @key = hash["key"]
31
26
  @token = load_token("token")
32
27
  @header = {
@@ -1,7 +1,7 @@
1
1
  ---
2
- agentId: 32093209323
3
- host: "localhost"
4
- path : "/service"
5
- port: 8080
6
- key: "monitoring"
7
- token: "e2FsZz1IUzI1NiwgdHlwPUNUfQ.e3Y9MCwgZD1tb25pdG9yaW5nLCBpYXQ9MTQwNDc1NzMyNH0.rG0biCuH_-X1vulEr19H2m42i4DGRR8PGwgXastyk3Q"
2
+ agentId: 32093209323
3
+ host: localhost
4
+ path: /service
5
+ port: '8080'
6
+ key: monitoring
7
+ token: e2FsZz1IUzI1NiwgdHlwPUNUfQ.e3Y9MCwgZD1tb25pdG9yaW5nLCBpYXQ9MTQwNDc1NzMyNH0.rG0biCuH_-X1vulEr19H2m42i4DGRR8PGwgXastyk3Q
@@ -8,4 +8,4 @@ settings: !ruby/object:Cloudscale::Monitor::Settings
8
8
  coredataCollectionInterval: 0
9
9
  tableCollectionInterval: 1500
10
10
  reportingInterval: 5
11
- started: 1439644965000
11
+ started: 1440004610000
@@ -1,5 +1,5 @@
1
1
  ---
2
- host: 88.198.249.51
2
+ host: 88.198.249.58
3
3
  port: 8086
4
4
  database: monitoring
5
5
  username: monitoring
@@ -0,0 +1 @@
1
+ I"localhost:ET
@@ -0,0 +1 @@
1
+ I" 8080:ET
@@ -4,5 +4,5 @@
4
4
  #
5
5
  ##
6
6
  module Cloudscale
7
- VERSION = "0.0.3" unless const_defined?(:VERSION)
7
+ VERSION = "0.0.4" unless const_defined?(:VERSION)
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudscale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Hiemer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-16 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -217,6 +217,8 @@ files:
217
217
  - lib/cloudscale/store/agent/agent.store
218
218
  - lib/cloudscale/store/agent/agent_instance.store
219
219
  - lib/cloudscale/store/agent/influxdb.store
220
+ - lib/cloudscale/store/plugin/host
221
+ - lib/cloudscale/store/plugin/port
220
222
  - lib/cloudscale/store/plugin/token
221
223
  - lib/cloudscale/version.rb
222
224
  - lib/cloudscale.rb