pi 0.1.28 → 0.1.29

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.
@@ -134,11 +134,20 @@ module PI::Cli::Command
134
134
  err"The dns zone id is not exist!" if zoneid_flag != true
135
135
  end
136
136
 
137
- projects = client.projects
138
- projectname = ask"Project name", :choices => projects.collect { |p| p[:name] }, :indexed => true unless projectid
139
- projects.each do |p|
140
- projectid = p[:id] if p[:name] == projectname
141
- end
137
+ projects = client.projects
138
+ if projectid
139
+ projectid_flag = false
140
+ projects.each do |p|
141
+ projectid_flag = true if p[:id].to_s == projectid
142
+ end
143
+ err"Invalid project id: #{projectid}" if projectid_flag != true
144
+ else
145
+ projectname = ask"Project name", :choices => projects.collect { |p| p[:name] }, :indexed => true
146
+ projects.each do |p|
147
+ projectid = p[:id] if p[:name] == projectname
148
+ end
149
+ end
150
+
142
151
  unless zoneid
143
152
  zonename = ask"Select dns zone", :choices => dns_zone.collect { |d| d[:name] }, :indexed => true
144
153
  dns_zone.each do |d|
@@ -263,6 +272,29 @@ module PI::Cli::Command
263
272
  display "OK".green
264
273
  end
265
274
 
275
+ def dns_records(dnsid=nil)
276
+ client.check_login_status
277
+ unless dnsid
278
+ dnsid = choose_dnsid
279
+ end
280
+ record_info = Array.new
281
+ targets = client.usable_dns_target(dnsid)
282
+ targets.each do |t|
283
+ t[:records].each do |v|
284
+ i = 0
285
+ record_info.push({ :id => v[:id],:targetName => t[:targetName],:view => v[:view]}) if not t[:records].empty?
286
+ i = i + 1
287
+ end
288
+ end
289
+ record_info_table = table do |t|
290
+ t.headings = 'Record ID', 'Target Name', 'View Name'
291
+ record_info.each do |s|
292
+ t << [s[:id],s[:targetName], s[:view]]
293
+ end
294
+ end
295
+ display record_info_table
296
+ end
297
+
266
298
  private
267
299
 
268
300
  def do_unmap_dns(appid, url)
@@ -105,6 +105,7 @@ module PI::Cli::Command
105
105
  end
106
106
  }
107
107
  end
