auser-poolparty 1.3.11 → 1.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/bin/cloud-thrift +5 -1
- data/config/jeweler.rb +1 -1
- data/lib/poolparty/cloud.rb +11 -1
- data/lib/poolparty/monitor.rb +24 -2
- data/lib/proto/poolparty.thrift +1 -0
- data/test/lib/poolparty/cloud_test.rb +7 -2
- data/test/lib/poolparty/monitor_test.rb +28 -0
- metadata +5 -4
data/VERSION.yml
CHANGED
data/bin/cloud-thrift
CHANGED
data/config/jeweler.rb
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
s.description = "PoolParty: The easy, open-source, cross-cloud management solution"
|
16
16
|
s.summary = <<-EOM
|
17
17
|
Self-healing, auto-scaling system administration, provisioning
|
18
|
-
and maintaining tool that makes cloud computing
|
18
|
+
and maintaining tool that makes cloud computing easier.
|
19
19
|
EOM
|
20
20
|
|
21
21
|
s.homepage = "http://poolpartyrb.com"
|
data/lib/poolparty/cloud.rb
CHANGED
@@ -239,7 +239,7 @@ Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}
|
|
239
239
|
def run_monitor(monitor_name, value)
|
240
240
|
mon = monitors[monitor_name.to_sym]
|
241
241
|
if mon
|
242
|
-
mon.run(value
|
242
|
+
mon.run(value)
|
243
243
|
else
|
244
244
|
"unhandled monitor"
|
245
245
|
end
|
@@ -250,6 +250,16 @@ Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}
|
|
250
250
|
@monitors ||= {}
|
251
251
|
end
|
252
252
|
|
253
|
+
def monitor_format(mon_name, meth, &block)
|
254
|
+
delayed_action do
|
255
|
+
if monitors.has_key?(mon_name)
|
256
|
+
monitors[mon_name].format(meth, &block)
|
257
|
+
else
|
258
|
+
raise PoolPartyError.create("MonitorsFormattingError", "You created a monitor format for an unknown monitor. Please check and try again!")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
253
263
|
##### Internal methods #####
|
254
264
|
# Methods that only the cloud itself will use
|
255
265
|
# and thus are private
|
data/lib/poolparty/monitor.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
module PoolParty
|
16
16
|
class Monitor
|
17
17
|
|
18
|
-
attr_reader :name, :monitor_block
|
18
|
+
attr_reader :name, :monitor_block, :value_format
|
19
19
|
|
20
20
|
def initialize(monitor_name, &block)
|
21
21
|
msg =<<-EOE
|
@@ -37,11 +37,33 @@ You must pass a block with your monitor
|
|
37
37
|
# retrieved and return the methods available.
|
38
38
|
def run(val)
|
39
39
|
@methods = nil
|
40
|
-
instance_exec val, &monitor_block
|
40
|
+
instance_exec format_value(val), &monitor_block
|
41
41
|
methods
|
42
42
|
end
|
43
43
|
|
44
|
+
# Format the monitor values
|
45
|
+
# Set the monitor format here.
|
46
|
+
# The default will be to turn the value into a float
|
47
|
+
# but to allow other formats, call the value here, for instance:
|
48
|
+
# mon.format :to_s
|
49
|
+
# Blocks are also permitted
|
50
|
+
def format(meth=nil, &block)
|
51
|
+
@value_format ||= (meth ? meth : block)
|
52
|
+
end
|
53
|
+
|
44
54
|
private
|
55
|
+
|
56
|
+
# Format the value of the monitor
|
57
|
+
def format_value(value)
|
58
|
+
case value_format
|
59
|
+
when Proc
|
60
|
+
value_format.call(value)
|
61
|
+
when nil
|
62
|
+
value.to_f
|
63
|
+
else
|
64
|
+
value.send value_format
|
65
|
+
end
|
66
|
+
end
|
45
67
|
|
46
68
|
# We don't want the methods actually executing since we are executing the methods
|
47
69
|
# in a cloud, we just want to store the output values of the
|
data/lib/proto/poolparty.thrift
CHANGED
@@ -158,13 +158,18 @@ class CloudTest < Test::Unit::TestCase
|
|
158
158
|
configure if v < 0.2
|
159
159
|
vote_for(:expand) if v > 1.1
|
160
160
|
end
|
161
|
+
monitor :load do |a|
|
162
|
+
# [0.42 0.43 0.37]
|
163
|
+
vote_for(:expand) if a > 0.8
|
164
|
+
end
|
161
165
|
end
|
162
166
|
end
|
163
167
|
|
164
|
-
assert_equal
|
165
|
-
assert_equal [:cpu], clouds["monitor_app"].monitors.map {|m,v| v.name }
|
168
|
+
assert_equal 2, clouds["monitor_app"].monitors.size
|
169
|
+
assert_equal [:cpu, :load], clouds["monitor_app"].monitors.map {|m,v| v.name }
|
166
170
|
assert_equal({:configure => []}, clouds["monitor_app"].run_monitor("cpu", "0.1"))
|
167
171
|
assert_equal({:vote_for => [:expand]}, clouds["monitor_app"].run_monitor("cpu", "1.4"))
|
172
|
+
assert_equal({:vote_for => [:expand]}, clouds["monitor_app"].run_monitor("load", "0.98, 0.23, 0.1"))
|
168
173
|
end
|
169
174
|
|
170
175
|
def test_add_monitoring_stack_if_needed
|
@@ -27,4 +27,32 @@ class MonitorTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_formatting_input
|
31
|
+
mon = PoolParty::Monitor.new("memory-used") {|c| long if c.length > 2}
|
32
|
+
mon.format(:to_s)
|
33
|
+
assert_equal({:long => []}, mon.run("hellllllllooooo world"))
|
34
|
+
|
35
|
+
mon = PoolParty::Monitor.new("memory-used") do |c|
|
36
|
+
long if c.length > 2
|
37
|
+
short if c.length < 2
|
38
|
+
end
|
39
|
+
mon.format(:to_a)
|
40
|
+
assert_equal({:long => []}, mon.run(%w(1 2 3 4)))
|
41
|
+
assert_equal({:short => []}, mon.run(%w(1)))
|
42
|
+
|
43
|
+
mon = PoolParty::Monitor.new("memory-used") do |saying, to|
|
44
|
+
if saying == "hello"
|
45
|
+
hello
|
46
|
+
else
|
47
|
+
goodbye
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
mon.format do |d|
|
52
|
+
return *d.split(",")
|
53
|
+
end
|
54
|
+
assert_equal({:hello => []}, mon.run("hello, world"))
|
55
|
+
assert_equal({:short => []}, mon.run("good day"))
|
56
|
+
end
|
57
|
+
|
30
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auser-poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-09-
|
14
|
+
date: 2009-09-04 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -1114,6 +1114,7 @@ files:
|
|
1114
1114
|
- vendor/gems/trollop/www/index.html
|
1115
1115
|
has_rdoc: false
|
1116
1116
|
homepage: http://poolpartyrb.com
|
1117
|
+
licenses:
|
1117
1118
|
post_install_message:
|
1118
1119
|
rdoc_options:
|
1119
1120
|
- --quiet
|
@@ -1139,10 +1140,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1139
1140
|
requirements: []
|
1140
1141
|
|
1141
1142
|
rubyforge_project:
|
1142
|
-
rubygems_version: 1.
|
1143
|
+
rubygems_version: 1.3.5
|
1143
1144
|
signing_key:
|
1144
1145
|
specification_version: 3
|
1145
|
-
summary: Self-healing, auto-scaling system administration, provisioning and maintaining tool that makes cloud computing
|
1146
|
+
summary: Self-healing, auto-scaling system administration, provisioning and maintaining tool that makes cloud computing easier.
|
1146
1147
|
test_files:
|
1147
1148
|
- test/test_helper.rb
|
1148
1149
|
- test/test_methods.rb
|