c66 0.1.0 → 0.1.10

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 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
- doc/
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.10)
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
- # Cloud 66 Toolbelt: c66
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
- 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!
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
- $ gem install c66
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
- $ c66 help
20
+ <p>
21
+ <kbd>$ c66</kbd>
22
+ </p>
17
23
 
18
- or
24
+ or for a specific command:
19
25
 
20
- $ c66
26
+ <p>
27
+ <kbd>$ c66 help &lt;command&gt;</kbd>
28
+ </p>
21
29
 
22
- ### Initialize the Toolbelt
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
- $ c66 init
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: This is a one-off task.
41
+ **Note**: This is a one-off task.
33
42
 
34
- ### List the Stacks
43
+ ## List the Stacks {: class=divider-title}
35
44
 
36
45
  You can list all your stacks using:
37
46
 
38
- $ c66 list
47
+ <p>
48
+ <kbd>$ c66 list</kbd>
49
+ </p>
39
50
 
40
- ### Deploy a Stack
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
- $ c66 deploy --stack <stack_UID>
45
-
55
+ <p>
56
+ <kbd>$ c66 deploy --stack &lt;stack_UID&gt;</kbd>
57
+ </p>
58
+
46
59
  or
47
60
 
48
- $ c66 deploy -s <stack_UID>
49
-
61
+ <p>
62
+ <kbd>$ c66 deploy -s &lt;stack_UID&gt;</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
- The stack UID is saved when you deploy through the Cloud 66 Toolbelt. It allows you to deploy a stack without putting the stack UID every time:
69
+ There is a command to save a default stack UID:
70
+
71
+ <p>
72
+ <kbd>$ c66 save --stack &lt;stack_UID&gt;</kbd>
73
+ </p>
74
+
75
+ or
76
+
77
+ <p>
78
+ <kbd>$ c66 save -s &lt;stack_UID&gt;</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
- $ c66 deploy
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
- $ c66 d
92
+ <p>
93
+ <kbd>$ c66 d</kbd>
94
+ </p>
63
95
 
64
- ### Settings of a Stack
96
+ You can save multiple stack UID by giving an alias to a specific stack:
65
97
 
66
- It is possible to retrieve the settings of a specified stack and to easily modify them:
98
+ <p>
99
+ <kbd>$ c66 save --stack &lt;stack_UID&gt; --alias &lt;stack_alias&gt;</kbd>
100
+ </p>
67
101
 
68
- To display the settings:
102
+ Then you can use commands and specific a stack's alias, like so:
69
103
 
70
- $ c66 settings --stack <stack_UID>
104
+ <p>
105
+ <kbd>$ c66 deploy -s &lt;stack_alias&gt;</kbd>
106
+ </p>
71
107
 
72
- or
108
+ ## Settings of a Stack {: class=divider-title}
73
109
 
74
- $ c66 settings -s <stack_UID>
110
+ It is possible to retrieve the settings of a specified stack and to easily modify them:
75
111
 
76
- If your stack UID is saved:
112
+ To display the settings:
113
+
114
+ <p>
115
+ <kbd>$ c66 settings --stack &lt;stack_UID&gt;</kbd>
116
+ </p>
117
+
118
+ or
77
119
 
78
- $ c66 settings
120
+ <p>
121
+ <kbd>$ c66 settings -s &lt;stack_UID&gt;</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
- $ c66 set --stack <stack_UID> --setting_name <setting_name> --value <value>
132
+ <p>
133
+ <kbd>$ c66 set --stack &lt;stack_UID&gt; --setting_name &lt;setting_name&gt; --value &lt;value&gt;</kbd>
134
+ </p>
135
+
136
+ or
137
+
138
+ <p>
139
+ <kbd>$ c66 set -s &lt;stack_UID&gt; -n &lt;setting_name&gt; -v &lt;value&gt;</kbd>
140
+ </p>
141
+
142
+ If a default stack UID is saved:
83
143
 
144
+ <p>
145
+ <kbd>$ c66 set --setting_name &lt;setting_name&gt; --value &lt;value&gt;</kbd>
146
+ </p>
147
+
84
148
  or
85
149
 
86
- $ c66 set -s <stack_UID> -n <setting_name> -v <value>
150
+ <p>
151
+ <kbd>$ c66 set -n &lt;setting_name&gt; -v &lt;value&gt;</kbd>
152
+ </p>
87
153
 
88
- If the stack UID is saved:
154
+ ## Lease an IP address {: class=divider-title}
89
155
 
