right_agent 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +78 -0
  3. data/Rakefile +86 -0
  4. data/lib/right_agent.rb +66 -0
  5. data/lib/right_agent/actor.rb +163 -0
  6. data/lib/right_agent/actor_registry.rb +76 -0
  7. data/lib/right_agent/actors/agent_manager.rb +189 -0
  8. data/lib/right_agent/agent.rb +735 -0
  9. data/lib/right_agent/agent_config.rb +403 -0
  10. data/lib/right_agent/agent_identity.rb +209 -0
  11. data/lib/right_agent/agent_tags_manager.rb +213 -0
  12. data/lib/right_agent/audit_formatter.rb +107 -0
  13. data/lib/right_agent/broker_client.rb +683 -0
  14. data/lib/right_agent/command.rb +30 -0
  15. data/lib/right_agent/command/agent_manager_commands.rb +134 -0
  16. data/lib/right_agent/command/command_client.rb +136 -0
  17. data/lib/right_agent/command/command_constants.rb +42 -0
  18. data/lib/right_agent/command/command_io.rb +128 -0
  19. data/lib/right_agent/command/command_parser.rb +87 -0
  20. data/lib/right_agent/command/command_runner.rb +105 -0
  21. data/lib/right_agent/command/command_serializer.rb +63 -0
  22. data/lib/right_agent/console.rb +65 -0
  23. data/lib/right_agent/core_payload_types.rb +42 -0
  24. data/lib/right_agent/core_payload_types/cookbook.rb +61 -0
  25. data/lib/right_agent/core_payload_types/cookbook_position.rb +46 -0
  26. data/lib/right_agent/core_payload_types/cookbook_repository.rb +116 -0
  27. data/lib/right_agent/core_payload_types/cookbook_sequence.rb +70 -0
  28. data/lib/right_agent/core_payload_types/dev_repositories.rb +90 -0
  29. data/lib/right_agent/core_payload_types/event_categories.rb +38 -0
  30. data/lib/right_agent/core_payload_types/executable_bundle.rb +138 -0
  31. data/lib/right_agent/core_payload_types/login_policy.rb +72 -0
  32. data/lib/right_agent/core_payload_types/login_user.rb +62 -0
  33. data/lib/right_agent/core_payload_types/planned_volume.rb +94 -0
  34. data/lib/right_agent/core_payload_types/recipe_instantiation.rb +60 -0
  35. data/lib/right_agent/core_payload_types/repositories_bundle.rb +50 -0
  36. data/lib/right_agent/core_payload_types/right_script_attachment.rb +95 -0
  37. data/lib/right_agent/core_payload_types/right_script_instantiation.rb +73 -0
  38. data/lib/right_agent/core_payload_types/secure_document.rb +66 -0
  39. data/lib/right_agent/core_payload_types/secure_document_location.rb +63 -0
  40. data/lib/right_agent/core_payload_types/software_repository_instantiation.rb +61 -0
  41. data/lib/right_agent/daemonize.rb +35 -0
  42. data/lib/right_agent/dispatcher.rb +348 -0
  43. data/lib/right_agent/enrollment_result.rb +217 -0
  44. data/lib/right_agent/exceptions.rb +30 -0
  45. data/lib/right_agent/ha_broker_client.rb +1278 -0
  46. data/lib/right_agent/idempotent_request.rb +140 -0
  47. data/lib/right_agent/log.rb +418 -0
  48. data/lib/right_agent/monkey_patches.rb +29 -0
  49. data/lib/right_agent/monkey_patches/amqp_patch.rb +274 -0
  50. data/lib/right_agent/monkey_patches/ruby_patch.rb +49 -0
  51. data/lib/right_agent/monkey_patches/ruby_patch/array_patch.rb +29 -0
  52. data/lib/right_agent/monkey_patches/ruby_patch/darwin_patch.rb +24 -0
  53. data/lib/right_agent/monkey_patches/ruby_patch/linux_patch.rb +24 -0
  54. data/lib/right_agent/monkey_patches/ruby_patch/linux_patch/file_patch.rb +30 -0
  55. data/lib/right_agent/monkey_patches/ruby_patch/object_patch.rb +49 -0
  56. data/lib/right_agent/monkey_patches/ruby_patch/singleton_patch.rb +46 -0
  57. data/lib/right_agent/monkey_patches/ruby_patch/string_patch.rb +107 -0
  58. data/lib/right_agent/monkey_patches/ruby_patch/windows_patch.rb +32 -0
  59. data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/file_patch.rb +90 -0
  60. data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/process_patch.rb +63 -0
  61. data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/stdio_patch.rb +27 -0
  62. data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/time_patch.rb +55 -0
  63. data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/win32ole_patch.rb +34 -0
  64. data/lib/right_agent/multiplexer.rb +91 -0
  65. data/lib/right_agent/operation_result.rb +270 -0
  66. data/lib/right_agent/packets.rb +637 -0
  67. data/lib/right_agent/payload_formatter.rb +104 -0
  68. data/lib/right_agent/pid_file.rb +159 -0
  69. data/lib/right_agent/platform.rb +319 -0
  70. data/lib/right_agent/platform/darwin.rb +227 -0
  71. data/lib/right_agent/platform/linux.rb +268 -0
  72. data/lib/right_agent/platform/windows.rb +1204 -0
  73. data/lib/right_agent/scripts/agent_controller.rb +522 -0
  74. data/lib/right_agent/scripts/agent_deployer.rb +379 -0
  75. data/lib/right_agent/scripts/common_parser.rb +153 -0
  76. data/lib/right_agent/scripts/log_level_manager.rb +193 -0
  77. data/lib/right_agent/scripts/stats_manager.rb +256 -0
  78. data/lib/right_agent/scripts/usage.rb +58 -0
  79. data/lib/right_agent/secure_identity.rb +92 -0
  80. data/lib/right_agent/security.rb +32 -0
  81. data/lib/right_agent/security/cached_certificate_store_proxy.rb +63 -0
  82. data/lib/right_agent/security/certificate.rb +102 -0
  83. data/lib/right_agent/security/certificate_cache.rb +89 -0
  84. data/lib/right_agent/security/distinguished_name.rb +56 -0
  85. data/lib/right_agent/security/encrypted_document.rb +84 -0
  86. data/lib/right_agent/security/rsa_key_pair.rb +76 -0
  87. data/lib/right_agent/security/signature.rb +86 -0
  88. data/lib/right_agent/security/static_certificate_store.rb +69 -0
  89. data/lib/right_agent/sender.rb +937 -0
  90. data/lib/right_agent/serialize.rb +29 -0
  91. data/lib/right_agent/serialize/message_pack.rb +102 -0
  92. data/lib/right_agent/serialize/secure_serializer.rb +131 -0
  93. data/lib/right_agent/serialize/secure_serializer_initializer.rb +47 -0
  94. data/lib/right_agent/serialize/serializable.rb +135 -0
  95. data/lib/right_agent/serialize/serializer.rb +149 -0
  96. data/lib/right_agent/stats_helper.rb +731 -0
  97. data/lib/right_agent/subprocess.rb +38 -0
  98. data/lib/right_agent/tracer.rb +124 -0
  99. data/right_agent.gemspec +60 -0
  100. data/spec/actor_registry_spec.rb +81 -0
  101. data/spec/actor_spec.rb +99 -0
  102. data/spec/agent_config_spec.rb +226 -0
  103. data/spec/agent_identity_spec.rb +75 -0
  104. data/spec/agent_spec.rb +571 -0
  105. data/spec/broker_client_spec.rb +961 -0
  106. data/spec/command/agent_manager_commands_spec.rb +51 -0
  107. data/spec/command/command_io_spec.rb +93 -0
  108. data/spec/command/command_parser_spec.rb +79 -0
  109. data/spec/command/command_runner_spec.rb +72 -0
  110. data/spec/command/command_serializer_spec.rb +51 -0
  111. data/spec/core_payload_types/dev_repositories_spec.rb +64 -0
  112. data/spec/core_payload_types/executable_bundle_spec.rb +59 -0
  113. data/spec/core_payload_types/login_user_spec.rb +98 -0
  114. data/spec/core_payload_types/right_script_attachment_spec.rb +65 -0
  115. data/spec/core_payload_types/spec_helper.rb +23 -0
  116. data/spec/dispatcher_spec.rb +372 -0
  117. data/spec/enrollment_result_spec.rb +53 -0
  118. data/spec/ha_broker_client_spec.rb +1673 -0
  119. data/spec/idempotent_request_spec.rb +136 -0
  120. data/spec/log_spec.rb +177 -0
  121. data/spec/monkey_patches/amqp_patch_spec.rb +100 -0
  122. data/spec/monkey_patches/eventmachine_spec.rb +62 -0
  123. data/spec/monkey_patches/string_patch_spec.rb +99 -0
  124. data/spec/multiplexer_spec.rb +48 -0
  125. data/spec/operation_result_spec.rb +171 -0
  126. data/spec/packets_spec.rb +418 -0
  127. data/spec/platform/platform_spec.rb +60 -0
  128. data/spec/results_mock.rb +45 -0
  129. data/spec/secure_identity_spec.rb +50 -0
  130. data/spec/security/cached_certificate_store_proxy_spec.rb +56 -0
  131. data/spec/security/certificate_cache_spec.rb +71 -0
  132. data/spec/security/certificate_spec.rb +49 -0
  133. data/spec/security/distinguished_name_spec.rb +46 -0
  134. data/spec/security/encrypted_document_spec.rb +55 -0
  135. data/spec/security/rsa_key_pair_spec.rb +55 -0
  136. data/spec/security/signature_spec.rb +66 -0
  137. data/spec/security/static_certificate_store_spec.rb +52 -0
  138. data/spec/sender_spec.rb +887 -0
  139. data/spec/serialize/message_pack_spec.rb +131 -0
  140. data/spec/serialize/secure_serializer_spec.rb +102 -0
  141. data/spec/serialize/serializable_spec.rb +90 -0
  142. data/spec/serialize/serializer_spec.rb +174 -0
  143. data/spec/spec.opts +2 -0
  144. data/spec/spec_helper.rb +77 -0
  145. data/spec/stats_helper_spec.rb +681 -0
  146. data/spec/tracer_spec.rb +114 -0
  147. metadata +320 -0
