lbrt 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +3 -1
- data/lib/lbrt/alert/dsl/context/alert/condition.rb +6 -1
- data/lib/lbrt/alert/dsl/context/alert.rb +7 -2
- data/lib/lbrt/alert/dsl/context.rb +10 -1
- data/lib/lbrt/service/dsl/context/service.rb +6 -1
- data/lib/lbrt/service/dsl/context.rb +10 -1
- data/lib/lbrt/space/dsl/context/space/chart/stream.rb +2 -0
- data/lib/lbrt/space/dsl/context/space/chart.rb +2 -0
- data/lib/lbrt/space/dsl/context/space.rb +4 -13
- data/lib/lbrt/space/dsl/context.rb +10 -6
- data/lib/lbrt/utils.rb +16 -0
- data/lib/lbrt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b555b4fcdd3a4b7874718d2ac738a8f94662f34e
|
4
|
+
data.tar.gz: 9cabe6071054fdf219e15d19cea1717ea6741bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f73a2df7ded73d26b0d95525103efe4051ec71347ceeb64881c30d96a768e16361ed3f81b55b7b68ac016ef9cc57cb6a3421201d580ff99418bfae88fbc9fdb
|
7
|
+
data.tar.gz: c1655ea651077562dc8a3c14b6c6a73497d3ec5a44f51cbb6e054f6ae7f1023bc0c5da72c5092b887054224eb64d9003fca3f0efa56b6b953c9ecac3bc4443e3
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -198,7 +198,7 @@ space "My Space2" do
|
|
198
198
|
end
|
199
199
|
```
|
200
200
|
|
201
|
-
|
201
|
+
## template
|
202
202
|
|
203
203
|
```ruby
|
204
204
|
template "dstat" do
|
@@ -231,6 +231,8 @@ space "my-host-001" do
|
|
231
231
|
end
|
232
232
|
```
|
233
233
|
|
234
|
+
You can use the template in the `alert` and `service`.
|
235
|
+
|
234
236
|
## Show resource by [peco](https://github.com/peco/peco)
|
235
237
|
|
236
238
|
```sh
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class Lbrt::Alert::DSL::Context::Alert::Condition
|
2
|
+
include Lbrt::Utils::TemplateHelper
|
3
|
+
|
2
4
|
REQUIRED_ATTRIBUTES = %w(
|
3
5
|
type
|
4
6
|
metric_name
|
@@ -11,12 +13,15 @@ class Lbrt::Alert::DSL::Context::Alert::Condition
|
|
11
13
|
'active' => %W(duration),
|
12
14
|
}
|
13
15
|
|
14
|
-
def initialize(alert_name, &block)
|
16
|
+
def initialize(context, alert_name, &block)
|
17
|
+
@context = context.dup
|
15
18
|
@alert_name = alert_name
|
16
19
|
@result = {}
|
17
20
|
instance_eval(&block)
|
18
21
|
end
|
19
22
|
|
23
|
+
attr_reader :context
|
24
|
+
|
20
25
|
def result
|
21
26
|
REQUIRED_ATTRIBUTES.each do |name|
|
22
27
|
unless @result.has_key?(name)
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class Lbrt::Alert::DSL::Context::Alert
|
2
|
+
include Lbrt::Utils::TemplateHelper
|
3
|
+
|
2
4
|
REQUIRED_ATTRIBUTES = %w(
|
3
5
|
description
|
4
6
|
attributes
|
@@ -7,7 +9,8 @@ class Lbrt::Alert::DSL::Context::Alert
|
|
7
9
|
rearm_per_signal
|
8
10
|
)
|
9
11
|
|
10
|
-
def initialize(name, services, &block)
|
12
|
+
def initialize(context, name, services, &block)
|
13
|
+
@context = context.merge(:alert_name => name)
|
11
14
|
@name = name
|
12
15
|
@services = services
|
13
16
|
|
@@ -20,6 +23,8 @@ class Lbrt::Alert::DSL::Context::Alert
|
|
20
23
|
instance_eval(&block)
|
21
24
|
end
|
22
25
|
|
26
|
+
attr_reader :context
|
27
|
+
|
23
28
|
def result
|
24
29
|
REQUIRED_ATTRIBUTES.each do |name|
|
25
30
|
unless @result.has_key?(name)
|
@@ -57,7 +62,7 @@ class Lbrt::Alert::DSL::Context::Alert
|
|
57
62
|
end
|
58
63
|
|
59
64
|
def condition(&block)
|
60
|
-
@result['conditions'] << Lbrt::Alert::DSL::Context::Alert::Condition.new(@name, &block).result
|
65
|
+
@result['conditions'] << Lbrt::Alert::DSL::Context::Alert::Condition.new(@context, @name, &block).result
|
61
66
|
end
|
62
67
|
|
63
68
|
def service(type, title)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class Lbrt::Alert::DSL::Context
|
2
2
|
include Lbrt::Utils::ContextHelper
|
3
|
+
include Lbrt::Utils::TemplateHelper
|
3
4
|
|
4
5
|
def self.eval(client, dsl, path, options = {})
|
5
6
|
self.new(client, path, options) {
|
@@ -8,12 +9,20 @@ class Lbrt::Alert::DSL::Context
|
|
8
9
|
end
|
9
10
|
|
10
11
|
attr_reader :result
|
12
|
+
attr_reader :context
|
11
13
|
|
12
14
|
def initialize(client, path, options = {}, &block)
|
13
15
|
@path = path
|
14
16
|
@options = options
|
15
17
|
@result = {}
|
16
18
|
@services = Lbrt::Service::Exporter.export(client, options)
|
19
|
+
|
20
|
+
@context = Hashie::Mash.new(
|
21
|
+
:path => path,
|
22
|
+
:options => options,
|
23
|
+
:templates => {}
|
24
|
+
)
|
25
|
+
|
17
26
|
instance_eval(&block)
|
18
27
|
end
|
19
28
|
|
@@ -26,7 +35,7 @@ class Lbrt::Alert::DSL::Context
|
|
26
35
|
raise "Alert `#{name}` is already defined"
|
27
36
|
end
|
28
37
|
|
29
|
-
alrt = Lbrt::Alert::DSL::Context::Alert.new(name, @services, &block).result
|
38
|
+
alrt = Lbrt::Alert::DSL::Context::Alert.new(@context, name, @services, &block).result
|
30
39
|
@result[name] = alrt
|
31
40
|
end
|
32
41
|
end
|
@@ -1,15 +1,20 @@
|
|
1
1
|
class Lbrt::Service::DSL::Context::Service
|
2
|
+
include Lbrt::Utils::TemplateHelper
|
3
|
+
|
2
4
|
REQUIRED_ATTRIBUTES = %w(
|
3
5
|
settings
|
4
6
|
)
|
5
7
|
|
6
|
-
def initialize(type, title, &block)
|
8
|
+
def initialize(context, type, title, &block)
|
9
|
+
@context = context.merge(:service_type => type, :service_title => title)
|
7
10
|
@type = type
|
8
11
|
@title = title
|
9
12
|
@result = {}
|
10
13
|
instance_eval(&block)
|
11
14
|
end
|
12
15
|
|
16
|
+
attr_reader :context
|
17
|
+
|
13
18
|
def result
|
14
19
|
REQUIRED_ATTRIBUTES.each do |name|
|
15
20
|
unless @result.has_key?(name)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class Lbrt::Service::DSL::Context
|
2
2
|
include Lbrt::Utils::ContextHelper
|
3
|
+
include Lbrt::Utils::TemplateHelper
|
3
4
|
|
4
5
|
def self.eval(dsl, path, options = {})
|
5
6
|
self.new(path, options) {
|
@@ -8,11 +9,19 @@ class Lbrt::Service::DSL::Context
|
|
8
9
|
end
|
9
10
|
|
10
11
|
attr_reader :result
|
12
|
+
attr_reader :context
|
11
13
|
|
12
14
|
def initialize(path, options = {}, &block)
|
13
15
|
@path = path
|
14
16
|
@options = options
|
15
17
|
@result = {}
|
18
|
+
|
19
|
+
@context = Hashie::Mash.new(
|
20
|
+
:path => path,
|
21
|
+
:options => options,
|
22
|
+
:templates => {}
|
23
|
+
)
|
24
|
+
|
16
25
|
instance_eval(&block)
|
17
26
|
end
|
18
27
|
|
@@ -27,7 +36,7 @@ class Lbrt::Service::DSL::Context
|
|
27
36
|
raise "Service `#{type}/#{title}` is already defined"
|
28
37
|
end
|
29
38
|
|
30
|
-
srvc = Lbrt::Service::DSL::Context::Service.new(type, title, &block).result
|
39
|
+
srvc = Lbrt::Service::DSL::Context::Service.new(@context, type, title, &block).result
|
31
40
|
@result[key] = srvc
|
32
41
|
end
|
33
42
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class Lbrt::Space::DSL::Context::Space
|
2
|
-
|
2
|
+
include Lbrt::Utils::TemplateHelper
|
3
|
+
|
4
|
+
def initialize(context, name_or_id, &block)
|
5
|
+
@context = context.merge(:space_name => name_or_id)
|
3
6
|
@name_or_id = name_or_id
|
4
|
-
@templates = templates
|
5
7
|
@result = {'charts' => {}}
|
6
|
-
@context = Hashie::Mash.new(:space_name => name_or_id)
|
7
8
|
instance_eval(&block)
|
8
9
|
end
|
9
10
|
|
@@ -12,16 +13,6 @@ class Lbrt::Space::DSL::Context::Space
|
|
12
13
|
|
13
14
|
private
|
14
15
|
|
15
|
-
def include_template(template_name)
|
16
|
-
tmplt = @templates[template_name.to_s]
|
17
|
-
|
18
|
-
unless tmplt
|
19
|
-
raise "Space `#{@name_or_id}`: Template `#{template_name}` is not defined"
|
20
|
-
end
|
21
|
-
|
22
|
-
instance_eval(&tmplt)
|
23
|
-
end
|
24
|
-
|
25
16
|
def chart(chart_name_or_id, &block)
|
26
17
|
if @result[chart_name_or_id]
|
27
18
|
raise "Space `#{@name_or_id}` > Chart `#{chart_name_or_id}` is already defined"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class Lbrt::Space::DSL::Context
|
2
2
|
include Lbrt::Utils::ContextHelper
|
3
|
+
include Lbrt::Utils::TemplateHelper
|
3
4
|
|
4
5
|
def self.eval(dsl, path, options = {})
|
5
6
|
self.new(path, options) {
|
@@ -8,27 +9,30 @@ class Lbrt::Space::DSL::Context
|
|
8
9
|
end
|
9
10
|
|
10
11
|
attr_reader :result
|
12
|
+
attr_reader :context
|
11
13
|
|
12
14
|
def initialize(path, options = {}, &block)
|
13
15
|
@path = path
|
14
16
|
@options = options
|
15
|
-
@templates = {}
|
16
17
|
@result = {}
|
18
|
+
|
19
|
+
@context = Hashie::Mash.new(
|
20
|
+
:path => path,
|
21
|
+
:options => options,
|
22
|
+
:templates => {}
|
23
|
+
)
|
24
|
+
|
17
25
|
instance_eval(&block)
|
18
26
|
end
|
19
27
|
|
20
28
|
private
|
21
29
|
|
22
|
-
def template(name, &block)
|
23
|
-
@templates[name.to_s] = block
|
24
|
-
end
|
25
|
-
|
26
30
|
def space(name_or_id, &block)
|
27
31
|
if @result[name_or_id]
|
28
32
|
raise "Space `#{name_or_id}` is already defined"
|
29
33
|
end
|
30
34
|
|
31
|
-
spc = Lbrt::Space::DSL::Context::Space.new(
|
35
|
+
spc = Lbrt::Space::DSL::Context::Space.new(@context, name_or_id, &block).result
|
32
36
|
@result[name_or_id] = spc
|
33
37
|
end
|
34
38
|
end
|
data/lib/lbrt/utils.rb
CHANGED
@@ -33,6 +33,22 @@ class Lbrt::Utils
|
|
33
33
|
Kernel.require(file)
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
def template(name, &block)
|
38
|
+
@context.templates[name.to_s] = block
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module TemplateHelper
|
43
|
+
def include_template(template_name)
|
44
|
+
tmplt = @context.templates[template_name.to_s]
|
45
|
+
|
46
|
+
unless tmplt
|
47
|
+
raise "Template `#{template_name}` is not defined"
|
48
|
+
end
|
49
|
+
|
50
|
+
instance_eval(&tmplt)
|
51
|
+
end
|
36
52
|
end
|
37
53
|
|
38
54
|
module CLIHelper
|
data/lib/lbrt/version.rb
CHANGED