c66 0.1.0 → 0.1.7.beta

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,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .cloud66
5
6
  .yardoc
6
7
  Gemfile.lock
7
8
  InstalledFiles
data/README.md CHANGED
@@ -1,32 +1,37 @@
1
- # Cloud 66 Toolbelt: c66
2
-
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!
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>
4
3
 
5
4
  ## Installation
6
5
 
7
6
  You can install the Cloud 66 Toolbelt using [RubyGems](http://rubygems.org/):
8
-
9
- $ gem install c66
7
+ <p>
8
+ <kbd>$ gem install c66</kbd>
9
+ </p>
10
10
 
11
11
  ## Usage
12
12
 
13
13
  ### Help
14
- With c66 installed, you can display the help with one of the following instructions:
15
-
16
- $ c66 help
17
14
 
15
+ With c66 installed, you can display the help with one of the following instructions:
16
+ <p>
17
+ <kbd>$ c66 help</kbd>
18
+ </p>
19
+
18
20
  or
19
21
 
20
- $ c66
22
+ <p>
23
+ <kbd>$ c66</kbd>
24
+ </p>
21
25
 
22
26
  ### Initialize the Toolbelt
23
27
 
24
28
  Firstly, to use the Toolbelt, you will need to initiate it using:
25
29
 
26
- $ c66 init
27
-
30
+ <p>
31
+ <kbd>$ c66 init</kbd>
32
+ </p>
33
+
28
34
  Then visit the URL given once authorized, copy and paste the `authorization code` into the command-line interface.
29
-
30
35
  You need to sign in and allow the Cloud 66 Toolbelt application to use your account to access to the authorization code.
31
36
 
32
37
  Note: This is a one-off task.
@@ -35,31 +40,52 @@ Note: This is a one-off task.
35
40
 
36
41
  You can list all your stacks using:
37
42
 
38
- $ c66 list
43
+ <p>
44
+ <kbd>$ c66 list</kbd>
45
+ </p>
39
46
 
40
47
  ### Deploy a Stack
41
48
 
42
49
  Deploy a stack using the command `deploy` with a stack UID (Unique Identifer):
43
50
 
44
- $ c66 deploy --stack <stack_UID>
45
-
51
+ <p>
52
+ <kbd>$ c66 deploy --stack &lt;stack_UID&gt;</kbd>
53
+ </p>
54
+
46
55
  or
47
56
 
48
- $ c66 deploy -s <stack_UID>
49
-
57
+ <p>
58
+ <kbd>$ c66 deploy -s &lt;stack_UID&gt;</kbd>
59
+ </p>
60
+
50
61
  You can retrieve the UID of a stack using the `list` command.
51
-
52
62
  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
63
  ![stack_uid](http://cdn.cloud66.com.s3.amazonaws.com/images/Toolbelt/exemple_stack_uid.PNG)
55
64
 
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:
65
+ There is a command to save your stack UID:
66
+
67
+ <p>
68
+ <kbd>$ c66 save --stack &lt;stack_UID&gt;</kbd>
69
+ </p>
70
+
71
+ or
72
+
73
+ <p>
74
+ <kbd>$ c66 save -s &lt;stack_UID&gt;</kbd>
75
+ </p>
57
76
 
58
- $ c66 deploy
77
+ When your stack UID is saved, you are able to use other commands without specify the stack UID.
78
+ For instance, it allows you to deploy a stack without putting the stack UID every time:
59
79
 
80
+ <p>
81
+ <kbd>$ c66 deploy</kbd>
82
+ </p>
83
+
60
84
  you can use a short-cut for this command:
61
85
 
62
- $ c66 d
86
+ <p>
87
+ <kbd>$ c66 d</kbd>
88
+ </p>
63
89
 
64
90
  ### Settings of a Stack
65
91
 
@@ -67,45 +93,50 @@ It is possible to retrieve the settings of a specified stack and to easily modif
67
93
 
68
94
  To display the settings:
69
95
 
70
- $ c66 settings --stack <stack_UID>
71
-
96
+ <p>
97
+ <kbd>$ c66 settings --stack &lt;stack_UID&gt;</kbd>
98
+ </p>
99
+
72
100
  or
73
101
 
74
- $ c66 settings -s <stack_UID>
75
-
102
+ <p>
103
+ <kbd>$ c66 settings -s &lt;stack_UID&gt;</kbd>
104
+ </p>
105
+
76
106
  If your stack UID is saved:
77
107
 
78
- $ c66 settings
79
-
108
+ <p>
109
+ <kbd>$ c66 settings</kbd>
110
+ </p>
111
+
80
112
  To modify a setting:
81
113
 
82
- $ c66 set --stack <stack_UID> --setting_name <setting_name> --value <value>
83
-
114
+ <p>
115
+ <kbd>$ c66 set --stack &lt;stack_UID&gt; --setting_name &lt;setting_name&gt; --value &lt;value&gt;</kbd>
116
+ </p>
117
+
84
118
  or
85
119
 
86
- $ c66 set -s <stack_UID> -n <setting_name> -v <value>
87
-
120
+ <p>
121
+ <kbd>$ c66 set -s &lt;stack_UID&gt; -n &lt;setting_name&gt; -v &lt;value&gt;</kbd>
122
+ </p>
123
+
88
124
  If the stack UID is saved:
89
125
 
90
- $ c66 set --setting_name <setting_name> --value <value>
91
-
92
- or
93
-
94
- $ c66 set -n <setting_name> -v <value>
126
+ <p>
127
+ <kbd>$ c66 set --setting_name &lt;setting_name&gt; --value &lt;value&gt;</kbd>
128
+ </p>
129
+
130
+ or
95
131
 
132
+ <p>
133
+ <kbd>$ c66 set -n &lt;setting_name&gt; -v &lt;value&gt;</kbd>
134
+ </p>
96
135
 
97
136
  ## Contributing
98
137
 
99
138
  1. Fork it
100
-
101
- 2. Create your feature branch (`git checkout -b my-new-feature`)
102
-
103
- 3. Commit your changes (`git commit -am 'Add some feature'`)
104
-
105
- 4. Push to the branch (`git push origin my-new-feature`)
106
-
139
+ 2. Create your feature branch `git checkout -b my-new-feature`
140
+ 3. Commit your changes `git commit -am 'Add some feature'`
141
+ 4. Push to the branch `git push origin my-new-feature`
107
142
  5. Create new Pull Request
108
-
109
- ## Copyright
110
-
111
- Copyright (c) 2013 Cloud66 Limited.. See LICENSE for details.
@@ -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
@@ -88,7 +89,7 @@ module C66
88
89
 
89
90
  def save_config
90
91
  if !File.directory?(c66_path)
91
- Dir.mkdir_p(c66_path)
92
+ Dir.mkdir(c66_path)
92
93
  end
93
94
 
94
95
  File.open(config_file,"w") do |f|
@@ -96,30 +97,25 @@ module C66
96
97
  end
97
98
  end
98
99
 
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)
106
- end
107
- @stack = stack_id
108
- say "Stack #{stack_id} saved to #{stack_file}"
109
- end
110
-
111
100
  def load_stack
112
101
  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}"