90
- $ c66 set --setting_name <setting_name> --value <value>
156
+ You can allow an IP address to connect temporary to the specific stack through ssh (22):
91
157
 
92
- or
158
+ <p>
159
+ <kbd>$ c66 lease --stack &lt;stack_UID&gt; --ip-address &lt;ip_address&gt; --time-to-open &lt;time_to_open&gt;</kbd>
160
+ </p>
93
161
 
94
- $ c66 set -n <setting_name> -v <value>
162
+ or
95
163
 
164
+ <p>
165
+ <kbd>$ c66 lease -s &lt;stack_UID&gt; -i &lt;ip_address&gt; -t &lt;time_to_open&gt;</kbd>
166
+ </p>
96
167
 
97
- ## Contributing
168
+ Options *ip-address* and *time-to-open* are optional.
169
+ By default:
98
170
 
99
- 1. Fork it
171
+ - *ip-address* : your IP address
172
+ - *time-to-open* : 20 minutes
100
173
 
101
- 2. Create your feature branch (`git checkout -b my-new-feature`)
174
+ To allow your own IP address to connect temporary to the specific stack:
102
175
 
103
- 3. Commit your changes (`git commit -am 'Add some feature'`)
176
+ <p>
177
+ <kbd>$ c66 lease --stack &lt;stack_UID&gt;</kbd>
178
+ </p>
104
179
 
105
- 4. Push to the branch (`git push origin my-new-feature`)
180
+ If a default stack UID is saved:
106
181
 
107
- 5. Create new Pull Request
182
+ <p>
183
+ <kbd>$ c66 lease</kbd>
184
+ </p>
108
185
 
109
- ## Copyright
186
+ ## Information of your toolbelt settings {: class=divider-title}
110
187
 
111
- Copyright (c) 2013 Cloud66 Limited.. See LICENSE for details.
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
@@ -47,6 +48,7 @@ module C66
47
48
  end
48
49
 
49
50
  def base_url
51
+ load_params
50
52
  values[:base_url]
51
53
  end
52
54
 
@@ -74,8 +76,16 @@ module C66
74
76
  File.join(c66_path, "params.json")
75
77
  end
76
78
 
77
- def stack_file
78
- File.join(stack_path, "stack.json")
79
+ def stack_file(alias_name = nil)
80
+ if alias_name
81
+ if alias_name.match(/\w/)
82
+ File.join(stack_path, "#{alias_name}.json")
83
+ else
84
+ abort "#{alias_name} is an invalid alias."
85
+ end
86
+ else
87
+ File.join(stack_path, "stack.json")
88
+ end
79
89
  end
80
90
 
81
91
  def load_config
@@ -88,7 +98,7 @@ module C66
88
98
 
89
99
  def save_config
90
100
  if !File.directory?(c66_path)
91
- Dir.mkdir_p(c66_path)
101
+ Dir.mkdir(c66_path)
92
102
  end
93
103
 
94
104
  File.open(config_file,"w") do |f|
@@ -96,28 +106,23 @@ module C66
96
106
  end
97
107
  end
98
108
 
99
- def save_stack(stack_id)
100
- if !File.directory?(stack_path)
101
- Dir.mkdir(stack_path)
102
- end
103
- @stack_json = { :stack_id => stack_id}
104
- File.open(stack_file,"w") do |f|
105
- f.write(@stack_json.to_json)
109
+ def load_stack(alias_name)
110
+ if File.exists?(stack_file(alias_name))
111
+ if file = JSON.load(IO.read(stack_file(alias_name)))
112
+ if file.has_key? 'stack_id'
113
+ @stack = file['stack_id']
114
+ end
115
+ if file.has_key? 'stack_name' and !@stack.nil?
116
+ @stack_name = file['stack_name']
117
+ say "Stack #{@stack_name} loaded."
118
+ end
119
+ end
106
120
  end
107
- @stack = stack_id
108
- say "Stack #{stack_id} saved to #{stack_file}"
109
121
  end
110
122
 
111
- def load_stack
112
- if File.exists?(stack_file)
113
- if @stack = JSON.load(IO.read(stack_file))['stack_id']
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
123
+ def abort_no_stack
124
+ abort "No stack provided or saved, please use '--stack' or '-s' option. "\
125
+ "You can also use the 'save' method with '--stack' or '-s' option."
121
126
  end
122
127
 
123
128
  def load_params
@@ -130,25 +135,28 @@ module C66
130
135
  if @params.has_key? 'base_url'
