right_agent 2.0.7-x86-mingw32
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/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
@@ -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,44 @@
|
|
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_repository'))
|
31
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'dev_repositories'))
|
32
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'executable_bundle'))
|
33
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'event_categories'))
|
34
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'recipe_instantiation'))
|
35
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'repositories_bundle'))
|
36
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'software_repository_instantiation'))
|
37
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'right_script_attachment'))
|
38
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'right_script_instantiation'))
|
39
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'login_policy'))
|
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'))
|
42
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'secure_document'))
|
43
|
+
require File.normalize_path(File.join(CORE_PAYLOAD_TYPES_BASE_DIR, 'secure_document_location'))
|
44
|
+
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
|
@@ -0,0 +1,116 @@
|
|
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
|
+
# Cookbook repository
|
27
|
+
class CookbookRepository
|
28
|
+
|
29
|
+
include Serializable
|
30
|
+
|
31
|
+
# List of characters used to build cookbooks sha1 hash path component
|
32
|
+
CHARS = ("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a
|
33
|
+
|
34
|
+
# (Symbol) Type of repository: one of :git, :svn, :download or :local
|
35
|
+
# * :git denotes a 'git' repository that should be retrieved via 'git clone'
|
36
|
+
# * :svn denotes a 'svn' repository that should be retrieved via 'svn checkout'
|
37
|
+
# * :download denotes a tar ball that should be retrieved via HTTP GET (HTTPS if url starts with https://)
|
38
|
+
# * :local denotes an already available cookbook (useful for testing)
|
39
|
+
attr_accessor :repo_type
|
40
|
+
|
41
|
+
# (String) URI to repository (e.g. git://github.com/opscode/chef-repo.git)
|
42
|
+
attr_accessor :url
|
43
|
+
|
44
|
+
# (String) git commit or svn branch that should be used to retrieve repository
|
45
|
+
# Use 'master' for git and 'trunk' for svn if tag is nil.
|
46
|
+
# Not used for raw repositories.
|
47
|
+
attr_accessor :tag
|
48
|
+
|
49
|
+
# (Array) Path to cookbooks inside repostory
|
50
|
+
# Append to the location of the repository on disk prior to running chef.
|
51
|
+
# Optional (use location of repository as cookbook path if nil)
|
52
|
+
attr_accessor :cookbooks_path
|
53
|
+
|
54
|
+
# (String) Private SSH key used to retrieve git repositories
|
55
|
+
# Not used for svn and raw repositories.
|
56
|
+
attr_accessor :ssh_key
|
57
|
+
|
58
|
+
# (String) Username used to retrieve svn and raw repositories
|
59
|
+
# Not used for git repositories.
|
60
|
+
attr_accessor :username
|
61
|
+
|
62
|
+
# (String) Password used to retrieve svn and raw repositories
|
63
|
+
# Not used for git repositories.
|
64
|
+
attr_accessor :password
|
65
|
+
|
66
|
+
# Initialize fields from given arguments
|
67
|
+
def initialize(*args)
|
68
|
+
@repo_type = args[0].to_sym
|
69
|
+
@url = args[1] if args.size > 1
|
70
|
+
@tag = args[2] if args.size > 2
|
71
|
+
@cookbooks_path = args[3] if args.size > 3
|
72
|
+
@ssh_key = args[4] if args.size > 4
|
73
|
+
@username = args[5] if args.size > 5
|
74
|
+
@password = args[6] if args.size > 6
|
75
|
+
end
|
76
|
+
|
77
|
+
# Instantiate from hash
|
78
|
+
# Keys of hash should be the corresponding symolized field name
|
79
|
+
#
|
80
|
+
# === Parameters
|
81
|
+
# h(Hash):: Hash of values used to initialize cookbook repository
|
82
|
+
#
|
83
|
+
# === Return
|
84
|
+
# repo(RightScale::CookbookRepository):: Corresponding instance
|
85
|
+
def self.from_hash(h)
|
86
|
+
repo = new(h[:repo_type], h[:url], h[:tag], h[:cookbooks_path], h[:ssh_key], h[:username], h[:password])
|
87
|
+
end
|
88
|
+
|
89
|
+
# Array of serialized fields given to constructor
|
90
|
+
def serialized_members
|
91
|
+
[ @repo_type, @url, @tag, @cookbooks_path, @ssh_key, @username, @password ]
|
92
|
+
end
|
93
|
+
|
94
|
+
# Human friendly name used for audits
|
95
|
+
#
|
96
|
+
# === Return
|
97
|
+
# name(String):: Cookbook repository display name
|
98
|
+
def display_name
|
99
|
+
name = @url + (@tag && !@tag.empty? ? ":#{@tag}" : '')
|
100
|
+
end
|
101
|
+
alias :to_s :display_name
|
102
|
+
|
103
|
+
# SVN username or git SSH key
|
104
|
+
# Provide compatibility for scraper
|
105
|
+
def first_credential
|
106
|
+
@ssh_key || @username
|
107
|
+
end
|
108
|
+
|
109
|
+
# SVN password
|
110
|
+
# Provide compatibility for scraper
|
111
|
+
def second_credential
|
112
|
+
@password
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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
|
+
# Sequence of cookbooks and where to put them.
|
26
|
+
class CookbookSequence
|
27
|
+
include Serializable
|
28
|
+
|
29
|
+
# (Array) relative cookbook paths to use from the repository root.
|
30
|
+
attr_accessor :paths
|
31
|
+
# (Array) CookbookPosition objects for each cookbook.
|
32
|
+
attr_accessor :positions
|
33
|
+
# (String) Hash for the repository this came from
|
34
|
+
attr_accessor :hash
|
35
|
+
|
36
|
+
# Initialize fields from given arguments
|
37
|
+
def initialize(*args)
|
38
|
+
@paths = args[0]
|
39
|
+
@positions = args[1] if args.size > 1
|
40
|
+
@hash = args[2] if args.size > 2
|
41
|
+
end
|
42
|
+
|
43
|
+
# Array of serialized fields given to constructor
|
44
|
+
def serialized_members
|
45
|
+
[ @paths, @positions, @hash ]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Reorder @positions so it respects @path. The comparison rule is
|
49
|
+
# as follows:
|
50
|
+
# - for two pairs of cookbooks [a_pos, a_cookbook], [b_pos, b_cookbook]
|
51
|
+
# - let a_index be the index of the first element of cookbooks_path that is a prefix for a_pos.
|
52
|
+
# - let b_index be similarly defined on b_pos.
|
53
|
+
# - if a_index != b_index, sort on a_index and b_index.
|
54
|
+
# - otherwise lexically sort on a_pos and b_pos.
|
55
|
+
def sort_by_path!
|
56
|
+
indices = @positions.map {|a|
|
57
|
+
@paths.index(@paths.find {|p| a.position.start_with? p})
|
58
|
+
}
|
59
|
+
@positions = indices.zip(@positions).sort {|a, b|
|
60
|
+
aindex, acb = a
|
61
|
+
bindex, bcb = b
|
62
|
+
if aindex == bindex
|
63
|
+
acb.position <=> bcb.position
|
64
|
+
else
|
65
|
+
aindex <=> bindex
|
66
|
+
end
|
67
|
+
}.map {|p| p.last}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,100 @@
|
|
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
|
+
require File.join(File.dirname(__FILE__), 'dev_repository')
|
25
|
+
|
26
|
+
module RightScale
|
27
|
+
# Sequence of cookbooks to be checked out on the instance.
|
28
|
+
class DevRepositories
|
29
|
+
include Serializable
|
30
|
+
|
31
|
+
attr_accessor :repositories
|
32
|
+
|
33
|
+
# Initialize fields from given arguments
|
34
|
+
def initialize(*args)
|
35
|
+
@repositories = args[0] || {}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Array of serialized fields given to constructor
|
39
|
+
def serialized_members
|
40
|
+
[ @repositories ]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Add a repository...
|
44
|
+
#
|
45
|
+
# === Parameters
|
46
|
+
# (Hash):: collection of repos to be checked out on the instance
|
47
|
+
# :repo_sha (String):: the hash id (SHA) of the repository
|
48
|
+
# :repo_detail (Hash):: info needed to checkout this repo
|
49
|
+
# {
|
50
|
+
# <Symbol> Type of repository: one of :git, :svn, :download or :local
|
51
|
+
# * :git denotes a 'git' repository that should be retrieved via 'git clone'
|
52
|
+
# * :svn denotes a 'svn' repository that should be retrieved via 'svn checkout'
|
53
|
+
# * :download denotes a tar ball that should be retrieved via HTTP GET (HTTPS if uri starts with https://)
|
54
|
+
# * :local denotes cookbook that is already local and doesn't need to be retrieved
|
55
|
+
# :repo_type => <Symbol>,
|
56
|
+
# <String> URL to repository (e.g. git://github.com/opscode/chef-repo.git)
|
57
|
+
# :url => <String>,
|
58
|
+
# <String> git commit or svn branch that should be used to retrieve repository
|
59
|
+
# Optional, use 'master' for git and 'trunk' for svn if tag is nil.
|
60
|
+
# Not used for raw repositories.
|
61
|
+
# :tag => <String>,
|
62
|
+
# <Array> Path to cookbooks inside repostory
|
63
|
+
# Optional (use location of repository as cookbook path if nil)
|
64
|
+
# :cookbooks_path => <Array>,
|
65
|
+
# <String> Private SSH key used to retrieve git repositories
|
66
|
+
# Optional, not used for svn and raw repositories.
|
67
|
+
# :ssh_key => <String>,
|
68
|
+
# <String> Username used to retrieve svn and raw repositories
|
69
|
+
# Optional, not used for git repositories.
|
70
|
+
# :username => <String>,
|
71
|
+
# <String> Password used to retrieve svn and raw repositories
|
72
|
+
# Optional, not used for git repositories.
|
73
|
+
# :password => <String>
|
74
|
+
# }
|
75
|
+
# :cookbook_positions (Array):: List of CookbookPositions to be developed. Represents the subset of cookbooks identified as the "dev cookbooks"
|
76
|
+
#
|
77
|
+
# === Return
|
78
|
+
# result(Hash):: The entry added to the collection of repositories
|
79
|
+
def add_repo(repo_sha, repo_detail, cookbook_positions)
|
80
|
+
@repositories ||= {}
|
81
|
+
@repositories[repo_sha] = DevRepository.new(repo_detail[:repo_type],
|
82
|
+
repo_detail[:url],
|
83
|
+
repo_detail[:tag],
|
84
|
+
repo_detail[:cookboooks_path],
|
85
|
+
repo_detail[:ssh_key],
|
86
|
+
repo_detail[:username],
|
87
|
+
repo_detail[:password],
|
88
|
+
repo_sha,
|
89
|
+
cookbook_positions)
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# === Return
|
94
|
+
# (Boolean):: true if there are no repositories, false otherwise
|
95
|
+
def empty?
|
96
|
+
@repositories.count == 0
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|