right_link 5.9.0

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 (199) hide show
  1. data/actors/agent_manager.rb +88 -0
  2. data/actors/instance_scheduler.rb +321 -0
  3. data/actors/instance_services.rb +64 -0
  4. data/actors/instance_setup.rb +567 -0
  5. data/bin/cloud +25 -0
  6. data/bin/cook_runner +44 -0
  7. data/bin/deploy +120 -0
  8. data/bin/enroll +385 -0
  9. data/bin/rad +32 -0
  10. data/bin/rchk +29 -0
  11. data/bin/rnac +39 -0
  12. data/bin/rs_connect +33 -0
  13. data/bin/rs_log_level +31 -0
  14. data/bin/rs_ohai +28 -0
  15. data/bin/rs_reenroll +31 -0
  16. data/bin/rs_run_recipe +34 -0
  17. data/bin/rs_run_right_script +34 -0
  18. data/bin/rs_shutdown +33 -0
  19. data/bin/rs_tag +33 -0
  20. data/bin/rs_thunk +33 -0
  21. data/bin/rstat +31 -0
  22. data/bin/system +16 -0
  23. data/ext/Rakefile +18 -0
  24. data/init/config.yml +5 -0
  25. data/init/init.rb +79 -0
  26. data/lib/chef/ohai_setup.rb +51 -0
  27. data/lib/chef/plugins/cloud.rb +91 -0
  28. data/lib/chef/plugins/cloudstack.rb +23 -0
  29. data/lib/chef/plugins/ec2.rb +23 -0
  30. data/lib/chef/plugins/linux/block_device2.rb +24 -0
  31. data/lib/chef/plugins/rackspace.rb +23 -0
  32. data/lib/chef/plugins/rightscale.rb +125 -0
  33. data/lib/chef/plugins/windows/network.rb +114 -0
  34. data/lib/chef/plugins.rb +74 -0
  35. data/lib/chef/providers/dns_dnsmadeeasy_provider.rb +81 -0
  36. data/lib/chef/providers/dns_resource.rb +100 -0
  37. data/lib/chef/providers/executable_schedule_provider.rb +70 -0
  38. data/lib/chef/providers/executable_schedule_resource.rb +144 -0
  39. data/lib/chef/providers/remote_recipe_provider.rb +86 -0
  40. data/lib/chef/providers/remote_recipe_resource.rb +101 -0
  41. data/lib/chef/providers/right_link_tag_provider.rb +73 -0
  42. data/lib/chef/providers/right_link_tag_resource.rb +59 -0
  43. data/lib/chef/providers/right_script_provider.rb +190 -0
  44. data/lib/chef/providers/right_script_resource.rb +113 -0
  45. data/lib/chef/providers/rs_shutdown_provider.rb +75 -0
  46. data/lib/chef/providers/rs_shutdown_resource.rb +55 -0
  47. data/lib/chef/providers/server_collection_provider.rb +66 -0
  48. data/lib/chef/providers/server_collection_resource.rb +93 -0
  49. data/lib/chef/providers/windows/powershell_provider.rb +151 -0
  50. data/lib/chef/providers/windows/powershell_resource.rb +111 -0
  51. data/lib/chef/providers/windows/unsupported_provider.rb +51 -0
  52. data/lib/chef/right_providers.rb +55 -0
  53. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ChefNodeCmdlet.csproj +104 -0
  54. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ChefNodeCmdlet.dll-Help.xml +141 -0
  55. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/Exceptions.cs +182 -0
  56. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetChefNodeCommand.cs +58 -0
  57. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetChefNodeRequest.cs +46 -0
  58. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetChefNodeResponse.cs +45 -0
  59. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetCurrentResourceCommand.cs +58 -0
  60. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetCurrentResourceRequest.cs +46 -0
  61. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetCurrentResourceResponse.cs +45 -0
  62. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNewResourceCommand.cs +58 -0
  63. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNewResourceRequest.cs +46 -0
  64. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNewResourceResponse.cs +45 -0
  65. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNextActionCommand.cs +178 -0
  66. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNextActionRequest.cs +67 -0
  67. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNextActionResponse.cs +58 -0
  68. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNodeValueCommandBase.cs +142 -0
  69. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNodeValueRequestBase.cs +64 -0
  70. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNodeValueResponseBase.cs +69 -0
  71. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/JsonTransport.cs +110 -0
  72. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/PipeClient.cs +158 -0
  73. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/PipeServer.cs +142 -0
  74. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/Properties/AssemblyInfo.cs +16 -0
  75. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ProtocolConstants.cs +55 -0
  76. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ProtocolUtilities.cs +77 -0
  77. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ReadMe.txt +53 -0
  78. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetChefNodeCommand.cs +59 -0
  79. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetChefNodeRequest.cs +46 -0
  80. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetChefNodeResponse.cs +58 -0
  81. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetCurrentResourceCommand.cs +59 -0
  82. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetCurrentResourceRequest.cs +46 -0
  83. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetCurrentResourceResponse.cs +40 -0
  84. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNewResourceCommand.cs +59 -0
  85. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNewResourceRequest.cs +46 -0
  86. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNewResourceResponse.cs +40 -0
  87. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNodeValueCommandBase.cs +293 -0
  88. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNodeValueRequestBase.cs +75 -0
  89. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNodeValueResponseBase.cs +45 -0
  90. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/Transport.cs +91 -0
  91. data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet.sln +35 -0
  92. data/lib/chef/windows/ChefNodeCmdlet/TestChefNodeCmdlet/Program.cs +374 -0
  93. data/lib/chef/windows/ChefNodeCmdlet/TestChefNodeCmdlet/Properties/AssemblyInfo.cs +16 -0
  94. data/lib/chef/windows/ChefNodeCmdlet/TestChefNodeCmdlet/TestChefNodeCmdlet.csproj +65 -0
  95. data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/Program.cs +136 -0
  96. data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/Properties/AssemblyInfo.cs +36 -0
  97. data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/ReadMe.txt +46 -0
  98. data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/TestNextActionCmdlet.csproj +68 -0
  99. data/lib/chef/windows/bin/Newtonsoft.Json.dll +0 -0
  100. data/lib/chef/windows/chef_node_server.rb +463 -0
  101. data/lib/chef/windows/dynamic_powershell_provider.rb +296 -0
  102. data/lib/chef/windows/pipe_server.rb +283 -0
  103. data/lib/chef/windows/powershell_host.rb +285 -0
  104. data/lib/chef/windows/powershell_pipe_server.rb +136 -0
  105. data/lib/chef/windows/powershell_provider_base.rb +92 -0
  106. data/lib/chef/windows/scripts/run_loop.ps1 +105 -0
  107. data/lib/clouds/cloud.rb +557 -0
  108. data/lib/clouds/cloud_factory.rb +250 -0
  109. data/lib/clouds/cloud_utilities.rb +244 -0
  110. data/lib/clouds/clouds/azure.rb +106 -0
  111. data/lib/clouds/clouds/cloudstack.rb +114 -0
  112. data/lib/clouds/clouds/ec2.rb +113 -0
  113. data/lib/clouds/clouds/eucalyptus.rb +46 -0
  114. data/lib/clouds/clouds/google.rb +102 -0
  115. data/lib/clouds/clouds/none.rb +76 -0
  116. data/lib/clouds/clouds/openstack.rb +30 -0
  117. data/lib/clouds/clouds/rackspace-ng.rb +54 -0
  118. data/lib/clouds/clouds/rackspace.rb +78 -0
  119. data/lib/clouds/clouds/softlayer.rb +91 -0
  120. data/lib/clouds/metadata_formatter.rb +108 -0
  121. data/lib/clouds/metadata_provider.rb +128 -0
  122. data/lib/clouds/metadata_source.rb +87 -0
  123. data/lib/clouds/metadata_sources/certificate_metadata_source.rb +207 -0
  124. data/lib/clouds/metadata_sources/config_drive_metadata_source.rb +129 -0
  125. data/lib/clouds/metadata_sources/file_metadata_source.rb +74 -0
  126. data/lib/clouds/metadata_sources/http_metadata_source.rb +277 -0
  127. data/lib/clouds/metadata_sources/selective_metadata_source.rb +122 -0
  128. data/lib/clouds/metadata_tree_climber.rb +144 -0
  129. data/lib/clouds/metadata_writer.rb +155 -0
  130. data/lib/clouds/metadata_writers/dictionary_metadata_writer.rb +72 -0
  131. data/lib/clouds/metadata_writers/ruby_metadata_writer.rb +76 -0
  132. data/lib/clouds/metadata_writers/shell_metadata_writer.rb +121 -0
  133. data/lib/clouds/register_clouds.rb +34 -0
  134. data/lib/clouds.rb +32 -0
  135. data/lib/gem_dependencies.rb +83 -0
  136. data/lib/git_hooks/commit-msg.rb +7 -0
  137. data/lib/instance/agent_config.rb +168 -0
  138. data/lib/instance/agent_watcher.rb +233 -0
  139. data/lib/instance/audit_cook_stub.rb +104 -0
  140. data/lib/instance/audit_proxy.rb +247 -0
  141. data/lib/instance/bundle_queue.rb +104 -0
  142. data/lib/instance/cook/agent_connection.rb +109 -0
  143. data/lib/instance/cook/audit_logger.rb +165 -0
  144. data/lib/instance/cook/audit_stub.rb +142 -0
  145. data/lib/instance/cook/ca-bundle.crt +2794 -0
  146. data/lib/instance/cook/chef_state.rb +211 -0
  147. data/lib/instance/cook/cook.rb +306 -0
  148. data/lib/instance/cook/cook_state.rb +298 -0
  149. data/lib/instance/cook/cookbook_path_mapping.rb +66 -0
  150. data/lib/instance/cook/cookbook_repo_retriever.rb +190 -0
  151. data/lib/instance/cook/executable_sequence.rb +765 -0
  152. data/lib/instance/cook/external_parameter_gatherer.rb +190 -0
  153. data/lib/instance/cook/repose_downloader.rb +349 -0
  154. data/lib/instance/cook/shutdown_request_proxy.rb +121 -0
  155. data/lib/instance/cook.rb +41 -0
  156. data/lib/instance/downloader.rb +208 -0
  157. data/lib/instance/duplicable.rb +67 -0
  158. data/lib/instance/exceptions.rb +49 -0
  159. data/lib/instance/executable_sequence_proxy.rb +278 -0
  160. data/lib/instance/instance_commands.rb +577 -0
  161. data/lib/instance/instance_state.rb +633 -0
  162. data/lib/instance/json_utilities.rb +102 -0
  163. data/lib/instance/login_manager.rb +533 -0
  164. data/lib/instance/login_user_manager.rb +522 -0
  165. data/lib/instance/message_encoder.rb +118 -0
  166. data/lib/instance/multi_thread_bundle_queue.rb +232 -0
  167. data/lib/instance/operation_context.rb +60 -0
  168. data/lib/instance/options_bag.rb +65 -0
  169. data/lib/instance/payload_formatter.rb +46 -0
  170. data/lib/instance/policy.rb +53 -0
  171. data/lib/instance/policy_audit.rb +100 -0
  172. data/lib/instance/policy_manager.rb +146 -0
  173. data/lib/instance/reenroll_manager.rb +104 -0
  174. data/lib/instance/right_scripts_cookbook.rb +181 -0
  175. data/lib/instance/shutdown_request.rb +221 -0
  176. data/lib/instance/single_thread_bundle_queue.rb +189 -0
  177. data/lib/instance/volume_management.rb +450 -0
  178. data/lib/instance.rb +50 -0
  179. data/lib/repo_conf_generators/apt_conf_generators.rb +106 -0
  180. data/lib/repo_conf_generators/gem_conf_generators.rb +80 -0
  181. data/lib/repo_conf_generators/rightscale_conf_generators.rb +254 -0
  182. data/lib/repo_conf_generators/rightscale_key.pub +17 -0
  183. data/lib/repo_conf_generators/yum_conf_generators.rb +225 -0
  184. data/lib/repo_conf_generators.rb +30 -0
  185. data/lib/run_shell.rb +28 -0
  186. data/scripts/agent_checker.rb +571 -0
  187. data/scripts/agent_controller.rb +247 -0
  188. data/scripts/agent_deployer.rb +148 -0
  189. data/scripts/bundle_runner.rb +336 -0
  190. data/scripts/cloud_controller.rb +176 -0
  191. data/scripts/log_level_manager.rb +142 -0
  192. data/scripts/ohai_runner.rb +33 -0
  193. data/scripts/reenroller.rb +193 -0
  194. data/scripts/server_importer.rb +293 -0
  195. data/scripts/shutdown_client.rb +183 -0
  196. data/scripts/system_configurator.rb +367 -0
  197. data/scripts/tagger.rb +381 -0
  198. data/scripts/thunker.rb +356 -0
  199. metadata +418 -0
