c66 0.1.0 → 0.1.91
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of c66 might be problematic. Click here for more details.
- data/.gitignore +10 -5
- data/Gemfile.lock +42 -0
- data/README.md +139 -50
- data/lib/c66/commands/c66_toolbelt.rb +201 -59
- data/lib/c66/utils/version.rb +2 -1
- metadata +102 -70
- /data/bin/{c66.rb → c66} +0 -0
data/.gitignore
CHANGED
@@ -2,12 +2,8 @@
|
|
2
2
|
*.rbc
|
3
3
|
.bundle
|
4
4
|
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
5
|
coverage
|
10
|
-
|
6
|
+
InstalledFiles
|
11
7
|
lib/bundler/man
|
12
8
|
pkg
|
13
9
|
rdoc
|
@@ -15,3 +11,12 @@ spec/reports
|
|
15
11
|
test/tmp
|
16
12
|
test/version_tmp
|
17
13
|
tmp
|
14
|
+
.cloud66
|
15
|
+
|
16
|
+
# YARD artifacts
|
17
|
+
.yardoc
|
18
|
+
_yardoc
|
19
|
+
doc/
|
20
|
+
|
21
|
+
.ruby-gemset
|
22
|
+
.ruby-version
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
c66 (0.1.91)
|
5
|
+
bundler (~> 1.3)
|
6
|
+
httparty (~> 0.11.0)
|
7
|
+
json (~> 1.7.7)
|
8
|
+
oauth2 (~> 0.9.2)
|
9
|
+
rake (~> 10.1.0)
|
10
|
+
thor (~> 0.18.1)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
faraday (0.8.8)
|
16
|
+
multipart-post (~> 1.2.0)
|
17
|
+
httparty (0.11.0)
|
18
|
+
multi_json (~> 1.0)
|
19
|
+
multi_xml (>= 0.5.2)
|
20
|
+
httpauth (0.2.0)
|
21
|
+
json (1.7.7)
|
22
|
+
jwt (0.1.8)
|
23
|
+
multi_json (>= 1.5)
|
24
|
+
multi_json (1.7.8)
|
25
|
+
multi_xml (0.5.4)
|
26
|
+
multipart-post (1.2.0)
|
27
|
+
oauth2 (0.9.2)
|
28
|
+
faraday (~> 0.8)
|
29
|
+
httpauth (~> 0.2)
|
30
|
+
jwt (~> 0.1.4)
|
31
|
+
multi_json (~> 1.0)
|
32
|
+
multi_xml (~> 0.5)
|
33
|
+
rack (~> 1.2)
|
34
|
+
rack (1.4.5)
|
35
|
+
rake (10.1.0)
|
36
|
+
thor (0.18.1)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
c66!
|
data/README.md
CHANGED
@@ -1,111 +1,200 @@
|
|
1
|
-
|
1
|
+
<h1 class="doc-title">Cloud 66 Toolbelt</h1>
|
2
|
+
<p class="lead">Cloud 66 Toolbelt is a simple command-line tool for the awesome Cloud 66 customers. It allows you to deploy, modify settings and retrieve the current status of your Cloud 66 stacks, and much more!</p>
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
## Installation
|
4
|
+
## Installation {: class=divider-title}
|
6
5
|
|
7
6
|
You can install the Cloud 66 Toolbelt using [RubyGems](http://rubygems.org/):
|
7
|
+
<p>
|
8
|
+
<kbd>$ gem install c66</kbd>
|
9
|
+
</p>
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
## Usage
|
11
|
+
## Help {: class=divider-title}
|
12
12
|
|
13
|
-
### Help
|
14
13
|
With c66 installed, you can display the help with one of the following instructions:
|
14
|
+
<p>
|
15
|
+
<kbd>$ c66 help</kbd>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
or
|
15
19
|
|
16
|
-
|
20
|
+
<p>
|
21
|
+
<kbd>$ c66</kbd>
|
22
|
+
</p>
|
17
23
|
|
18
|
-
or
|
24
|
+
or for a specific command:
|
19
25
|
|
20
|
-
|
26
|
+
<p>
|
27
|
+
<kbd>$ c66 help <command></kbd>
|
28
|
+
</p>
|
21
29
|
|
22
|
-
|
30
|
+
## Initialize the Toolbelt {: class=divider-title}
|
23
31
|
|
24
32
|
Firstly, to use the Toolbelt, you will need to initiate it using:
|
25
33
|
|
26
|
-
|
27
|
-
|
34
|
+
<p>
|
35
|
+
<kbd>$ c66 init</kbd>
|
36
|
+
</p>
|
37
|
+
|
28
38
|
Then visit the URL given once authorized, copy and paste the `authorization code` into the command-line interface.
|
29
|
-
|
30
39
|
You need to sign in and allow the Cloud 66 Toolbelt application to use your account to access to the authorization code.
|
31
40
|
|
32
|
-
Note
|
41
|
+
**Note**: This is a one-off task.
|
33
42
|
|
34
|
-
|
43
|
+
## List the Stacks {: class=divider-title}
|
35
44
|
|
36
45
|
You can list all your stacks using:
|
37
46
|
|
38
|
-
|
47
|
+
<p>
|
48
|
+
<kbd>$ c66 list</kbd>
|
49
|
+
</p>
|
39
50
|
|
40
|
-
|
51
|
+
## Deploy a Stack {: class=divider-title}
|
41
52
|
|
42
53
|
Deploy a stack using the command `deploy` with a stack UID (Unique Identifer):
|
43
54
|
|
44
|
-
|
45
|
-
|
55
|
+
<p>
|
56
|
+
<kbd>$ c66 deploy --stack <stack_UID></kbd>
|
57
|
+
</p>
|
58
|
+
|
46
59
|
or
|
47
60
|
|
48
|
-
|
49
|
-
|
61
|
+
<p>
|
62
|
+
<kbd>$ c66 deploy -s <stack_UID></kbd>
|
63
|
+
</p>
|
64
|
+
|
50
65
|
You can retrieve the UID of a stack using the `list` command.
|
51
|
-
|
52
66
|
Through the Cloud 66 interface, click on your stack, then click on the cog and select the stack information view to retrieve the UID:
|
53
|
-
|
54
67
|
![stack_uid](http://cdn.cloud66.com.s3.amazonaws.com/images/Toolbelt/exemple_stack_uid.PNG)
|
55
68
|
|
56
|
-
|
69
|
+
There is a command to save a default stack UID:
|
70
|
+
|
71
|
+
<p>
|
72
|
+
<kbd>$ c66 save --stack <stack_UID></kbd>
|
73
|
+
</p>
|
74
|
+
|
75
|
+
or
|
76
|
+
|
77
|
+
<p>
|
78
|
+
<kbd>$ c66 save -s <stack_UID></kbd>
|
79
|
+
</p>
|
80
|
+
|
81
|
+
**Note:** The stack is saved in your current folder (.cloud66/stack.json) and only one default stack will be saved per folder.
|
57
82
|
|
58
|
-
|
83
|
+
When your stack UID is saved, you are able to use other commands without specify the stack UID.
|
84
|
+
For instance, it allows you to deploy a stack without putting the stack UID every time:
|
59
85
|
|
86
|
+
<p>
|
87
|
+
<kbd>$ c66 deploy</kbd>
|
88
|
+
</p>
|
89
|
+
|
60
90
|
you can use a short-cut for this command:
|
61
91
|
|
62
|
-
|
92
|
+
<p>
|
93
|
+
<kbd>$ c66 d</kbd>
|
94
|
+
</p>
|
63
95
|
|
64
|
-
|
96
|
+
You can save multiple stack UID by giving an alias to a specific stack:
|
65
97
|
|
66
|
-
|
98
|
+
<p>
|
99
|
+
<kbd>$ c66 save --stack <stack_UID> --alias <stack_alias></kbd>
|
100
|
+
</p>
|
67
101
|
|
68
|
-
|
102
|
+
Then you can use commands and specific a stack's alias, like so:
|
69
103
|
|
70
|
-
|
104
|
+
<p>
|
105
|
+
<kbd>$ c66 deploy -s <stack_alias></kbd>
|
106
|
+
</p>
|
71
107
|
|
72
|
-
|
108
|
+
## Settings of a Stack {: class=divider-title}
|
73
109
|
|
74
|
-
|
110
|
+
It is possible to retrieve the settings of a specified stack and to easily modify them:
|
75
111
|
|
76
|
-
|
112
|
+
To display the settings:
|
113
|
+
|
114
|
+
<p>
|
115
|
+
<kbd>$ c66 settings --stack <stack_UID></kbd>
|
116
|
+
</p>
|
117
|
+
|
118
|
+
or
|
77
119
|
|
78
|
-
|
120
|
+
<p>
|
121
|
+
<kbd>$ c66 settings -s <stack_UID></kbd>
|
122
|
+
</p>
|
123
|
+
|
124
|
+
If a default stack UID is saved:
|
79
125
|
|
126
|
+
<p>
|
127
|
+
<kbd>$ c66 settings</kbd>
|
128
|
+
</p>
|
129
|
+
|
80
130
|
To modify a setting:
|
81
131
|
|
82
|
-
|
132
|
+
<p>
|
133
|
+
<kbd>$ c66 set --stack <stack_UID> --setting_name <setting_name> --value <value></kbd>
|
134
|
+
</p>
|
135
|
+
|
136
|
+
or
|
137
|
+
|
138
|
+
<p>
|
139
|
+
<kbd>$ c66 set -s <stack_UID> -n <setting_name> -v <value></kbd>
|
140
|
+
</p>
|
141
|
+
|
142
|
+
If a default stack UID is saved:
|
83
143
|
|
144
|
+
<p>
|
145
|
+
<kbd>$ c66 set --setting_name <setting_name> --value <value></kbd>
|
146
|
+
</p>
|
147
|
+
|
84
148
|
or
|
85
149
|
|
86
|
-
|
150
|
+
<p>
|
151
|
+
<kbd>$ c66 set -n <setting_name> -v <value></kbd>
|
152
|
+
</p>
|
87
153
|
|
88
|
-
|
154
|
+
## Lease an IP address (version ≥ 0.1.91){: class=divider-title}
|
89
155
|
|
90
|
-
|
156
|
+
You can allow an IP address to connect temporary to the specific stack through ssh (22):
|
91
157
|
|
92
|
-
|
158
|
+
<p>
|
159
|
+
<kbd>$ c66 lease --stack <stack_UID> --ip-address <ip_address> --time-to-open <time_to_open></kbd>
|
160
|
+
</p>
|
93
161
|
|
94
|
-
|
162
|
+
or
|
95
163
|
|
164
|
+
<p>
|
165
|
+
<kbd>$ c66 lease -s <stack_UID> -i <ip_address> -t <time_to_open></kbd>
|
166
|
+
</p>
|
96
167
|
|
97
|
-
|
168
|
+
Options *ip-address* and *time-to-open* are optional.
|
169
|
+
By default:
|
98
170
|
|
99
|
-
|
171
|
+
- *ip-address* : your IP address
|
172
|
+
- *time-to-open* : 20 minutes
|
100
173
|
|
101
|
-
|
174
|
+
To allow your own IP address to connect temporary to the specific stack:
|
102
175
|
|
103
|
-
|
176
|
+
<p>
|
177
|
+
<kbd>$ c66 lease --stack <stack_UID></kbd>
|
178
|
+
</p>
|
104
179
|
|
105
|
-
|
180
|
+
If a default stack UID is saved:
|
106
181
|
|
107
|
-
|
182
|
+
<p>
|
183
|
+
<kbd>$ c66 lease</kbd>
|
184
|
+
</p>
|
108
185
|
|
109
|
-
##
|
186
|
+
## Information of your toolbelt settings {: class=divider-title}
|
110
187
|
|
111
|
-
|
188
|
+
At any time, you can see your toolbelt settings, it includes the version of the toolbelt but also some information about your saved stacks:
|
189
|
+
|
190
|
+
<p>
|
191
|
+
<kbd>$ c66 info</kbd>
|
192
|
+
</p>
|
193
|
+
|
194
|
+
## Contributing {: class=divider-title}
|
195
|
+
|
196
|
+
1. Fork it
|
197
|
+
2. Create your feature branch `git checkout -b my-new-feature`
|
198
|
+
3. Commit your changes `git commit -am 'Add some feature'`
|
199
|
+
4. Push to the branch `git push origin my-new-feature`
|
200
|
+
5. Create new Pull Request
|
@@ -8,6 +8,7 @@ module C66
|
|
8
8
|
module Commands
|
9
9
|
|
10
10
|
CLIENT_NAME = 'c66'
|
11
|
+
CLIENT_FULLNAME = 'Cloud 66 Toolbelt'
|
11
12
|
|
12
13
|
STK_QUEUED = 0
|
13
14
|
STK_SUCCESS = 1
|
@@ -18,6 +19,8 @@ module C66
|
|
18
19
|
STK_DEPLOYING = 6
|
19
20
|
STK_TERMINAL_FAILURE = 7
|
20
21
|
|
22
|
+
FORBIDDEN_STACKS_ALIAS = ['params', 'toolbelt']
|
23
|
+
|
21
24
|
STATUS = {
|
22
25
|
STK_QUEUED => 'Pending analysis',
|
23
26
|
STK_SUCCESS => 'Deployed successfully',
|
@@ -47,6 +50,7 @@ module C66
|
|
47
50
|
end
|
48
51
|
|
49
52
|
def base_url
|
53
|
+
load_params
|
50
54
|
values[:base_url]
|
51
55
|
end
|
52
56
|
|
@@ -74,8 +78,16 @@ module C66
|
|
74
78
|
File.join(c66_path, "params.json")
|
75
79
|
end
|
76
80
|
|
77
|
-
def stack_file
|
78
|
-
|
81
|
+
def stack_file(alias_name = nil)
|
82
|
+
if alias_name
|
83
|
+
if alias_name.match(/\w/)
|
84
|
+
File.join(stack_path, "#{alias_name}.json")
|
85
|
+
else
|
86
|
+
abort "#{alias_name} is an invalid alias."
|
87
|
+
end
|
88
|
+
else
|
89
|
+
File.join(stack_path, "stack.json")
|
90
|
+
end
|
79
91
|
end
|
80
92
|
|
81
93
|
def load_config
|
@@ -88,7 +100,7 @@ module C66
|
|
88
100
|
|
89
101
|
def save_config
|
90
102
|
if !File.directory?(c66_path)
|
91
|
-
Dir.
|
103
|
+
Dir.mkdir(c66_path)
|
92
104
|
end
|
93
105
|
|
94
106
|
File.open(config_file,"w") do |f|
|
@@ -96,28 +108,23 @@ module C66
|
|
96
108
|
end
|
97
109
|
end
|
98
110
|
|
99
|
-
def
|
100
|
-
if
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
111
|
+
def load_stack(alias_name)
|
112
|
+
if File.exists?(stack_file(alias_name))
|
113
|
+
if file = JSON.load(IO.read(stack_file(alias_name)))
|
114
|
+
if file.has_key? 'stack_id'
|
115
|
+
@stack = file['stack_id']
|
116
|
+
end
|
117
|
+
if file.has_key? 'stack_name' and !@stack.nil?
|
118
|
+
@stack_name = file['stack_name']
|
119
|
+
say "Stack #{@stack_name} loaded."
|
120
|
+
end
|
121
|
+
end
|
106
122
|
end
|
107
|
-
@stack = stack_id
|
108
|
-
say "Stack #{stack_id} saved to #{stack_file}"
|
109
123
|
end
|
110
124
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
say "Stack #{@stack} loaded."
|
115
|
-
else
|
116
|
-
abort "No stack id found at #{stack_file}"
|
117
|
-
end
|
118
|
-
else
|
119
|
-
say("No stack saved at #{stack_file}.")
|
120
|
-
end
|
125
|
+
def abort_no_stack
|
126
|
+
abort "No stack provided or saved, please use '--stack' or '-s' option. "\
|
127
|
+
"You can also use the 'save' method with '--stack' or '-s' option."
|
121
128
|
end
|
122
129
|
|
123
130
|
def load_params
|
@@ -130,25 +137,28 @@ module C66
|
|
130
137
|
if @params.has_key? 'base_url'
|
131
138
|
values[:base_url] = @params['base_url']
|
132
139
|
else
|
133
|
-
abort "Missing 'base_url' parameter in #{params_file}"
|
140
|
+
abort "Missing 'base_url' parameter in #{params_file}"
|
134
141
|
end
|
135
142
|
if @params.has_key? 'client_id'
|
136
143
|
values[:client_id] = @params['client_id']
|
137
144
|
else
|
138
|
-
abort "Missing 'client_id' parameter in #{params_file}"
|
145
|
+
abort "Missing 'client_id' parameter in #{params_file}"
|
139
146
|
end
|
140
147
|
if @params.has_key? 'client_secret'
|
141
148
|
values[:client_secret] = @params['client_secret']
|
142
149
|
else
|
143
|
-
abort "Missing 'client_secret' parameter in #{params_file}"
|
150
|
+
abort "Missing 'client_secret' parameter in #{params_file}"
|
144
151
|
end
|
145
|
-
say "Parameters loaded."
|
152
|
+
#say "Parameters loaded."
|
146
153
|
end
|
147
154
|
end
|
148
155
|
|
149
|
-
def get_stack(
|
150
|
-
|
151
|
-
|
156
|
+
def get_stack(stack_id_or_alias_name)
|
157
|
+
if stack_id_or_alias_name && !File.exist?(stack_file(stack_id_or_alias_name))
|
158
|
+
@stack=stack_id_or_alias_name
|
159
|
+
else
|
160
|
+
load_stack(stack_id_or_alias_name)
|
161
|
+
end
|
152
162
|
end
|
153
163
|
|
154
164
|
def client
|
@@ -173,33 +183,70 @@ module C66
|
|
173
183
|
end
|
174
184
|
end
|
175
185
|
|
176
|
-
def
|
186
|
+
def error_message(error)
|
187
|
+
begin
|
188
|
+
if !error.response.parsed.nil?
|
189
|
+
if (error.response.parsed.has_key? 'details')
|
190
|
+
puts error.response.parsed['details']
|
191
|
+
else
|
192
|
+
puts error.response.parsed['error_description']
|
193
|
+
end
|
194
|
+
end
|
195
|
+
rescue => e
|
196
|
+
abort e.message
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def get_version
|
177
201
|
begin
|
178
|
-
JSON.load(HTTParty.get(VERSION_FILE)).fetch("version")
|
202
|
+
JSON.load(HTTParty.get(VERSION_FILE).response.body).fetch("version")
|
179
203
|
rescue => e
|
180
204
|
puts "Failed to retrieve the latest version of Cloud 66 Toolbelt, please contact us"
|
181
205
|
end
|
182
206
|
end
|
183
207
|
|
184
|
-
|
185
|
-
|
186
|
-
|
208
|
+
def display_info
|
209
|
+
say "#{CLIENT_FULLNAME} version #{C66::Utils::VERSION}\n\n"
|
210
|
+
end
|
211
|
+
|
212
|
+
def compare_versions
|
213
|
+
result = C66::Utils::VERSION <=> Gem::Version.new(get_version)
|
187
214
|
case result
|
188
215
|
when 0..1
|
189
|
-
|
190
|
-
|
191
|
-
|
216
|
+
#say "Version is up-to-date."
|
217
|
+
when -1
|
218
|
+
say "There is a new version of Cloud66 Toolbelt. Pease run \"gem update #{CLIENT_NAME}\".",:red
|
192
219
|
end
|
193
|
-
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# def pending_intercom_messages
|
223
|
+
# begin
|
224
|
+
# result = parse_response(token.get("#{base_url}/users/unread_messages.json"))
|
225
|
+
# nb_messages = result['response']['unread_messages']
|
226
|
+
# say "You have #{nb_messages} pending message(s), check them out at www.cloud66.com !",:green if nb_messages > 0
|
227
|
+
# rescue
|
228
|
+
# # nop
|
229
|
+
# end
|
230
|
+
# end
|
231
|
+
|
232
|
+
def before_each_action
|
233
|
+
compare_versions
|
234
|
+
# pending_intercom_messages
|
235
|
+
end
|
194
236
|
}
|
195
237
|
|
196
|
-
package_name "
|
197
|
-
|
198
|
-
|
238
|
+
package_name "#{CLIENT_FULLNAME}: version #{C66::Utils::VERSION}\n"
|
239
|
+
|
240
|
+
default_task :default
|
199
241
|
|
200
|
-
|
201
|
-
|
242
|
+
desc "default", "hidden method", :hide => true
|
243
|
+
def default
|
244
|
+
before_each_action
|
245
|
+
help
|
246
|
+
end
|
202
247
|
|
248
|
+
desc "init", "Initialize the toolbelt"
|
249
|
+
map "d" => :deploy
|
203
250
|
long_desc <<-LONGDESC
|
204
251
|
Initialize Cloud 66 toolbelt
|
205
252
|
LONGDESC
|
@@ -226,33 +273,42 @@ module C66
|
|
226
273
|
|
227
274
|
desc "list", "Lists all the stacks"
|
228
275
|
def list
|
229
|
-
|
276
|
+
before_each_action
|
277
|
+
begin
|
278
|
+
response = parse_response(token.get("#{base_url}/stacks.json"))
|
230
279
|
|
231
|
-
|
232
|
-
|
233
|
-
|
280
|
+
if response['count'] != 0
|
281
|
+
response['response'].each do |stack|
|
282
|
+
say "#{stack['name']} (#{stack['uid']}) : #{stack['environment']} - #{STATUS[stack['status']]}"
|
283
|
+
end
|
284
|
+
else
|
285
|
+
say "No stacks found"
|
234
286
|
end
|
235
|
-
|
236
|
-
|
287
|
+
rescue OAuth2::Error => e
|
288
|
+
error_message(e)
|
237
289
|
end
|
238
290
|
end
|
239
291
|
|
240
292
|
desc "settings", "Get the list of settings for this stack"
|
241
293
|
option :stack, :aliases => "-s", :required => false
|
242
|
-
def settings
|
294
|
+
def settings
|
295
|
+
before_each_action
|
243
296
|
begin
|
244
297
|
get_stack(options[:stack])
|
245
|
-
|
298
|
+
abort_no_stack if @stack.nil?
|
246
299
|
response = token.get("#{base_url}/stacks/#{@stack}/settings.json")
|
247
300
|
settings = JSON.parse(response.body)['response']
|
301
|
+
number_settings = JSON.parse(response.body)['count']
|
302
|
+
stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
|
303
|
+
stack_name = stack_details['response']['name']
|
248
304
|
|
249
305
|
abort "No settings found" if settings.nil?
|
250
|
-
|
306
|
+
say "Getting #{stack_name} settings:"
|
251
307
|
settings.each do |setting|
|
252
308
|
say "#{setting['key']}\t\t#{setting['value']}\t#{setting['readonly'] ? '(readonly)' : ''}\r\n"
|
253
309
|
end
|
254
310
|
rescue OAuth2::Error => e
|
255
|
-
|
311
|
+
error_message(e)
|
256
312
|
end
|
257
313
|
end
|
258
314
|
|
@@ -261,26 +317,112 @@ module C66
|
|
261
317
|
option :setting_name, :aliases => "-n", :required => true
|
262
318
|
option :value, :aliases => "-v", :required => true
|
263
319
|
def set()
|
320
|
+
before_each_action
|
264
321
|
begin
|
265
322
|
get_stack(options[:stack])
|
266
|
-
|
323
|
+
abort_no_stack if @stack.nil?
|
324
|
+
stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
|
325
|
+
stack_name = stack_details['response']['name']
|
267
326
|
response = token.post("#{base_url}/stacks/#{@stack}/setting.json", { :body => { :setting_name => options[:setting_name], :setting_value => options[:value] }})
|
268
|
-
say "
|
327
|
+
say "On #{stack_name}: applied value '#{options[:value]}' to setting '#{options[:setting_name]}'" if JSON.parse(response.body)['response']['ok']
|
269
328
|
rescue OAuth2::Error => e
|
270
|
-
|
329
|
+
error_message(e)
|
271
330
|
end
|
272
331
|
end
|
273
332
|
|
274
333
|
desc "deploy", "Deploy the given stack"
|
275
334
|
option :stack, :aliases => "-s", :required => false
|
276
|
-
def deploy
|
335
|
+
def deploy
|
336
|
+
before_each_action
|
277
337
|
begin
|
278
338
|
get_stack(options[:stack])
|
279
|
-
|
339
|
+
abort_no_stack if @stack.nil?
|
340
|
+
stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
|
341
|
+
stack_name = stack_details['response']['name']
|
342
|
+
say stack_name+": "
|
280
343
|
response = token.post("#{base_url}/stacks/#{@stack}/redeploy.json", {})
|
281
344
|
say JSON.parse(response.body)['response']['message']
|
282
345
|
rescue OAuth2::Error => e
|
283
|
-
|
346
|
+
error_message(e)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
desc "save", "Save the given stack information in the current directory"
|
351
|
+
option :stack, :aliases => "-s", :required => true
|
352
|
+
option :alias, :aliases => "-a", :required => false
|
353
|
+
def save
|
354
|
+
before_each_action
|
355
|
+
begin
|
356
|
+
stack_details = parse_response(token.get("#{base_url}/stacks/#{options[:stack]}.json"))
|
357
|
+
stack_name = stack_details['response']['name']
|
358
|
+
if !File.directory?(stack_path)
|
359
|
+
Dir.mkdir(stack_path)
|
360
|
+
end
|
361
|
+
@stack_json = { :stack_id => options[:stack], :stack_name => stack_name}
|
362
|
+
if (!FORBIDDEN_STACKS_ALIAS.include? options[:alias])
|
363
|
+
File.open(stack_file(options[:alias]),"w") do |f|
|
364
|
+
f.write(@stack_json.to_json)
|
365
|
+
end
|
366
|
+
else
|
367
|
+
abort 'Stack alias "'+options[:alias]+'" is forbidden, please retry with another alias.'
|
368
|
+
end
|
369
|
+
@stack = options[:stack]
|
370
|
+
|
371
|
+
say "Linked stack #{stack_name} to #{stack_file(options[:alias])}.\n"
|
372
|
+
if !options[:alias]
|
373
|
+
say "You are now able to use other commands without specify the stack UID."
|
374
|
+
else
|
375
|
+
say "You are now able to use other commands and specific this stack's alias, like so: "\
|
376
|
+
"`c66 deploy -s #{options[:alias]}`"
|
377
|
+
end
|
378
|
+
rescue OAuth2::Error => e
|
379
|
+
error_message(e)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
desc "info", "#{CLIENT_FULLNAME} information"
|
384
|
+
def info
|
385
|
+
before_each_action
|
386
|
+
begin
|
387
|
+
say "#{CLIENT_FULLNAME} version #{C66::Utils::VERSION}\n\n"
|
388
|
+
Dir.glob("#{stack_path}/*.json") do |stack_file|
|
389
|
+
stack_alias = File.basename(stack_file, ".json")
|
390
|
+
if (!FORBIDDEN_STACKS_ALIAS.include? stack_alias)
|
391
|
+
load_stack(stack_alias)
|
392
|
+
if stack_alias == "stack"
|
393
|
+
say "Default stack: no alias"
|
394
|
+
else
|
395
|
+
say "Alias: #{stack_alias}"
|
396
|
+
end
|
397
|
+
stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
|
398
|
+
say "Name: #{stack_details['response']['name']}"
|
399
|
+
say "UID: #{stack_details['response']['uid']}"
|
400
|
+
say "Environment: #{stack_details['response']['environment']}"
|
401
|
+
say "Status: #{STATUS[stack_details['response']['status']]}\n\n"
|
402
|
+
end
|
403
|
+
end
|
404
|
+
rescue OAuth2::Error => e
|
405
|
+
puts "Didn't find any valid stack, please use the 'save' method."
|
406
|
+
error_message(e)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
desc "lease", "Allow an IP address to connect temporary to the specific stack through ssh (22)"
|
411
|
+
option :stack, :aliases => "-s", :required => false
|
412
|
+
option :ip_address, :aliases => "-i", :required => false
|
413
|
+
option :time_to_open, :aliases => "-t", :required => false, :default => 20
|
414
|
+
def lease()
|
415
|
+
before_each_action
|
416
|
+
begin
|
417
|
+
abort "time_to_open value is invalid. The value must be an integer between 0 and 240 (~4 hours)." if !(0..240).include? options[:time_to_open].to_i
|
418
|
+
get_stack(options[:stack])
|
419
|
+
abort_no_stack if @stack.nil?
|
420
|
+
stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
|
421
|
+
stack_name = stack_details['response']['name']
|
422
|
+
response = token.post("#{base_url}/stacks/#{@stack}/lease.json", { :body => { :ip_address => options[:ip_address], :time_to_open => options[:time_to_open] }})
|
423
|
+
say JSON.parse(response.body)['response']['message'] if JSON.parse(response.body)['response']['ok']
|
424
|
+
rescue OAuth2::Error => e
|
425
|
+
error_message(e)
|
284
426
|
end
|
285
427
|
end
|
286
428
|
end
|
data/lib/c66/utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,123 +1,155 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: c66
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 91
|
9
|
+
version: 0.1.91
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Cloud 66
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2013-08-21 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: bundler
|
16
|
-
|
17
|
-
|
18
|
-
requirements:
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
19
25
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 3
|
30
|
+
version: "1.3"
|
22
31
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
26
34
|
name: rake
|
27
|
-
|
28
|
-
|
29
|
-
requirements:
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
30
38
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 10
|
42
|
+
- 1
|
43
|
+
- 0
|
32
44
|
version: 10.1.0
|
33
45
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
37
48
|
name: thor
|
38
|
-
|
39
|
-
|
40
|
-
requirements:
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
41
52
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
- 18
|
57
|
+
- 1
|
43
58
|
version: 0.18.1
|
44
59
|
type: :runtime
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
48
62
|
name: oauth2
|
49
|
-
|
50
|
-
|
51
|
-
requirements:
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
52
66
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
- 9
|
71
|
+
- 2
|
54
72
|
version: 0.9.2
|
55
73
|
type: :runtime
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
74
|
+
version_requirements: *id004
|
75
|
+
- !ruby/object:Gem::Dependency
|
59
76
|
name: json
|
60
|
-
|
61
|
-
|
62
|
-
requirements:
|
77
|
+
prerelease: false
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
63
80
|
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 1
|
84
|
+
- 7
|
85
|
+
- 7
|
65
86
|
version: 1.7.7
|
66
87
|
type: :runtime
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
88
|
+
version_requirements: *id005
|
89
|
+
- !ruby/object:Gem::Dependency
|
70
90
|
name: httparty
|
71
|
-
|
72
|
-
|
73
|
-
requirements:
|
91
|
+
prerelease: false
|
92
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
74
94
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
- 11
|
99
|
+
- 0
|
76
100
|
version: 0.11.0
|
77
101
|
type: :runtime
|
78
|
-
|
79
|
-
version_requirements: *70093107962820
|
102
|
+
version_requirements: *id006
|
80
103
|
description: See https://www.cloud66.com for more info
|
81
|
-
email:
|
104
|
+
email:
|
82
105
|
- hello@cloud66.com
|
83
|
-
executables:
|
84
|
-
- c66
|
106
|
+
executables:
|
107
|
+
- c66
|
85
108
|
extensions: []
|
109
|
+
|
86
110
|
extra_rdoc_files: []
|
87
|
-
|
111
|
+
|
112
|
+
files:
|
88
113
|
- .gitignore
|
89
114
|
- Gemfile
|
115
|
+
- Gemfile.lock
|
90
116
|
- LICENSE.txt
|
91
117
|
- README.md
|
92
118
|
- Rakefile
|
93
|
-
- bin/c66
|
119
|
+
- bin/c66
|
94
120
|
- c66.gemspec
|
95
121
|
- lib/c66.rb
|
96
122
|
- lib/c66/commands/c66_toolbelt.rb
|
97
123
|
- lib/c66/utils/version.rb
|
124
|
+
has_rdoc: true
|
98
125
|
homepage: https://www.cloud66.com
|
99
|
-
licenses:
|
126
|
+
licenses:
|
100
127
|
- MIT
|
101
128
|
post_install_message:
|
102
129
|
rdoc_options: []
|
103
|
-
|
130
|
+
|
131
|
+
require_paths:
|
104
132
|
- lib
|
105
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
117
147
|
requirements: []
|
148
|
+
|
118
149
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.3.6
|
120
151
|
signing_key:
|
121
152
|
specification_version: 3
|
122
153
|
summary: Cloud 66 Toolbelt
|
123
154
|
test_files: []
|
155
|
+
|
/data/bin/{c66.rb → c66}
RENAMED
File without changes
|