131
136
  values[:base_url] = @params['base_url']
132
137
  else
133
- abort "Missing 'base_url' parameter in #{params_file}"
138
+ abort "Missing 'base_url' parameter in #{params_file}"
134
139
  end
135
140
  if @params.has_key? 'client_id'
136
141
  values[:client_id] = @params['client_id']
137
142
  else
138
- abort "Missing 'client_id' parameter in #{params_file}"
143
+ abort "Missing 'client_id' parameter in #{params_file}"
139
144
  end
140
145
  if @params.has_key? 'client_secret'
141
146
  values[:client_secret] = @params['client_secret']
142
147
  else
143
- abort "Missing 'client_secret' parameter in #{params_file}"
148
+ abort "Missing 'client_secret' parameter in #{params_file}"
144
149
  end
145
- say "Parameters loaded."
150
+ #say "Parameters loaded."
146
151
  end
147
152
  end
148
153
 
149
- def get_stack(stack)
150
- save_stack(stack) if stack
151
- load_stack if stack.nil?
154
+ def get_stack(stack_id_or_alias_name)
155
+ if stack_id_or_alias_name && !File.exist?(stack_file(stack_id_or_alias_name))
156
+ @stack=stack_id_or_alias_name
157
+ else
158
+ load_stack(stack_id_or_alias_name)
159
+ end
152
160
  end
153
161
 
154
162
  def client
@@ -173,33 +181,70 @@ module C66
173
181
  end
174
182
  end
175
183
 
176
- def self.get_version
184
+ def error_message(error)
185
+ begin
186
+ if !error.response.parsed.nil?
187
+ if (error.response.parsed.has_key? 'details')
188
+ puts error.response.parsed['details']
189
+ else
190
+ puts error.response.parsed['error_description']
191
+ end
192
+ end
193
+ rescue => e
194
+ abort e.message
195
+ end
196
+ end
197
+
198
+ def get_version
177
199
  begin
178
- JSON.load(HTTParty.get(VERSION_FILE)).fetch("version")
200
+ JSON.load(HTTParty.get(VERSION_FILE).response.body).fetch("version")
179
201
  rescue => e
180
202
  puts "Failed to retrieve the latest version of Cloud 66 Toolbelt, please contact us"
181
203
  end
182
204
  end
183
205
 
184
-
185
- def self.compare_versions
186
- result = C66::Utils::VERSION<=>get_version
206
+ def display_info
207
+ say "#{CLIENT_FULLNAME} version #{C66::Utils::VERSION}\n\n"
208
+ end
209
+
210
+ def compare_versions
211
+ result = C66::Utils::VERSION <=> Gem::Version.new(get_version)
187
212
  case result
188
213
  when 0..1
189
- #say "Version is up-to-date."
190
- when -1
191
- puts "There is a new version of Cloud66 Toolbelt. Pease run \"gem update #{CLIENT_NAME}\"."
214
+ #say "Version is up-to-date."
215
+ when -1
216
+ say "There is a new version of Cloud66 Toolbelt. Pease run \"gem update #{CLIENT_NAME}\".",:red
192
217
  end
193
- end
218
+ end
219
+
220
+ # def pending_intercom_messages
221
+ # begin
222
+ # result = parse_response(token.get("#{base_url}/users/unread_messages.json"))
223
+ # nb_messages = result['response']['unread_messages']
224
+ # say "You have #{nb_messages} pending message(s), check them out at www.cloud66.com !",:green if nb_messages > 0
225
+ # rescue
226
+ # # nop
227
+ # end
228
+ # end
229
+
230
+ def before_each_action
231
+ compare_versions
232
+ # pending_intercom_messages
233
+ end
194
234
  }
195
235
 
196
- package_name "Cloud 66 Toolbelt"
197
- desc "init", "Initialize the toolbelt"
198
- map "d" => :deploy
236
+ package_name "#{CLIENT_FULLNAME}: version #{C66::Utils::VERSION}\n"
237
+
238
+ default_task :default
199
239
 
200
- compare_versions
201
-
240
+ desc "default", "hidden method", :hide => true
241
+ def default
242
+ before_each_action
243
+ help
244
+ end
202
245
 
246
+ desc "init", "Initialize the toolbelt"
247
+ map "d" => :deploy
203
248
  long_desc <<-LONGDESC
204
249
  Initialize Cloud 66 toolbelt
205
250
  LONGDESC
@@ -226,33 +271,42 @@ module C66
226
271
 
227
272
  desc "list", "Lists all the stacks"
