staugaard-cloudmaster 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/app/active_set_factory.rb +16 -0
- data/app/active_set_none.rb +16 -0
- data/app/active_set_queue.rb +27 -0
- data/app/active_set_s3.rb +25 -0
- data/app/configuration.rb +85 -0
- data/app/default-config.ini +95 -0
- data/app/ec2_image_enumerator.rb +41 -0
- data/app/ec2_instance_enumerator.rb +25 -0
- data/app/instance.rb +146 -0
- data/app/instance_pool.rb +326 -0
- data/app/named_queue.rb +75 -0
- data/app/policy.rb +113 -0
- data/app/policy_daytime.rb +18 -0
- data/app/policy_factory.rb +16 -0
- data/app/policy_fixed.rb +19 -0
- data/app/policy_job.rb +54 -0
- data/app/policy_limit.rb +68 -0
- data/app/policy_manual.rb +36 -0
- data/app/policy_resource.rb +110 -0
- data/app/pool_configuration.rb +172 -0
- data/app/pool_manager.rb +239 -0
- data/app/pool_runner.rb +54 -0
- data/app/reporter.rb +81 -0
- data/app/status_parser_factory.rb +16 -0
- data/app/status_parser_lifeguard.rb +48 -0
- data/app/status_parser_std.rb +11 -0
- metadata +27 -1
@@ -0,0 +1,16 @@
|
|
1
|
+
# This is a factory for StatusParser implementations.
|
2
|
+
require 'factory'
|
3
|
+
|
4
|
+
module Cloudmaster
|
5
|
+
class StatusParserFactory
|
6
|
+
include Factory
|
7
|
+
def StatusParserFactory.create(type, *params)
|
8
|
+
name = type.nil? ? 'none' : type.to_s
|
9
|
+
require 'status_parser_' + name.downcase
|
10
|
+
class_name = 'StatusParser' + name.capitalize
|
11
|
+
status_parser = Factory.create_object_from_string(class_name, *params)
|
12
|
+
raise "Bad configuration -- bad status_parser_set #{class_name}" unless status_parser
|
13
|
+
status_parser
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# The standard implementation of status parser
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
# Process a message as sent from Linfguard.
|
6
|
+
# Convert it into a form usable with pob pools.
|
7
|
+
# If we want to make an accurate load estimate, we need to take
|
8
|
+
# the last interval into account, and average over some time period.
|
9
|
+
module Cloudmaster
|
10
|
+
class StatusParserLifeguard
|
11
|
+
|
12
|
+
# Parse a lifeguard message.
|
13
|
+
def parse_message(body)
|
14
|
+
msg = { :type => 'status'}
|
15
|
+
doc = REXML::Document.new(body)
|
16
|
+
doc.root.each_element do |elem|
|
17
|
+
val = elem.get_text.to_s.lstrip.rstrip
|
18
|
+
case elem.name
|
19
|
+
when 'InstanceId'
|
20
|
+
msg[:instance_id] = val
|
21
|
+
when 'State'
|
22
|
+
case val
|
23
|
+
when 'busy'
|
24
|
+
# Lifeguard's busy maps into active
|
25
|
+
msg[:state] = 'active'
|
26
|
+
msg[:load_estimate] = 1
|
27
|
+
else
|
28
|
+
# all else maps to idle
|
29
|
+
msg[:state] = 'idle'
|
30
|
+
msg[:load_estimate] = 0
|
31
|
+
end
|
32
|
+
when 'Timestamp'
|
33
|
+
if ! val.include?('-')
|
34
|
+
# This is a mock time
|
35
|
+
msg[:timestamp] = Clock.at(val.to_i)
|
36
|
+
elsif val.include?('T')
|
37
|
+
# This is a time in xmlschema form
|
38
|
+
msg[:timestamp] = Clock.xmlschema(val)
|
39
|
+
else
|
40
|
+
# OK, let's try plain parse (don't expect this to happen)
|
41
|
+
msg[:timestamp] = Clock.parse(val)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
msg
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: staugaard-cloudmaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cchayden
|
@@ -66,6 +66,32 @@ files:
|
|
66
66
|
- lib/string_logger.rb
|
67
67
|
- lib/sys_logger.rb
|
68
68
|
- lib/user_data.rb
|
69
|
+
- app/active_set_factory.rb
|
70
|
+
- app/active_set_none.rb
|
71
|
+
- app/active_set_queue.rb
|
72
|
+
- app/active_set_s3.rb
|
73
|
+
- app/configuration.rb
|
74
|
+
- app/default-config.ini
|
75
|
+
- app/ec2_image_enumerator.rb
|
76
|
+
- app/ec2_instance_enumerator.rb
|
77
|
+
- app/instance.rb
|
78
|
+
- app/instance_pool.rb
|
79
|
+
- app/named_queue.rb
|
80
|
+
- app/policy.rb
|
81
|
+
- app/policy_daytime.rb
|
82
|
+
- app/policy_factory.rb
|
83
|
+
- app/policy_fixed.rb
|
84
|
+
- app/policy_job.rb
|
85
|
+
- app/policy_limit.rb
|
86
|
+
- app/policy_manual.rb
|
87
|
+
- app/policy_resource.rb
|
88
|
+
- app/pool_configuration.rb
|
89
|
+
- app/pool_manager.rb
|
90
|
+
- app/pool_runner.rb
|
91
|
+
- app/reporter.rb
|
92
|
+
- app/status_parser_factory.rb
|
93
|
+
- app/status_parser_lifeguard.rb
|
94
|
+
- app/status_parser_std.rb
|
69
95
|
- test/aws-config.ini
|
70
96
|
- test/cloudmaster-tests.rb
|
71
97
|
- test/configuration-test.rb
|