app42 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/RELEASE.md +11 -0
- data/lib/app42/base/constants.rb +3 -0
- data/lib/app42/base/help.rb +106 -32
- data/lib/app42/base/shell.rb +3 -0
- data/lib/app42/base/util.rb +15 -3
- data/lib/app42/client/app42_rest_client.rb +3 -1
- data/lib/app42/command/app.rb +47 -5
- data/lib/app42/command/base.rb +126 -3
- data/lib/app42/command/client.rb +16 -1
- data/lib/app42/command/service.rb +23 -2
- data/lib/app42/command/setup.rb +20 -6
- data/lib/app42/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a1b5e706f83bc170fb06160de374c77912e5d53
|
4
|
+
data.tar.gz: e4294db156a5bbd323aed881022b7c34ef49ae39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d2b686b7711fd5e5d0206f8dd2fbb9e6da4a911b022cc111942374ab1493c595f460657a2fb91779fc3d0ce7415df7893bb1794937adb2c9c2ba596832128ef
|
7
|
+
data.tar.gz: 6e247caef14644a2917c2298a26b2cbea9adf308bb37b8ddd557608543303bcbea8e2e73260e2e52134d3645596d102d38578cbedff25a568e97d8ef0bb55290
|
data/RELEASE.md
ADDED
data/lib/app42/base/constants.rb
CHANGED
data/lib/app42/base/help.rb
CHANGED
@@ -35,8 +35,8 @@ module App42
|
|
35
35
|
setupInfra # Setup your deployment and runtime environment i.e. Instance(Memory, CPU) and Technology Stack
|
36
36
|
deploy # Deploy the application over your runtime environment
|
37
37
|
update # Update the application over your runtime environment
|
38
|
-
scale # Scale application by number of instance(s)
|
39
|
-
descale # Descale application by number of instance(s)
|
38
|
+
scale # Scale application either by number of instance(s) OR kontena(s)
|
39
|
+
descale # Descale application either by number of instance(s) OR kontena(s)
|
40
40
|
start # Start the application
|
41
41
|
stop # Stop the application
|
42
42
|
restart # Restart the application
|
@@ -52,6 +52,7 @@ module App42
|
|
52
52
|
startService # Start the service
|
53
53
|
restartService # Restart the service
|
54
54
|
stopService # Stop the service
|
55
|
+
uploadBackup # Upload file data into a service
|
55
56
|
services # List all the provisioned services with their meta details
|
56
57
|
serviceInfo # Show meta information of the provisioned service
|
57
58
|
resetServicePassword # Reset password of provisioned service
|
@@ -66,10 +67,12 @@ module App42
|
|
66
67
|
activities # List all activities with their status
|
67
68
|
|
68
69
|
Setup
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
setupBPaaS # Setup App42 BPaaS by choosing required configuration
|
71
|
+
deleteSetup # Delete the setup
|
72
|
+
startBPaaS # Start the BPaaS
|
73
|
+
stopBPaaS # Stop the BPaaS
|
74
|
+
setupInfo # Show setup information
|
75
|
+
setups # List all the setups
|
73
76
|
|
74
77
|
Help
|
75
78
|
version # Show Ruby client gem version
|
@@ -211,13 +214,13 @@ Usage:
|
|
211
214
|
Example:
|
212
215
|
$app42 apps
|
213
216
|
|
214
|
-
|
215
|
-
|
|
216
|
-
|
217
|
-
| App Url | App Status | Iaas Provider | Name | Runtime | Instance Count | Memory |
|
218
|
-
|
219
|
-
| https://demo.iab.app42paas.com | RUNNING | Amazon (Oregon) | demo | Ruby 2.0.0 | 1 | 256 MB |
|
220
|
-
|
217
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
218
|
+
| === My Apps === |
|
219
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
220
|
+
| App Url | App Status | Iaas Provider | Name | Runtime | Instance Count | Framework | Memory |
|
221
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
222
|
+
| https://demo.iab.app42paas.com | RUNNING | Amazon (Oregon) | demo | Ruby 2.0.0 | 1 | Ruby on Rack | 256 MB |
|
223
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
221
224
|
DESC
|
222
225
|
|
223
226
|
end
|
@@ -371,7 +374,7 @@ Example:
|
|
371
374
|
Usage:
|
372
375
|
app42 descale
|
373
376
|
|
374
|
-
Descale application by number of instance(s)
|
377
|
+
Descale application either by number of instance(s) OR kontena(s)
|
375
378
|
|
376
379
|
Options:
|
377
380
|
[--app APP] # Name of app, you want to descale
|
@@ -379,12 +382,15 @@ Options:
|
|
379
382
|
Example:
|
380
383
|
$app42 descale
|
381
384
|
Enter App Name: demo
|
382
|
-
|
383
|
-
|
385
|
+
|
386
|
+
1: Horizontal
|
387
|
+
2: Vertical
|
388
|
+
Choose Scale Type [Horizontal]:
|
389
|
+
|
390
|
+
Horizontal descale by instance(s) [1]: 1
|
391
|
+
Descaling Application demo by instance 1... OK
|
384
392
|
|
385
393
|
Operation is in progress, Please wait...|
|
386
|
-
1 out of 2 descaled
|
387
|
-
-
|
388
394
|
Descale completed successfully.
|
389
395
|
DESC
|
390
396
|
end
|
@@ -394,7 +400,7 @@ Example:
|
|
394
400
|
Usage:
|
395
401
|
app42 scale
|
396
402
|
|
397
|
-
Scale application by number of instance(s)
|
403
|
+
Scale application either by number of instance(s) OR kontena(s)
|
398
404
|
|
399
405
|
Options:
|
400
406
|
[--app APP] # Name of app, you want to scale
|
@@ -402,16 +408,46 @@ Options:
|
|
402
408
|
Example:
|
403
409
|
$app42 scale
|
404
410
|
Enter App Name: demo
|
405
|
-
Scale by instance(s) [1]: 2
|
406
|
-
Scaling Application demo by instance 2... OK
|
407
411
|
|
408
|
-
|
409
|
-
|
410
|
-
|
412
|
+
1: Horizontal
|
413
|
+
2: Vertical
|
414
|
+
Choose Scale Type [Horizontal]: 2
|
415
|
+
|
416
|
+
Vertical descale by kontena power(s) [1]:
|
417
|
+
Scaling Application demo by kontena(s) 1... OK
|
418
|
+
|
419
|
+
Operation is in progress, Please wait...|
|
420
|
+
|
411
421
|
Scale completed successfully.
|
412
422
|
DESC
|
413
423
|
end
|
414
424
|
|
425
|
+
def uploadbackup
|
426
|
+
print <<-DESC
|
427
|
+
Usage:
|
428
|
+
app42 uploadBackup
|
429
|
+
|
430
|
+
Upload file data into a service
|
431
|
+
|
432
|
+
Options:
|
433
|
+
[--service SERVICE] # Name of service, you want to scale
|
434
|
+
|
435
|
+
Example:
|
436
|
+
$app42 uploadBackup
|
437
|
+
Enter Service Name: db
|
438
|
+
|
439
|
+
Enter Backup File Path: /home/ubuntu/Downloads/demo_production-27Nov2013.sql
|
440
|
+
|
441
|
+
Do you also want to restore uploaded backup? [Yn]: n
|
442
|
+
Please be patient... This process may take a while to complete.
|
443
|
+
|
444
|
+
Uploading Service Backup... OK
|
445
|
+
|
446
|
+
Operation is in progress, Please wait...
|
447
|
+
Backup has been successfully restored.
|
448
|
+
DESC
|
449
|
+
end
|
450
|
+
|
415
451
|
def appinfo
|
416
452
|
print <<-DESC
|
417
453
|
Usage:
|
@@ -425,14 +461,14 @@ Options:
|
|
425
461
|
Example:
|
426
462
|
$app42 appInfo
|
427
463
|
Enter App Name: demo
|
428
|
-
|
429
|
-
|
|
430
|
-
|
431
|
-
| App Url | App Status | Iaas Provider | Name | Runtime | Instance Count | Memory |
|
432
|
-
|
433
|
-
| https://demo.iab.app42paas.com | RUNNING | Amazon (Oregon) | demo | Ruby 2.0.0 | 1 | 256 MB |
|
434
|
-
|
435
|
-
|
464
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
465
|
+
| === demo Info === |
|
466
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
467
|
+
| App Url | App Status | Iaas Provider | Name | Runtime | Instance Count | Framework | Memory |
|
468
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
469
|
+
| https://demo.iab.app42paas.com | RUNNING | Amazon (Oregon) | demo | Ruby 2.0.0 | 1 | Ruby on Rack | 256 MB |
|
470
|
+
+--------------------------------+------------+-----------------+------+------------+----------------+---------------+--------+
|
471
|
+
DESC
|
436
472
|
end
|
437
473
|
|
438
474
|
def appstate
|
@@ -949,6 +985,44 @@ Example:
|
|
949
985
|
DESC
|
950
986
|
end
|
951
987
|
|
988
|
+
def startbpaas
|
989
|
+
print <<-DESC
|
990
|
+
Usage:
|
991
|
+
app42 startBPaaS
|
992
|
+
|
993
|
+
Start the BPaaS setup
|
994
|
+
|
995
|
+
Example:
|
996
|
+
$app42 startBPaaS
|
997
|
+
Enter Setup Name: demo
|
998
|
+
Starting BPaaS Setup demo... OK
|
999
|
+
|
1000
|
+
Operation is in progress, Please wait...|
|
1001
|
+
|
1002
|
+
BPaaS setup demo started successfully.
|
1003
|
+
|
1004
|
+
DESC
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
def stopbpaas
|
1008
|
+
print <<-DESC
|
1009
|
+
Usage:
|
1010
|
+
app42 stopBPaaS
|
1011
|
+
|
1012
|
+
Stop the BPaaS setup
|
1013
|
+
|
1014
|
+
Example:
|
1015
|
+
$app42 stopBPaaS
|
1016
|
+
Enter Setup Name: demo
|
1017
|
+
Stopping BPaaS Setup demo... OK
|
1018
|
+
|
1019
|
+
Operation is in progress, Please wait...|
|
1020
|
+
|
1021
|
+
BPaaS setup demo stopped successfully.
|
1022
|
+
|
1023
|
+
DESC
|
1024
|
+
end
|
1025
|
+
|
952
1026
|
def version
|
953
1027
|
print <<-DESC
|
954
1028
|
Usage:
|
data/lib/app42/base/shell.rb
CHANGED
@@ -34,11 +34,14 @@ module App42
|
|
34
34
|
'startservice',
|
35
35
|
'restartservice',
|
36
36
|
'stopservice',
|
37
|
+
'uploadbackup',
|
37
38
|
'resetservicepassword',
|
38
39
|
'bindip',
|
39
40
|
'unbindip',
|
40
41
|
'bindinfo',
|
41
42
|
'setupbpaas',
|
43
|
+
'startbpaas',
|
44
|
+
'stopbpaas',
|
42
45
|
'deletesetup',
|
43
46
|
'setupinfo',
|
44
47
|
'setups'
|
data/lib/app42/base/util.rb
CHANGED
@@ -8,6 +8,7 @@ module App42
|
|
8
8
|
# ask application name to user
|
9
9
|
def ask_app_name
|
10
10
|
input "Enter App Name", [], true
|
11
|
+
print_new_line
|
11
12
|
end
|
12
13
|
|
13
14
|
#
|
@@ -296,6 +297,17 @@ module App42
|
|
296
297
|
end
|
297
298
|
end
|
298
299
|
|
300
|
+
# Check whether +uploadbackup+ path is valid OR not
|
301
|
+
# predefined extension are allowed only like .sql, .zip, .dump etc
|
302
|
+
def validate_upload_backup_path path
|
303
|
+
if path.include?('.zip') || path.include?('.sql') || path.include?('.tar.gz') || path.include?('.gzip') || path.include?('.dump')
|
304
|
+
return path
|
305
|
+
else
|
306
|
+
message "Please provide valid file.", true, 'red'
|
307
|
+
return false
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
299
311
|
# Check whether +setup+ name is valid OR not
|
300
312
|
# +setup+ name length should not be more than 30 character
|
301
313
|
# And should not contain any special character
|
@@ -346,7 +358,7 @@ module App42
|
|
346
358
|
unless response["success"]
|
347
359
|
return true
|
348
360
|
else
|
349
|
-
message "App with
|
361
|
+
message "App with name '#{app_name}' does not exist.", true, 'red'
|
350
362
|
exit!
|
351
363
|
end
|
352
364
|
end
|
@@ -362,7 +374,7 @@ module App42
|
|
362
374
|
unless response["success"]
|
363
375
|
return true
|
364
376
|
else
|
365
|
-
message "Service with
|
377
|
+
message "Service with name '#{service_name}' does not exist.", true, 'red'
|
366
378
|
exit!
|
367
379
|
end
|
368
380
|
end
|
@@ -377,7 +389,7 @@ module App42
|
|
377
389
|
unless response["success"]
|
378
390
|
return true
|
379
391
|
else
|
380
|
-
message "Setup
|
392
|
+
message "Setup with name '#{setup_name}' does not exist.", true, 'red'
|
381
393
|
exit!
|
382
394
|
end
|
383
395
|
end
|
@@ -371,8 +371,10 @@ module App42
|
|
371
371
|
)
|
372
372
|
rescue Errno::ECONNREFUSED => e
|
373
373
|
@exception_msg = "#{Message::COULD_NOT_CONNECT}"
|
374
|
+
rescue Errno::ENOENT => e
|
375
|
+
@exception_msg = "#{e.message}"
|
374
376
|
rescue SystemCallError, SocketError => e
|
375
|
-
@exception_msg = "#{Message::NW_CONNECTION_ERROR}"
|
377
|
+
@exception_msg = "#{Message::NW_CONNECTION_ERROR}"
|
376
378
|
rescue RestClient::RequestTimeout => e
|
377
379
|
@exception_msg = "#{Message::TIME_OUT_ERROR}"
|
378
380
|
rescue => e
|
data/lib/app42/command/app.rb
CHANGED
@@ -112,6 +112,10 @@ module App42
|
|
112
112
|
input "Choose Upload Type", app_source_type, true
|
113
113
|
end
|
114
114
|
|
115
|
+
def ask_scale_type #:ndoc:
|
116
|
+
input "Choose Scale Type", App42::SCALE_TYPE, true
|
117
|
+
end
|
118
|
+
|
115
119
|
# @param binary/git
|
116
120
|
# @return path
|
117
121
|
def get_source_path app_source
|
@@ -128,20 +132,58 @@ module App42
|
|
128
132
|
# then scale app by no of instance
|
129
133
|
def scale
|
130
134
|
@options[:name] = get_app_name if @options[:name].nil?
|
131
|
-
|
132
|
-
|
133
|
-
|
135
|
+
scale_type = ask_scale_type
|
136
|
+
if scale_type == App42::SCALE_TYPE.first
|
137
|
+
hscale @options[:name]
|
138
|
+
else
|
139
|
+
vscale @options[:name]
|
140
|
+
end
|
134
141
|
end
|
135
142
|
|
136
143
|
# read +app name+ and number of +instance+ from user
|
137
144
|
# then descale app by no of instance
|
138
145
|
def descale
|
139
146
|
@options[:name] = get_app_name if @options[:name].nil?
|
140
|
-
|
141
|
-
|
147
|
+
scale_type = ask_scale_type
|
148
|
+
if scale_type == App42::SCALE_TYPE.first
|
149
|
+
hdescale @options[:name]
|
150
|
+
else
|
151
|
+
vdescale @options[:name]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# read +app name+ and number of +instance+ from user
|
156
|
+
# then scale app by no of instance
|
157
|
+
def hscale app_name
|
158
|
+
@options[:instance] = get_instance "Horizontal scale" if is_app_exist? app_name and @options[:instance].nil?
|
159
|
+
scale_or_descal_res = scale_or_descale_app "scale", @options[:instance], app_name
|
142
160
|
exit! if scale_or_descal_res
|
143
161
|
end
|
144
162
|
|
163
|
+
# read +app name+ and number of +instance+ from user
|
164
|
+
# then descale app by no of instance
|
165
|
+
def hdescale app_name
|
166
|
+
@options[:instance] = get_instance "Horizontal descale" if is_app_exist? app_name and @options[:instance].nil?
|
167
|
+
scale_or_descal_res = scale_or_descale_app "descale", @options[:instance], app_name
|
168
|
+
exit! if scale_or_descal_res
|
169
|
+
end
|
170
|
+
|
171
|
+
# read +app name+ and number of +instance+ from user
|
172
|
+
# then vertically scale app by no of instance
|
173
|
+
def vscale app_name
|
174
|
+
@options[:kontena] = get_kontena "Vertical scale" if is_app_exist? app_name and @options[:kontena].nil?
|
175
|
+
vscale_or_vdescal_res = vscale_or_vdescale_app __method__, @options[:kontena], app_name
|
176
|
+
exit! if vscale_or_vdescal_res
|
177
|
+
end
|
178
|
+
|
179
|
+
# read +app name+ and number of +instance+ from user
|
180
|
+
# then vertically descale app by no of instance
|
181
|
+
def vdescale app_name
|
182
|
+
@options[:kontena] = get_kontena "Vertical descale" if is_app_exist? app_name and @options[:kontena].nil?
|
183
|
+
vscale_or_vdescal_res = vscale_or_vdescale_app __method__, @options[:kontena], app_name
|
184
|
+
exit! if vscale_or_vdescal_res
|
185
|
+
end
|
186
|
+
|
145
187
|
# app42 start
|
146
188
|
#
|
147
189
|
# start the app, return true or error code/message
|
data/lib/app42/command/base.rb
CHANGED
@@ -73,8 +73,8 @@ module App42
|
|
73
73
|
|
74
74
|
# Ask application name from user and
|
75
75
|
# will wait for user response (user will enter application name)
|
76
|
-
def get_app_name
|
77
|
-
app_name =
|
76
|
+
def get_app_name
|
77
|
+
app_name = input "Enter App Name", [], true
|
78
78
|
valid_app_name = validate_app_and_service_name "App name", app_name.strip
|
79
79
|
valid_app_name ? (return valid_app_name) : get_app_name
|
80
80
|
end
|
@@ -414,6 +414,40 @@ module App42
|
|
414
414
|
return response
|
415
415
|
end
|
416
416
|
|
417
|
+
# upload service backup
|
418
|
+
# @params service name, file upload path and restore(wanted to restore running db)
|
419
|
+
def upload_service_backup service_name, path, restore
|
420
|
+
begin
|
421
|
+
query_params = params
|
422
|
+
query_params.store('serviceName', service_name)
|
423
|
+
query_params.store('restore', restore.to_s)
|
424
|
+
message "#{Message::WAIT_FOR_WHILE}", true, 'green'
|
425
|
+
response = with_progress(Paint["Uploading Service Backup", :yellow]) do |s|
|
426
|
+
@connection.multipart(signature(query_params), resource_url("service/backup", "upload"), query_params, query_params, path)
|
427
|
+
end
|
428
|
+
|
429
|
+
if response["success"] == true && response["transactionId"]
|
430
|
+
check_transaction_status response["transactionId"], previous_completed = 0, 'Uploaded'
|
431
|
+
else response["success"] == true
|
432
|
+
message "#{response['message']}", true, 'green'
|
433
|
+
exit!
|
434
|
+
end
|
435
|
+
|
436
|
+
if response['success']
|
437
|
+
exit!
|
438
|
+
else
|
439
|
+
puts Paint["#{response['description']}", :red]
|
440
|
+
exit!
|
441
|
+
end
|
442
|
+
rescue Interrupt
|
443
|
+
puts Paint[" Command cancelled.", :red]
|
444
|
+
exit!
|
445
|
+
rescue Exception => e
|
446
|
+
puts e
|
447
|
+
end
|
448
|
+
return response
|
449
|
+
end
|
450
|
+
|
417
451
|
# It's common methods of app information like app state, info etc.
|
418
452
|
# methods expect +what+ as operation and +app_name+ as Application name
|
419
453
|
def app_information what, app_name
|
@@ -456,6 +490,34 @@ module App42
|
|
456
490
|
end
|
457
491
|
end
|
458
492
|
|
493
|
+
# vertical scale or descale application by no of kontena,
|
494
|
+
# expect +what+ as operation and kontena as no of kontena
|
495
|
+
def vscale_or_vdescale_app what, kontena, app_name
|
496
|
+
begin
|
497
|
+
body = {'app42' => {"request"=> {
|
498
|
+
'appName' => app_name,
|
499
|
+
"kontenaPower" => kontena.to_s
|
500
|
+
}}}.to_json
|
501
|
+
|
502
|
+
query_params = params
|
503
|
+
query_params.store('body', body)
|
504
|
+
|
505
|
+
response = with_progress( Paint[ what.to_s == 'vscale' ? "Scaling Application #{app_name} by kontena(s) #{kontena}" : "Descaling Application #{app_name} by kontena(s) #{kontena}", :yellow]) do |s|
|
506
|
+
build_post_request body, query_params, "app", what
|
507
|
+
end
|
508
|
+
|
509
|
+
check_transaction_status response["transactionId"], previous_completed = 0, "#{what}d" if response["success"] == true && response["transactionId"]
|
510
|
+
response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
|
511
|
+
|
512
|
+
rescue Interrupt
|
513
|
+
puts Paint[" Command cancelled.", :red]
|
514
|
+
exit!
|
515
|
+
rescue Exception => e
|
516
|
+
puts e
|
517
|
+
exit!
|
518
|
+
end
|
519
|
+
end
|
520
|
+
|
459
521
|
# common methods for app42paas config request like runtimes,frameworks etc
|
460
522
|
def interactive_get resource, get_obj
|
461
523
|
begin
|
@@ -634,6 +696,47 @@ module App42
|
|
634
696
|
end
|
635
697
|
end
|
636
698
|
|
699
|
+
# All application operation will take placed like app start, stop etc.
|
700
|
+
# expect +what+ as operation and +setup_name+ as BPaaS name.
|
701
|
+
def clouldapi_operation what, setup_name
|
702
|
+
begin
|
703
|
+
if what.to_s == 'stop'
|
704
|
+
response = with_progress(Paint[ "Stopping BPaaS Setup #{setup_name}", :yellow]) do |s|
|
705
|
+
body = {'app42' => {"request"=> {
|
706
|
+
"setupName" => setup_name
|
707
|
+
}}}.to_json
|
708
|
+
|
709
|
+
query_params = params
|
710
|
+
query_params.store('body', body)
|
711
|
+
build_put_request body, query_params, "setup", "#{what}" if what.to_s == 'stop'
|
712
|
+
end
|
713
|
+
else
|
714
|
+
response = with_progress(Paint["#{what.capitalize}ing BPaaS Setup #{setup_name}", :yellow]) do |s|
|
715
|
+
body = {'app42' => {"request"=> {
|
716
|
+
"setupName" => setup_name
|
717
|
+
}}}.to_json
|
718
|
+
|
719
|
+
query_params = params
|
720
|
+
query_params.store('body', body)
|
721
|
+
build_put_request body, query_params, "setup", "#{what}" if what.to_s == 'restart' || what.to_s == 'start'
|
722
|
+
end
|
723
|
+
end
|
724
|
+
|
725
|
+
if response["success"] == true && response["transactionId"]
|
726
|
+
if what.to_s == 'stop'
|
727
|
+
check_transaction_status response["transactionId"], previous_completed = 0, "#{what}ped"
|
728
|
+
else
|
729
|
+
check_transaction_status response["transactionId"], previous_completed = 0, "#{what}ed"
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
|
734
|
+
rescue Interrupt
|
735
|
+
puts Paint[" Command cancelled.", :red]
|
736
|
+
exit!
|
737
|
+
end
|
738
|
+
end
|
739
|
+
|
637
740
|
# reset service password and fetch service latest details
|
638
741
|
#
|
639
742
|
# ==== Parameters
|
@@ -680,7 +783,7 @@ module App42
|
|
680
783
|
|
681
784
|
|
682
785
|
# All application operation will take placed like app start, stop etc.
|
683
|
-
# expect +what+ as operation and +
|
786
|
+
# expect +what+ as operation and +service_name+ as Service name.
|
684
787
|
def service_operation what, service_name
|
685
788
|
begin
|
686
789
|
if what.to_s == 'stop'
|
@@ -833,6 +936,26 @@ module App42
|
|
833
936
|
get_instance obj
|
834
937
|
end
|
835
938
|
end
|
939
|
+
|
940
|
+
#
|
941
|
+
# return no of kontena power
|
942
|
+
#
|
943
|
+
def get_kontena obj
|
944
|
+
kontena = @options[:kontena] if @options[:kontena]
|
945
|
+
unless kontena
|
946
|
+
kontena = nil
|
947
|
+
kontena = ask Paint[ "#{obj.capitalize} by kontena power(s)", :cyan], :default => 1
|
948
|
+
end
|
949
|
+
|
950
|
+
kontena_count = number_valid? kontena
|
951
|
+
|
952
|
+
if kontena_count
|
953
|
+
return kontena_count
|
954
|
+
else
|
955
|
+
message "#{Message::NOT_A_VALID_NUM}", true, 'red'
|
956
|
+
get_kontena obj
|
957
|
+
end
|
958
|
+
end
|
836
959
|
end
|
837
960
|
end
|
838
961
|
end
|
data/lib/app42/command/client.rb
CHANGED
@@ -70,9 +70,15 @@ module App42
|
|
70
70
|
opts.on('--instance INSTANCE') { |instance| @options[:instance] = instance }
|
71
71
|
opts.on('-i INSTANCE') { |instance| @options[:instance] = instance }
|
72
72
|
|
73
|
+
opts.on('--kontena KONTENA') { |kontena| @options[:kontena] = kontena }
|
74
|
+
opts.on('-i KONTENA') { |kontena| @options[:kontena] = kontena }
|
75
|
+
|
73
76
|
opts.on('--service SERVICE') { |service| @options[:service] = service }
|
74
77
|
opts.on('-s SERVICE') { |service| @options[:service] = service }
|
75
78
|
|
79
|
+
opts.on('--setup SETUP') { |setup| @options[:setup] = setup }
|
80
|
+
opts.on('-s SETUP') { |setup| @options[:setup] = setup }
|
81
|
+
|
76
82
|
opts.on('-h', '--help') { puts "#{App42::Base::Help.usage(command)}\n"; exit! }
|
77
83
|
end
|
78
84
|
opts_parser.parse!(args)
|
@@ -208,7 +214,10 @@ module App42
|
|
208
214
|
set_cmd(:service, :restart)
|
209
215
|
|
210
216
|
when 'stopservice'
|
211
|
-
set_cmd(:service, :stop)
|
217
|
+
set_cmd(:service, :stop)
|
218
|
+
|
219
|
+
when 'uploadbackup'
|
220
|
+
set_cmd(:service, :uploadbackup)
|
212
221
|
|
213
222
|
when 'resetservicepassword'
|
214
223
|
set_cmd(:service, :reset_pass)
|
@@ -225,6 +234,12 @@ module App42
|
|
225
234
|
when 'setupbpaas'
|
226
235
|
set_cmd(:setup, :setup_cloud_api)
|
227
236
|
|
237
|
+
when 'startbpaas'
|
238
|
+
set_cmd(:setup, :start)
|
239
|
+
|
240
|
+
when 'stopbpaas'
|
241
|
+
set_cmd(:setup, :stop)
|
242
|
+
|
228
243
|
when 'deletesetup'
|
229
244
|
set_cmd(:setup, :delete_cloud_api)
|
230
245
|
|
@@ -23,6 +23,12 @@ module App42::Command
|
|
23
23
|
build_get_request params, 'service', nil
|
24
24
|
end
|
25
25
|
|
26
|
+
def get_uploadbackup_path #:nodoc:
|
27
|
+
path = ask(Paint["\nEnter Backup File Path", :cyan])
|
28
|
+
valid_path = validate_upload_backup_path path.strip
|
29
|
+
valid_path ? (return valid_path) : get_uploadbackup_path
|
30
|
+
end
|
31
|
+
|
26
32
|
# ask service name to user
|
27
33
|
def ask_service_name
|
28
34
|
service_name = ask Paint["Enter Service Name", :cyan]
|
@@ -39,8 +45,9 @@ module App42::Command
|
|
39
45
|
def ask_source_ip what
|
40
46
|
ip = input "#{Message::BIND_NOTE}", [], true if what.to_s == 'bind'
|
41
47
|
ip = input "#{Message::UNBIND_NOTE}", [], true if what.to_s == 'unbind'
|
42
|
-
|
43
|
-
|
48
|
+
ip_address = ip.strip
|
49
|
+
if ip_address_valid? ip_address
|
50
|
+
return ip_address
|
44
51
|
else
|
45
52
|
message "#{Message::IP_NOT_VALID}", true, 'red'
|
46
53
|
ask_source_ip what
|
@@ -117,6 +124,20 @@ module App42::Command
|
|
117
124
|
exit! if response
|
118
125
|
end
|
119
126
|
|
127
|
+
# read +app name+ and number of +instance+ from user
|
128
|
+
# then vertically descale app by no of instance
|
129
|
+
def uploadbackup
|
130
|
+
@options[:service] = ask_service_name if @options[:service].nil?
|
131
|
+
path = get_uploadbackup_path if is_service_exist? @options[:service]
|
132
|
+
restore = ask(
|
133
|
+
Paint["\nDo you also want to restore uploaded backup?", :cyan],
|
134
|
+
:default => true
|
135
|
+
)
|
136
|
+
|
137
|
+
status = upload_service_backup @options[:service], path, restore
|
138
|
+
return status
|
139
|
+
end
|
140
|
+
|
120
141
|
# collect service name from user and proceed service resetPassword request
|
121
142
|
def reset_pass
|
122
143
|
@options[:service] = ask_service_name if @options[:service].nil?
|
data/lib/app42/command/setup.rb
CHANGED
@@ -19,8 +19,22 @@ module App42
|
|
19
19
|
|
20
20
|
# Delete App42 cloud API setup, return true or error code/message
|
21
21
|
def delete_cloud_api
|
22
|
-
@options[:
|
23
|
-
response = delete_clouldapi @options[:
|
22
|
+
@options[:setup] = get_setup_name if @options[:setup].nil?
|
23
|
+
response = delete_clouldapi @options[:setup] if is_setup_name_exist? @options[:setup]
|
24
|
+
exit! if response
|
25
|
+
end
|
26
|
+
|
27
|
+
# collect BPaaS setup name from user and proceed BPaaS start request
|
28
|
+
def start
|
29
|
+
@options[:setup] = get_setup_name if @options[:setup].nil?
|
30
|
+
response = clouldapi_operation __method__, @options[:setup] if is_setup_name_exist? @options[:setup]
|
31
|
+
exit! if response
|
32
|
+
end
|
33
|
+
|
34
|
+
# collect BPaaS setup name from user and proceed BPaaS stop request
|
35
|
+
def stop
|
36
|
+
@options[:setup] = get_setup_name if @options[:setup].nil?
|
37
|
+
response = clouldapi_operation __method__, @options[:setup] if is_setup_name_exist? @options[:setup]
|
24
38
|
exit! if response
|
25
39
|
end
|
26
40
|
|
@@ -47,10 +61,10 @@ module App42
|
|
47
61
|
|
48
62
|
# get details information of App42 cloud setup
|
49
63
|
def info
|
50
|
-
@options[:
|
64
|
+
@options[:setup] = get_setup_name if @options[:setup].nil?
|
51
65
|
query_params = params
|
52
|
-
query_params.store('setupName', @options[:
|
53
|
-
setup_info = build_get_request query_params, 'setup', "#{@options[:
|
66
|
+
query_params.store('setupName', @options[:setup])
|
67
|
+
setup_info = build_get_request query_params, 'setup', "#{@options[:setup]}"
|
54
68
|
rows, rows_header_final, rows_header = [], [], nil
|
55
69
|
if setup_info && setup_info['setupInfo']
|
56
70
|
rows_header = setup_info['setupInfo'].keys
|
@@ -58,7 +72,7 @@ module App42
|
|
58
72
|
|
59
73
|
rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) }
|
60
74
|
|
61
|
-
table = Terminal::Table.new :title => Paint["=== #{@options[:
|
75
|
+
table = Terminal::Table.new :title => Paint["=== #{@options[:setup]} Details ===", :green], :headings => rows_header_final, :rows => rows
|
62
76
|
puts table
|
63
77
|
end
|
64
78
|
end
|
data/lib/app42/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app42
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ShepHertz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- Gemfile
|
191
191
|
- LICENSE.txt
|
192
192
|
- README.md
|
193
|
+
- RELEASE.md
|
193
194
|
- Rakefile
|
194
195
|
- app42.gemspec
|
195
196
|
- bin/app42
|