right_link 5.9.1 → 5.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/RELEASES.rdoc +40 -5
- data/actors/instance_setup.rb +1 -1
- data/bin/cook_runner +1 -0
- data/lib/instance/cook/audit_logger.rb +1 -3
- data/lib/instance/cook/cook.rb +12 -0
- data/lib/instance/cook/cook_state.rb +6 -13
- data/lib/instance/cook/executable_sequence.rb +8 -0
- data/lib/instance/cook/repose_downloader.rb +5 -5
- data/lib/right_link/version.rb +4 -0
- data/scripts/agent_checker.rb +13 -19
- data/scripts/agent_controller.rb +4 -9
- data/scripts/agent_deployer.rb +1 -1
- data/scripts/bundle_runner.rb +10 -49
- data/scripts/cloud_controller.rb +8 -5
- data/scripts/command_helper.rb +101 -0
- data/scripts/log_level_manager.rb +37 -25
- data/scripts/ohai_runner.rb +1 -1
- data/scripts/reenroller.rb +9 -13
- data/scripts/server_importer.rb +9 -43
- data/scripts/shutdown_client.rb +9 -49
- data/scripts/system_configurator.rb +4 -10
- data/scripts/tagger.rb +96 -168
- data/scripts/thunker.rb +12 -33
- metadata +6 -4
@@ -1,7 +1,7 @@
|
|
1
1
|
# === Synopsis:
|
2
|
-
# RightScale Log Level Manager (rs_log_level) - (c) 2009-
|
2
|
+
# RightScale Log Level Manager (rs_log_level) - (c) 2009-2013 RightScale Inc
|
3
3
|
#
|
4
|
-
# Log level manager allows setting and retrieving the RightLink agent
|
4
|
+
# Log level manager allows setting and retrieving the RightLink agent and Chef/RightScript
|
5
5
|
# log level.
|
6
6
|
#
|
7
7
|
# === Examples:
|
@@ -16,20 +16,26 @@
|
|
16
16
|
# rs_set_log_level [--log-level, -l debug|info|warn|error|fatal]
|
17
17
|
#
|
18
18
|
# Options:
|
19
|
-
# --log-level, -l LVL Set log level
|
19
|
+
# --log-level, -l LVL Set log level(for Chef/RightScript by default)
|
20
|
+
# --agent Set/get log level of RightLink agent
|
20
21
|
# --verbose, -v Display debug information
|
21
22
|
# --help: Display help
|
22
23
|
# --version: Display version information
|
23
24
|
#
|
24
|
-
# No options prints the current
|
25
|
+
# No options prints the current Chef/RightScript log level
|
25
26
|
#
|
26
27
|
|
27
28
|
require 'right_agent/scripts/log_level_manager'
|
28
29
|
require 'trollop'
|
30
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'command_helper'))
|
31
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'tagger'))
|
29
32
|
|
30
33
|
module RightScale
|
31
34
|
|
32
35
|
class RightLinkLogLevelManager < LogLevelManager
|
36
|
+
include CommandHelper
|
37
|
+
|
38
|
+
LOG_LEVEL_TAG = "rs_agent_dev:log_level"
|
33
39
|
|
34
40
|
# Convenience wrapper for creating and running log level manager
|
35
41
|
#
|
@@ -39,6 +45,7 @@ module RightScale
|
|
39
45
|
m = RightLinkLogLevelManager.new
|
40
46
|
|
41
47
|
options = m.parse_args
|
48
|
+
m.check_privileges
|
42
49
|
m.manage(options)
|
43
50
|
|
44
51
|
if options[:level] =~ /debug/i && !RightScale::Platform.windows?
|
@@ -47,10 +54,25 @@ module RightScale
|
|
47
54
|
puts " log daemon may discard these messages. If debug messages do not appear,"
|
48
55
|
puts " review your syslog configuration and restart the daemon."
|
49
56
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
def manage(options)
|
60
|
+
return super(options) if options[:agent]
|
61
|
+
cmd = options[:level] ? { :name => :add_tag, } : { :name => :get_tags }
|
62
|
+
cmd[:tag] = "#{LOG_LEVEL_TAG}=#{options[:level]}" if options[:level]
|
63
|
+
res = send_command(cmd, options[:verbose], Tagger::TAG_REQUEST_TIMEOUT)
|
64
|
+
case cmd[:name]
|
65
|
+
when :get_tags
|
66
|
+
fail("Getting log level failed: #{res.inspect}") unless res.kind_of?(Array)
|
67
|
+
log_level_tag = res.detect { |tag| tag.start_with?(LOG_LEVEL_TAG) }
|
68
|
+
level = log_level_tag ? log_level_tag.split("=").last : send_command({ :name => 'get_log_level' }, options[:verbose], 5)
|
69
|
+
write_output("Chef/RightScript log level: #{level.to_s.upcase}")
|
70
|
+
when :add_tag
|
71
|
+
r = serialize_operation_result(res)
|
72
|
+
fail("Setting log level failed: #{r.inspect}") unless r.kind_of?(OperationResult)
|
73
|
+
fail("Setting log level failed: #{r.content}") unless r.success?
|
74
|
+
write_output("Successfully set log level to #{options[:level]}")
|
75
|
+
end
|
54
76
|
end
|
55
77
|
|
56
78
|
# Create options hash from command line arguments
|
@@ -62,31 +84,22 @@ module RightScale
|
|
62
84
|
|
63
85
|
parser = Trollop::Parser.new do
|
64
86
|
opt :level, "", :type => String, :long => "--log-level", :short => "-l"
|
87
|
+
opt :agent
|
65
88
|
opt :verbose
|
66
89
|
version ""
|
67
90
|
end
|
68
91
|
|
69
|
-
|
92
|
+
parse do
|
70
93
|
options.merge!(parser.parse)
|
71
94
|
if options[:level]
|
72
95
|
fail("Invalig log level '#{options[:level]}'") unless AgentManager::LEVELS.include?(options[:level].to_sym)
|
73
96
|
end
|
74
97
|
options
|
75
|
-
rescue Trollop::HelpNeeded
|
76
|
-
write_output(Usage.scan(__FILE__))
|
77
|
-
exit
|
78
|
-
rescue Trollop::VersionNeeded
|
79
|
-
write_output(version)
|
80
|
-
succeed
|
81
|
-
rescue SystemExit => e
|
82
|
-
raise e
|
83
|
-
rescue Exception => e
|
84
|
-
write_output(e.message + "\nUse --help for additional information")
|
85
|
-
exit(1)
|
86
98
|
end
|
87
99
|
end
|
88
100
|
|
89
101
|
protected
|
102
|
+
|
90
103
|
# Writes to STDOUT (and a placeholder for spec mocking).
|
91
104
|
#
|
92
105
|
# === Parameters
|
@@ -99,7 +112,7 @@ protected
|
|
99
112
|
#
|
100
113
|
# === Parameters
|
101
114
|
# @param [String] message to write
|
102
|
-
def write_error(message)
|
115
|
+
def self.write_error(message)
|
103
116
|
STDERR.puts(message)
|
104
117
|
end
|
105
118
|
|
@@ -108,12 +121,11 @@ protected
|
|
108
121
|
# === Return
|
109
122
|
# (String):: Version information
|
110
123
|
def version
|
111
|
-
|
112
|
-
"rs_log_level #{gemspec.version} - RightLink's log level (c) 2011 RightScale"
|
124
|
+
"rs_log_level #{right_link_version} - RightLink's log level (c) 2013 RightScale"
|
113
125
|
end
|
114
126
|
|
115
|
-
def
|
116
|
-
|
127
|
+
def usage
|
128
|
+
Usage.scan(__FILE__)
|
117
129
|
end
|
118
130
|
|
119
131
|
end
|
data/scripts/ohai_runner.rb
CHANGED
data/scripts/reenroller.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# === Synopsis:
|
2
|
-
# RightScale Re-enroller (rs_reenroll) - (c) 2010-
|
2
|
+
# RightScale Re-enroller (rs_reenroll) - (c) 2010-2013 RightScale Inc
|
3
3
|
#
|
4
4
|
# Re-enroller causes the instance to re-enroll
|
5
5
|
# CAUTION: This process may take a while to take place, during that time
|
@@ -21,12 +21,14 @@ require 'fileutils'
|
|
21
21
|
require 'right_agent'
|
22
22
|
require 'right_agent/scripts/usage'
|
23
23
|
require 'right_agent/scripts/common_parser'
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'command_helper'))
|
24
25
|
|
25
26
|
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'agent_config'))
|
26
27
|
|
27
28
|
module RightScale
|
28
29
|
|
29
30
|
class Reenroller
|
31
|
+
include CommandHelper
|
30
32
|
|
31
33
|
if RightScale::Platform.windows?
|
32
34
|
# Note we currently only need a reenroller state file under windows.
|
@@ -96,17 +98,8 @@ module RightScale
|
|
96
98
|
version ""
|
97
99
|
end
|
98
100
|
|
99
|
-
|
101
|
+
parse do
|
100
102
|
parser.parse
|
101
|
-
rescue Trollop::HelpNeeded
|
102
|
-
puts Usage.scan(__FILE__)
|
103
|
-
exit
|
104
|
-
rescue Trollop::VersionNeeded
|
105
|
-
puts version
|
106
|
-
exit(0)
|
107
|
-
rescue Trollop::CommandlineError => e
|
108
|
-
puts e.message + "\nUse --help for additional information"
|
109
|
-
exit(1)
|
110
103
|
end
|
111
104
|
end
|
112
105
|
|
@@ -162,8 +155,11 @@ module RightScale
|
|
162
155
|
# === Return
|
163
156
|
# (String):: Version information
|
164
157
|
def version
|
165
|
-
|
166
|
-
|
158
|
+
"rs_reenroll #{right_link_version} - RightLink's reenroller (c) 2013 RightScale"
|
159
|
+
end
|
160
|
+
|
161
|
+
def usage
|
162
|
+
Usage.scan(__FILE__)
|
167
163
|
end
|
168
164
|
|
169
165
|
end # Reenroller
|
data/scripts/server_importer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# === Synopsis:
|
2
|
-
# RightScale Server Import Utility (rs_connect) - (c)
|
2
|
+
# RightScale Server Import Utility (rs_connect) - (c) 2013 RightScale Inc
|
3
3
|
#
|
4
4
|
# This utility allows an arbitrary virtual or physical machine to be
|
5
5
|
# managed by the RightScale dashboard.
|
@@ -32,10 +32,12 @@ require 'right_agent/scripts/usage'
|
|
32
32
|
require 'right_agent/scripts/common_parser'
|
33
33
|
require 'right_http_connection'
|
34
34
|
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance'))
|
35
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'command_helper'))
|
35
36
|
|
36
37
|
module RightScale
|
37
38
|
|
38
39
|
class ServerImporter
|
40
|
+
include CommandHelper
|
39
41
|
# Exception class to use as a token that something went wrong with an HTTP query
|
40
42
|
class QueryFailed < Exception; end
|
41
43
|
|
@@ -136,55 +138,22 @@ module RightScale
|
|
136
138
|
version ""
|
137
139
|
end
|
138
140
|
|
139
|
-
|
141
|
+
parse do
|
140
142
|
options.merge(parser.parse)
|
141
|
-
rescue Trollop::HelpNeeded
|
142
|
-
puts Usage.scan(__FILE__)
|
143
|
-
exit
|
144
|
-
rescue Trollop::CommandlineError => e
|
145
|
-
puts e.message + "\nUse --help for additional information"
|
146
|
-
exit(1)
|
147
|
-
rescue Trollop::VersionNeeded
|
148
|
-
puts version
|
149
|
-
succeed
|
150
143
|
end
|
151
144
|
end
|
152
145
|
|
153
146
|
protected
|
154
|
-
|
155
|
-
# Print error on console and exit abnormally
|
156
|
-
#
|
157
|
-
# === Parameter
|
158
|
-
# reason(String|Exception):: Error message or exception, default to nil (no message printed)
|
159
|
-
# print_usage(Boolean):: Whether script usage should be printed, default to false
|
160
|
-
#
|
161
|
-
# === Return
|
162
|
-
# R.I.P. does not return
|
163
|
-
def fail(reason=nil, print_usage=false)
|
164
|
-
case reason
|
165
|
-
when Errno::EACCES
|
166
|
-
STDERR.puts reason.message
|
167
|
-
STDERR.puts "Try elevating privilege (sudo/runas) before invoking this command."
|
168
|
-
code = 2
|
169
|
-
when Exception
|
170
|
-
STDERR.puts "** #{reason.message}"
|
171
|
-
code = 1
|
172
|
-
else
|
173
|
-
STDERR.puts "** #{reason}" if reason
|
174
|
-
code = 1
|
175
|
-
end
|
176
|
-
|
177
|
-
puts Usage.scan(__FILE__) if print_usage
|
178
|
-
exit(code)
|
179
|
-
end
|
180
|
-
|
181
147
|
# Version information
|
182
148
|
#
|
183
149
|
# === Return
|
184
150
|
# (String):: Version information
|
185
151
|
def version
|
186
|
-
|
187
|
-
|
152
|
+
"rs_connect #{right_link_version} - RightLink's server importer (c) 2013 RightScale"
|
153
|
+
end
|
154
|
+
|
155
|
+
def usage
|
156
|
+
Usage.scan(__FILE__)
|
188
157
|
end
|
189
158
|
|
190
159
|
private
|
@@ -285,9 +254,6 @@ protected
|
|
285
254
|
return uri
|
286
255
|
end
|
287
256
|
|
288
|
-
def succeed
|
289
|
-
exit(0)
|
290
|
-
end
|
291
257
|
end
|
292
258
|
|
293
259
|
end
|
data/scripts/shutdown_client.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# === Synopsis:
|
2
|
-
# RightScale System Shutdown Utility (rs_shutdown) - (c)
|
2
|
+
# RightScale System Shutdown Utility (rs_shutdown) - (c) 2013 RightScale Inc
|
3
3
|
#
|
4
4
|
# This utility allows the given system to be shutdown or rebooted.
|
5
5
|
#
|
@@ -35,10 +35,12 @@ require 'right_agent/scripts/usage'
|
|
35
35
|
require 'right_agent/scripts/common_parser'
|
36
36
|
|
37
37
|
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'shutdown_request'))
|
38
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'command_helper'))
|
38
39
|
|
39
40
|
module RightScale
|
40
41
|
|
41
42
|
class ShutdownClient
|
43
|
+
include CommandHelper
|
42
44
|
|
43
45
|
# Run
|
44
46
|
#
|
@@ -48,17 +50,14 @@ module RightScale
|
|
48
50
|
# === Return
|
49
51
|
# true:: Always return true
|
50
52
|
def run(options)
|
53
|
+
check_privileges
|
51
54
|
fail("Missing required shutdown argument") unless options[:level]
|
52
55
|
cmd = {}
|
53
56
|
cmd[:name] = :set_shutdown_request
|
54
57
|
cmd[:level] = options[:level]
|
55
58
|
cmd[:immediately] = options[:immediately]
|
56
|
-
config_options = AgentConfig.agent_options('instance')
|
57
|
-
listen_port = config_options[:listen_port]
|
58
|
-
fail('Could not retrieve agent listen port') unless listen_port
|
59
|
-
client = CommandClient.new(listen_port, config_options[:cookie])
|
60
59
|
begin
|
61
|
-
|
60
|
+
send_command(cmd, options[:verbose]) do |response|
|
62
61
|
if response[:error]
|
63
62
|
fail("Failed #{cmd.inspect} with #{response[:error]}")
|
64
63
|
else
|
@@ -94,66 +93,27 @@ module RightScale
|
|
94
93
|
conflicts :deferred, :immediately
|
95
94
|
end
|
96
95
|
|
97
|
-
|
96
|
+
parse do
|
98
97
|
options.merge!(parser.parse)
|
99
98
|
options[:level] = ::RightScale::ShutdownRequest::REBOOT if options[:reboot]
|
100
99
|
options[:level] = ::RightScale::ShutdownRequest::STOP if options[:stop]
|
101
100
|
options[:level] = ::RightScale::ShutdownRequest::TERMINATE if options[:terminate]
|
102
101
|
options[:immediately] = false if options[:deferred]
|
103
|
-
rescue Trollop::VersionNeeded
|
104
|
-
puts version
|
105
|
-
succeed
|
106
|
-
rescue Trollop::HelpNeeded
|
107
|
-
puts Usage.scan(__FILE__)
|
108
|
-
exit
|
109
|
-
rescue SystemExit => e
|
110
|
-
raise e
|
111
|
-
rescue Exception => e
|
112
|
-
puts e.message + "\nUse --help for additional information"
|
113
|
-
exit(1)
|
114
102
|
end
|
115
103
|
options
|
116
104
|
end
|
117
105
|
|
118
106
|
protected
|
119
|
-
|
120
|
-
# Print error on console and exit abnormally
|
121
|
-
#
|
122
|
-
# === Parameter
|
123
|
-
# reason(String|Exception):: Error message or exception, default to nil (no message printed)
|
124
|
-
# print_usage(Boolean):: Whether script usage should be printed, default to false
|
125
|
-
#
|
126
|
-
# === Return
|
127
|
-
# R.I.P. does not return
|
128
|
-
def fail(reason=nil, print_usage=false)
|
129
|
-
case reason
|
130
|
-
when Errno::EACCES
|
131
|
-
STDERR.puts "** #{reason.message}"
|
132
|
-
STDERR.puts "** Try elevating privilege (sudo/runas) before invoking this command."
|
133
|
-
code = 2
|
134
|
-
when Exception
|
135
|
-
STDERR.puts "** #{reason.message}"
|
136
|
-
code = 1
|
137
|
-
else
|
138
|
-
STDERR.puts "** #{reason}" if reason
|
139
|
-
code = 1
|
140
|
-
end
|
141
|
-
|
142
|
-
puts Usage.scan(__FILE__) if print_usage
|
143
|
-
exit(code)
|
144
|
-
end
|
145
|
-
|
146
107
|
# Version information
|
147
108
|
#
|
148
109
|
# === Return
|
149
110
|
# (String):: Version information
|
150
111
|
def version
|
151
|
-
|
152
|
-
"rs_shutdown #{gemspec.version} - RightLink's shutdown client (c) 2011 RightScale"
|
112
|
+
"rs_shutdown #{right_link_version} - RightLink's shutdown client (c) 2013 RightScale"
|
153
113
|
end
|
154
114
|
|
155
|
-
def
|
156
|
-
|
115
|
+
def usage
|
116
|
+
Usage.scan(__FILE__)
|
157
117
|
end
|
158
118
|
|
159
119
|
end # ShutdownClient
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# === Synopsis:
|
2
|
-
# RightScale System Configuration Utility (system) - (c)
|
2
|
+
# RightScale System Configuration Utility (system) - (c) 2013 RightScale Inc
|
3
3
|
#
|
4
4
|
# This utility performs miscellaneous system configuration tasks.
|
5
5
|
#
|
@@ -24,6 +24,7 @@ require 'right_agent/scripts/common_parser'
|
|
24
24
|
|
25
25
|
# RightLink dependencies
|
26
26
|
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'agent_config'))
|
27
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'command_helper'))
|
27
28
|
|
28
29
|
cloud_dir = RightScale::AgentConfig.cloud_state_dir
|
29
30
|
|
@@ -41,6 +42,7 @@ end
|
|
41
42
|
|
42
43
|
module RightScale
|
43
44
|
class SystemConfigurator
|
45
|
+
include CommandHelper
|
44
46
|
RSA_KEY = File.join(RightScale::Platform.filesystem.ssh_cfg_dir, 'ssh_host_rsa_key')
|
45
47
|
DSA_KEY = File.join(RightScale::Platform.filesystem.ssh_cfg_dir, 'ssh_host_dsa_key')
|
46
48
|
SUDO_USER = 'rightscale'
|
@@ -109,16 +111,8 @@ module RightScale
|
|
109
111
|
opt :action, "", :type => :string
|
110
112
|
end
|
111
113
|
|
112
|
-
|
114
|
+
parse do
|
113
115
|
parser.parse
|
114
|
-
rescue Trollop::HelpNeeded
|
115
|
-
puts Usage.scan(__FILE__)
|
116
|
-
exit
|
117
|
-
rescue Trollop::CommandlineError => e
|
118
|
-
puts e.message + "\nUse --help for additional information"
|
119
|
-
exit(1)
|
120
|
-
rescue SystemExit => e
|
121
|
-
raise e
|
122
116
|
end
|
123
117
|
end
|
124
118
|
|