right_agent 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +78 -0
- data/Rakefile +86 -0
- data/lib/right_agent.rb +66 -0
- data/lib/right_agent/actor.rb +163 -0
- data/lib/right_agent/actor_registry.rb +76 -0
- data/lib/right_agent/actors/agent_manager.rb +189 -0
- data/lib/right_agent/agent.rb +735 -0
- data/lib/right_agent/agent_config.rb +403 -0
- data/lib/right_agent/agent_identity.rb +209 -0
- data/lib/right_agent/agent_tags_manager.rb +213 -0
- data/lib/right_agent/audit_formatter.rb +107 -0
- data/lib/right_agent/broker_client.rb +683 -0
- data/lib/right_agent/command.rb +30 -0
- data/lib/right_agent/command/agent_manager_commands.rb +134 -0
- data/lib/right_agent/command/command_client.rb +136 -0
- data/lib/right_agent/command/command_constants.rb +42 -0
- data/lib/right_agent/command/command_io.rb +128 -0
- data/lib/right_agent/command/command_parser.rb +87 -0
- data/lib/right_agent/command/command_runner.rb +105 -0
- data/lib/right_agent/command/command_serializer.rb +63 -0
- data/lib/right_agent/console.rb +65 -0
- data/lib/right_agent/core_payload_types.rb +42 -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 +90 -0
- data/lib/right_agent/core_payload_types/event_categories.rb +38 -0
- data/lib/right_agent/core_payload_types/executable_bundle.rb +138 -0
- data/lib/right_agent/core_payload_types/login_policy.rb +72 -0
- data/lib/right_agent/core_payload_types/login_user.rb +62 -0
- data/lib/right_agent/core_payload_types/planned_volume.rb +94 -0
- data/lib/right_agent/core_payload_types/recipe_instantiation.rb +60 -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 +73 -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/dispatcher.rb +348 -0
- data/lib/right_agent/enrollment_result.rb +217 -0
- data/lib/right_agent/exceptions.rb +30 -0
- data/lib/right_agent/ha_broker_client.rb +1278 -0
- data/lib/right_agent/idempotent_request.rb +140 -0
- data/lib/right_agent/log.rb +418 -0
- data/lib/right_agent/monkey_patches.rb +29 -0
- data/lib/right_agent/monkey_patches/amqp_patch.rb +274 -0
- data/lib/right_agent/monkey_patches/ruby_patch.rb +49 -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/singleton_patch.rb +46 -0
- data/lib/right_agent/monkey_patches/ruby_patch/string_patch.rb +107 -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 +90 -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 +91 -0
- data/lib/right_agent/operation_result.rb +270 -0
- data/lib/right_agent/packets.rb +637 -0
- data/lib/right_agent/payload_formatter.rb +104 -0
- data/lib/right_agent/pid_file.rb +159 -0
- data/lib/right_agent/platform.rb +319 -0
- data/lib/right_agent/platform/darwin.rb +227 -0
- data/lib/right_agent/platform/linux.rb +268 -0
- data/lib/right_agent/platform/windows.rb +1204 -0
- data/lib/right_agent/scripts/agent_controller.rb +522 -0
- data/lib/right_agent/scripts/agent_deployer.rb +379 -0
- data/lib/right_agent/scripts/common_parser.rb +153 -0
- data/lib/right_agent/scripts/log_level_manager.rb +193 -0
- data/lib/right_agent/scripts/stats_manager.rb +256 -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 +63 -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 +84 -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 +69 -0
- data/lib/right_agent/sender.rb +937 -0
- data/lib/right_agent/serialize.rb +29 -0
- data/lib/right_agent/serialize/message_pack.rb +102 -0
- data/lib/right_agent/serialize/secure_serializer.rb +131 -0
- data/lib/right_agent/serialize/secure_serializer_initializer.rb +47 -0
- data/lib/right_agent/serialize/serializable.rb +135 -0
- data/lib/right_agent/serialize/serializer.rb +149 -0
- data/lib/right_agent/stats_helper.rb +731 -0
- data/lib/right_agent/subprocess.rb +38 -0
- data/lib/right_agent/tracer.rb +124 -0
- data/right_agent.gemspec +60 -0
- data/spec/actor_registry_spec.rb +81 -0
- data/spec/actor_spec.rb +99 -0
- data/spec/agent_config_spec.rb +226 -0
- data/spec/agent_identity_spec.rb +75 -0
- data/spec/agent_spec.rb +571 -0
- data/spec/broker_client_spec.rb +961 -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 +72 -0
- data/spec/command/command_serializer_spec.rb +51 -0
- data/spec/core_payload_types/dev_repositories_spec.rb +64 -0
- data/spec/core_payload_types/executable_bundle_spec.rb +59 -0
- data/spec/core_payload_types/login_user_spec.rb +98 -0
- data/spec/core_payload_types/right_script_attachment_spec.rb +65 -0
- data/spec/core_payload_types/spec_helper.rb +23 -0
- data/spec/dispatcher_spec.rb +372 -0
- data/spec/enrollment_result_spec.rb +53 -0
- data/spec/ha_broker_client_spec.rb +1673 -0
- data/spec/idempotent_request_spec.rb +136 -0
- data/spec/log_spec.rb +177 -0
- data/spec/monkey_patches/amqp_patch_spec.rb +100 -0
- data/spec/monkey_patches/eventmachine_spec.rb +62 -0
- data/spec/monkey_patches/string_patch_spec.rb +99 -0
- data/spec/multiplexer_spec.rb +48 -0
- data/spec/operation_result_spec.rb +171 -0
- data/spec/packets_spec.rb +418 -0
- data/spec/platform/platform_spec.rb +60 -0
- data/spec/results_mock.rb +45 -0
- data/spec/secure_identity_spec.rb +50 -0
- data/spec/security/cached_certificate_store_proxy_spec.rb +56 -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 +52 -0
- data/spec/sender_spec.rb +887 -0
- data/spec/serialize/message_pack_spec.rb +131 -0
- data/spec/serialize/secure_serializer_spec.rb +102 -0
- data/spec/serialize/serializable_spec.rb +90 -0
- data/spec/serialize/serializer_spec.rb +174 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +77 -0
- data/spec/stats_helper_spec.rb +681 -0
- data/spec/tracer_spec.rb +114 -0
- metadata +320 -0
@@ -0,0 +1,87 @@
|
|
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
|
+
|
24
|
+
module RightScale
|
25
|
+
|
26
|
+
class CommandParser
|
27
|
+
|
28
|
+
# Register callback block
|
29
|
+
#
|
30
|
+
# === Block
|
31
|
+
# Block that will get called back whenever a command is successfully parsed
|
32
|
+
#
|
33
|
+
# === Raise
|
34
|
+
# (RightScale::Exceptions::Argument): If block is missing
|
35
|
+
def initialize &block
|
36
|
+
raise RightScale::Exceptions::Argument, 'Missing handler block' unless block
|
37
|
+
@callback = block
|
38
|
+
@buildup = ''
|
39
|
+
end
|
40
|
+
|
41
|
+
# Parse given input
|
42
|
+
# May cause multiple callbacks if multiple commands are successfully parsed
|
43
|
+
# Callback happens in next EM tick
|
44
|
+
#
|
45
|
+
# === Parameters
|
46
|
+
# chunk(String):: Chunck of serialized command(s) to be parsed
|
47
|
+
#
|
48
|
+
# === Return
|
49
|
+
# true:: If callback was called at least once
|
50
|
+
# false:: Otherwise
|
51
|
+
def parse_chunk(chunk)
|
52
|
+
@buildup << chunk
|
53
|
+
chunks = @buildup.split(CommandSerializer::SEPARATOR, -1)
|
54
|
+
if do_call = chunks.size > 1
|
55
|
+
commands = []
|
56
|
+
(0..chunks.size - 2).each do |i|
|
57
|
+
begin
|
58
|
+
commands << CommandSerializer.load(chunks[i])
|
59
|
+
rescue Exception => e
|
60
|
+
# log any exceptions caused by serializing individual chunks instead
|
61
|
+
# of halting EM. each command is discrete so we need to keep trying
|
62
|
+
# so long as there are more commands to process (although subsequent
|
63
|
+
# commands may lack context if previous commands failed).
|
64
|
+
Log.error("Failed parsing command chunk", e, :trace)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
commands.each do |cmd|
|
68
|
+
EM.next_tick do
|
69
|
+
begin
|
70
|
+
@callback.call(cmd)
|
71
|
+
rescue Exception => e
|
72
|
+
# log any exceptions raised by callback instead of halting EM.
|
73
|
+
Log.error("Failed executing parsed command", e, :trace)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
@buildup = chunks.last
|
78
|
+
end
|
79
|
+
do_call
|
80
|
+
rescue Exception => e
|
81
|
+
# log any other exceptions instead of halting EM.
|
82
|
+
Log.error("Failed parsing command chunk", e, :trace)
|
83
|
+
end
|
84
|
+
|
85
|
+
end # CommandParser
|
86
|
+
|
87
|
+
end # RightScale
|
@@ -0,0 +1,105 @@
|
|
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
|
+
module RightScale
|
24
|
+
|
25
|
+
# Run commands exposed by an agent
|
26
|
+
# External processes can send commands through a socket with the specified port
|
27
|
+
class CommandRunner
|
28
|
+
|
29
|
+
class << self
|
30
|
+
# (Integer) Port command runner is listening on
|
31
|
+
attr_reader :listen_port
|
32
|
+
|
33
|
+
# (String) Cookie used by command protocol
|
34
|
+
attr_reader :cookie
|
35
|
+
end
|
36
|
+
|
37
|
+
# Command runner listens to commands and deserializes them using YAML
|
38
|
+
# Each command is expected to be a hash containing the :name and :options keys
|
39
|
+
#
|
40
|
+
# === Parameters
|
41
|
+
# socket_port(Integer):: Base socket port on which to listen for connection,
|
42
|
+
# increment and retry if port already taken
|
43
|
+
# identity(String):: Agent identity
|
44
|
+
# commands(Hash):: Commands exposed by agent
|
45
|
+
#
|
46
|
+
# === Return
|
47
|
+
# cmd_options[:cookie](String):: Command protocol cookie
|
48
|
+
# cmd_options[:listen_port](Integer):: Command server listen port
|
49
|
+
#
|
50
|
+
# === Raise
|
51
|
+
# (RightScale::Exceptions::Application):: If +start+ has already been called and +stop+ hasn't since
|
52
|
+
def self.start(socket_port, identity, commands)
|
53
|
+
cmd_options = nil
|
54
|
+
@listen_port = socket_port
|
55
|
+
begin
|
56
|
+
CommandIO.instance.listen(socket_port) do |c, conn|
|
57
|
+
begin
|
58
|
+
cmd_cookie = c[:cookie]
|
59
|
+
if cmd_cookie == @cookie
|
60
|
+
cmd_name = c[:name].to_sym
|
61
|
+
if commands.include?(cmd_name)
|
62
|
+
commands[cmd_name].call(c, conn)
|
63
|
+
else
|
64
|
+
Log.warning("Unknown command '#{cmd_name}', known commands: #{commands.keys.join(', ')}")
|
65
|
+
end
|
66
|
+
else
|
67
|
+
Log.error("Invalid cookie used by command protocol client (#{cmd_cookie})")
|
68
|
+
end
|
69
|
+
rescue Exception => e
|
70
|
+
Log.warning("Command failed (#{e.message}) at\n#{e.backtrace.join("\n")}")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
@cookie = AgentIdentity.generate
|
75
|
+
cmd_options = { :listen_port => @listen_port, :cookie => @cookie }
|
76
|
+
# Now update pid file with command port and cookie
|
77
|
+
pid_file = PidFile.new(identity)
|
78
|
+
if pid_file.exists?
|
79
|
+
pid_file.set_command_options(cmd_options)
|
80
|
+
else
|
81
|
+
Log.warning("Failed to update listen port in PID file - no pid file found for agent with identity #{identity}")
|
82
|
+
end
|
83
|
+
|
84
|
+
Log.info("[setup] Command server started listening on port #{@listen_port}")
|
85
|
+
rescue Exceptions::IO
|
86
|
+
# Port already taken, increment and retry
|
87
|
+
cmd_options = start(socket_port + 1, identity, commands)
|
88
|
+
end
|
89
|
+
|
90
|
+
cmd_options
|
91
|
+
end
|
92
|
+
|
93
|
+
# Stop command runner, cleanup all opened file descriptors and delete pipe
|
94
|
+
#
|
95
|
+
# === Return
|
96
|
+
# true:: If command listener was listening
|
97
|
+
# false:: Otherwise
|
98
|
+
def self.stop
|
99
|
+
CommandIO.instance.stop_listening
|
100
|
+
Log.info("[stop] Command server stopped listening")
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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
|
+
|
24
|
+
module RightScale
|
25
|
+
|
26
|
+
class CommandSerializer
|
27
|
+
|
28
|
+
# String appended to serialized data to delimit between commands
|
29
|
+
SEPARATOR = "\n#GO\n"
|
30
|
+
|
31
|
+
# Serialize given command so it can be sent to command listener
|
32
|
+
#
|
33
|
+
# === Parameters
|
34
|
+
# command(Object):: Command to serialize
|
35
|
+
#
|
36
|
+
# === Return
|
37
|
+
# data(String):: Corresponding serialized data
|
38
|
+
def self.dump(command)
|
39
|
+
data = YAML::dump(command)
|
40
|
+
data += SEPARATOR
|
41
|
+
end
|
42
|
+
|
43
|
+
# Deserialize command that was previously serialized with +dump+
|
44
|
+
#
|
45
|
+
# === Parameters
|
46
|
+
# data(String):: String containing serialized data
|
47
|
+
#
|
48
|
+
# === Return
|
49
|
+
# command(Object):: Deserialized command
|
50
|
+
#
|
51
|
+
# === Raise
|
52
|
+
# (RightScale::Exceptions::IO): If serialized data is incorrect
|
53
|
+
def self.load(data)
|
54
|
+
command = YAML::load(data)
|
55
|
+
raise RightScale::Exceptions::IO, "Invalid serialized command:\n#{data}" unless command
|
56
|
+
command
|
57
|
+
rescue RightScale::Exceptions::IO
|
58
|
+
raise
|
59
|
+
rescue Exception => e
|
60
|
+
raise RightScale::Exceptions::IO, "Invalid serialized command: #{e.message}\n#{data}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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
|
+
module RightScale
|
24
|
+
|
25
|
+
module ConsoleHelper
|
26
|
+
def self.included(base)
|
27
|
+
@@base = base
|
28
|
+
end
|
29
|
+
|
30
|
+
def start_console
|
31
|
+
puts "Starting #{@@base.name.split(":").last.downcase} console (#{self.identity})"
|
32
|
+
Thread.new do
|
33
|
+
Console.start(self)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end # ConsoleHelper
|
38
|
+
|
39
|
+
module Console
|
40
|
+
class << self; attr_accessor :instance; end
|
41
|
+
|
42
|
+
def self.start(binding, quit_on_exit=true)
|
43
|
+
require 'irb'
|
44
|
+
old_args = ARGV.dup
|
45
|
+
ARGV.replace ["--simple-prompt"]
|
46
|
+
|
47
|
+
IRB.setup(nil)
|
48
|
+
self.instance = IRB::Irb.new(IRB::WorkSpace.new(binding))
|
49
|
+
|
50
|
+
@CONF = IRB.instance_variable_get(:@CONF)
|
51
|
+
@CONF[:IRB_RC].call self.instance.context if @CONF[:IRB_RC]
|
52
|
+
@CONF[:MAIN_CONTEXT] = self.instance.context
|
53
|
+
|
54
|
+
catch(:IRB_EXIT) { self.instance.eval_input }
|
55
|
+
ensure
|
56
|
+
ARGV.replace old_args
|
57
|
+
# Clean up tty settings in some evil, evil cases
|
58
|
+
begin; catch(:IRB_EXIT) { irb_exit }; rescue Exception; end
|
59
|
+
# Make agent exit when irb does
|
60
|
+
EM.stop if EM.reactor_running? && quit_on_exit
|
61
|
+
end
|
62
|
+
|
63
|
+
end # Console
|
64
|
+
|
65
|
+
end # RightScale
|
@@ -0,0 +1,42 @@
|
|
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
|
+
|
24
|
+
CORE_PAYLOAD_TYPES_BASE_DIR = File.join(File.dirname(__FILE__), 'core_payload_types')
|
25
|
+
|
26
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'cookbook'))
|
27
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'cookbook_repository'))
|
28
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'cookbook_sequence'))
|
29
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'cookbook_position'))
|
30
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'dev_repositories'))
|
31
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'executable_bundle'))
|
32
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'event_categories'))
|
33
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'recipe_instantiation'))
|
34
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'repositories_bundle'))
|
35
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'software_repository_instantiation'))
|
36
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'right_script_attachment'))
|
37
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'right_script_instantiation'))
|
38
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'login_policy'))
|
39
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'login_user'))
|
40
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'secure_document'))
|
41
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'secure_document_location'))
|
42
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'planned_volume'))
|
@@ -0,0 +1,61 @@
|
|
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
|
+
|
24
|
+
module RightScale
|
25
|
+
|
26
|
+
# Individual cookbook
|
27
|
+
class Cookbook
|
28
|
+
|
29
|
+
include Serializable
|
30
|
+
|
31
|
+
# (String) Cookbook SHA hash.
|
32
|
+
attr_accessor :hash
|
33
|
+
|
34
|
+
# (String) Authentication token
|
35
|
+
attr_accessor :token
|
36
|
+
|
37
|
+
# (String) User readable cookbook name
|
38
|
+
attr_accessor :name
|
39
|
+
|
40
|
+
# Initialize fields from given arguments
|
41
|
+
def initialize(*args)
|
42
|
+
@hash = args[0] if args.size > 0
|
43
|
+
@token = args[1] if args.size > 1
|
44
|
+
@name = args[2] if args.size > 2
|
45
|
+
end
|
46
|
+
|
47
|
+
# Array of serialized fields given to constructor
|
48
|
+
def serialized_members
|
49
|
+
[ @hash, @token, @name ]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Human friendly name used for audits
|
53
|
+
#
|
54
|
+
# === Return
|
55
|
+
# name(String):: Cookbook repository display name
|
56
|
+
def display_name
|
57
|
+
name = "Cookbook #{@name}:#{@hash}"
|
58
|
+
end
|
59
|
+
alias :to_s :display_name
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright: Copyright (c) 2010-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 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
|
+
module RightScale
|
25
|
+
# Cookbook / position pairs.
|
26
|
+
class CookbookPosition
|
27
|
+
include Serializable
|
28
|
+
|
29
|
+
# (String) relative position in the filesystem that the cookbook
|
30
|
+
# should be expanded at.
|
31
|
+
attr_accessor :position
|
32
|
+
# (Cookbook) cookbook to expand.
|
33
|
+
attr_accessor :cookbook
|
34
|
+
|
35
|
+
# Initialize fields from given arguments
|
36
|
+
def initialize(*args)
|
37
|
+
@position = args[0]
|
38
|
+
@cookbook = args[1] if args.size > 1
|
39
|
+
end
|
40
|
+
|
41
|
+
# Array of serialized fields given to constructor
|
42
|
+
def serialized_members
|
43
|
+
[ @position, @cookbook ]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|