dtk-action-agent 0.0.4 → 0.0.5
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 +4 -4
- data/lib/command.rb +27 -13
- data/lib/dtk-action-agent/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: 8ceb9bc809895890686ccd58e4783db04dd98607
|
4
|
+
data.tar.gz: dd303a2fe410acaaa1e1bebb2b5c37d2be231658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b9d0492fbb95fa778718c900bb7accc860b795a2ae53609a6aea453223a5153a7c851f5c0a1775877dc42ad2d2fd9f8d338918df0befd4dd12bd89b69962c49
|
7
|
+
data.tar.gz: 80e42e95161fd18359a5d0988180a6d27e405371d5835de83b2bf7f79a0b5c97c6dee84ecfca4afac784ca6cedd4ded3a3370db5c2c0d5df5d78b059f4fd1a03
|
data/lib/command.rb
CHANGED
@@ -9,19 +9,24 @@ module DTK
|
|
9
9
|
attr_accessor :command_type, :command, :if_success, :if_fail, :process, :child_task
|
10
10
|
|
11
11
|
##
|
12
|
-
# command
|
13
|
-
# type
|
14
|
-
# if
|
15
|
-
# unless
|
16
|
-
#
|
12
|
+
# command - string to be run on system, e.g. ifconfig
|
13
|
+
# type - type of command e.g. syscall, ruby
|
14
|
+
# if - callback to be run if exit status is = 0
|
15
|
+
# unless - callback to be run if exit status is != 0
|
16
|
+
# stdout_redirect - redirect all output to stdout
|
17
|
+
# child_task - if it is spawned by another main task
|
17
18
|
#
|
19
|
+
|
20
|
+
STDOUT_REDIRECT = ' 2>&1'
|
21
|
+
|
18
22
|
def initialize(value_hash)
|
19
|
-
@command_type
|
20
|
-
@command
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
23
|
+
@command_type = value_hash['type']
|
24
|
+
@command = value_hash['command']
|
25
|
+
@stdout_redirect = !!value_hash['stdout_redirect']
|
26
|
+
@if_success = value_hash['if']
|
27
|
+
@if_fail = value_hash['unless']
|
28
|
+
@spawned = false
|
29
|
+
@child_task = value_hash['child_task'] || false
|
25
30
|
|
26
31
|
if @if_success && @if_fail
|
27
32
|
Log.warn "Unexpected case, both if/unless conditions have been set for command #{@command}(#{@command_type})"
|
@@ -33,7 +38,7 @@ module DTK
|
|
33
38
|
#
|
34
39
|
def start_task
|
35
40
|
begin
|
36
|
-
@process = POSIX::Spawn::Child.new(
|
41
|
+
@process = POSIX::Spawn::Child.new(formulate_command)
|
37
42
|
Log.debug("Command started: '#{self.to_s}'")
|
38
43
|
rescue Exception => e
|
39
44
|
@error_message = e.message
|
@@ -86,7 +91,16 @@ module DTK
|
|
86
91
|
end
|
87
92
|
|
88
93
|
def to_s
|
89
|
-
"#{
|
94
|
+
"#{formulate_command} (#{command_type})"
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
#
|
100
|
+
# Based on stdout-redirect flag
|
101
|
+
#
|
102
|
+
def formulate_command
|
103
|
+
@stdout_redirect ? "#{@command} #{STDOUT_REDIRECT}" : @command
|
90
104
|
end
|
91
105
|
|
92
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-action-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich PELAVIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: posix-spawn
|