102
+ if file = JSON.load(IO.read(stack_file))
103
+ if file.has_key? 'stack_id'
104
+ @stack = file['stack_id']
105
+ end
106
+ if file.has_key? 'stack_name' and !@stack.nil?
107
+ @stack_name = file['stack_name']
108
+ say "Stack #{@stack_name} loaded."
109
+ end
117
110
  end
118
- else
119
- say("No stack saved at #{stack_file}.")
120
111
  end
121
112
  end
122
113
 
114
+ def abort_no_stack
115
+ abort "No stack provided or saved, please use '--stack' or '-s' option. "\
116
+ "You can also use the 'save' method with '--stack' or '-s' option."
117
+ end
118
+
123
119
  def load_params
124
120
  if File.exists?(params_file) && File.size(params_file)!=0
125
121
  begin
@@ -147,7 +143,7 @@ module C66
147
143
  end
148
144
 
149
145
  def get_stack(stack)
150
- save_stack(stack) if stack
146
+ @stack=stack
151
147
  load_stack if stack.nil?
152
148
  end
153
149
 
@@ -173,11 +169,26 @@ module C66
173
169
  end
174
170
  end
175
171
 
172
+ def error_message(error)
173
+ begin
174
+ if (!error.response.parsed.nil?)
175
+ then
176
+ if (error.response.parsed.has_key? 'details')
177
+ puts error.response.parsed['details']
178
+ else
179
+ puts error.response.parsed['error_description']
180
+ end
181
+ end
182
+ rescue => e
183
+ abort e.message
184
+ end
185
+ end
186
+
176
187
  def self.get_version
