rightscale-cli 0.5.2 → 0.5.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1156a9a906152fa3289a2d566200e0f3c50973ac
|
4
|
+
data.tar.gz: eefa246fca31de0429b29abc099eb1b97569570d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4bb172cb85e1ca200369881305106b507807a33a5c88c9afe83d9bdec8719a1c7941530c3bcb108422b905d7d1f550a453255332fde9dda8bcd2561a9eac8e3
|
7
|
+
data.tar.gz: 03050c7b7e681593ae161b008860bb065f4599b5e7e1d70b6e1a6731320bf50d9e38643e93def8fe2e7b0d3919a567ea177731b108aa9ec46e2bc4b6f375434e
|
@@ -25,7 +25,7 @@ class RightScaleCLI
|
|
25
25
|
attr_accessor :render
|
26
26
|
|
27
27
|
def initialize(options)
|
28
|
-
config = RightScaleCLI::Config.new.
|
28
|
+
config = RightScaleCLI::Config.new.directives
|
29
29
|
config[:account_id] = options['account'] if options[:account]
|
30
30
|
config[:email] = options['user'] if options[:user]
|
31
31
|
config[:api_version] = options['api'] if options[:api]
|
@@ -15,14 +15,34 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'yaml'
|
18
|
+
require 'fileutils'
|
18
19
|
|
19
20
|
class RightScaleCLI
|
20
21
|
class Config
|
21
|
-
attr_accessor :
|
22
|
+
attr_accessor :template_path, :config_home, :config_path, :directives
|
22
23
|
|
23
24
|
def initialize(*args)
|
24
|
-
@
|
25
|
-
@
|
25
|
+
@template_path = File.join(File.dirname(__FILE__), '..', 'templates', 'right_api_client.yml.erb')
|
26
|
+
@config_home = File.join(ENV['HOME'], '.rightscale')
|
27
|
+
@config_path = File.join(@config_home, 'right_api_client.yml')
|
28
|
+
|
29
|
+
Dir.mkdir(@config_home) unless File.exists?(@config_home)
|
30
|
+
FileUtils.touch(@config_path)
|
31
|
+
|
32
|
+
# write a fresh file if it does not load/parse
|
33
|
+
unless YAML.load_file(@config_path)
|
34
|
+
@directives = {
|
35
|
+
:account_id => '',
|
36
|
+
:email => '',
|
37
|
+
:password_base64 => '',
|
38
|
+
:api_url => 'https://us-4.rightscale.com',
|
39
|
+
:api_version => '1.5'
|
40
|
+
}
|
41
|
+
File.open(@config_path, 'w') {|f| f.write(ERB.new(IO.read(@template_path)).result(binding)) }
|
42
|
+
end
|
43
|
+
|
44
|
+
# load/reload the directives from the file
|
45
|
+
@directives = YAML.load_file(@config_path)
|
26
46
|
end
|
27
47
|
end
|
28
48
|
end
|
@@ -30,60 +30,53 @@ class RightScaleCLI
|
|
30
30
|
def initialize(*args)
|
31
31
|
super
|
32
32
|
@logger = RightScaleCLI::Logger.new()
|
33
|
-
@template_path = File.join(File.dirname(__FILE__), '..', 'templates', '/right_api_client.yml.erb')
|
34
33
|
@config = RightScaleCLI::Config.new
|
35
|
-
@directives =
|
34
|
+
@directives = @config.directives
|
36
35
|
end
|
37
36
|
|
38
37
|
no_commands{
|
39
|
-
def update_conf(
|
40
|
-
|
41
|
-
Dir.mkdir(File.dirname(@config.path)) unless File.exists?(File.dirname(@config.path))
|
42
|
-
File.open(@config.path, 'w') {|f| f.write(renderer.result(binding)) }
|
38
|
+
def update_conf()
|
39
|
+
File.open(@config.config_path, 'w') {|f| f.write(ERB.new(IO.read(@config.template_path)).result(binding)) }
|
43
40
|
end
|
44
41
|
}
|
45
42
|
|
46
43
|
desc "account", "Configure the RightScale account ID for the client."
|
47
44
|
def account()
|
48
|
-
|
45
|
+
@directives.merge!( { :account_id => ask("RightScale account ID (e.g. 1337):")})
|
46
|
+
update_conf
|
49
47
|
end
|
50
48
|
|
51
49
|
desc "user", "Configure the RightScale user for the client."
|
52
50
|
def user()
|
53
|
-
|
51
|
+
@directives.merge!( { :email => ask("RightScale username (e.g. bill.gates@microsoft.com):") })
|
52
|
+
update_conf
|
54
53
|
end
|
55
54
|
|
56
55
|
desc "password", "Configure the RightScale user password for the client."
|
57
56
|
def password()
|
58
|
-
|
57
|
+
@directives.merge!( { :password_base64 => Base64.encode64(ask_pass).strip })
|
58
|
+
update_conf
|
59
59
|
end
|
60
60
|
|
61
61
|
desc "api", "Configure the RightScale API version used by the client."
|
62
62
|
def api()
|
63
|
-
|
63
|
+
@directives.merge!( { :api_version => ask("RightScale API version (e.g. 1.5):") })
|
64
|
+
update_conf
|
64
65
|
end
|
65
66
|
|
66
67
|
desc "shard", "Configure the RightScale shard used by the client."
|
67
68
|
def shard()
|
68
|
-
|
69
|
+
@directives.merge!( { :api_url => "https://#{ask("RightScale shard (e.g. us-4.rightscale.com):")}" })
|
70
|
+
update_conf
|
69
71
|
end
|
70
72
|
|
71
73
|
desc "show", "Print the current configuration from ~/.rightscale/right_api_client.yml."
|
72
74
|
def show()
|
73
|
-
puts @
|
75
|
+
puts @directives
|
74
76
|
end
|
75
77
|
|
76
78
|
desc "all", "Configure RightScale CLI."
|
77
79
|
def all()
|
78
|
-
# directives = {
|
79
|
-
# :account_id => account(),
|
80
|
-
# :email => user(),
|
81
|
-
# :password_base64 => Base64.encode64(ask_pass).strip,
|
82
|
-
# :api_url => shard(),
|
83
|
-
# :api_version => api()
|
84
|
-
# }
|
85
|
-
# @logger.debug(directives)
|
86
|
-
|
87
80
|
# currently this is the lazy way, each is written sequentially
|
88
81
|
account
|
89
82
|
user
|
@@ -57,10 +57,11 @@ class RightScaleCLI
|
|
57
57
|
def terminate(deployment)
|
58
58
|
@client.show('deployments', deployment, 'servers').each { |server|
|
59
59
|
unless server['state'] == 'inactive'
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
server.terminate
|
61
|
+
#current_instance = server['links'].select { |link| link['rel'] == 'current_instance' }.first['href']
|
62
|
+
#cloud = current_instance.split('/')[3]
|
63
|
+
#instance_id = current_instance.split('/').last
|
64
|
+
#@client.client.clouds(:id => cloud).show.instances(:id => instance_id).terminate
|
64
65
|
end
|
65
66
|
}
|
66
67
|
end
|
@@ -4,17 +4,17 @@
|
|
4
4
|
# Account ID is a required parameter. You can find your account number by logging into the
|
5
5
|
# RightScale dashboard (https://my.rightscale.com), navigate to the Settings > Account Settings page.
|
6
6
|
# The account number is at the end of the browser address bar.
|
7
|
-
:account_id: <%= directives[:account_id] %>
|
7
|
+
:account_id: <%= @directives[:account_id] %>
|
8
8
|
|
9
9
|
# There are five login mechanisms:
|
10
10
|
|
11
11
|
# 0. Use the following parameters to login with your email and base64-encoded password:
|
12
12
|
# To encode your plaintext password, use 'base64' command or similar.
|
13
|
-
:email: <%= directives[:email] %>
|
14
|
-
:password_base64: <%= directives[:password_base64] %>
|
13
|
+
:email: <%= @directives[:email] %>
|
14
|
+
:password_base64: <%= @directives[:password_base64] %>
|
15
15
|
|
16
16
|
# 1. Use the following parameters to login with your email and plaintext password:
|
17
|
-
#:email: <%= directives[:email] %>
|
17
|
+
#:email: <%= @directives[:email] %>
|
18
18
|
#:password: my_password
|
19
19
|
|
20
20
|
# 2. Use the following parameter to login with an instance_token:
|
@@ -31,5 +31,5 @@
|
|
31
31
|
#:access_token: my_token_string
|
32
32
|
|
33
33
|
# The following are optional parameters:
|
34
|
-
:api_url: <%= directives[:api_url] %>
|
35
|
-
:api_version: <%= directives[:api_version] %>
|
34
|
+
:api_url: <%= @directives[:api_url] %>
|
35
|
+
:api_version: <%= @directives[:api_version] %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rightscale-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Fordham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|