228
273
  def list
229
- response = parse_response(token.get("#{base_url}/stacks.json"))
274
+ before_each_action
275
+ begin
276
+ response = parse_response(token.get("#{base_url}/stacks.json"))
230
277
 
231
- if response['count'] != 0
232
- response['response'].each do |stack|
233
- say "#{stack['name']} (#{stack['uid']}) : #{stack['environment']} - #{STATUS[stack['status']]}"
278
+ if response['count'] != 0
279
+ response['response'].each do |stack|
280
+ say "#{stack['name']} (#{stack['uid']}) : #{stack['environment']} - #{STATUS[stack['status']]}"
281
+ end
282
+ else
283
+ say "No stacks found"
234
284
  end
235
- else
236
- say "No stacks found"
285
+ rescue OAuth2::Error => e
286
+ error_message(e)
237
287
  end
238
288
  end
239
289
 
240
290
  desc "settings", "Get the list of settings for this stack"
241
291
  option :stack, :aliases => "-s", :required => false
242
- def settings()
292
+ def settings
293
+ before_each_action
243
294
  begin
244
295
  get_stack(options[:stack])
245
- abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil?
296
+ abort_no_stack if @stack.nil?
246
297
  response = token.get("#{base_url}/stacks/#{@stack}/settings.json")
247
298
  settings = JSON.parse(response.body)['response']
299
+ number_settings = JSON.parse(response.body)['count']
300
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
301
+ stack_name = stack_details['response']['name']
248
302
 
249
303
  abort "No settings found" if settings.nil?
250
-
304
+ say "Getting #{stack_name} settings:"
251
305
  settings.each do |setting|
252
306
  say "#{setting['key']}\t\t#{setting['value']}\t#{setting['readonly'] ? '(readonly)' : ''}\r\n"
253
307
  end
254
308
  rescue OAuth2::Error => e
255
- abort e.message
309
+ error_message(e)
256
310
  end
257
311
  end
258
312
 
@@ -261,26 +315,106 @@ module C66
261
315
  option :setting_name, :aliases => "-n", :required => true
262
316
  option :value, :aliases => "-v", :required => true
263
317
  def set()
318
+ before_each_action
264
319
  begin
265
320
  get_stack(options[:stack])
266
- abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil?
321
+ abort_no_stack if @stack.nil?
322
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
323
+ stack_name = stack_details['response']['name']
267
324
  response = token.post("#{base_url}/stacks/#{@stack}/setting.json", { :body => { :setting_name => options[:setting_name], :setting_value => options[:value] }})
268
- say "Setting applied" if JSON.parse(response.body)['response']['ok']
325
+ say "On #{stack_name}: applied value '#{options[:value]}' to setting '#{options[:setting_name]}'" if JSON.parse(response.body)['response']['ok']
269
326
  rescue OAuth2::Error => e
270
- abort e.message
327
+ error_message(e)
271
328
  end
272
329
  end
273
330
 
274
331
  desc "deploy", "Deploy the given stack"
275
332
  option :stack, :aliases => "-s", :required => false
276
- def deploy()
333
+ def deploy
334
+ before_each_action
277
335
  begin
278
336
  get_stack(options[:stack])
279
- abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil?
337
+ abort_no_stack if @stack.nil?
338
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
339
+ stack_name = stack_details['response']['name']
340
+ say stack_name+": "
280
341
  response = token.post("#{base_url}/stacks/#{@stack}/redeploy.json", {})
281
342
  say JSON.parse(response.body)['response']['message']
282
343
  rescue OAuth2::Error => e
