populus 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/echo.popl +7 -3
- data/lib/populus/accepter.rb +1 -1
- data/lib/populus/node.rb +2 -2
- data/lib/populus/remote_runner.rb +26 -0
- data/lib/populus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee4c83fd76f437d2fedee3e9079655a2e0b7c420
|
4
|
+
data.tar.gz: 674f5e3e39eedfa5c42e9db13f0cc5a2ae623588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aac3ab29d5b0f6702d54b56e331b00bd4dd8fe24e9e8aac2ec74c9e474bf426985f0a2954ca8eac923fe0bf3104486a8447ccde551952bf3af4c12c459d88333
|
7
|
+
data.tar.gz: c595120a3771cb62d3796fc78c7b5958f8c87a7fd7cfe3608655000d3187396833a4db04bc0e3006cd75b42ce1f639bc9e5bc1fc9e39ef3d4ed7a7435dd8d734
|
data/examples/echo.popl
CHANGED
@@ -6,12 +6,16 @@ Populus.config do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
Populus.watch :event, name: "sample" do
|
9
|
-
cond {|data| data.any?{|d| d
|
9
|
+
cond {|data| data.any?{|d| !d['Payload'].nil? } }
|
10
10
|
runs do |data|
|
11
|
-
event = data.find{|d| d
|
11
|
+
event = data.find{|d| !d['Payload'].nil? }
|
12
12
|
Populus.logger.info "From populus!!!"
|
13
13
|
Populus.logger.info Base64.decode64(event['Payload'])
|
14
14
|
|
15
|
-
notify_to_slack(
|
15
|
+
notify_to_slack(<<-EOF, channel: '#bot_test', username: "Populus")
|
16
|
+
Hello!!!
|
17
|
+
Consul event payload:
|
18
|
+
>>> `#{event.inspect}`"
|
19
|
+
EOF
|
16
20
|
end
|
17
21
|
end
|
data/lib/populus/accepter.rb
CHANGED
data/lib/populus/node.rb
CHANGED
@@ -3,12 +3,12 @@ require 'specinfra'
|
|
3
3
|
module Populus
|
4
4
|
class Node
|
5
5
|
class << self
|
6
|
-
def
|
6
|
+
def registry
|
7
7
|
@nodes ||= {}
|
8
8
|
end
|
9
9
|
|
10
10
|
def register_host(hostname)
|
11
|
-
|
11
|
+
registry[hostname] = gen_host(hostname)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'specinfra'
|
2
|
+
require 'erb'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'fileutils'
|
2
5
|
|
3
6
|
module Populus
|
4
7
|
class RemoteRunner
|
@@ -15,5 +18,28 @@ module Populus
|
|
15
18
|
Populus.logger.debug("stderr:\n%s" % res.stderr)
|
16
19
|
Populus.logger.info("Command exited: %d" % res.exit_status)
|
17
20
|
end
|
21
|
+
|
22
|
+
def create_file(path, template="", context=nil)
|
23
|
+
file = Tempfile.new(".populus-tmp")
|
24
|
+
content = ERB.new(template).result(context || binding)
|
25
|
+
file.write content
|
26
|
+
file.close
|
27
|
+
@backend.send_file(file.path, path)
|
28
|
+
Populus.logger.info("Created Successfully: %s" % path)
|
29
|
+
|
30
|
+
FileUtils.rm_f(file.path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def upload_file(to_path, local: nil)
|
34
|
+
raise ArgumentError unless local
|
35
|
+
@backend.send_file(local, to_path)
|
36
|
+
Populus.logger.info("Upload Successfully: %s to %s" % [local, to_path])
|
37
|
+
end
|
38
|
+
|
39
|
+
def upload_dir(to_dir, local: nil)
|
40
|
+
raise ArgumentError unless local
|
41
|
+
@backend.send_directory(local, to_dir)
|
42
|
+
Populus.logger.info("Upload Directory Successfully: %s to %s" % [local, to_dir])
|
43
|
+
end
|
18
44
|
end
|
19
45
|
end
|
data/lib/populus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: populus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uchio, KONDO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: specinfra
|