177
188
  begin
178
- JSON.load(HTTParty.get(VERSION_FILE)).fetch("version")
189
+ JSON.load(HTTParty.get(VERSION_FILE).response.body).fetch("version")
179
190
  rescue => e
180
- puts "Failed to retrieve the latest version of Cloud 66 Toolbelt, please contact us"
191
+ puts "Failed to retrieve the latest version of #{CLIENT_FULLNAME}, please contact us"
181
192
  end
182
193
  end
183
194
 
@@ -190,19 +201,17 @@ module C66
190
201
  when -1
191
202
  puts "There is a new version of Cloud66 Toolbelt. Pease run \"gem update #{CLIENT_NAME}\"."
192
203
  end
193
- end
204
+ end
194
205
  }
195
206
 
196
- package_name "Cloud 66 Toolbelt"
207
+ compare_versions
208
+
209
+ package_name "#{CLIENT_FULLNAME}: version #{C66::Utils::VERSION}\n"
197
210
  desc "init", "Initialize the toolbelt"
198
211
  map "d" => :deploy
199
212
 
200
- compare_versions
201
213
 
202
214
 
203
- long_desc <<-LONGDESC
204
- Initialize Cloud 66 toolbelt
205
- LONGDESC
206
215
  def init
207
216
  load_params
208
217
  result = client.auth_code.authorize_url(:redirect_uri => values[:redirect_url], :scope => values[:scope])
@@ -226,14 +235,18 @@ module C66
226
235
 
227
236
  desc "list", "Lists all the stacks"
228
237
  def list
229
- response = parse_response(token.get("#{base_url}/stacks.json"))
238
+ begin
239
+ response = parse_response(token.get("#{base_url}/stacks.json"))
230
240
 
231
- if response['count'] != 0
232
- response['response'].each do |stack|
233
- say "#{stack['name']} (#{stack['uid']}) : #{stack['environment']} - #{STATUS[stack['status']]}"
241
+ if response['count'] != 0
242
+ response['response'].each do |stack|
243
+ say "#{stack['name']} (#{stack['uid']}) : #{stack['environment']} - #{STATUS[stack['status']]}"
244
+ end
245
+ else
246
+ say "No stacks found"
234
247
  end
235
- else
236
- say "No stacks found"
248
+ rescue OAuth2::Error => e
249
+ error_message(e)
237
250
  end
238
251
  end
239
252
 
@@ -242,17 +255,20 @@ module C66
242
255
  def settings()
243
256
  begin
244
257
  get_stack(options[:stack])
245
- abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil?
258
+ abort_no_stack if @stack.nil?
246
259
  response = token.get("#{base_url}/stacks/#{@stack}/settings.json")
247
260
  settings = JSON.parse(response.body)['response']
261
+ number_settings = JSON.parse(response.body)['count']
262
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
263
+ stack_name = stack_details['response']['name']
248
264
 
249
265
  abort "No settings found" if settings.nil?
250
-
266
+ say "Getting "+stack_name+" settings:"
251
267
  settings.each do |setting|
252
268
  say "#{setting['key']}\t\t#{setting['value']}\t#{setting['readonly'] ? '(readonly)' : ''}\r\n"
253
269
  end
254
270
  rescue OAuth2::Error => e
255
- abort e.message
271
+ error_message(e)
256
272
  end
257
273
  end
258
274
 