@@ -0,0 +1,247 @@
1
+ # === Synopsis:
2
+ # RightScale Agent Controller (rnac) - (c) 2009-2011 RightScale Inc
3
+ #
4
+ # rnac is a command line tool for managing a RightLink agent
5
+ #
6
+ # === Examples:
7
+ # Start new agent named AGENT:
8
+ # rnac --start AGENT
9
+ # rnac -s AGENT
10
+ #
11
+ # Stop running agent named AGENT:
12
+ # rnac --stop AGENT
13
+ # rnac -p AGENT
14
+ #
15
+ # Stop agent with given serialized ID:
16
+ # rnac --stop-agent ID
17
+ #
18
+ # Terminate all agents on local machine:
19
+ # rnac --killall
20
+ # rnac -K
21
+ #
22
+ # List agents configured on local machine:
23
+ # rnac --list
24
+ # rnac -l
25
+ #
26
+ # List status of agents configured on local machine:
27
+ # rnac --status
28
+ # rnac -U
29
+ #
30
+ # Start new agent named AGENT in foreground:
31
+ # rnac --start AGENT --foreground
32
+ # rnac -s AGENT -f
33
+ #
34
+ # Start new agent named AGENT of type TYPE:
35
+ # rnac --start AGENT --type TYPE
36
+ # rnac -s AGENT -t TYPE
37
+ #
38
+ # Note: To start multiple agents of the same type generate one
39
+ # config.yml file with rad and then start each agent with rnac:
40
+ # rad my_agent
41
+ # rnac -s my_agent_1 -t my_agent
42
+ # rnac -s my_agent_2 -t my_agent
43
+ #
44
+ # === Usage:
45
+ # rnac [options]
46
+ #
47
+ # options:
48
+ # --start, -s AGENT Start agent named AGENT
49
+ # --stop, -p AGENT Stop agent named AGENT
50
+ # --stop-agent ID Stop agent with serialized identity ID
51
+ # --kill, -k PIDFILE Kill process with given process id file
52
+ # --killall, -K Stop all running agents
53
+ # --decommission, -d [AGENT] Send decommission signal to instance agent named AGENT,
54
+ # defaults to 'instance'
55
+ # --shutdown, -S [AGENT] Send a terminate request to agent named AGENT,
56
+ # defaults to 'instance'
57
+ # --status, -U List running agents on local machine
58
+ # --identity, -i ID Use base id ID to build agent's identity
59
+ # --token, -t TOKEN Use token TOKEN to build agent's identity
60
+ # --prefix, -x PREFIX Use prefix PREFIX to build agent's identity
61
+ # --type TYPE Use agent type TYPE to build agent's' identity,98589
62
+ # defaults to AGENT with any trailing '_[0-9]+' removed
63
+ # --list, -l List all configured agents
64
+ # --user, -u USER Set AMQP user
65
+ # --pass, -p PASS Set AMQP password
66
+ # --vhost, -v VHOST Set AMQP vhost
67
+ # --host, -h HOST Set AMQP server hostname
68
+ # --port, -P PORT Set AMQP server port
69
+ # --cfg-dir, -c DIR Set directory containing configuration for all agents
70
+ # --pid-dir, -z DIR Set directory containing agent process id files
71
+ # --log-dir DIR Set log directory
72
+ # --log-level LVL Log level (debug, info, warning, error or fatal)
73
+ # --foreground, -f Run agent in foreground
74
+ # --interactive, -I Spawn an irb console after starting agent
75
+ # --test Use test settings
76
+ # --help Display help
77
+
78
+ require 'rubygems'
79
+ require 'right_agent/scripts/agent_controller'
80
+
81
+ require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'agent_watcher'))
82
+
83
+ module RightScale
84
+
85
+ class RightLinkAgentController < AgentController
86
+
87
+ # Create and run controller
88
+ #
89
+ # === Return
90
+ # true:: Always return true
91
+ def self.run
92
+ c = RightLinkAgentController.new
93
+ c.control(c.parse_args)
94
+ rescue Errno::EACCES => e
95
+ STDERR.puts e.message
96
+ STDERR.puts "Try elevating privilege (sudo/runas) before invoking this command."
97
+ exit(2)
98
+ end
99
+
100
+ protected
101
+
102
+ # Parse other arguments used by infrastructure agents
103
+ #
104
+ # === Parameters
105
+ # opts(OptionParser):: Options parser with options to be parsed
106
+ # options(Hash):: Storage for options that are parsed
107
+ #
108
+ # === Return
109
+ # true:: Always return true
110
+ def parse_other_args(opts, options)
111
+ opts.on("-d", "--decommission [AGENT]") do |a|
112
+ options[:action] = 'decommission'
113
+ options[:agent_name] = a || 'instance'
114
+ options[:thin_command_client] = true
115
+ end
116
+
117
+ opts.on("-S", "--shutdown [AGENT]") do |a|
118
+ options[:action] = 'shutdown'
119
+ options[:agent_name] = a || 'instance'
120
+ options[:thin_command_client] = true
121
+ end
122
+
123
+ opts.on('--help') do
124
+ puts Usage.scan(__FILE__)
125
+ exit
126
+ end
127
+ end
128
+
129
+ # Decommission instance agent
130
+ #
131
+ # === Parameters
132
+ # agent_name(String):: Agent name
133
+ #
134
+ # === Return
135
+ # (Boolean):: true if process was decommissioned, otherwise false
136
+ def decommission_agent(agent_name)
137
+ run_command('Decommissioning...', 'decommission')
138
+ end
139
+
140
+ # Shutdown instance agent
141
+ #
142
+ # === Parameters
143
+ # agent_name(String):: Agent name
144
+ #
145
+ # === Return
146
+ # (Boolean):: true if process was shutdown, otherwise false
147
+ def shutdown_agent(agent_name)
148
+ run_command('Shutting down...', 'terminate')
149
+ end
150
+
151
+ # Trigger execution of given command in instance agent and wait for it to be done
152
+ #
153
+ # === Parameters
154
+ # message(String):: Console display message
155
+ # command(String):: Command name
156
+ #
157
+ # === Return
158
+ # (Boolean):: true if command executed successfully, otherwise false
159
+ def run_command(message, command)
160
+ options = AgentConfig.agent_options(@options[:agent_name])
161
+ listen_port = options[:listen_port]
162
+ unless listen_port
163
+ $stderr.puts "Could not retrieve listen port for agent #{@options[:identity]}"
164
+ return false
165
+ end
166
+ puts message
167
+ begin
168
+ @client = CommandClient.new(listen_port, options[:cookie])
169
+ @client.send_command({ :name => command }, verbose = false, timeout = 100) { |r| puts r }
170
+ rescue SystemExit => e
171
+ raise e
172
+ rescue Exception => e
173
+ $stderr.puts Log.format("Failed or else time limit was exceeded, confirm that local instance is still running", e, :trace)
174
+ return false
175
+ end
176
+ true
177
+ end
178
+
179
+ # Start agent
180
+ #
181
+ # === Parameters
182
+ # agent_name(String):: Agent name
183
+ # agent_class(Agent):: Agent class
184
+ #
185
+ # === Return
186
+ # true:: Always return true
187
+ def start_agent(agent_name, agent_class = Agent)
188
+ # note that our Windows service monitors rnac and rchk processes
189
+ # externally and restarts them if they die, so no need to roll our
190
+ # own cross-monitoring on that platform.
191
+ use_agent_watcher = !RightScale::Platform.windows?
192
+ agent_watcher = nil
193
+ if use_agent_watcher
194
+ agent_watcher = AgentWatcher.new( lambda { |s| Log.info(s) }, @options[:pid_dir] )
195
+ agent_watcher.watch_agent("#{@options[:identity]}-rchk", '/opt/rightscale/bin/rchk', '--start', '--stop')
196
+ @options[:ready_callback] = Proc.new { agent_watcher.start_watching() }
197
+ end
198
+ super
199
+ agent_watcher.stop_watching if use_agent_watcher
200
+ end
201
+
202
+ # Determine syslog program name based on options
203
+ #
204
+ # === Parameters
205
+ # options(Hash):: Command line options
206
+ #
207
+ # === Return
208
+ # (String):: Program name
209
+ def syslog_program_name(options)
210
+ 'RightLink'
211
+ end
212
+
213
+ # Determine syslog facility based on options
214
+ #
215
+ # === Parameters
216
+ # options(Hash):: Command line options
217
+ #
218
+ # === Return
219
+ # (String):: 'user'
220
+ def syslog_facility(options)
221
+ 'user'
222
+ end
223
+ end # RightLinkAgentController
224
+
225
+ end # RightScale
226
+
227
+ #
228
+ # Copyright (c) 2009-2011 RightScale Inc
229
+ #
230
+ # Permission is hereby granted, free of charge, to any person obtaining
231
+ # a copy of this software and associated documentation files (the
232
+ # "Software"), to deal in the Software without restriction, including
233
+ # without limitation the rights to use, copy, modify, merge, publish,
234
+ # distribute, sublicense, and/or sell copies of the Software, and to
235
+ # permit persons to whom the Software is furnished to do so, subject to
236
+ # the following conditions:
237
+ #
238
+ # The above copyright notice and this permission notice shall be
239
+ # included in all copies or substantial portions of the Software.
240
+ #
241
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
242
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
243
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
244
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
245
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
246
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
247
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,148 @@
1
+ # === Synopsis:
2
+ # RightScale Agent Deployer (rad) - (c) 2009-2011 RightScale Inc
3
+ #
4
+ # rad is a command line tool for building the configuration file for a RightLink agent
5
+ #
6
+ # The configuration file is generated in:
7
+ # <agent name>/config.yml
8
+ # in platform-specific RightAgent configuration directory
9
+ #
10
+ # === Examples:
11
+ # Build configuration for agent named AGENT with default options:
12
+ # rad AGENT
13
+ #
14
+ # Build configuration for agent named AGENT so it uses given AMQP settings:
15
+ # rad AGENT --user USER --pass PASSWORD --vhost VHOST --port PORT --host HOST
16
+ # rad AGENT -u USER -p PASSWORD -v VHOST -P PORT -h HOST
17
+ #
18
+ # === Usage:
19
+ # rad AGENT [options]
20
+ #
21
+ # options:
22
+ # --root-dir, -r DIR Set agent root directory (containing init, actors, and/or certs subdirectories)
23
+ # --cfg-dir, -c DIR Set directory where generated configuration files for all agents are stored
24
+ # --pid-dir, -z DIR Set directory containing process id file
25
+ # --identity, -i ID Use base id ID to build agent's identity
26
+ # --token, -t TOKEN Use token TOKEN to build agent's identity
27
+ # --prefix, -x PREFIX Use prefix PREFIX to build agent's identity
28
+ # --type TYPE Use agent type TYPE to build agent's' identity,
29
+ # defaults to AGENT with any trailing '_[0-9]+' removed
30
+ # --secure-identity, -S Derive actual token from given TOKEN and ID
31
+ # --url Set agent AMQP connection URL (host, port, user, pass, vhost)
32
+ # --user, -u USER Set agent AMQP username
33
+ # --password, -p PASS Set agent AMQP password
34
+ # --vhost, -v VHOST Set agent AMQP virtual host
35
+ # --host, -h HOST Set AMQP broker host
36
+ # --port, -P PORT Set AMQP broker port
37
+ # --prefetch COUNT Set maximum requests AMQP broker is to prefetch before current is ack'd
38
+ # --http-proxy PROXY Use a proxy for all agent-originated HTTP traffic
39
+ # --http-no-proxy NOPROXY Comma-separated list of proxy exceptions (e.g. metadata server)
40
+ # --time-to-live SEC Set maximum age in seconds before a request times out and is rejected
41
+ # --retry-timeout SEC Set maximum number of seconds to retry request before give up
42
+ # --retry-interval SEC Set number of seconds before initial request retry, increases exponentially
43
+ # --check-interval SEC Set number of seconds between failed connection checks, increases exponentially
44
+ # --ping-interval SEC Set minimum number of seconds since last message receipt for the agent
45
+ # to ping the mapper to check connectivity, 0 means disable ping
46
+ # --reconnect-interval SEC Set number of seconds between broker reconnect attempts
47
+ # --offline-queueing, -q Enable queuing of requests when lose broker connectivity
48
+ # --grace-timeout SEC Set number of seconds before graceful termination times out
49
+ # --[no-]dup-check Set whether to check for and reject duplicate requests, .e.g., due to retries
50
+ # --options, -o KEY=VAL Set options that act as final override for any persisted configuration settings
51
+ # --test Build test deployment using default test settings
52
+ # --quiet, -Q Do not produce output
53
+ # --help Display help
54
+
55
+ require 'rubygems'
56
+ require 'right_agent/scripts/agent_deployer'
57
+
58
+ module RightScale
59
+
60
+ class RightLinkAgentDeployer < AgentDeployer
61
+
62
+ # Create and run deployer
63
+ #
64
+ # === Return
65
+ # true:: Always return true
66
+ def self.run
67
+ d = RightLinkAgentDeployer.new
68
+ d.deploy(d.parse_args)
69
+ rescue Errno::EACCES => e
70
+ STDERR.puts e.message
71
+ STDERR.puts "Try elevating privilege (sudo/runas) before invoking this command."
72
+ exit(2)
73
+ end
74
+
75
+ protected
76
+
77
+ # Parse other arguments used by infrastructure agents
78
+ #
79
+ # === Parameters
80
+ # opts(OptionParser):: Options parser with options to be parsed
81
+ # options(Hash):: Storage for options that are parsed
82
+ #
83
+ # === Return
84
+ # true:: Always return true
85
+ def parse_other_args(opts, options)
86
+ opts.on('-q', '--offline-queueing') do
87
+ options[:offline_queueing] = true
88
+ end
89
+
90
+ opts.on('--help') do
91
+ puts Usage.scan(__FILE__)
92
+ exit
93
+ end
94
+ end
95
+
96
+ # Determine configuration settings to be persisted
97
+ #
98
+ # === Parameters
99
+ # options(Hash):: Command line options
100
+ # cfg(Hash):: Initial configuration settings
101
+ #
102
+ # === Return
103
+ # cfg(Hash):: Configuration settings
104
+ def configure(options, cfg)
105
+ cfg = super(options, cfg)
106
+ cfg[:offline_queueing] = options[:offline_queueing]
107
+ cfg
108
+ end
109
+
110
+ # Setup agent monitoring
111
+ # NOTE: Defunct, keep here to overwrite AgentDeployer's
112
+ # version of this method just in case someone still passes
113
+ # in the --monit flag.
114
+ #
115
+ # === Parameters
116
+ # options(Hash):: Command line options
117
+ #
118
+ # === Return
119
+ # true:: Always return true
120
+ def monitor(options)
121
+ true
122
+ end
123
+
124
+ end # RightLinkAgentDeployer
125
+
126
+ end # RightScale
127
+
128
+ #
129
+ # Copyright (c) 2009-2011 RightScale Inc
130
+ #
131
+ # Permission is hereby granted, free of charge, to any person obtaining
132
+ # a copy of this software and associated documentation files (the
133
+ # "Software"), to deal in the Software without restriction, including
134
+ # without limitation the rights to use, copy, modify, merge, publish,
135
+ # distribute, sublicense, and/or sell copies of the Software, and to
136
+ # permit persons to whom the Software is furnished to do so, subject to
137
+ # the following conditions:
138
+ #
139
+ # The above copyright notice and this permission notice shall be
140
+ # included in all copies or substantial portions of the Software.
141
+ #
142
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
143
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
144
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
145
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
146
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
147
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
148
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.