108
+ err "New password is same with old one. Don't need to change password." if oldpassword == newpassword
108
109
  manifest = {
109
110
  :newPassword => newpassword,
110
111
  :oldPassword => oldpassword
@@ -242,7 +242,7 @@ class PI::Cli::Runner
242
242
  set_cmd(:apps, :restart_app, @args.size == 1 ? 1 : 0)
243
243
 
244
244
  when 'scale-app'
245
- usage('pi scale-app [appid] [--instance N] [--graceful] or pi scale-app <appname> <--target TARGET> [--instance N] [--graceful]')
245
+ usage('pi scale-app [appid] [--instance N] or pi scale-app <appname> <--target TARGET> [--instance N]')
246
246
  set_cmd(:apps, :scale_app, @args.size == 1 ? 1 : 0)
247
247
 
248
248
  when 'update-app'
@@ -282,11 +282,11 @@ class PI::Cli::Runner
282
282
  set_cmd(:services, :app_service, @args.size == 1 ? 1 : 0)
283
283
 
284
284
  when 'bind-service'
285
- usage('pi bind-service [appid] [--service SERVICE] [--graceful] or pi bind-service <appname> <--target TARGET> [--service SERVICE] [--graceful]')
285
+ usage('pi bind-service [appid] [--service SERVICE] or pi bind-service <appname> <--target TARGET> [--service SERVICE]')
286
286
  set_cmd(:services, :bind_service, @args.size == 1 ? 1 : 0)
287
287
 
288
288
  when 'unbind-service'
289
- usage('pi unbind-service [appid] [--service SERVICE] [--graceful] or pi unbind-service <appname> <--target TARGET> [--service SERVICE] [--graceful]')
289
+ usage('pi unbind-service [appid] [--service SERVICE] or pi unbind-service <appname> <--target TARGET> [--service SERVICE]')
290
290
  set_cmd(:services, :unbind_service, @args.size == 1 ? 1 : 0)
291
291
 
292
292
  when 'services'
@@ -356,6 +356,10 @@ class PI::Cli::Runner
356
356
  when 'register-dns'
357
357
  usage('pi register-dns [dnsid] [--target,--continent,--country]')
358
358
  set_cmd(:dns, :register_dns, @args.size == 1 ? 1 : 0)
359
+
360
+ when 'dns-records'
361
+ usage('pi dns-records [dnsid]')
362
+ set_cmd(:dns, :dns_records, @args.size == 1 ? 1 : 0)
359
363
 
360
364
  when 'deregister-dns'
361
365
  usage('pi deregister-dns [dnsid] [--recordid ID]')
@@ -62,7 +62,6 @@ Currently available pi commands are:
62
62
  restart-app --graceful Restart the application in a graceful mode
63
63
  scale-app [appid] [--instance N] Scale the application instances up or down
64
64
  scale-app <appname> <--target TARGET> [--instance N] Scale the application instances up or down
65
- scale-app --graceful Scale the application instances in a graceful mode
66
65
  update-app [appid] [--ver VERSION] Update the application
67
66
  update-app <appname> <--target TARGET> [--ver VERSION] Update the application
68
67
  update-app --graceful Update the application in a graceful mode
@@ -84,10 +83,8 @@ Currently available pi commands are:
84
83
  app-service <appname> <--target TARGET> Display the binded services for the application
85
84
  bind-service [appid] [--service SERVICE] Bind the services for the application
86
85
  bind-service <appname> <--target TARGET> [--service] Bind the services for the application
87
- bind-service --graceful Bind the services for the application in a graceful mode
88
86
  unbind-service [appid] [--service SERVICE] Unbind the services for the application
89
87
  unbind-service <appname> <--target TARGET> [--service] Unbind the services for the application
90
- unbind-service --graceful Unbind the services for the application in a graceful mode
91
88
  services List dedicated services
92
89
  service [serviceid] List the connection info for the service
93
90
  export-service [serviceid] Export dedicated service url
@@ -106,6 +103,7 @@ Currently available pi commands are:
106
103
  unmap-dns <appname> <--target TARGET> [--dns DNS] Unmap the urls for the application
107
104
  dns List the dns
108
105
  zones List the dns zones
106
+ dns-records [dnsid] List the record info for the registered dns
109
107
  create-dns [dnsname] [--zoneid,--projectid,--desc] Create a new dns
110
108
  register-dns [dnsid] [--target,--continent,--country] Register to target
111
109
  deregister-dns [dnsid] [--recordid ID] Deregister to target
@@ -1,5 +1,5 @@
1
1
  module PI
2
2
  module Cli
3
- VERSION = '0.1.28'
3
+ VERSION = '0.1.29'
4
4
  end
5
5
  end
@@ -125,6 +125,7 @@ class PI::Client
125
125
  end
126
126
 
127
127
  def delete_project(projectid)
128
+ projectid = uri_encode(projectid)
128
129
  http_delete("#{PI::PROJECT_PATH}/#{projectid}",'application/json')
129
130
  end
130
131
 
@@ -134,39 +135,52 @@ class PI::Client
134
135
  end
135
136
 
136
137
  def delete_binary(binaryid)
138
+ binaryid = uri_encode(binaryid)
137
139
  http_delete("#{PI::PROJECT_PATH}/binary/#{binaryid}",'application/json')
138
140
  end
139
141
 
140
142
  def project_events(projectid)
143
+ projectid = uri_encode(projectid)
141
144
  json_get("#{PI::PROJECT_PATH}/events/#{projectid}")
142
145
  end
143
146
 
144
147
  def project_tags(projectid)
148
+ projectid = uri_encode(projectid)
145
149
  json_get("#{PI::PROJECT_PATH}/tags/#{projectid}")
146
150
  end
147
151
 
148
152
  def project_commits_bytag(projectid,tag)
153
+ projectid = uri_encode(projectid)
154
+ tag = uri_encode(tag)
149
155
  json_get("#{PI::PROJECT_PATH}/commitinfo/#{projectid}/#{tag}")
150
156
  end
151
157
 
152
158
  def project_commits_bybranch(projectid,branch="master")
159
+ projectid = uri_encode(projectid)
160
+ branch = uri_encode(branch)
153
161
  json_get("#{PI::PROJECT_PATH}/commitinfo/branch/#{projectid}/#{branch}")
154
162
  end
155
163
 
156
164
  def project_binary(projectid)
165
+ projectid = uri_encode(projectid)
157
166
  json_get("#{PI::PROJECT_PATH}/binary/list/#{projectid}")
158
167
  end
159
168
 
160
169
  def project_binary_existed(projectid,versionname)
161
170
  versionname = uri_encode(versionname)
171
+ projectid = uri_encode(projectid)
162
172
  http_get("#{PI::PROJECT_PATH}/binary/existed/#{projectid}/#{versionname}")
163
173
  end
164
174
 
165
175
  def apps(projectid=0, targetname=nil, pageNum=-1, numPerPage=-1)
176
+ projectid = uri_encode(projectid)
177
+ targetname = uri_encode(targetname)
166
178
  json_get("#{PI::PROJECT_PATH}/apps?projectId=#{projectid}&targetName=#{targetname}&pageNum=#{pageNum}&numPerPage=#{numPerPage}")
167
179
  end
168
180
 
169
181
  def app_sum(projectid=0, targetname=nil)
182
+ projectid = uri_encode(projectid)
183
+ targetname = uri_encode(targetname)
170
184
  http_get("#{PI::PROJECT_PATH}/apps/sum?projectId=#{projectid}&targetName=#{targetname}")
171
185
  end
172
186
 
@@ -175,6 +189,7 @@ class PI::Client
175
189
  #####################################################
176
190
 
177
191
  def app_get_byid(appid)
192
+ appid = uri_encode(appid)
178
193
  json_get("#{PI::APP_PATH}/#{appid}")
179
194
  end
180
195
 
@@ -185,6 +200,7 @@ class PI::Client
185
200
  end
186
201
 
187
202
  def app_search_target_is_all(appname)
203
+ appname = uri_encode(appname)
188
204
  json_get("#{PI::PROJECT_PATH}/apps?appName=#{appname}")
189
205
  end
190
206
 
@@ -193,6 +209,7 @@ class PI::Client
193
209
  end
194
210
 
195
211
  def target_memory(targetname)
212
+ targetname = uri_encode(targetname)
196
213
  http_get("#{PI::APP_PATH}/target/#{targetname}/memory")
197
214
  end
198
215
 
@@ -201,57 +218,73 @@ class PI::Client
201
218
  end
202
219
 
203
220
  def delete_app(appid)
221
+ appid = uri_encode(appid)
204
222
  http_delete("#{PI::APP_PATH}/#{appid}",'application/json')
205
223
  end
206
224
 
207
225
  def start_app(appid)
226
+ appid = uri_encode(appid)
208
227
  json_post("#{PI::APP_PATH}/#{appid}/start",manifest={})
209
228
  end
210
229
 
211
230
  def stop_app(appid, graceful)
231
+ appid = uri_encode(appid)
212
232
  json_post("#{PI::APP_PATH}/#{appid}/stop?graceful=#{graceful}",manifest={})
213
233
  end
214
234
 
215
235
  def restart_app(appid, graceful)
236
+ appid = uri_encode(appid)
216
237
  json_post("#{PI::APP_PATH}/#{appid}/restart?graceful=#{graceful}",manifest={})
217
238
  end
218
239
 
219
240
  def scale_app(appid, instance)
241
+ appid = uri_encode(appid)
242
+ instance = uri_encode(instance)
220
243
  json_post("#{PI::APP_PATH}/#{appid}/scale?instance=#{instance}", manifest={})
221
244
  end
222
245
 
223
246
  def update_app(appid, tag, graceful)
247
+ tag = uri_encode(tag)
248
+ appid = uri_encode(appid)
224
249
  json_post("#{PI::APP_PATH}/#{appid}/rollback/#{tag}?graceful=#{graceful}", manifest={})
225
250
  end
226
251
 
227
252
  def status(appid)
253
+ appid = uri_encode(appid)
228
254
  json_get("#{PI::APP_PATH}/#{appid}/monitor")
229
255
  end
230
256
 
231
257
  def app_log(appid, filepath, instanceindex)
232
258
  filepath = uri_encode(filepath)
259
+ appid = uri_encode(appid)
260
+ instanceindex = uri_encode(instanceindex)
233
261
  http_get("#{PI::APP_PATH}/#{appid}/logs?filePath=#{filepath}&instanceIndex=#{instanceindex}")
234
262
  end
235
263
 
236
264
  def app_env(appid)
265
+ appid = uri_encode(appid)
237
266
  json_get("#{PI::APP_PATH}/#{appid}/env/list")
238
267
  end
239
268
 
240
269
  def create_env(appid, manifest={})
270
+ appid = uri_encode(appid)
241
271
  json_post("#{PI::APP_PATH}/#{appid}/env", manifest)
242
272
  end
243
273
 
244
274
  def delete_env(appid, env)
245
275
  env = uri_encode(env)
276
+ appid = uri_encode(appid)
246
277
  http_delete("#{PI::APP_PATH}/#{appid}/env/#{env}",'application/json')
247
278
  end
248
279
 
249
280
  def env_verify(appid, name)
250
281
  name = uri_encode(name)
282
+ appid = uri_encode(appid)
251
283
  http_get("#{PI::APP_PATH}/#{appid}/env/verify?name=#{name}")
252
284
  end
253
285
 
254
286
  def app_debug_info(appid)
287
+ appid = uri_encode(appid)
255
288
  json_get("#{PI::APP_PATH}/#{appid}/debug")
256
289
  end
257
290
 
@@ -260,18 +293,23 @@ class PI::Client
260
293
  #####################################################
261
294
 
262
295
  def usable_services(appid)
296
+ appid = uri_encode(appid)
263
297
  json_get("#{PI::APP_PATH}/#{appid}/service/usable")
264
298
  end
265
299
 
266
300
  def app_service(appid)
301
+ appid = uri_encode(appid)
267
302
  json_get("#{PI::APP_PATH}/#{appid}/service/bind")
268
303
  end
269
304
 
270
305
  def bind_service(appid, manifest={})
306
+ appid = uri_encode(appid)
271
307
  json_post("#{PI::APP_PATH}/#{appid}/service/bind",manifest)
272
308
  end
273
309
 
274
310
  def unbind_service(appid, servicename)
311
+ appid = uri_encode(appid)
312
+ servicename = uri_encode(servicename)
275
313
  http_delete("#{PI::APP_PATH}/#{appid}/service/unbind/#{servicename}",'application/json')
276
314
  end
277
315
 
@@ -280,6 +318,7 @@ class PI::Client
280
318
  end
281
319
 
282
320
  def service(serviceid)
321
+ serviceid = uri_encode(serviceid)
283
322
  json_get("#{PI::SERVICE_PATH}/#{serviceid}")
284
323
  end
285
324
 
@@ -288,30 +327,39 @@ class PI::Client
288
327
  end
289
328
 
290
329
  def export_service(serviceid)
330
+ serviceid = uri_encode(serviceid)
291
331
  http_get("#{PI::SERVICE_PATH}/exporturl/#{serviceid}")
292
332
  end
293
333
 
294
334
  def check_service(serviceid)
335
+ serviceid = uri_encode(serviceid)
295
336
  http_get("#{PI::SERVICE_PATH}/check/#{serviceid}")
296
337
  end
297
338
 
298
339
  def delete_service(serviceid)
340
+ serviceid = uri_encode(serviceid)
299
341
  http_delete("#{PI::SERVICE_PATH}/#{serviceid}", 'application/json')
300
342
  end
301
343
 
302
344
  def usable_service_target(serviceid)
345
+ serviceid = uri_encode(serviceid)
303
346
  json_get("#{PI::SERVICE_PATH}/target/usable/#{serviceid}")
304
347
  end
305
348
 
306
349
  def service_target(serviceid)
350
+ serviceid = uri_encode(serviceid)
307
351
  json_get("#{PI::SERVICE_PATH}/servicetarget/#{serviceid}")
308
352
  end
309
353
 
310
354
  def register_service(serviceid, targetname, servicetype, manifest={})
355
+ serviceid = uri_encode(serviceid)
356
+ targetname = uri_encode(targetname)
357
+ servicetype = uri_encode(servicetype)
311
358
  json_post("#{PI::SERVICE_PATH}/register/#{targetname}/#{serviceid}?serviceType=#{servicetype}",manifest)
312
359
  end
313
360
 
314
361
  def deregister_service(servicetargetid)
362
+ servicetargetid = uri_encode(servicetargetid)
315
363
  http_delete("#{PI::SERVICE_PATH}/unregister/#{servicetargetid}",'application/json')
316
364
  end
317
365
 
@@ -320,18 +368,23 @@ class PI::Client
320
368
  #####################################################
321
369
 
322
370
  def usable_dns(appid)
371
+ appid = uri_encode(appid)
323
372
  json_get("#{PI::APP_PATH}/#{appid}/url/usable")
324
373
  end
325
374
 
326
375
  def app_dns(appid)
376
+ appid = uri_encode(appid)
327
377
  json_get("#{PI::APP_PATH}/#{appid}/url/map")
328
378
  end
329
379
 
330
380
  def map_dns(appid, manifest={})
381
+ appid = uri_encode(appid)
331
382
  json_post("#{PI::APP_PATH}/#{appid}/url/map", manifest)
332
383
  end
333
384
 
334
385
  def unmap_dns(appid, url)
386
+ appid = uri_encode(appid)
387
+ url = uri_encode(url)
335
388
  http_delete("#{PI::APP_PATH}/#{appid}/url/unmap/#{url}", 'application/json')
336
389
  end
337
390
 
@@ -348,14 +401,18 @@ class PI::Client
348
401
  end
349
402
 
350
403
  def verify_dns(dnsname, zoneid)
404
+ dnsname = uri_encode(dnsname)
405
+ zoneid = uri_encode(zoneid)
351
406
  http_get("#{PI::DNS_PATH}/verify?dnsName=#{dnsname}&zoneId=#{zoneid}")
352
407
  end
353
408
 
354
409
  def delete_dns(dnsid)
410
+ dnsid = uri_encode(dnsid)
355
411
  http_delete("#{PI::DNS_PATH}/#{dnsid}",'application/json')
356
412
  end
357
413
 
358
414
  def usable_dns_target(dnsid)
415
+ dnsid = uri_encode(dnsid)
359
416
  json_get("#{PI::DNS_PATH}/dnstarget/#{dnsid}")
360
417
  end
361
418
 
@@ -364,14 +421,18 @@ class PI::Client
364
421
  end
365
422
 
366
423
  def dns_country(continents)
424
+ continents = uri_encode(continents)
367
425
  json_get("#{PI::DNS_PATH}/country/#{continents}")
368
426
  end
369
427
 
370
428
  def register_dns(dnsid, target, manifest={})
429
+ dnsid = uri_encode(dnsid)
430
+ target = uri_encode(target)
371
431
  json_post("#{PI::DNS_PATH}/view/#{dnsid}/#{target}", manifest)
372
432
  end
373
433
 
374
434
  def deregister_dns(recordid)
435
+ recordid = uri_encode(recordid)
375
436
  http_delete("#{PI::DNS_PATH}/record/#{recordid}",'application/json')
376
437
  end
377
438
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
4
+ hash: 33
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 28
10
- version: 0.1.28
9
+ - 29
10
+ version: 0.1.29
11
11
  platform: ruby
12
12
  authors:
13
13
  - Samsung
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-31 00:00:00 Z
18
+ date: 2012-09-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json_pure