right_agent 0.5.1

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.
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,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,90 @@
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 to be checked out on the instance.
26
+ class DevRepositories
27
+ include Serializable
28
+
29
+ attr_accessor :repositories
30
+
31
+ # Initialize fields from given arguments
32
+ def initialize(*args)
33
+ @repositories = args[0] || {}
34
+ end
35
+
36
+ # Array of serialized fields given to constructor
37
+ def serialized_members
38
+ [ @repositories ]
39
+ end
40
+
41
+ # Add a repository...
42
+ #
43
+ # === Parameters
44
+ # (Hash):: collection of repos to be checked out on the instance
45
+ # :repo_sha (String):: the hash id (SHA) of the repository
46
+ # :repo_detail (Hash):: info needed to checkout this repo
47
+ # {
48
+ # <Symbol> Type of repository: one of :git, :svn, :download or :local
49
+ # * :git denotes a 'git' repository that should be retrieved via 'git clone'
50
+ # * :svn denotes a 'svn' repository that should be retrieved via 'svn checkout'
51
+ # * :download denotes a tar ball that should be retrieved via HTTP GET (HTTPS if uri starts with https://)
52
+ # * :local denotes cookbook that is already local and doesn't need to be retrieved
53
+ # :repo_type => <Symbol>,
54
+ # <String> URL to repository (e.g. git://github.com/opscode/chef-repo.git)
55
+ # :url => <String>,
56
+ # <String> git commit or svn branch that should be used to retrieve repository
57
+ # Optional, use 'master' for git and 'trunk' for svn if tag is nil.
58
+ # Not used for raw repositories.
59
+ # :tag => <String>,
60
+ # <Array> Path to cookbooks inside repostory
61
+ # Optional (use location of repository as cookbook path if nil)
62
+ # :cookbooks_path => <Array>,
63
+ # <String> Private SSH key used to retrieve git repositories
64
+ # Optional, not used for svn and raw repositories.
65
+ # :ssh_key => <String>,
66
+ # <String> Username used to retrieve svn and raw repositories
67
+ # Optional, not used for git repositories.
68
+ # :username => <String>,
69
+ # <String> Password used to retrieve svn and raw repositories
70
+ # Optional, not used for git repositories.
71
+ # :password => <String>
72
+ # }
73
+ # :cookbook_positions (Array):: List of CookbookPositions to be developed. Represents the subset of cookbooks identified as the "dev cookbooks"
74
+ #
75
+ # === Return
76
+ # result(Hash):: The entry added to the collection of repositories
77
+ def add_repo(repo_sha, repo_detail, cookbook_positions)
78
+ @repositories ||= {}
79
+ @repositories[repo_sha] = { :repo => repo_detail, :positions => cookbook_positions }
80
+ end
81
+
82
+ #
83
+ # === Return
84
+ # (Boolean):: true if there are no repositories, false otherwise
85
+ def empty?
86
+ @repositories.count == 0
87
+ end
88
+ end
89
+ end
90
+
@@ -0,0 +1,38 @@
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 event categories used by auditor
27
+ # For now only support generic and security categories
28
+ class EventCategories
29
+
30
+ NONE = 'None'.freeze # No notification
31
+ CATEGORY_NOTIFICATION = 'Notification'.freeze # Generic notification
32
+ CATEGORY_SECURITY = 'Security'.freeze # Security topic notification
33
+ CATEGORY_ERROR = 'Error'.freeze # Error event
34
+
35
+ CATEGORIES = [ NONE, CATEGORY_NOTIFICATION, CATEGORY_SECURITY, CATEGORY_ERROR ]
36
+
37
+ end
38
+ end
@@ -0,0 +1,138 @@
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
+ # Boot, operation or decommission executable bundle, includes:
27
+ # * RightScripts with associated packages, parameters and attachments
28
+ # * Recipes with associated JSON
29
+ # * Cookbook repositories with associated attributes
30
+ # * Audit id
31
+ # Recipes and RightScripts instantiations are interspersed and ordered into one collection
32
+ # The instance agent can use the audit created by the core agent to audit messages
33
+ # associated with the processing of the software repositories
34
+ class ExecutableBundle
35
+
36
+ include Serializable
37
+
38
+ # Default thread name when no thread is specified for an executable bundle.
39
+ DEFAULT_THREAD_NAME = 'default'
40
+
41
+ # (Array) Collection of RightScripts and chef recipes instantiations
42
+ attr_accessor :executables
43
+
44
+ # (Array) Chef cookbook repositories
45
+ attr_accessor :cookbook_repositories
46
+
47
+ # (Integer) ID of corresponding audit entry
48
+ attr_accessor :audit_id
49
+
50
+ # (Boolean) Whether a full or partial converge should be done
51
+ # Note: Obsolete as of r_s_version 8, kept for backwards compatibility
52
+ attr_accessor :full_converge
53
+
54
+ # (Array) Chef cookbooks
55
+ attr_accessor :cookbooks
56
+
57
+ # (String) Repose server to use
58
+ attr_accessor :repose_servers
59
+
60
+ # (Hash):: collection of repos to be checked out on the instance
61
+ # :key (String):: the hash id (SHA) of the repository
62
+ # :value (Hash):: repo and cookbook detail
63
+ # :repo (Hash):: repo details
64
+ # {
65
+ # <Symbol> Type of repository: one of :git, :svn, :download or :local
66
+ # * :git denotes a 'git' repository that should be retrieved via 'git clone'
67
+ # * :svn denotes a 'svn' repository that should be retrieved via 'svn checkout'
68
+ # * :download denotes a tar ball that should be retrieved via HTTP GET (HTTPS if uri starts with https://)
69
+ # * :local denotes cookbook that is already local and doesn't need to be retrieved
70
+ # :repo_type => <Symbol>,
71
+ # <String> URL to repository (e.g. git://github.com/opscode/chef-repo.git)
72
+ # :url => <String>,
73
+ # <String> git commit or svn branch that should be used to retrieve repository
74
+ # Optional, use 'master' for git and 'trunk' for svn if tag is nil.
75
+ # Not used for raw repositories.
76
+ # :tag => <String>,
77
+ # <Array> Path to cookbooks inside repostory
78
+ # Optional (use location of repository as cookbook path if nil)
79
+ # :cookbooks_path => <Array>,
80
+ # <String> Private SSH key used to retrieve git repositories
81
+ # Optional, not used for svn and raw repositories.
82
+ # :ssh_key => <String>,
83
+ # <String> Username used to retrieve svn and raw repositories
84
+ # Optional, not used for git repositories.
85
+ # :username => <String>,
86
+ # <String> Password used to retrieve svn and raw repositories
87
+ # Optional, not used for git repositories.
88
+ # :password => <String>
89
+ # }
90
+ # :positions (Array):: List of CookbookPositions to be developed. Represents the subset of cookbooks identified as the "dev cookbooks"
91
+ attr_accessor :dev_cookbooks
92
+
93
+ def initialize(*args)
94
+ @executables = args[0]
95
+ @cookbook_repositories = args[1] if args.size > 1
96
+ @audit_id = args[2] if args.size > 2
97
+ @full_converge = args[3] if args.size > 3
98
+ @cookbooks = args[4] if args.size > 4
99
+ @repose_servers = args[5] if args.size > 5
100
+ @dev_cookbooks = args[6] if args.size > 6
101
+ @thread_name = args[7] if args.size > 7
102
+ end
103
+
104
+ # Array of serialized fields given to constructor
105
+ def serialized_members
106
+ [ @executables,
107
+ @cookbook_repositories,
108
+ @audit_id,
109
+ @full_converge,
110
+ @cookbooks,
111
+ @repose_servers,
112
+ @dev_cookbooks,
113
+ @thread_name ]
114
+ end
115
+
116
+ # Human readable representation
117
+ #
118
+ # === Return
119
+ # desc(String):: Auditable description
120
+ def to_s
121
+ desc = @executables.collect { |e| e.nickname }.join(', ') if @executables
122
+ desc ||= 'empty bundle'
123
+ end
124
+
125
+ # Gets the thread name from a bundle, if any. Uses the default thread name for
126
+ # when a thread name is not specified (for backward compatibility, etc.).
127
+ #
128
+ # === Parameters
129
+ # bundle(ExecutableBundle):: bundle to inspect
130
+ #
131
+ # === Return
132
+ # thread_name(String):: thread name for bundle execution
133
+ def thread_name(value = nil)
134
+ @thread_name = value if value
135
+ return @thread_name || DEFAULT_THREAD_NAME
136
+ end
137
+ end
138
+ end