283
- abort "Could't find your stack, maybe it was moved, deleted or you accidentally mistyped the stack ID"
344
+ error_message(e)
345
+ end
346
+ end
347
+
348
+ desc "save", "Save the given stack information in the current directory"
349
+ option :stack, :aliases => "-s", :required => true
350
+ option :alias, :aliases => "-a", :required => false
351
+ def save
352
+ before_each_action
353
+ begin
354
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{options[:stack]}.json"))
355
+ stack_name = stack_details['response']['name']
356
+ if !File.directory?(stack_path)
357
+ Dir.mkdir(stack_path)
358
+ end
359
+ @stack_json = { :stack_id => options[:stack], :stack_name => stack_name}
360
+ File.open(stack_file(options[:alias]),"w") do |f|
361
+ f.write(@stack_json.to_json)
362
+ end
363
+ @stack = options[:stack]
364
+
365
+ say "Linked stack #{stack_name} to #{stack_file(options[:alias])}.\n"
366
+ if !options[:alias]
367
+ say "You are now able to use other commands without specify the stack UID."
368
+ else
369
+ say "You are now able to use other commands and specific this stack's alias, like so: "\
370
+ "`c66 deploy -s #{options[:alias]}`"
371
+ end
372
+ rescue OAuth2::Error => e
373
+ error_message(e)
374
+ end
375
+ end
376
+
377
+ desc "info", "#{CLIENT_FULLNAME} information"
378
+ def info
379
+ before_each_action
380
+ begin
381
+ say "#{CLIENT_FULLNAME} version #{C66::Utils::VERSION}\n\n"
382
+ Dir.glob("#{stack_path}/*.json") do |stack_file|
383
+ stack_alias = File.basename(stack_file, ".json")
384
+ load_stack(stack_alias)
385
+ if stack_alias == "stack"
386
+ say "Default stack: no alias"
387
+ else
388
+ say "Alias: #{stack_alias}"
389
+ end
390
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
391
+ say "Name: #{stack_details['response']['name']}"
392
+ say "UID: #{stack_details['response']['uid']}"
393
+ say "Environment: #{stack_details['response']['environment']}"
394
+ say "Status: #{STATUS[stack_details['response']['status']]}\n\n"
395
+ end
396
+ rescue OAuth2::Error => e
397
+ puts "Didn't find any valid stack, please use the 'save' method."
398
+ error_message(e)
399
+ end
400
+ end
401
+
402
+ desc "lease", "Allow an IP address to connect temporary to the specific stack through ssh (22)"
403
+ option :stack, :aliases => "-s", :required => false
404
+ option :ip_address, :aliases => "-i", :required => false
405
+ option :time_to_open, :aliases => "-t", :required => false, :default => 20
406
+ def lease()
407
+ before_each_action
408
+ begin
409
+ 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
410
+ get_stack(options[:stack])
411
+ abort_no_stack if @stack.nil?
412
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
413
+ stack_name = stack_details['response']['name']
414
+ response = token.post("#{base_url}/stacks/#{@stack}/lease.json", { :body => { :ip_address => options[:ip_address], :time_to_open => options[:time_to_open] }})
415
+ say JSON.parse(response.body)['response']['message'] if JSON.parse(response.body)['response']['ok']
416
+ rescue OAuth2::Error => e
417
+ error_message(e)
284
418
  end
285
419
  end
286
420
  end
@@ -1,6 +1,7 @@
1
1
  module C66
2
2
  module Utils
3
- VERSION = "0.1.0"
3
+ #Version format
4
+ VERSION = Gem::Version.new("0.1.10")
4
5
  end
5
6
  end
6
7
 
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
- version: 0.1.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 10
9
+ version: 0.1.10
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Cloud 66
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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
- requirement: &70093107966800 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
19
25
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.3'
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 3
30
+ version: "1.3"
22
31
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70093107966800
25
- - !ruby/object:Gem::Dependency
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
26
34
  name: rake
27
- requirement: &70093107966180 !ruby/object:Gem::Requirement
28
- none: false
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
- prerelease: false
35
- version_requirements: *70093107966180
36
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
37
48
  name: thor
38
- requirement: &70093107965480 !ruby/object:Gem::Requirement
39
- none: false
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
- prerelease: false
46
- version_requirements: *70093107965480
47
- - !ruby/object:Gem::Dependency
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
48
62
  name: oauth2
49
- requirement: &70093107964520 !ruby/object:Gem::Requirement
50
- none: false
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
- prerelease: false
57
- version_requirements: *70093107964520
58
- - !ruby/object:Gem::Dependency
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
59
76
  name: json
60
- requirement: &70093107963280 !ruby/object:Gem::Requirement
61
- none: false
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
- prerelease: false
68
- version_requirements: *70093107963280
69
- - !ruby/object:Gem::Dependency
88
+ version_requirements: *id005
89
+ - !ruby/object:Gem::Dependency
70
90
  name: httparty
71
- requirement: &70093107962820 !ruby/object:Gem::Requirement
72
- none: false
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
- prerelease: false
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.rb
106
+ executables:
107
+ - c66
85
108
  extensions: []
109
+
86
110
  extra_rdoc_files: []
87
- files:
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.rb
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
- require_paths:
130
+
131
+ require_paths:
104
132
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
- requirements:
114
- - - ! '>='
115
- - !ruby/object:Gem::Version
116
- version: '0'
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.8.15
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
+
File without changes