right_agent 0.9.5 → 0.9.6
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.
- data/lib/right_agent.rb +1 -1
- data/lib/right_agent/agent_config.rb +22 -0
- data/lib/right_agent/{agent_tags_manager.rb → agent_tag_manager.rb} +42 -10
- data/lib/right_agent/core_payload_types.rb +1 -0
- data/lib/right_agent/core_payload_types/executable_bundle.rb +5 -5
- data/lib/right_agent/core_payload_types/runlist_policy.rb +44 -0
- data/lib/right_agent/idempotent_request.rb +1 -1
- data/lib/right_agent/log.rb +34 -1
- data/lib/right_agent/multiplexer.rb +11 -0
- data/lib/right_agent/platform/darwin.rb +0 -4
- data/lib/right_agent/platform/linux.rb +0 -4
- data/lib/right_agent/platform/windows.rb +1 -5
- data/right_agent.gemspec +2 -2
- data/spec/core_payload_types/executable_bundle_spec.rb +9 -1
- metadata +6 -5
data/lib/right_agent.rb
CHANGED
@@ -43,7 +43,7 @@ require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'security'))
|
|
43
43
|
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'operation_result'))
|
44
44
|
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'subprocess'))
|
45
45
|
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'agent_identity'))
|
46
|
-
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, '
|
46
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'agent_tag_manager'))
|
47
47
|
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'actor'))
|
48
48
|
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'actor_registry'))
|
49
49
|
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'dispatcher'))
|
@@ -98,6 +98,28 @@ module RightScale
|
|
98
98
|
def self.valid_thread_name
|
99
99
|
VALID_THREAD_NAME
|
100
100
|
end
|
101
|
+
|
102
|
+
# Default policy name when no policy is specified for an executable bundle.
|
103
|
+
DEFAULT_POLICY_NAME = nil
|
104
|
+
|
105
|
+
# Default policy name when no policy is specified for an executable bundle.
|
106
|
+
#
|
107
|
+
# === Return
|
108
|
+
# (String):: default policy name...
|
109
|
+
def self.default_policy_name
|
110
|
+
DEFAULT_POLICY_NAME
|
111
|
+
end
|
112
|
+
|
113
|
+
# Default period for policies
|
114
|
+
DEFAULT_POLICY_PERIOD = 60 * 60 * 24
|
115
|
+
|
116
|
+
# Default audit period when a runlist policy does not specify a period.
|
117
|
+
#
|
118
|
+
# === Return
|
119
|
+
# (String):: default policy name...
|
120
|
+
def self.default_audit_period
|
121
|
+
DEFAULT_POLICY_PERIOD
|
122
|
+
end
|
101
123
|
|
102
124
|
# Initialize path to root directory of agent
|
103
125
|
#
|
@@ -25,7 +25,7 @@ require 'singleton'
|
|
25
25
|
module RightScale
|
26
26
|
|
27
27
|
# Agent tags management
|
28
|
-
class
|
28
|
+
class AgentTagManager
|
29
29
|
include Singleton
|
30
30
|
|
31
31
|
# (Agent) Agent being managed
|
@@ -33,14 +33,19 @@ module RightScale
|
|
33
33
|
|
34
34
|
# Retrieve current agent tags and give result to block
|
35
35
|
#
|
36
|
+
# === Parameters
|
37
|
+
# options(Hash):: Request options
|
38
|
+
# :raw(Boolean):: true to yield raw tag response instead of deserialized tags
|
39
|
+
# :timeout(Integer):: timeout in seconds before giving up and yielding an error message
|
40
|
+
#
|
36
41
|
# === Block
|
37
42
|
# Given block should take one argument which will be set with an array
|
38
43
|
# initialized with the tags of this instance
|
39
44
|
#
|
40
45
|
# === Return
|
41
46
|
# true:: Always return true
|
42
|
-
def tags
|
43
|
-
do_query(nil, @agent.identity) do |result|
|
47
|
+
def tags(options={})
|
48
|
+
do_query(nil, @agent.identity, options) do |result|
|
44
49
|
if result.kind_of?(Hash)
|
45
50
|
yield(result.size == 1 ? result.values.first['tags'] : [])
|
46
51
|
else
|
@@ -54,6 +59,9 @@ module RightScale
|
|
54
59
|
#
|
55
60
|
# === Parameters
|
56
61
|
# tags(Array):: tags to query or empty
|
62
|
+
# options(Hash):: Request options
|
63
|
+
# :raw(Boolean):: true to yield raw tag response instead of deserialized tags
|
64
|
+
# :timeout(Integer):: timeout in seconds before giving up and yielding an error message
|
57
65
|
#
|
58
66
|
# === Block
|
59
67
|
# Given block should take one argument which will be set with an array
|
@@ -62,7 +70,14 @@ module RightScale
|
|
62
70
|
# === Return
|
63
71
|
# true:: Always return true
|
64
72
|
def query_tags(*tags)
|
65
|
-
|
73
|
+
if tags.last.respond_to?(:keys)
|
74
|
+
tags = tags[0..-2]
|
75
|
+
options = tags.last
|
76
|
+
else
|
77
|
+
options = {}
|
78
|
+
end
|
79
|
+
|
80
|
+
do_query(tags, nil, options) { |result| yield result }
|
66
81
|
end
|
67
82
|
|
68
83
|
# Queries a list of servers in the current deployment which have one or more
|
@@ -71,14 +86,17 @@ module RightScale
|
|
71
86
|
# === Parameters
|
72
87
|
# tags(Array):: tags to query or empty
|
73
88
|
# agent_ids(Array):: agent IDs to query or empty or nil
|
89
|
+
# options(Hash):: Request options
|
90
|
+
# :timeout(Integer):: timeout in seconds before giving up and yielding an error message
|
74
91
|
#
|
75
92
|
# === Block
|
76
93
|
# Given block should take one argument which will be set with the raw response
|
77
94
|
#
|
78
95
|
# === Return
|
79
96
|
# true:: Always return true
|
80
|
-
def query_tags_raw(tags, agent_ids = nil)
|
81
|
-
|
97
|
+
def query_tags_raw(tags, agent_ids = nil, options={})
|
98
|
+
options = options.merge(:raw=>true)
|
99
|
+
do_query(tags, agent_ids, options) { |raw_response| yield raw_response }
|
82
100
|
end
|
83
101
|
|
84
102
|
# Add given tags to agent
|
@@ -168,7 +186,9 @@ module RightScale
|
|
168
186
|
# === Parameters
|
169
187
|
# tags(Array):: tags to query or empty or nil
|
170
188
|
# agent_ids(Array):: agent IDs to query or empty or nil
|
171
|
-
#
|
189
|
+
# options(Hash):: Request options
|
190
|
+
# :raw(Boolean):: true to yield raw tag response instead of deserialized tags
|
191
|
+
# :timeout(Integer):: timeout in seconds before giving up and yielding an error message
|
172
192
|
#
|
173
193
|
# === Block
|
174
194
|
# Given block should take one argument which will be set with an array
|
@@ -176,12 +196,20 @@ module RightScale
|
|
176
196
|
#
|
177
197
|
# === Return
|
178
198
|
# true:: Always return true
|
179
|
-
def do_query(tags = nil, agent_ids = nil,
|
199
|
+
def do_query(tags = nil, agent_ids = nil, options={})
|
200
|
+
raw = options[:raw] || false
|
201
|
+
timeout = options[:timeout]
|
202
|
+
|
203
|
+
request_options = {}
|
204
|
+
request_options[:timeout] = timeout if timeout
|
205
|
+
|
180
206
|
agent_check
|
181
207
|
payload = {:agent_identity => @agent.identity}
|
182
208
|
payload[:tags] = ensure_flat_array_value(tags) unless tags.nil? || tags.empty?
|
183
209
|
payload[:agent_ids] = ensure_flat_array_value(agent_ids) unless agent_ids.nil? || agent_ids.empty?
|
184
|
-
request = RightScale::IdempotentRequest.new("/mapper/query_tags",
|
210
|
+
request = RightScale::IdempotentRequest.new("/mapper/query_tags",
|
211
|
+
payload,
|
212
|
+
request_options)
|
185
213
|
request.callback { |result| yield raw ? request.raw_response : result }
|
186
214
|
request.errback do |message|
|
187
215
|
Log.error("Failed to query tags: #{message}")
|
@@ -208,6 +236,10 @@ module RightScale
|
|
208
236
|
value
|
209
237
|
end
|
210
238
|
|
211
|
-
end #
|
239
|
+
end # AgentTagManager
|
212
240
|
|
241
|
+
# This class has been renamed as of RightAgent 0.9.6; provide an alias
|
242
|
+
# to the old typename
|
243
|
+
# TODO remove this alias for RightAgent 1.0
|
244
|
+
AgentTagsManager = AgentTagManager
|
213
245
|
end # RightScale
|
@@ -38,6 +38,7 @@ require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'right_script
|
|
38
38
|
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'right_script_instantiation'))
|
39
39
|
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'login_policy'))
|
40
40
|
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'login_user'))
|
41
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'runlist_policy'))
|
41
42
|
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'secure_document'))
|
42
43
|
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'secure_document_location'))
|
43
44
|
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'planned_volume'))
|
@@ -54,9 +54,6 @@ module RightScale
|
|
54
54
|
# (String) Repose server to use
|
55
55
|
attr_accessor :repose_servers
|
56
56
|
|
57
|
-
# (String) The name of the RIghtLink thread to run this bundle on
|
58
|
-
attr_accessor :thread_name
|
59
|
-
|
60
57
|
# (Hash):: collection of repos to be checked out on the instance
|
61
58
|
# :key (String):: the hash id (SHA) of the repository
|
62
59
|
# :value (Hash):: repo and cookbook detail
|
@@ -89,6 +86,9 @@ module RightScale
|
|
89
86
|
# }
|
90
87
|
# :positions (Array):: List of CookbookPositions to be developed. Represents the subset of cookbooks identified as the "dev cookbooks"
|
91
88
|
attr_accessor :dev_cookbooks
|
89
|
+
|
90
|
+
# (RunlistPolicy) The RightLink policy this bundle belongs to
|
91
|
+
attr_accessor :runlist_policy
|
92
92
|
|
93
93
|
def initialize(*args)
|
94
94
|
@executables = args[0]
|
@@ -98,7 +98,7 @@ module RightScale
|
|
98
98
|
@cookbooks = args[4] if args.size > 4
|
99
99
|
@repose_servers = args[5] if args.size > 5
|
100
100
|
@dev_cookbooks = args[6] if args.size > 6
|
101
|
-
@
|
101
|
+
@runlist_policy = args[7] if args.size > 7
|
102
102
|
end
|
103
103
|
|
104
104
|
# Array of serialized fields given to constructor
|
@@ -110,7 +110,7 @@ module RightScale
|
|
110
110
|
@cookbooks,
|
111
111
|
@repose_servers,
|
112
112
|
@dev_cookbooks,
|
113
|
-
@
|
113
|
+
@runlist_policy ]
|
114
114
|
end
|
115
115
|
|
116
116
|
# Human readable representation
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2012 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
module RightScale
|
25
|
+
|
26
|
+
class RunlistPolicy
|
27
|
+
include Serializable
|
28
|
+
|
29
|
+
attr_accessor :policy_name, :thread_name, :audit_period
|
30
|
+
|
31
|
+
# Initialize fields from given arguments
|
32
|
+
def initialize(*args)
|
33
|
+
@policy_name = args[0]
|
34
|
+
@thread_name = args[1]
|
35
|
+
@audit_period = args[2]
|
36
|
+
end
|
37
|
+
|
38
|
+
# Array of serialized fields given to constructor
|
39
|
+
def serialized_members
|
40
|
+
[ @policy_name, @thread_name, @audit_period ]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -80,7 +80,7 @@ module RightScale
|
|
80
80
|
# increasing delay exponentially and decreasing this count exponentially, defaults to
|
81
81
|
# DEFAULT_RETRY_DELAY_COUNT
|
82
82
|
# :max_retry_delay(Fixnum):: Maximum number of seconds of retry delay, defaults to DEFAULT_MAX_RETRY_DELAY
|
83
|
-
# :timeout(Fixnum):: Number of seconds with no response before error callback gets called with
|
83
|
+
# :timeout(Fixnum):: Number of seconds with no response before error callback gets called, with
|
84
84
|
# -1 meaning never, defaults to DEFAULT_TIMEOUT
|
85
85
|
#
|
86
86
|
# === Raises
|
data/lib/right_agent/log.rb
CHANGED
@@ -131,6 +131,21 @@ module RightScale
|
|
131
131
|
@logger.__send__(m, *args)
|
132
132
|
end
|
133
133
|
|
134
|
+
# Determine whether this object, or its method_missing proxy, responds
|
135
|
+
# to the given method name. This follows the best practice of always
|
136
|
+
# overriding #respond_to? whenever one implements dynamic dispatch
|
137
|
+
# via #method_missing.
|
138
|
+
#
|
139
|
+
# === Parameters
|
140
|
+
# m(Symbol):: Forwarded method name
|
141
|
+
#
|
142
|
+
# === Return
|
143
|
+
# (true|false):: True if this object or its proxy responds to the names method, false otherwise
|
144
|
+
def respond_to?(m)
|
145
|
+
init unless @initialized
|
146
|
+
super(m) || @logger.respond_to?(m)
|
147
|
+
end
|
148
|
+
|
134
149
|
# Log warning and optionally append exception information
|
135
150
|
#
|
136
151
|
# === Parameters
|
@@ -296,6 +311,22 @@ module RightScale
|
|
296
311
|
@program_name = prog_name
|
297
312
|
end
|
298
313
|
|
314
|
+
# Sets the syslog facility that will be used when emitting syslog messages.
|
315
|
+
# Can only be successfully called before logging is initialized
|
316
|
+
#
|
317
|
+
# === Parameters
|
318
|
+
# facility(String):: A syslog facility name, e.g. 'user' or 'local0'
|
319
|
+
#
|
320
|
+
# === Return
|
321
|
+
# program_name(String):: The input string
|
322
|
+
#
|
323
|
+
# === Raise
|
324
|
+
# RuntimeError:: If logger is already initialized
|
325
|
+
def facility=(facility)
|
326
|
+
raise 'Logger already initialized' if @initialized
|
327
|
+
@facility = facility
|
328
|
+
end
|
329
|
+
|
299
330
|
# Sets the level for the Logger by symbol or by Logger constant
|
300
331
|
#
|
301
332
|
# === Parameters
|
@@ -403,7 +434,9 @@ module RightScale
|
|
403
434
|
logger.formatter.datetime_format = "%b %d %H:%M:%S"
|
404
435
|
else
|
405
436
|
$stderr.puts "Logging to syslog" if opts[:print]
|
406
|
-
|
437
|
+
program_name = @program_name || identity || 'RightAgent'
|
438
|
+
facility = @facility || 'local0'
|
439
|
+
logger = RightSupport::Log::SystemLogger.new(program_name, :facility=>facility)
|
407
440
|
end
|
408
441
|
|
409
442
|
@logger = Multiplexer.new(logger)
|
@@ -87,5 +87,16 @@ module RightScale
|
|
87
87
|
res[0]
|
88
88
|
end
|
89
89
|
|
90
|
+
# Determine whether this object, or ALL of its targets, responds to
|
91
|
+
# the named method.
|
92
|
+
#
|
93
|
+
# === Parameters
|
94
|
+
# m(Symbol):: Forwarded method name
|
95
|
+
#
|
96
|
+
# === Return
|
97
|
+
# (true|false):: True if this object, or ALL targets, respond to the names method; false otherwise
|
98
|
+
def respond_to?(m)
|
99
|
+
super(m) || @targets.all? { |t| t.respond_to?(m) }
|
100
|
+
end
|
90
101
|
end
|
91
102
|
end
|
@@ -212,13 +212,9 @@ module RightScale
|
|
212
212
|
@right_link_home_dir
|
213
213
|
end
|
214
214
|
|
215
|
-
def right_link_dir
|
216
|
-
return pretty_path(File.join(right_link_home_dir, 'right_link'))
|
217
|
-
end
|
218
|
-
|
219
215
|
# Path to right link configuration and internal usage scripts
|
220
216
|
def private_bin_dir
|
221
|
-
return pretty_path(File.join(
|
217
|
+
return pretty_path(File.join(right_link_home_dir, 'right_link', 'scripts', 'windows'))
|
222
218
|
end
|
223
219
|
|
224
220
|
def sandbox_dir
|
data/right_agent.gemspec
CHANGED
@@ -24,8 +24,8 @@ require 'rubygems'
|
|
24
24
|
|
25
25
|
Gem::Specification.new do |spec|
|
26
26
|
spec.name = 'right_agent'
|
27
|
-
spec.version = '0.9.
|
28
|
-
spec.date = '2012-03-
|
27
|
+
spec.version = '0.9.6'
|
28
|
+
spec.date = '2012-03-23'
|
29
29
|
spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro']
|
30
30
|
spec.email = 'lee@rightscale.com'
|
31
31
|
spec.homepage = 'https://github.com/rightscale/right_agent'
|
@@ -27,7 +27,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'r
|
|
27
27
|
module RightScale
|
28
28
|
describe ExecutableBundle do
|
29
29
|
context 'serialized_members' do
|
30
|
-
it 'contains
|
30
|
+
it 'contains 9 elements' do
|
31
31
|
ExecutableBundle.new.serialized_members.count.should == 8
|
32
32
|
end
|
33
33
|
end
|
@@ -54,6 +54,14 @@ module RightScale
|
|
54
54
|
bundle.serialized_members[6].should be_nil
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
context 'runlist policy' do
|
59
|
+
let(:bundle) { ExecutableBundle.new(nil, nil, nil, nil, nil, nil, nil, RunlistPolicy.new) }
|
60
|
+
|
61
|
+
it 'should serialize into a runlist policy object' do
|
62
|
+
bundle.serialized_members[7].should be_an_instance_of(RunlistPolicy)
|
63
|
+
end
|
64
|
+
end
|
57
65
|
end
|
58
66
|
end
|
59
67
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 6
|
10
|
+
version: 0.9.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lee Kirchhoff
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-03-
|
20
|
+
date: 2012-03-23 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -155,7 +155,7 @@ files:
|
|
155
155
|
- lib/right_agent/agent.rb
|
156
156
|
- lib/right_agent/agent_config.rb
|
157
157
|
- lib/right_agent/agent_identity.rb
|
158
|
-
- lib/right_agent/
|
158
|
+
- lib/right_agent/agent_tag_manager.rb
|
159
159
|
- lib/right_agent/audit_formatter.rb
|
160
160
|
- lib/right_agent/command.rb
|
161
161
|
- lib/right_agent/command/agent_manager_commands.rb
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/right_agent/core_payload_types/repositories_bundle.rb
|
183
183
|
- lib/right_agent/core_payload_types/right_script_attachment.rb
|
184
184
|
- lib/right_agent/core_payload_types/right_script_instantiation.rb
|
185
|
+
- lib/right_agent/core_payload_types/runlist_policy.rb
|
185
186
|
- lib/right_agent/core_payload_types/secure_document.rb
|
186
187
|
- lib/right_agent/core_payload_types/secure_document_location.rb
|
187
188
|
- lib/right_agent/core_payload_types/software_repository_instantiation.rb
|