@@ -263,11 +279,13 @@ module C66
263
279
  def set()
264
280
  begin
265
281
  get_stack(options[:stack])
266
- abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil?
282
+ abort_no_stack if @stack.nil?
283
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
284
+ stack_name = stack_details['response']['name']
267
285
  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']
286
+ say "On #{stack_name}: applied value '#{options[:value]}' to setting '#{options[:setting_name]}'" if JSON.parse(response.body)['response']['ok']
269
287
  rescue OAuth2::Error => e
270
- abort e.message
288
+ error_message(e)
271
289
  end
272
290
  end
273
291
 
@@ -276,11 +294,51 @@ module C66
276
294
  def deploy()
277
295
  begin
278
296
  get_stack(options[:stack])
279
- abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil?
297
+ abort_no_stack if @stack.nil?
298
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
299
+ stack_name = stack_details['response']['name']
300
+ say stack_name+": "
280
301
  response = token.post("#{base_url}/stacks/#{@stack}/redeploy.json", {})
281
302
  say JSON.parse(response.body)['response']['message']
282
303
  rescue OAuth2::Error => e
283
- abort "Could't find your stack, maybe it was moved, deleted or you accidentally mistyped the stack ID"
304
+ error_message(e)
305
+ end
306
+ end
307
+
308
+ desc "save", "Save the given stack to simplify following commands"
309
+ option :stack, :aliases => "-s", :required => true
310
+ def save()
311
+ begin
312
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{options[:stack]}.json"))
313
+ stack_name = stack_details['response']['name']
314
+ if !File.directory?(stack_path)
315
+ Dir.mkdir(stack_path)
316
+ end
317
+ @stack_json = { :stack_id => options[:stack], :stack_name => stack_name}
318
+ File.open(stack_file,"w") do |f|
319
+ f.write(@stack_json.to_json)
320
+ end
321
+ @stack = options[:stack]
322
+ say "Linked stack #{stack_name} to #{stack_file}. "\
323
+ "You are now able to use other commands without specify the stack UID."
324
+ rescue OAuth2::Error => e
325
+ error_message(e)
326
+ end
327
+ end
328
+
329
+ desc "info", "#{CLIENT_FULLNAME} information"
330
+ def info()
331
+ begin
332
+ say "#{CLIENT_FULLNAME} version #{C66::Utils::VERSION}\n\n"
333
+ load_stack
334
+ stack_details = parse_response(token.get("#{base_url}/stacks/#{@stack}.json"))
335
+ say "name: "+stack_details['response']['name']
336
+ say "UID: "+stack_details['response']['uid']
337
+ say "Environment: "+stack_details['response']['environment']
338
+ say "Status: "+STATUS[stack_details['response']['status']]
339
+ rescue OAuth2::Error => e
340
+ puts "Stack loaded not valid."
341
+ error_message(e)
284
342
  end
285
343
  end
286
344
  end
@@ -1,6 +1,6 @@
1
1
  module C66
2
2
  module Utils
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.7.beta"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,123 +1,172 @@
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
+ hash: 31098197
5
+ prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 7
10
+ - beta
11
+ version: 0.1.7.beta
6
12
  platform: ruby
7
- authors:
13
+ authors:
8
14
  - Cloud 66
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2013-07-15 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: bundler
16
- requirement: &70093107966800 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
26
+ requirements:
19
27
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.3'
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 1
32
+ - 3
33
+ version: "1.3"
22
34
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70093107966800
25
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
26
37
  name: rake
27
- requirement: &70093107966180 !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
28
40
  none: false
29
- requirements:
41
+ requirements:
30
42
  - - ~>
31
- - !ruby/object:Gem::Version
43
+ - !ruby/object:Gem::Version
44
+ hash: 75
45
+ segments:
46
+ - 10
47
+ - 1
48
+ - 0
32
49
  version: 10.1.0
33
50
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70093107966180
36
- - !ruby/object:Gem::Dependency
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
37
53
  name: thor
38
- requirement: &70093107965480 !ruby/object:Gem::Requirement
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
39
56
  none: false