@@ -0,0 +1,72 @@
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
+ # List of authorized users for Managed Login feature
27
+ class LoginPolicy
28
+ PUBLIC_KEY_REGEXP = /(.*)?(ssh-[a-z]{1,3})\s+(\S+)\s*(.*)?$/
29
+
30
+ include Serializable
31
+
32
+ attr_accessor :audit_id, :created_at, :exclusive, :users
33
+
34
+ # Initialize fields from given arguments
35
+ def initialize(*args)
36
+ @audit_id = args[0]
37
+ @created_at = Time.at( (args[1]||Time.now).to_i )
38
+ @exclusive = args[2] || false
39
+ @users = args[3] || []
40
+ end
41
+
42
+ # Array of serialized fields given to constructor
43
+ def serialized_members
44
+ [ @audit_id, @created_at.to_i, @exclusive, @users ]
45
+ end
46
+
47
+ # Utility method to parse an SSH2-format public key and return a 4-tuple consisting
48
+ # of its constituent parts:
49
+ # * leading comment (optional)
50
+ # * algorithm (ssh-rsa or ssh-dsa)
51
+ # * public key material, as a base64 string
52
+ # * trailing comment or email (optional)
53
+ #
54
+ # === Parameters
55
+ # str(String):: the unparsed public key
56
+ #
57
+ # === Return
58
+ # components (Array|nil):: a 4-tuple of key components, or nil if the key was not a valid public key
59
+ #
60
+ def self.parse_public_key(str)
61
+ match = PUBLIC_KEY_REGEXP.match(str)
62
+
63
+ if match
64
+ #Return a nice array of strings with no leading/trailing whitespace, and empty
65
+ #strings transformed into nil
66
+ return match[1..4].map { |x| x.strip! ; x.empty? ? nil : x }
67
+ else
68
+ return nil
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,62 @@
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
+ # Authorized user for the Managed Login feature
27
+ class LoginUser
28
+
29
+ include Serializable
30
+
31
+ attr_accessor :uuid, :username, :public_key, :public_keys, :common_name, :superuser, :expires_at
32
+
33
+ # Initialize fields from given arguments
34
+ def initialize(*args)
35
+ @uuid = args[0]
36
+ @username = args[1]
37
+ @public_key = args[2]
38
+ @common_name = args[3] || ''
39
+ @superuser = args[4] || false
40
+ @expires_at = Time.at(args[5]) if args[5] && (args[5] != 0) # nil -> 0 because of expires_at.to_i below
41
+ @public_keys = args[6]
42
+
43
+ # we now expect an array of public_keys to be passed while supporting the
44
+ # singular public_key as a legacy member. when serialized back from a
45
+ # legacy LoginUser record, the singular value may be set while the plural
46
+ # is nil.
47
+ if @public_keys
48
+ raise ArgumentError, "Expected public_keys (seventh argument) to be an array" unless @public_keys.is_a?(Array)
49
+ @public_key = @public_keys.first
50
+ else
51
+ raise ArgumentError, "Expected public_key (third argument) to be a string" unless @public_key.is_a?(String)
52
+ @public_keys = [@public_key]
53
+ end
54
+ end
55
+
56
+ # Array of serialized fields given to constructor
57
+ def serialized_members
58
+ [ @uuid, @username, @public_key, @common_name, @superuser, @expires_at.to_i, @public_keys ]
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,94 @@
1
+ #
2
+ # Copyright (c) 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
+ # Represents any details of a planned volume which are needed by the instance
27
+ # for volume management purposes. A planned volume is a blank, snapshotted or
28
+ # existing volume which is associated with a server at launch time. It could
29
+ # also represent a volume which is planned dynamically by the instance itself
30
+ # as part of a script and which is then guaranteed to be properly managed if
31
+ # the instance is stopped/started.
32
+ class PlannedVolume
33
+
34
+ include Serializable
35
+
36
+ # (String) cloud-specific unique identifier for volume (relative to account
37
+ # or global)
38
+ attr_accessor :volume_id
39
+
40
+ # (String) cloud-agnostic current known status of the volume. must be nil or
41
+ # else one of the following:
42
+ # 'pending', 'attached', 'attaching', 'detached', 'detaching', 'deleted'
43
+ attr_accessor :volume_status
44
+
45
+ # (String) cloud-specific device name for volume (relative to instance)
46
+ attr_accessor :device_name
47
+
48
+ # (Array of String) instance platform-specific mount point(s) for the
49
+ # physical or virtual disk (which could have multiple partitions) associated
50
+ # with the planned volume. not all partitions are formatted and/or have a
51
+ # file system which is compatible with the instance's platform so only valid
52
+ # partitions are associated with mount points.
53
+ attr_accessor :mount_points
54
+
55
+ def initialize(*args)
56
+ @volume_id = args[0] if args.size > 0
57
+ @device_name = args[1] if args.size > 1
58
+ @mount_points = args[2] if args.size > 2
59
+ @volume_status = args[3] if args.size > 3
60
+ end
61
+
62
+ # Array of serialized fields given to constructor
63
+ def serialized_members
64
+ [ @volume_id, @device_name, @mount_points, @volume_status ]
65
+ end
66
+
67
+ # Determines if this object is valid.
68
+ #
69
+ # === Return
70
+ # result(Boolean):: true if this object is valid, false if required fields are nil or empty
71
+ def is_valid?
72
+ result = false == is_blank?(@volume_id) &&
73
+ false == is_blank?(@device_name) &&
74
+ false == is_blank?(@volume_status) &&
75
+ false == is_blank?(@mount_points) &&
76
+ nil == @mount_points.find { |mount_point| is_blank?(mount_point) }
77
+ return result
78
+ end
79
+
80
+ private
81
+
82
+ # Determines if the given value is nil or empty.
83
+ #
84
+ # === Parameters
85
+ # value(Object):: any value
86
+ #
87
+ # === Return
88
+ # true if value is nil or empty
89
+ def is_blank?(value)
90
+ value.nil? || value.empty?
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,60 @@
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
+ # Recipe with json
27
+ class RecipeInstantiation
28
+
29
+ include Serializable
30
+
31
+ # (String) Recipe nickname
32
+ attr_accessor :nickname
33
+
34
+ # (Hash) Recipe override attributes (JSON string for RightLink v5.0)
35
+ attr_accessor :attributes
36
+
37
+ # (Integer) Recipe id
38
+ attr_accessor :id
39
+
40
+ # (Boolean) Whether recipe inputs are ready
41
+ attr_accessor :ready
42
+
43
+ # (Array of SecureDocumentLocation) attributes that must be resolved by the instance
44
+ attr_accessor :external_inputs
45
+
46
+ def initialize(*args)
47
+ @nickname = args[0] if args.size > 0
48
+ @attributes = args[1] if args.size > 1
49
+ @id = args[2] if args.size > 2
50
+ @ready = args[3] if args.size > 3
51
+ @external_inputs = args[4] if args.size > 4
52
+ end
53
+
54
+ # Array of serialized fields given to constructor
55
+ def serialized_members
56
+ [ @nickname, @attributes, @id, @ready, @external_inputs ]
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,50 @@
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
+ # Software repositories together with audit id
27
+ # The instance agent can use the audit created by the core agent to audit messages
28
+ # associated with the processing of the software repositories
29
+ class RepositoriesBundle
30
+
31
+ include Serializable
32
+
33
+ # (Array) Repositories instantiations
34
+ attr_accessor :repositories
35
+
36
+ # (Integer) ID of corresponding audit entry
37
+ attr_accessor :audit_id
38
+
39
+ def initialize(*args)
40
+ @repositories = args[0]
41
+ @audit_id = args[1]
42
+ end
43
+
44
+ # Array of serialized fields given to constructor
45
+ def serialized_members
46
+ [ @repositories, @audit_id ]
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,95 @@
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
+ require 'digest/sha1'
25
+ require 'uri'
26
+
27
+ module RightScale
28
+
29
+ # RightScript attachment
30
+ class RightScriptAttachment
31
+
32
+ include Serializable
33
+
34
+ # (String) S3 attachment URL
35
+ attr_accessor :url
36
+
37
+ # (String) Attachment file name
38
+ attr_accessor :file_name
39
+
40
+ # (String) Cache identifier
41
+ attr_accessor :etag
42
+
43
+ # (Binary string) Repose token for attachment
44
+ attr_accessor :token
45
+
46
+ # (String) Content digest
47
+ attr_accessor :digest
48
+
49
+ def initialize(*args)
50
+ @url = args[0] if args.size > 0
51
+ @file_name = args[1] if args.size > 1
52
+ @etag = args[2] if args.size > 2
53
+ @token = args[3] if args.size > 3
54
+ @digest = args[4] if args.size > 4
55
+ end
56
+
57
+ # Array of serialized fields given to constructor
58
+ def serialized_members
59
+ [ @url, @file_name, @etag, @token, @digest ]
60
+ end
61
+
62
+ # Return the Repose hash for this attachment.
63
+ def to_hash
64
+ RightScriptAttachment.hash_for(@url, @file_name, @etag)
65
+ end
66
+
67
+ # Fill out the session cookie appropriately for this attachment.
68
+ def fill_out(session)
69
+ session['scope'] = "attachments"
70
+ if @digest
71
+ session['resource'] = @digest
72
+ else
73
+ session['resource'] = to_hash
74
+ session['url'] = @url
75
+ session['etag'] = @etag
76
+ end
77
+ @token = session.to_s
78
+ end
79
+
80
+ # Return the Repose hash for the given URL/filename/ETag triple.
81
+ #
82
+ # === Parameters
83
+ # url(String):: URL to request
84
+ # filename(String):: local filename
85
+ # etag(String):: expected ETag
86
+ #
87
+ # === Return
88
+ # String:: hashed token suitable for communicating to Repose
89
+ def self.hash_for(url, filename, etag)
90
+ uri = URI::parse(url).dup
91
+ uri.query = nil
92
+ Digest::SHA1.hexdigest("#{uri}\000#{etag}")
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,73 @@
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
+ # RightScript with parameters and attachments
27
+ class RightScriptInstantiation
28
+
29
+ include Serializable
30
+
31
+ # (String) RightScript name
32
+ attr_accessor :nickname
33
+
34
+ # (String) RightScript source
35
+ attr_accessor :source
36
+
37
+ # (Hash) RightScript parameters
38
+ # Hash of parameters names with associated value
39
+ attr_accessor :parameters
40
+
41
+ # (Array) RightScript attachments URLs, array of RightScriptAttachment
42
+ attr_accessor :attachments
43
+
44
+ # (Array) RightScripts required packages
45
+ attr_accessor :packages
46
+
47
+ # (Integer) RightScript id
48
+ attr_accessor :id
49
+
50
+ # (Boolean) Whether script inputs are ready
51
+ attr_accessor :ready
52
+
53
+ # (Array of SecureDocumentLocation) attributes that must be resolved by the instance
54
+ attr_accessor :external_inputs
55
+
56
+ def initialize(*args)
57
+ @nickname = args[0] if args.size > 0
58
+ @source = args[1] if args.size > 1
59
+ @parameters = args[2] if args.size > 2
60
+ @attachments = args[3] if args.size > 3
61
+ @packages = args[4] if args.size > 4
62
+ @id = args[5] if args.size > 5
63
+ @ready = args[6] if args.size > 6
64
+ @external_inputs = args[7] if args.size > 7
65
+ end
66
+
67
+ # Array of serialized fields given to constructor
68
+ def serialized_members
69
+ [ @nickname, @source, @parameters, @attachments, @packages, @id, @ready, @external_inputs ]
70
+ end
71
+
72
+ end
73
+ end