right_agent 2.0.7-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +82 -0
- data/Rakefile +113 -0
- data/lib/right_agent.rb +59 -0
- data/lib/right_agent/actor.rb +182 -0
- data/lib/right_agent/actor_registry.rb +76 -0
- data/lib/right_agent/actors/agent_manager.rb +232 -0
- data/lib/right_agent/agent.rb +1149 -0
- data/lib/right_agent/agent_config.rb +480 -0
- data/lib/right_agent/agent_identity.rb +210 -0
- data/lib/right_agent/agent_tag_manager.rb +237 -0
- data/lib/right_agent/audit_formatter.rb +107 -0
- data/lib/right_agent/clients.rb +31 -0
- data/lib/right_agent/clients/api_client.rb +383 -0
- data/lib/right_agent/clients/auth_client.rb +247 -0
- data/lib/right_agent/clients/balanced_http_client.rb +369 -0
- data/lib/right_agent/clients/base_retry_client.rb +495 -0
- data/lib/right_agent/clients/right_http_client.rb +279 -0
- data/lib/right_agent/clients/router_client.rb +493 -0
- data/lib/right_agent/command.rb +30 -0
- data/lib/right_agent/command/agent_manager_commands.rb +150 -0
- data/lib/right_agent/command/command_client.rb +136 -0
- data/lib/right_agent/command/command_constants.rb +33 -0
- data/lib/right_agent/command/command_io.rb +126 -0
- data/lib/right_agent/command/command_parser.rb +87 -0
- data/lib/right_agent/command/command_runner.rb +118 -0
- data/lib/right_agent/command/command_serializer.rb +63 -0
- data/lib/right_agent/connectivity_checker.rb +179 -0
- data/lib/right_agent/console.rb +65 -0
- data/lib/right_agent/core_payload_types.rb +44 -0
- data/lib/right_agent/core_payload_types/cookbook.rb +61 -0
- data/lib/right_agent/core_payload_types/cookbook_position.rb +46 -0
- data/lib/right_agent/core_payload_types/cookbook_repository.rb +116 -0
- data/lib/right_agent/core_payload_types/cookbook_sequence.rb +70 -0
- data/lib/right_agent/core_payload_types/dev_repositories.rb +100 -0
- data/lib/right_agent/core_payload_types/dev_repository.rb +76 -0
- data/lib/right_agent/core_payload_types/event_categories.rb +38 -0
- data/lib/right_agent/core_payload_types/executable_bundle.rb +130 -0
- data/lib/right_agent/core_payload_types/login_policy.rb +72 -0
- data/lib/right_agent/core_payload_types/login_user.rb +79 -0
- data/lib/right_agent/core_payload_types/planned_volume.rb +94 -0
- data/lib/right_agent/core_payload_types/recipe_instantiation.rb +73 -0
- data/lib/right_agent/core_payload_types/repositories_bundle.rb +50 -0
- data/lib/right_agent/core_payload_types/right_script_attachment.rb +95 -0
- data/lib/right_agent/core_payload_types/right_script_instantiation.rb +94 -0
- data/lib/right_agent/core_payload_types/runlist_policy.rb +44 -0
- data/lib/right_agent/core_payload_types/secure_document.rb +66 -0
- data/lib/right_agent/core_payload_types/secure_document_location.rb +63 -0
- data/lib/right_agent/core_payload_types/software_repository_instantiation.rb +61 -0
- data/lib/right_agent/daemonize.rb +35 -0
- data/lib/right_agent/dispatched_cache.rb +109 -0
- data/lib/right_agent/dispatcher.rb +272 -0
- data/lib/right_agent/enrollment_result.rb +221 -0
- data/lib/right_agent/exceptions.rb +87 -0
- data/lib/right_agent/history.rb +145 -0
- data/lib/right_agent/log.rb +460 -0
- data/lib/right_agent/minimal.rb +46 -0
- data/lib/right_agent/monkey_patches.rb +30 -0
- data/lib/right_agent/monkey_patches/ruby_patch.rb +55 -0
- data/lib/right_agent/monkey_patches/ruby_patch/array_patch.rb +29 -0
- data/lib/right_agent/monkey_patches/ruby_patch/darwin_patch.rb +24 -0
- data/lib/right_agent/monkey_patches/ruby_patch/linux_patch.rb +24 -0
- data/lib/right_agent/monkey_patches/ruby_patch/linux_patch/file_patch.rb +30 -0
- data/lib/right_agent/monkey_patches/ruby_patch/object_patch.rb +49 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch.rb +32 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/file_patch.rb +60 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/process_patch.rb +63 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/stdio_patch.rb +27 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/time_patch.rb +55 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/win32ole_patch.rb +34 -0
- data/lib/right_agent/multiplexer.rb +102 -0
- data/lib/right_agent/offline_handler.rb +270 -0
- data/lib/right_agent/operation_result.rb +300 -0
- data/lib/right_agent/packets.rb +673 -0
- data/lib/right_agent/payload_formatter.rb +104 -0
- data/lib/right_agent/pending_requests.rb +128 -0
- data/lib/right_agent/pid_file.rb +159 -0
- data/lib/right_agent/platform.rb +770 -0
- data/lib/right_agent/platform/unix/darwin/platform.rb +102 -0
- data/lib/right_agent/platform/unix/linux/platform.rb +305 -0
- data/lib/right_agent/platform/unix/platform.rb +226 -0
- data/lib/right_agent/platform/windows/mingw/platform.rb +447 -0
- data/lib/right_agent/platform/windows/mswin/platform.rb +236 -0
- data/lib/right_agent/platform/windows/platform.rb +1808 -0
- data/lib/right_agent/protocol_version_mixin.rb +69 -0
- data/lib/right_agent/retryable_request.rb +195 -0
- data/lib/right_agent/scripts/agent_controller.rb +543 -0
- data/lib/right_agent/scripts/agent_deployer.rb +400 -0
- data/lib/right_agent/scripts/common_parser.rb +160 -0
- data/lib/right_agent/scripts/log_level_manager.rb +192 -0
- data/lib/right_agent/scripts/stats_manager.rb +268 -0
- data/lib/right_agent/scripts/usage.rb +58 -0
- data/lib/right_agent/secure_identity.rb +92 -0
- data/lib/right_agent/security.rb +32 -0
- data/lib/right_agent/security/cached_certificate_store_proxy.rb +77 -0
- data/lib/right_agent/security/certificate.rb +102 -0
- data/lib/right_agent/security/certificate_cache.rb +89 -0
- data/lib/right_agent/security/distinguished_name.rb +56 -0
- data/lib/right_agent/security/encrypted_document.rb +83 -0
- data/lib/right_agent/security/rsa_key_pair.rb +76 -0
- data/lib/right_agent/security/signature.rb +86 -0
- data/lib/right_agent/security/static_certificate_store.rb +85 -0
- data/lib/right_agent/sender.rb +792 -0
- data/lib/right_agent/serialize.rb +29 -0
- data/lib/right_agent/serialize/message_pack.rb +107 -0
- data/lib/right_agent/serialize/secure_serializer.rb +151 -0
- data/lib/right_agent/serialize/secure_serializer_initializer.rb +47 -0
- data/lib/right_agent/serialize/serializable.rb +151 -0
- data/lib/right_agent/serialize/serializer.rb +159 -0
- data/lib/right_agent/subprocess.rb +38 -0
- data/lib/right_agent/tracer.rb +124 -0
- data/right_agent.gemspec +101 -0
- data/spec/actor_registry_spec.rb +80 -0
- data/spec/actor_spec.rb +162 -0
- data/spec/agent_config_spec.rb +235 -0
- data/spec/agent_identity_spec.rb +78 -0
- data/spec/agent_spec.rb +734 -0
- data/spec/agent_tag_manager_spec.rb +319 -0
- data/spec/clients/api_client_spec.rb +423 -0
- data/spec/clients/auth_client_spec.rb +272 -0
- data/spec/clients/balanced_http_client_spec.rb +576 -0
- data/spec/clients/base_retry_client_spec.rb +635 -0
- data/spec/clients/router_client_spec.rb +594 -0
- data/spec/clients/spec_helper.rb +111 -0
- data/spec/command/agent_manager_commands_spec.rb +51 -0
- data/spec/command/command_io_spec.rb +93 -0
- data/spec/command/command_parser_spec.rb +79 -0
- data/spec/command/command_runner_spec.rb +107 -0
- data/spec/command/command_serializer_spec.rb +51 -0
- data/spec/connectivity_checker_spec.rb +83 -0
- data/spec/core_payload_types/dev_repositories_spec.rb +64 -0
- data/spec/core_payload_types/dev_repository_spec.rb +33 -0
- data/spec/core_payload_types/executable_bundle_spec.rb +67 -0
- data/spec/core_payload_types/login_user_spec.rb +102 -0
- data/spec/core_payload_types/recipe_instantiation_spec.rb +81 -0
- data/spec/core_payload_types/right_script_attachment_spec.rb +65 -0
- data/spec/core_payload_types/right_script_instantiation_spec.rb +79 -0
- data/spec/core_payload_types/spec_helper.rb +23 -0
- data/spec/dispatched_cache_spec.rb +136 -0
- data/spec/dispatcher_spec.rb +324 -0
- data/spec/enrollment_result_spec.rb +53 -0
- data/spec/history_spec.rb +246 -0
- data/spec/log_spec.rb +192 -0
- data/spec/monkey_patches/eventmachine_spec.rb +62 -0
- data/spec/multiplexer_spec.rb +48 -0
- data/spec/offline_handler_spec.rb +340 -0
- data/spec/operation_result_spec.rb +208 -0
- data/spec/packets_spec.rb +461 -0
- data/spec/pending_requests_spec.rb +136 -0
- data/spec/platform/spec_helper.rb +216 -0
- data/spec/platform/unix/darwin/platform_spec.rb +181 -0
- data/spec/platform/unix/linux/platform_spec.rb +540 -0
- data/spec/platform/unix/spec_helper.rb +149 -0
- data/spec/platform/windows/mingw/platform_spec.rb +222 -0
- data/spec/platform/windows/mswin/platform_spec.rb +259 -0
- data/spec/platform/windows/spec_helper.rb +720 -0
- data/spec/retryable_request_spec.rb +306 -0
- data/spec/secure_identity_spec.rb +50 -0
- data/spec/security/cached_certificate_store_proxy_spec.rb +62 -0
- data/spec/security/certificate_cache_spec.rb +71 -0
- data/spec/security/certificate_spec.rb +49 -0
- data/spec/security/distinguished_name_spec.rb +46 -0
- data/spec/security/encrypted_document_spec.rb +55 -0
- data/spec/security/rsa_key_pair_spec.rb +55 -0
- data/spec/security/signature_spec.rb +66 -0
- data/spec/security/static_certificate_store_spec.rb +58 -0
- data/spec/sender_spec.rb +1045 -0
- data/spec/serialize/message_pack_spec.rb +131 -0
- data/spec/serialize/secure_serializer_spec.rb +132 -0
- data/spec/serialize/serializable_spec.rb +90 -0
- data/spec/serialize/serializer_spec.rb +197 -0
- data/spec/spec.opts +2 -0
- data/spec/spec.win32.opts +1 -0
- data/spec/spec_helper.rb +130 -0
- data/spec/tracer_spec.rb +114 -0
- metadata +447 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009-2011 RightScale, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
= RightAgent
|
2
|
+
|
3
|
+
= DESCRIPTION
|
4
|
+
|
5
|
+
== Synopsis
|
6
|
+
|
7
|
+
RightAgent provides a foundation for running an agent on a server to interface
|
8
|
+
in a secure fashion with other agents in the RightScale system using RightNet,
|
9
|
+
which operates in either HTTP or AMQP mode. When using HTTP, RightAgent
|
10
|
+
makes requests to RightApi servers and receives requests using long-polling or
|
11
|
+
WebSockets via the RightNet router. To respond to requests it posts to the
|
12
|
+
HTTP router. When using AMQP, RightAgent uses RabbitMQ as the message bus and
|
13
|
+
the RightNet router as the routing node to make requests; to receives requests
|
14
|
+
routed to it by the RightNet router, it establishes a queue on startup. The
|
15
|
+
packets are structured to invoke services in the agent represented by actors
|
16
|
+
and methods. The RightAgent may respond to these requests with a result packet
|
17
|
+
that the router then routes to the originator.
|
18
|
+
|
19
|
+
Refer to the wiki (https://github.com/rightscale/right_agent/wikis) for up-to-date
|
20
|
+
documentation.
|
21
|
+
|
22
|
+
Also use the built-in issues tracker (https://github.com/rightscale/right_agent/issues)
|
23
|
+
to report issues.
|
24
|
+
|
25
|
+
Maintained by the RightScale Teal Team
|
26
|
+
|
27
|
+
== Interface
|
28
|
+
|
29
|
+
A RightAgent exposes its services via actors and methods that are invoked by requests
|
30
|
+
packets it receives via its message queue. All RightAgents have a general purpose actor
|
31
|
+
named agent_manager that provides the following services:
|
32
|
+
|
33
|
+
* <b>agent_manager/ping</b>: Respond with basic status information to indicate that active
|
34
|
+
* <b>agent_manager/stats</b>: Retrieve statistics about agent operation
|
35
|
+
* <b>agent_manager/set_log_level</b>: Change log level of agent
|
36
|
+
* <b>agent_manager/execute</b>: Eval code in context of agent
|
37
|
+
* <b>agent_manager/connect</b>: Connect agent to additional broker or reconnect it to one
|
38
|
+
* <b>agent_manager/disconnect</b>: Disconnect agent from broker
|
39
|
+
|
40
|
+
RightAgent comes with several library modules for forming basic command line tools:
|
41
|
+
|
42
|
+
* <b>agent_deployer</b>: Build a configuration file for running the agent (rad tool)
|
43
|
+
* <b>agent_controller</b>: Manage an agent that has been configured (rnac tool)
|
44
|
+
* <b>stats_manager</b>: Display operation statistics for an agent (rstat tool)
|
45
|
+
* <b>log_level_manager</b>: Retrieve and set log level for an agent (rlog tool)
|
46
|
+
|
47
|
+
== Supported Configuration
|
48
|
+
|
49
|
+
RightAgent has been tested on EC2 instances running CentOS 5.2 and Ubuntu 8.10.
|
50
|
+
|
51
|
+
== Work in Progress
|
52
|
+
|
53
|
+
RightAgent is work in progress, expect more documentation and examples in the near future.
|
54
|
+
|
55
|
+
= ADDITIONAL RESOURCES
|
56
|
+
|
57
|
+
* [1] RabbitMQ is http://www.rabbitmq.com/documentation.html
|
58
|
+
|
59
|
+
= LICENSE
|
60
|
+
|
61
|
+
<b>RightAgent</b>
|
62
|
+
|
63
|
+
Copyright:: Copyright (c) 2011 RightScale, Inc.
|
64
|
+
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
66
|
+
a copy of this software and associated documentation files (the
|
67
|
+
'Software'), to deal in the Software without restriction, including
|
68
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
69
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
70
|
+
permit persons to whom the Software is furnished to do so, subject to
|
71
|
+
the following conditions:
|
72
|
+
|
73
|
+
The above copyright notice and this permission notice shall be
|
74
|
+
included in all copies or substantial portions of the Software.
|
75
|
+
|
76
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
77
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
78
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
79
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
80
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
81
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
82
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
#-- -*-ruby-*-
|
2
|
+
# Copyright: Copyright (c) 2010 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 NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
require 'bundler/setup'
|
26
|
+
require 'fileutils'
|
27
|
+
require 'rake'
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
require 'rake/rdoctask'
|
30
|
+
require 'rake/gempackagetask'
|
31
|
+
require 'rake/clean'
|
32
|
+
|
33
|
+
task :default => 'spec'
|
34
|
+
|
35
|
+
# == Gem packaging == #
|
36
|
+
module RightScale
|
37
|
+
class MultiPlatformGemTask
|
38
|
+
def self.gem_platform_override
|
39
|
+
@gem_platform_override
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.define(gem_platforms, spec_path, &callback)
|
43
|
+
gem_platforms.each do |gem_platform|
|
44
|
+
@gem_platform_override = gem_platform
|
45
|
+
callback.call(::Gem::Specification.load(spec_path))
|
46
|
+
end
|
47
|
+
ensure
|
48
|
+
@gem_platform_override = nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# multiply define gem and package task(s) using a gemspec with overridden gem
|
54
|
+
# platform value. this works because rake accumulates task actions instead of
|
55
|
+
# redefining them, so accumulated gem tasks will gem up all platforms. we need
|
56
|
+
# to produce multiple platform-specific .gem files because otherwise the gem
|
57
|
+
# dependencies for non-Linux platforms (i.e. Windows) are lost from the default
|
58
|
+
# .gem file produced on a Linux platform.
|
59
|
+
gemtask = nil
|
60
|
+
::RightScale::MultiPlatformGemTask.define(%w[linux mingw], 'right_agent.gemspec') do |spec|
|
61
|
+
gemtask = ::Rake::GemPackageTask.new(spec) do |gpt|
|
62
|
+
gpt.package_dir = ENV['PACKAGE_DIR'] || 'pkg'
|
63
|
+
|
64
|
+
# the following are used by 'package' task (but not by 'gem' task)
|
65
|
+
gpt.need_zip = !`which zip`.strip.empty? # not present on Windows by default
|
66
|
+
gpt.need_tar = true # some form of tar is required on Windows and Linux
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
directory gemtask.package_dir
|
71
|
+
|
72
|
+
CLEAN.include(gemtask.package_dir)
|
73
|
+
|
74
|
+
# == Unit tests == #
|
75
|
+
spec_opts_file = "\"#{File.dirname(__FILE__)}/spec/spec.opts\""
|
76
|
+
spec_opts_file = "\"#{File.dirname(__FILE__)}/spec/spec.win32.opts\"" if RUBY_PLATFORM =~ /mingw|mswin32/
|
77
|
+
RSPEC_OPTS = ['--options', spec_opts_file]
|
78
|
+
|
79
|
+
desc 'Run unit tests'
|
80
|
+
RSpec::Core::RakeTask.new do |t|
|
81
|
+
t.rspec_opts = RSPEC_OPTS
|
82
|
+
end
|
83
|
+
|
84
|
+
namespace :spec do
|
85
|
+
desc 'Run unit tests with RCov'
|
86
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
87
|
+
t.rspec_opts = RSPEC_OPTS
|
88
|
+
t.rcov = true
|
89
|
+
t.rcov_opts = %q[--exclude "spec"]
|
90
|
+
end
|
91
|
+
|
92
|
+
desc 'Print Specdoc for all unit tests'
|
93
|
+
RSpec::Core::RakeTask.new(:doc) do |t|
|
94
|
+
t.rspec_opts = ["--format", "documentation"]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# == Documentation == #
|
99
|
+
|
100
|
+
desc 'Generate API documentation to doc/rdocs/index.html'
|
101
|
+
Rake::RDocTask.new do |rd|
|
102
|
+
rd.rdoc_dir = 'doc/rdocs'
|
103
|
+
rd.main = 'README.rdoc'
|
104
|
+
rd.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
|
105
|
+
end
|
106
|
+
CLEAN.include('doc/rdocs')
|
107
|
+
|
108
|
+
# == Emacs integration ==
|
109
|
+
|
110
|
+
desc 'Rebuild TAGS file for emacs'
|
111
|
+
task :tags do
|
112
|
+
sh 'rtags -R lib spec'
|
113
|
+
end
|
data/lib/right_agent.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 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
|
+
# reuse minimal loader to ensure right_agent can safely be required after minimal.
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'right_agent', 'minimal'))
|
25
|
+
|
26
|
+
require 'json'
|
27
|
+
require 'openssl'
|
28
|
+
require 'right_amqp'
|
29
|
+
|
30
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'monkey_patches'))
|
31
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'protocol_version_mixin'))
|
32
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'payload_formatter'))
|
33
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'packets'))
|
34
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'enrollment_result'))
|
35
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'console'))
|
36
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'daemonize'))
|
37
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'exceptions'))
|
38
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'multiplexer'))
|
39
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'tracer'))
|
40
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'audit_formatter'))
|
41
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'serialize'))
|
42
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'security'))
|
43
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'operation_result'))
|
44
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'subprocess'))
|
45
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'agent_identity'))
|
46
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'agent_tag_manager'))
|
47
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'actor'))
|
48
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'actor_registry'))
|
49
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'dispatcher'))
|
50
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'dispatched_cache'))
|
51
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'pending_requests'))
|
52
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'offline_handler'))
|
53
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'connectivity_checker'))
|
54
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'sender'))
|
55
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'secure_identity'))
|
56
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'retryable_request'))
|
57
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'history'))
|
58
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'clients'))
|
59
|
+
require File.normalize_path(File.join(RIGHT_AGENT_BASE_DIR, 'agent'))
|
@@ -0,0 +1,182 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2013 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
|
+
module RightScale
|
24
|
+
|
25
|
+
# This mixin provides agent actor functionality.
|
26
|
+
#
|
27
|
+
# To use it simply include it your class containing the functionality to be exposed:
|
28
|
+
#
|
29
|
+
# class Foo
|
30
|
+
# include RightScale::Actor
|
31
|
+
# expose :bar
|
32
|
+
#
|
33
|
+
# def bar(payload)
|
34
|
+
# # ...
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# end
|
38
|
+
module Actor
|
39
|
+
|
40
|
+
# Callback invoked whenever Actor is included in another module or class.
|
41
|
+
#
|
42
|
+
# === Parameters
|
43
|
+
# base(Module):: Module that included Actor module
|
44
|
+
#
|
45
|
+
# === Return
|
46
|
+
# true:: Always return true
|
47
|
+
def self.included(base)
|
48
|
+
base.send :include, InstanceMethods
|
49
|
+
base.extend(ClassMethods)
|
50
|
+
end
|
51
|
+
|
52
|
+
module ClassMethods
|
53
|
+
|
54
|
+
# Construct default prefix by which actor is identified in requests
|
55
|
+
#
|
56
|
+
# === Return
|
57
|
+
# prefix(String):: Default prefix
|
58
|
+
def default_prefix
|
59
|
+
prefix = to_s.to_const_path
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add methods to list of services supported by actor and mark these methods
|
63
|
+
# as idempotent
|
64
|
+
#
|
65
|
+
# === Parameters
|
66
|
+
# methods(Array):: Symbol names for methods being exposed as actor idempotent services
|
67
|
+
#
|
68
|
+
# === Return
|
69
|
+
# true:: Always return true
|
70
|
+
def expose_idempotent(*methods)
|
71
|
+
@exposed ||= {}
|
72
|
+
methods.each do |m|
|
73
|
+
if @exposed[m] == false
|
74
|
+
Log.warning("Method #{m} declared both idempotent and non-idempotent, assuming non-idempotent")
|
75
|
+
else
|
76
|
+
@exposed[m] = true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Add methods to list of services supported by actor
|
83
|
+
# By default these methods are not idempotent
|
84
|
+
#
|
85
|
+
# === Parameters
|
86
|
+
# meths(Array):: Symbol names for methods being exposed as actor services
|
87
|
+
#
|
88
|
+
# === Return
|
89
|
+
# true:: Always return true
|
90
|
+
def expose_non_idempotent(*methods)
|
91
|
+
@exposed ||= {}
|
92
|
+
methods.each do |m|
|
93
|
+
Log.warning("Method #{m} declared both idempotent and non-idempotent, assuming non-idempotent") if @exposed[m]
|
94
|
+
@exposed[m] = false
|
95
|
+
end
|
96
|
+
true
|
97
|
+
end
|
98
|
+
|
99
|
+
alias :expose :expose_non_idempotent
|
100
|
+
|
101
|
+
# Get /prefix/method paths that actor responds to
|
102
|
+
#
|
103
|
+
# === Parameters
|
104
|
+
# prefix(String):: Prefix by which actor is identified in requests
|
105
|
+
#
|
106
|
+
# === Return
|
107
|
+
# (Array):: /prefix/method strings
|
108
|
+
def provides_for(prefix)
|
109
|
+
return [] unless @exposed
|
110
|
+
@exposed.each_key.select do |method|
|
111
|
+
if instance_methods.include?(method.to_s) or instance_methods.include?(method.to_sym)
|
112
|
+
true
|
113
|
+
else
|
114
|
+
Log.warning("Exposing non-existing method #{method} in actor #{prefix}")
|
115
|
+
false
|
116
|
+
end
|
117
|
+
end.map { |method| "/#{prefix}/#{method}".squeeze('/') }
|
118
|
+
end
|
119
|
+
|
120
|
+
# Determine whether actor method is idempotent
|
121
|
+
#
|
122
|
+
# === Parameters
|
123
|
+
# method(Symbol):: Name for actor method
|
124
|
+
#
|
125
|
+
# === Return
|
126
|
+
# (Boolean):: true if idempotent, false otherwise
|
127
|
+
def idempotent?(method)
|
128
|
+
@exposed[method] if @exposed
|
129
|
+
end
|
130
|
+
|
131
|
+
# Set method called when dispatching to this actor fails
|
132
|
+
#
|
133
|
+
# The callback method is required to accept the following parameters:
|
134
|
+
# method(Symbol):: Actor method being dispatched to
|
135
|
+
# deliverable(Packet):: Packet delivered to dispatcher
|
136
|
+
# exception(Exception):: Exception raised
|
137
|
+
#
|
138
|
+
# === Parameters
|
139
|
+
# proc(Proc|Symbol|String):: Procedure to be called on exception
|
140
|
+
#
|
141
|
+
# === Block
|
142
|
+
# Block to be executed if no Proc provided
|
143
|
+
#
|
144
|
+
# === Return
|
145
|
+
# @exception_callback(Proc):: Callback procedure
|
146
|
+
def on_exception(proc = nil, &blk)
|
147
|
+
raise 'No callback provided for on_exception' unless proc || blk
|
148
|
+
@exception_callback = proc || blk
|
149
|
+
end
|
150
|
+
|
151
|
+
# Get exception callback procedure
|
152
|
+
#
|
153
|
+
# === Return
|
154
|
+
# @exception_callback(Proc):: Callback procedure
|
155
|
+
def exception_callback
|
156
|
+
@exception_callback
|
157
|
+
end
|
158
|
+
|
159
|
+
end # ClassMethods
|
160
|
+
|
161
|
+
module InstanceMethods
|
162
|
+
|
163
|
+
# Agents using actors are required to define a Sender class providing linkage
|
164
|
+
# to a class that can perform the following send functions
|
165
|
+
|
166
|
+
# Helper method to send a request to one or more targets with no response expected
|
167
|
+
def send_push(*args)
|
168
|
+
Sender.instance.send_push(*args)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Helper method to send a request to a single target with a response expected
|
172
|
+
# The request is retried if the response is not received in a reasonable amount of time
|
173
|
+
# The request is allowed to expire per the agent's configured time-to-live, typically 1 minute
|
174
|
+
def send_request(*args, &blk)
|
175
|
+
Sender.instance.send_request(*args, &blk)
|
176
|
+
end
|
177
|
+
|
178
|
+
end # InstanceMethods
|
179
|
+
|
180
|
+
end # Actor
|
181
|
+
|
182
|
+
end # RightScale
|