rightscale-cli 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/rightscale_cli/clouds.rb +4 -3
- data/lib/rightscale_cli/deployments.rb +2 -4
- data/lib/rightscale_cli/instances.rb +115 -0
- data/lib/rightscale_cli/logger.rb +14 -119
- data/lib/rightscale_cli/rightscale_cli.rb +2 -0
- data/lib/rightscale_cli/server_arrays.rb +6 -13
- data/lib/rightscale_cli/server_arrays/current_instances.rb +1 -2
- data/lib/rightscale_cli/server_arrays/elasticity_params.rb +1 -2
- data/lib/rightscale_cli/server_arrays/links.rb +3 -2
- data/lib/rightscale_cli/server_arrays/multi_run_executable.rb +2 -3
- data/lib/rightscale_cli/server_templates.rb +0 -3
- data/lib/rightscale_cli/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cff866f57fce9ced5a2dd94da17a19047c963e9f
|
4
|
+
data.tar.gz: 3649dc2421f581ecf8f2a4ae807a18732014501c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca0028e8910348c4be6c24f8b860908f44646646c67220dcf63478a7252f499ae7517918d44759634c8dbbc127d3883fb99e4ee2e29087f9fbbffe30038a52e8
|
7
|
+
data.tar.gz: a49994234187dca2298bb12218a4fbccc2c46ea20867719965de0c8440e3fe194555a20ddb1494527558eb35290a69eb173aed779d346dc160937e6b9693a738
|
@@ -18,7 +18,6 @@ require 'thor'
|
|
18
18
|
require 'yaml'
|
19
19
|
require 'json'
|
20
20
|
require "active_support/core_ext"
|
21
|
-
require 'rightscale_cli/logger'
|
22
21
|
|
23
22
|
class RightScaleCLI
|
24
23
|
class Clouds < Thor
|
@@ -28,6 +27,9 @@ class RightScaleCLI
|
|
28
27
|
def list()
|
29
28
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
30
29
|
clouds = []
|
30
|
+
|
31
|
+
$log.info "Retrieving all clouds from #{rightscale.account_id}."
|
32
|
+
|
31
33
|
rightscale.clouds.index.each { |cloud|
|
32
34
|
clouds.push(cloud.raw)
|
33
35
|
}
|
@@ -46,14 +48,13 @@ class RightScaleCLI
|
|
46
48
|
option :cloud_type, :type => :string, :required => false
|
47
49
|
option :description, :type => :string, :required => false
|
48
50
|
def search()
|
49
|
-
log = CLILogger.new
|
50
51
|
|
51
52
|
filter = []
|
52
53
|
filter.push("name==#{options[:name]}") if options[:name]
|
53
54
|
filter.push("cloud_type==#{options[:cloud_type]}") if options[:cloud_type]
|
54
55
|
filter.push("description==#{options[:cloud]}") if options[:description]
|
55
56
|
|
56
|
-
log.info
|
57
|
+
$log.info "Searching for clouds!"
|
57
58
|
|
58
59
|
puts "filter: #{filter}" if options[:debug]
|
59
60
|
|
@@ -22,10 +22,8 @@ class RightScaleCLI
|
|
22
22
|
class Deployments < Thor
|
23
23
|
namespace :deployments
|
24
24
|
|
25
|
-
desc "
|
26
|
-
def
|
27
|
-
option :xml, :type => :boolean, :default => false, :aliases => '-X', :desc => 'Return XML.'
|
28
|
-
|
25
|
+
desc "list", "Lists all deployments."
|
26
|
+
def list()
|
29
27
|
deployments = Array.new
|
30
28
|
RightApi::Client.new(RightScaleCLI::Config::API).deployments.index.each { |deployment|
|
31
29
|
deployments.push(deployment.raw)
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# Author:: Chris Fordham (<chris@fordham-nagy.id.au>)
|
2
|
+
# Copyright:: Copyright (c) 2013 Chris Fordham
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'thor'
|
18
|
+
require 'yaml'
|
19
|
+
require 'right_api_client'
|
20
|
+
require 'rightscale_cli/logger'
|
21
|
+
|
22
|
+
class RightScaleCLI
|
23
|
+
class Instances < Thor
|
24
|
+
namespace :instances
|
25
|
+
|
26
|
+
desc "list", "Lists all instances for a given cloud."
|
27
|
+
option :cloud, :desc => 'The cloud to filter on.', :type => :string, :required => true
|
28
|
+
option :datacenter, :desc => 'The href of the datacenter to filter on', :type => :string, :required => false
|
29
|
+
option :deployment, :desc => 'The href of the deployment to filter on.', :type => :string, :required => false
|
30
|
+
option :name, :desc => 'Name of the Instance to filter on.', :type => :string, :required => false
|
31
|
+
option :os, :desc => 'The OS platform to filter on.', :type => :string, :required => false
|
32
|
+
option :parent, :desc => 'The href of the parent to filter on.', :type => :string, :required => false
|
33
|
+
option :private_dns => 'The private dns name to filter on.', :type => :string, :required => false
|
34
|
+
option :private_ip, :desc => 'The private ip address to filter on.', :type => :string, :required => false
|
35
|
+
option :public_dns, :desc => 'The public dns name to filter on.', :type => :string, :required => false
|
36
|
+
option :public_ip, :desc => 'The public ip address to filter on.', :type => :string, :required => false
|
37
|
+
option :resource_uid, :desc => 'Resource Unique IDentifier for the Instance to filter on.', :type => :string, :required => false
|
38
|
+
option :server_template, :desc => 'The href of the ServerTemplate to filter on.', :type => :string, :required => false
|
39
|
+
option :state, :desc => 'The state of Instances to filter on.', :type => :string, :required => false
|
40
|
+
def list()
|
41
|
+
instances = []
|
42
|
+
filter = []
|
43
|
+
|
44
|
+
filter.push("datacenter_href==#{options[:datacenter]}") if options[:datacenter]
|
45
|
+
filter.push("deployment_href==#{options[:deployment]}") if options[:deployment]
|
46
|
+
filter.push("name==#{options[:private_ip]}") if options[:name]
|
47
|
+
filter.push("os_platform==#{options[:os]}") if options[:os]
|
48
|
+
filter.push("parent_href==#{options[:parent]}") if options[:parent]
|
49
|
+
filter.push("private_dns_name==#{options[:private_dns]}") if options[:private_dns]
|
50
|
+
filter.push("private_ip_address==#{options[:private_ip]}") if options[:private_ip]
|
51
|
+
filter.push("public_dns==#{options[:public_dns]}") if options[:public_dns]
|
52
|
+
filter.push("public_ip_address==#{options[:public_ip]}") if options[:public_ip]
|
53
|
+
filter.push("resource_uid==#{options[:resource_uid]}") if options[:resource_uid]
|
54
|
+
filter.push("server_template_href==#{options[:server_template]}") if options[:server_template]
|
55
|
+
filter.push("state==#{options[:state]}") if options[:state]
|
56
|
+
|
57
|
+
$log.debug "filter: #{filter}" if options[:debug]
|
58
|
+
|
59
|
+
RightApi::Client.new(RightScaleCLI::Config::API).clouds(:id => options[:cloud]).show.instances(:filter => filter).index.each { |instance|
|
60
|
+
instances.push(instance.raw)
|
61
|
+
}
|
62
|
+
puts instances.to_yaml
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "run-exec", "Runs a chef recipe or rightscript on instances of a given cloud."
|
66
|
+
option :cloud, :desc => 'The cloud to filter on.', :type => :string, :required => true
|
67
|
+
option :datacenter, :desc => 'The href of the datacenter to filter on', :type => :string, :required => false
|
68
|
+
option :deployment, :desc => 'The href of the deployment to filter on.', :type => :string, :required => false
|
69
|
+
option :name, :desc => 'Name of the Instance to filter on.', :type => :string, :required => false
|
70
|
+
option :os, :desc => 'The OS platform to filter on.', :type => :string, :required => false
|
71
|
+
option :parent, :desc => 'The href of the parent to filter on.', :type => :string, :required => false
|
72
|
+
option :private_dns => 'The private dns name to filter on.', :type => :string, :required => false
|
73
|
+
option :private_ip, :desc => 'The private ip address to filter on.', :type => :string, :required => false
|
74
|
+
option :public_dns, :desc => 'The public dns name to filter on.', :type => :string, :required => false
|
75
|
+
option :public_ip, :desc => 'The public ip address to filter on.', :type => :string, :required => false
|
76
|
+
option :resource_uid, :desc => 'Resource Unique IDentifier for the Instance to filter on.', :type => :string, :required => false
|
77
|
+
option :server_template, :desc => 'The href of the ServerTemplate to filter on.', :type => :string, :required => false
|
78
|
+
option :state, :desc => 'The state of Instances to filter on.', :type => :string, :required => false
|
79
|
+
def run_exec(exec_type, exec_identifier)
|
80
|
+
params = {}
|
81
|
+
filter = []
|
82
|
+
|
83
|
+
if exec_type == 'recipe'
|
84
|
+
params['recipe_name'] = exec_identifier
|
85
|
+
elsif exec_type == 'rightscript'
|
86
|
+
params['right_script_href'] = "/api/right_scripts/#{exec_identifier}"
|
87
|
+
end
|
88
|
+
|
89
|
+
filter.push("datacenter_href==#{options[:datacenter]}") if options[:datacenter]
|
90
|
+
filter.push("deployment_href==#{options[:deployment]}") if options[:deployment]
|
91
|
+
filter.push("name==#{options[:private_ip]}") if options[:name]
|
92
|
+
filter.push("os_platform==#{options[:os]}") if options[:os]
|
93
|
+
filter.push("parent_href==#{options[:parent]}") if options[:parent]
|
94
|
+
filter.push("private_dns_name==#{options[:private_dns]}") if options[:private_dns]
|
95
|
+
filter.push("private_ip_address==#{options[:private_ip]}") if options[:private_ip]
|
96
|
+
filter.push("public_dns==#{options[:public_dns]}") if options[:public_dns]
|
97
|
+
filter.push("public_ip_address==#{options[:public_ip]}") if options[:public_ip]
|
98
|
+
filter.push("resource_uid==#{options[:resource_uid]}") if options[:resource_uid]
|
99
|
+
filter.push("server_template_href==#{options[:server_template]}") if options[:server_template]
|
100
|
+
filter.push("state==#{options[:state]}") if options[:state]
|
101
|
+
|
102
|
+
params['filter'] = filter
|
103
|
+
$log.debug "filter: #{filter}" if options[:debug]
|
104
|
+
$log.debug "params: #{params}" if options[:debug]
|
105
|
+
|
106
|
+
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
107
|
+
|
108
|
+
rightscale.clouds(:id => options[:cloud]).show.instances.multi_run_executable(params)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.banner(task, namespace = true, subcommand = false)
|
112
|
+
"#{basename} #{task.formatted_usage(self, true, subcommand)}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -16,124 +16,19 @@
|
|
16
16
|
|
17
17
|
require 'logger'
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
#
|
27
|
-
# So, by default:
|
28
|
-
# * debug messages do not appear anywhere
|
29
|
-
# * info messages appear on the standard output
|
30
|
-
# * warn, error, and fatal messagse appear on the standard error
|
31
|
-
# * The default format of messages is simply the message, no logging cruft, however if your output
|
32
|
-
# is redirected to a file, a better timestamped logging format is used
|
33
|
-
#
|
34
|
-
# You can customize this in several ways:
|
35
|
-
#
|
36
|
-
# * You can override the devices used by passing different devices to the constructor
|
37
|
-
# * You can adjust the level of message that goes to the error logger via error_level=
|
38
|
-
# * You can adjust the format for messages to the error logger separately via error_formatter=
|
39
|
-
#
|
40
|
-
# === Example
|
41
|
-
#
|
42
|
-
# logger = CLILogger.new
|
43
|
-
# logger.debug("Starting up") # => only the standard output gets this
|
44
|
-
# logger.warn("careful!") # => only the standard error gets this
|
45
|
-
# logger.error("Something went wrong!") # => only the standard error gets this
|
46
|
-
#
|
47
|
-
# logger = CLILogger.new
|
48
|
-
# logger.error_level = Logger::ERROR
|
49
|
-
# logger.debug("Starting up") # => only the standard output gets this
|
50
|
-
# logger.warn("careful!") # => only the standard OUTPUT gets this
|
51
|
-
# logger.error("Something went wrong!") # => only the standard error gets this
|
52
|
-
#
|
53
|
-
# logger = CLILogger.new('logfile.txt')
|
54
|
-
# logger.debug("Starting up") # => logfile.txt gets this
|
55
|
-
# logger.error("Something went wrong!") # => BOTH logfile.txt AND the standard error get this
|
56
|
-
class CLILogger < Logger
|
57
|
-
BLANK_FORMAT = proc { |severity,datetime,progname,msg|
|
58
|
-
msg + "\n"
|
59
|
-
}
|
60
|
-
|
61
|
-
# Helper to proxy methods to the super class AND to the internal error logger
|
62
|
-
#
|
63
|
-
# +symbol+:: Symbol for name of the method to proxy
|
64
|
-
def self.proxy_method(symbol) #:nodoc:
|
65
|
-
old_name = "old_#{symbol}".to_sym
|
66
|
-
alias_method old_name,symbol
|
67
|
-
define_method symbol do |*args,&block|
|
68
|
-
send(old_name,*args,&block)
|
69
|
-
@stderr_logger.send(symbol,*args,&block)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
proxy_method :'formatter='
|
74
|
-
proxy_method :'datetime_format='
|
75
|
-
|
76
|
-
def add(severity, message = nil, progname = nil, &block) #:nodoc:
|
77
|
-
if @split_logs
|
78
|
-
unless severity >= @stderr_logger.level
|
79
|
-
super(severity,message,progname,&block)
|
80
|
-
end
|
81
|
-
else
|
82
|
-
super(severity,message,progname,&block)
|
83
|
-
end
|
84
|
-
@stderr_logger.add(severity,message,progname,&block)
|
85
|
-
end
|
86
|
-
|
87
|
-
DEFAULT_ERROR_LEVEL = Logger::Severity::WARN
|
88
|
-
|
89
|
-
# A logger that logs error-type messages to a second device; useful
|
90
|
-
# for ensuring that error messages go to standard error. This should be
|
91
|
-
# pretty smart about doing the right thing. If both log devices are
|
92
|
-
# ttys, e.g. one is going to standard error and the other to the standard output,
|
93
|
-
# messages only appear once in the overall output stream. In other words,
|
94
|
-
# an ERROR logged will show up *only* in the standard error. If either
|
95
|
-
# log device is NOT a tty, then all messages go to +log_device+ and only
|
96
|
-
# errors go to +error_device+
|
97
|
-
#
|
98
|
-
# +log_device+:: device where all log messages should go, based on level
|
99
|
-
# +error_device+:: device where all error messages should go. By default, this is Logger::Severity::WARN
|
100
|
-
def initialize(log_device=$stdout,error_device=$stderr)
|
101
|
-
super(log_device)
|
102
|
-
@stderr_logger = Logger.new(error_device)
|
103
|
-
|
104
|
-
@split_logs = log_device.tty? && error_device.tty?
|
105
|
-
|
106
|
-
self.level = Logger::Severity::INFO
|
107
|
-
@stderr_logger.level = DEFAULT_ERROR_LEVEL
|
108
|
-
|
109
|
-
self.formatter = BLANK_FORMAT if log_device.tty?
|
110
|
-
@stderr_logger.formatter = BLANK_FORMAT if error_device.tty?
|
111
|
-
end
|
112
|
-
|
113
|
-
def level=(level)
|
114
|
-
super(level)
|
115
|
-
current_error_level = @stderr_logger.level
|
116
|
-
if (level > DEFAULT_ERROR_LEVEL) && @split_logs
|
117
|
-
@stderr_logger.level = level
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Set the threshold for what messages go to the error device. Note that calling
|
122
|
-
# #level= will *not* affect the error logger *unless* both devices are TTYs.
|
123
|
-
#
|
124
|
-
# +level+:: a constant from Logger::Severity for the level of messages that should go
|
125
|
-
# to the error logger
|
126
|
-
def error_level=(level)
|
127
|
-
@stderr_logger.level = level
|
128
|
-
end
|
129
|
-
|
130
|
-
# Overrides the formatter for the error logger. A future call to #formatter= will
|
131
|
-
# affect both, so the order of the calls matters.
|
132
|
-
#
|
133
|
-
# +formatter+:: Proc that handles the formatting, the same as for #formatter=
|
134
|
-
def error_formatter=(formatter)
|
135
|
-
@stderr_logger.formatter=formatter
|
19
|
+
unless defined? $log
|
20
|
+
log_init_msg = 'Initializing Logging using '
|
21
|
+
if ENV['RIGHT_API_CLIENT_LOG']
|
22
|
+
if File.exists?(ENV['RIGHT_API_CLIENT_LOG'])
|
23
|
+
file = File.open(ENV['RIGHT_API_CLIENT_LOG'], File::WRONLY | File::APPEND)
|
24
|
+
else
|
25
|
+
file = ENV['RIGHT_API_CLIENT_LOG']
|
136
26
|
end
|
137
|
-
|
27
|
+
$log = Logger.new(file)
|
28
|
+
log_init_msg += ENV['RIGHT_API_CLIENT_LOG']
|
29
|
+
else
|
30
|
+
$log = Logger.new(STDOUT)
|
31
|
+
log_init_msg += 'STDOUT'
|
138
32
|
end
|
139
|
-
|
33
|
+
$log.info log_init_msg
|
34
|
+
end
|
@@ -19,6 +19,7 @@ require 'rightscale_cli/output'
|
|
19
19
|
require 'rightscale_cli/clouds'
|
20
20
|
require 'rightscale_cli/dashboard'
|
21
21
|
require 'rightscale_cli/deployments'
|
22
|
+
require 'rightscale_cli/instances'
|
22
23
|
require 'rightscale_cli/servers'
|
23
24
|
require 'rightscale_cli/server_arrays'
|
24
25
|
require 'rightscale_cli/server_templates'
|
@@ -37,6 +38,7 @@ class RightScaleCLI
|
|
37
38
|
register(Dashboard, 'dashboard', 'dashboard <command>', 'RightScale Dashboard (HTTP hax).')
|
38
39
|
register(ServerArrays, 'arrays', 'arrays <command>', 'Manage server arrays.')
|
39
40
|
register(Deployments, 'deployments', 'deployments <command>', 'Manage deployments.')
|
41
|
+
register(Instances, 'instances', 'instances <command>', 'Manage instances.')
|
40
42
|
register(Servers, 'servers', 'servers <command>', 'Manage servers.')
|
41
43
|
register(ServerTemplates, 'server_templates', 'server-templates <command>', 'Manage ServerTemplates.')
|
42
44
|
end
|
@@ -39,7 +39,6 @@ class RightScaleCLI
|
|
39
39
|
option :deployment, :type => :string, :required => false
|
40
40
|
option :name, :type => :string, :required => false
|
41
41
|
def list()
|
42
|
-
log = CLILogger.new
|
43
42
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
44
43
|
|
45
44
|
filter = []
|
@@ -47,7 +46,7 @@ class RightScaleCLI
|
|
47
46
|
filter.push("deployment_href==/api/deployments/#{options[:cloud]}") if options[:deployment]
|
48
47
|
filter.push("name==#{options[:name]}") if options[:name]
|
49
48
|
|
50
|
-
log.
|
49
|
+
$log.debug "filter: #{filter}" if options[:debug]
|
51
50
|
|
52
51
|
server_arrays = []
|
53
52
|
rightscale.server_arrays.index(:filter => filter).each { |server_array|
|
@@ -65,7 +64,6 @@ class RightScaleCLI
|
|
65
64
|
|
66
65
|
desc "show", "Shows a server array."
|
67
66
|
def show(server_array_id)
|
68
|
-
log = CLILogger.new
|
69
67
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
70
68
|
|
71
69
|
server_array = rightscale.server_arrays(:id => server_array_id).show.raw
|
@@ -81,40 +79,35 @@ class RightScaleCLI
|
|
81
79
|
|
82
80
|
desc "state", "Shows the state of a server array."
|
83
81
|
def state(server_array_id)
|
84
|
-
log
|
85
|
-
log.info "Retrieving state for server array, #{server_array_id}."
|
82
|
+
$log.info "Retrieving state for server array, #{server_array_id}."
|
86
83
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
87
84
|
puts rightscale.server_arrays(:id => server_array_id).show.state
|
88
85
|
end
|
89
86
|
|
90
87
|
desc "instances_count", "Shows the instances count of a server array."
|
91
88
|
def instances_count(server_array_id)
|
92
|
-
log
|
93
|
-
log.info "Retrieving instances count for server array, #{server_array_id}."
|
89
|
+
$log.info "Retrieving instances count for server array, #{server_array_id}."
|
94
90
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
95
91
|
puts rightscale.server_arrays(:id => server_array_id).show.instances_count
|
96
92
|
end
|
97
93
|
|
98
94
|
desc "desc", "Shows the description of a server array."
|
99
95
|
def desc(server_array_id)
|
100
|
-
log
|
101
|
-
log.info "Retrieving description for server array, #{server_array_id}."
|
96
|
+
$log.info "Retrieving description for server array, #{server_array_id}."
|
102
97
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
103
98
|
puts rightscale.server_arrays(:id => server_array_id).show.description
|
104
99
|
end
|
105
100
|
|
106
101
|
desc "name", "Shows the name of a server array."
|
107
102
|
def name(server_array_id)
|
108
|
-
log
|
109
|
-
log.info "Retrieving name for server array, #{server_array_id}."
|
103
|
+
$log.info "Retrieving name for server array, #{server_array_id}."
|
110
104
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
111
105
|
puts rightscale.server_arrays(:id => server_array_id).show.name
|
112
106
|
end
|
113
107
|
|
114
108
|
desc "api_methods", "Lists the API methods available to a server array."
|
115
109
|
def api_methods(server_array_id)
|
116
|
-
log
|
117
|
-
log.info "Retrieving API methods for server array, #{server_array_id}."
|
110
|
+
$log.info "Retrieving API methods for server array, #{server_array_id}."
|
118
111
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
119
112
|
server_array = rightscale.server_arrays(:id => server_array_id).show.api_methods
|
120
113
|
puts server_array
|
@@ -35,7 +35,6 @@ class RightScaleCLI
|
|
35
35
|
option :state, :desc => 'The state of Instances to filter on.', :type => :string, :required => false
|
36
36
|
|
37
37
|
def instances(server_array_id)
|
38
|
-
log = CLILogger.new
|
39
38
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
40
39
|
|
41
40
|
array_instances = []
|
@@ -54,7 +53,7 @@ class RightScaleCLI
|
|
54
53
|
filter.push("server_template_href==#{options[:server_template]}") if options[:server_template]
|
55
54
|
filter.push("state==#{options[:state]}") if options[:state]
|
56
55
|
|
57
|
-
log.
|
56
|
+
$log.debug "filter: #{filter}" if options[:debug]
|
58
57
|
|
59
58
|
rightscale.server_arrays(:id => server_array_id).show.current_instances(:filter => filter).index.each { |array_instance|
|
60
59
|
array_instances.push(array_instance.raw)
|
@@ -20,8 +20,7 @@ class RightScaleCLI
|
|
20
20
|
desc "params", "Lists the elasticity parameters for a server array."
|
21
21
|
|
22
22
|
def params(server_array_id)
|
23
|
-
log
|
24
|
-
log.info "Retrieving elasticity parameters for server array, #{server_array_id}."
|
23
|
+
$log.info "Retrieving elasticity parameters for server array, #{server_array_id}."
|
25
24
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
26
25
|
puts rightscale.server_arrays(:id => server_array_id).show.elasticity_params.to_yaml
|
27
26
|
end
|
@@ -14,14 +14,15 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require 'rightscale_cli/logger'
|
18
|
+
|
17
19
|
class RightScaleCLI
|
18
20
|
class ServerArrays < Thor
|
19
21
|
|
20
22
|
desc "links", "Lists the links for a server array."
|
21
23
|
|
22
24
|
def links(server_array_id)
|
23
|
-
log
|
24
|
-
log.info "Retrieving links for server array, #{server_array_id}."
|
25
|
+
$log.info "Retrieving links for server array, #{server_array_id}."
|
25
26
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
26
27
|
puts rightscale.server_arrays(:id => server_array_id).show.links.to_yaml
|
27
28
|
end
|
@@ -20,7 +20,6 @@ class RightScaleCLI
|
|
20
20
|
desc "run_exec", "Runs a RightScript or Chef recipe on the array instances."
|
21
21
|
|
22
22
|
def run_exec(server_array_id, exec_type, exec_identifier)
|
23
|
-
log = CLILogger.new
|
24
23
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
25
24
|
|
26
25
|
params = {}
|
@@ -33,8 +32,8 @@ class RightScaleCLI
|
|
33
32
|
|
34
33
|
server_array = rightscale.server_arrays(:id => server_array_id)
|
35
34
|
|
36
|
-
log.info "params: #{params}" if options[:debug]
|
37
|
-
log.info "Running executable on server array."
|
35
|
+
$log.info "params: #{params}" if options[:debug]
|
36
|
+
$log.info "Running executable on server array."
|
38
37
|
|
39
38
|
server_array.multi_run_executable(params)
|
40
39
|
end
|
@@ -30,7 +30,6 @@ class RightScaleCLI
|
|
30
30
|
|
31
31
|
desc "list", "Lists ServerTemplates."
|
32
32
|
def list()
|
33
|
-
log = CLILogger.new
|
34
33
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
35
34
|
server_templates = []
|
36
35
|
rightscale.server_templates.index.each { |server_template|
|
@@ -48,7 +47,6 @@ class RightScaleCLI
|
|
48
47
|
|
49
48
|
desc "show", "Shows a ServerTemplate."
|
50
49
|
def show(server_template_id)
|
51
|
-
log = CLILogger.new
|
52
50
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
53
51
|
|
54
52
|
server_template = rightscale.server_templates(:id => server_template_id).show.raw
|
@@ -64,7 +62,6 @@ class RightScaleCLI
|
|
64
62
|
|
65
63
|
desc "inputs", "Shows a ServerTemplate's inputs."
|
66
64
|
def inputs(server_template_id)
|
67
|
-
log = CLILogger.new
|
68
65
|
rightscale = RightApi::Client.new(RightScaleCLI::Config::API)
|
69
66
|
|
70
67
|
server_template_inputs = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rightscale-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Fordham
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/rightscale_cli/rightscale_cli.rb
|
108
108
|
- lib/rightscale_cli/monkey_patches/client_attributes.rb
|
109
109
|
- lib/rightscale_cli/output.rb
|
110
|
+
- lib/rightscale_cli/instances.rb
|
110
111
|
- lib/rightscale_cli/client.rb
|
111
112
|
- lib/rightscale_cli/version.rb
|
112
113
|
- lib/rightscale_cli/server_templates.rb
|