40
- requirements:
57
+ requirements:
41
58
  - - ~>
42
- - !ruby/object:Gem::Version
59
+ - !ruby/object:Gem::Version
60
+ hash: 85
61
+ segments:
62
+ - 0
63
+ - 18
64
+ - 1
43
65
  version: 0.18.1
44
66
  type: :runtime
45
- prerelease: false
46
- version_requirements: *70093107965480
47
- - !ruby/object:Gem::Dependency
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
48
69
  name: oauth2
49
- requirement: &70093107964520 !ruby/object:Gem::Requirement
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
50
72
  none: false
51
- requirements:
73
+ requirements:
52
74
  - - ~>
53
- - !ruby/object:Gem::Version
75
+ - !ruby/object:Gem::Version
76
+ hash: 63
77
+ segments:
78
+ - 0
79
+ - 9
80
+ - 2
54
81
  version: 0.9.2
55
82
  type: :runtime
56
- prerelease: false
57
- version_requirements: *70093107964520
58
- - !ruby/object:Gem::Dependency
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
59
85
  name: json
60
- requirement: &70093107963280 !ruby/object:Gem::Requirement
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
61
88
  none: false
62
- requirements:
89
+ requirements:
63
90
  - - ~>
64
- - !ruby/object:Gem::Version
91
+ - !ruby/object:Gem::Version
92
+ hash: 5
93
+ segments:
94
+ - 1
95
+ - 7
96
+ - 7
65
97
  version: 1.7.7
66
98
  type: :runtime
67
- prerelease: false
68
- version_requirements: *70093107963280
69
- - !ruby/object:Gem::Dependency
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
70
101
  name: httparty
71
- requirement: &70093107962820 !ruby/object:Gem::Requirement
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
72
104
  none: false
73
- requirements:
105
+ requirements:
74
106
  - - ~>
75
- - !ruby/object:Gem::Version
107
+ - !ruby/object:Gem::Version
108
+ hash: 51
109
+ segments:
110
+ - 0
111
+ - 11
112
+ - 0
76
113
  version: 0.11.0
77
114
  type: :runtime
78
- prerelease: false
79
- version_requirements: *70093107962820
115
+ version_requirements: *id006
80
116
  description: See https://www.cloud66.com for more info
81
- email:
117
+ email:
82
118
  - hello@cloud66.com
83
- executables:
84
- - c66.rb
119
+ executables:
120
+ - c66
85
121
  extensions: []
122
+
86
123
  extra_rdoc_files: []
87
- files:
124
+
125
+ files:
88
126
  - .gitignore
89
127
  - Gemfile
90
128
  - LICENSE.txt
91
129
  - README.md
92
130
  - Rakefile
93
- - bin/c66.rb
131
+ - bin/c66
94
132
  - c66.gemspec
95
133
  - lib/c66.rb
96
134
  - lib/c66/commands/c66_toolbelt.rb
97
135
  - lib/c66/utils/version.rb
98
136
  homepage: https://www.cloud66.com
99
- licenses:
137
+ licenses:
100
138
  - MIT
101
139
  post_install_message:
102
140
  rdoc_options: []
103
- require_paths:
141
+
142
+ require_paths:
104
143
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
144
+ required_ruby_version: !ruby/object:Gem::Requirement
106
145
  none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ hash: 3
150
+ segments:
151
+ - 0
152
+ version: "0"
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
154
  none: false
113
- requirements:
114
- - - ! '>='
115
- - !ruby/object:Gem::Version
116
- version: '0'
155
+ requirements:
156
+ - - ">"
157
+ - !ruby/object:Gem::Version
158
+ hash: 25
159
+ segments:
160
+ - 1
161
+ - 3
162
+ - 1
163
+ version: 1.3.1
117
164
  requirements: []
165
+
118
166
  rubyforge_project:
119
- rubygems_version: 1.8.15
167
+ rubygems_version: 1.8.12
120
168
  signing_key:
121
169
  specification_version: 3
122
170
  summary: Cloud 66 Toolbelt
123
171
  test_files: []
172
+
File without changes