app42 0.5.10 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ef81a41d58513f52552f8bb1b014d174984ab74
4
- data.tar.gz: 1816b48b8e55b9eca9ef16f338c2ebdec661c3f4
3
+ metadata.gz: 72b1cf90b1aa79d2f2c7d7e07d09f21ad6d50ad0
4
+ data.tar.gz: 71e15470863e0a4c288294307c7e812dc2e1cfab
5
5
  SHA512:
6
- metadata.gz: 23f3a6c61c981d7fb4a5f54628e1a6143d0f88d769920c82d26f655d2386b80828eda8f43b2c3f95b3155b6263b63d4079f715de129b2aa11e5ddb0247fdecd8
7
- data.tar.gz: d1e95bae60ebc1caf63aed7fba33c1bcf0fe2747419ad859584a2bdc308ae69e44a88b24e32af2b821e1ce40669d17220f433659bcdbdfc8c4401787fc7c0070
6
+ metadata.gz: f773373c427bd715180ffdbf4f3eca4b21256e150faee645df1f734eb2044b3f0bbf0f329e608eba93bac2a3fc85b2c08758e909512eaf02db34a5d88fc7f144
7
+ data.tar.gz: 91ba3ce9113eb87ed77a00bfbb387669c651fe168ca77211cf78efad251dc009b84214a750d40c2f836f6e77885953b2780a0f6aae908cc6b960aba7e4165199
data/RELEASE.md CHANGED
@@ -15,4 +15,11 @@ Client library and command-line tool to deploy and manage apps on App42PaaS.
15
15
  - Service Vertical scale and descale
16
16
  - BPaaS setup upgrade
17
17
 
18
+ ### 0.6.0 (08-01-2014)
19
+
20
+ - Node.js support
21
+ - WordPress support
22
+ - BPaaS setup downgrade
23
+ - WordPress setup donwgrade
24
+
18
25
 
@@ -22,6 +22,9 @@ module App42
22
22
  # Scale type
23
23
  SCALE_TYPE = ['Horizontal', 'Vertical']
24
24
 
25
+ # flavour type
26
+ FLAVOUR_TYPE = ['light', 'medium', 'heavy']
27
+
25
28
  DATABASE_NAME_NOT_ALLOWED = %w(mysql couchdb mongodb postgresql database sql)
26
29
 
27
30
  # regex for special character
@@ -71,12 +71,23 @@ module App42
71
71
  Setup
72
72
  setupBPaaS # Setup App42 BPaaS by choosing required configuration
73
73
  deleteSetup # Delete the setup
74
- startBPaaS # Start the BPaaS
75
- stopBPaaS # Stop the BPaaS
74
+ startBPaaS # Start the BPaaS setup
75
+ stopBPaaS # Stop the BPaaS setup
76
76
  setupInfo # Show setup information
77
77
  upgradeBPaas # Upgrade BPaaS by choosing required configuration
78
+ downgradeBPaas # Downgrade BPaaS by choosing required configuration
78
79
  setups # List all the setups
79
80
 
81
+ WordPress
82
+ setupWordPress # Setup App42 WordPress by choosing required configuration
83
+ deleteWordPress # Delete the WordPress setup
84
+ startWordPress # Start the WordPress setup
85
+ stopWordPress # Stop the WordPress setup
86
+ upgradeWordPress # Upgrade WordPress by choosing required configuration
87
+ downgradeWordPress # Downgrade WordPress by choosing required configuration
88
+ wordPressInfo # Show WordPress setup information
89
+ wordPressSetups # List all the WordPress setups
90
+
80
91
  Help
81
92
  version # Show Ruby client gem version
82
93
  help # List available commands and their description
@@ -1091,10 +1102,210 @@ Example:
1091
1102
  Operation is in progress, Please wait...-
1092
1103
 
1093
1104
  BPaaS setup demo upgraded successfully.
1105
+ DESC
1106
+ end
1107
+
1108
+ def downgradebpaas
1109
+ print <<-DESC
1110
+ Usage:
1111
+ app42 downgradeBPaaS
1112
+
1113
+ Downgrade BPaaS by choosing required configuration
1114
+
1115
+ Example:
1116
+ $app42 downgradeBPaaS
1117
+ Enter Setup Name: demo
1118
+
1119
+ 1: Light
1120
+ 2: Medium
1121
+ Select Flavour [Light]: 2
1122
+
1123
+ Downgrading Setup... OK
1124
+
1125
+ Operation is in progress, Please wait...-
1126
+
1127
+ BPaaS setup demo downgraded successfully.
1128
+ DESC
1129
+ end
1130
+
1131
+ def setupwordpress
1132
+ print <<-DESC
1133
+ Usage:
1134
+ app42 setupWordPress
1135
+
1136
+ Setup App42 WordPress by choosing required configuration
1137
+
1138
+ Example:
1139
+ $app42 setupWordPress
1140
+ Enter WordPress Name: demo
1141
+
1142
+ Checking WordPress Name Availability... OK
1143
+
1144
+ 1: Shared
1145
+ Select Instance Type [Shared]:
1146
+
1147
+ 1: Amazon (Northern Virginia)
1148
+ Select IaaS Provider [Amazon (Northern Virginia)]:
1149
+
1150
+ 1: Light
1151
+ 2: Medium
1152
+ 3: Heavy
1153
+ Select Flavour [Light]:
1154
+
1155
+ Setting up the infrastructure... OK
1156
+
1157
+ Operation is in progress, Please wait...-
1158
+
1159
+ Your WordPress setup has been completed successfully, For details, Login to AppHQ console.
1160
+
1161
+ DESC
1162
+ end
1163
+
1164
+ def startwordpress
1165
+ print <<-DESC
1166
+ Usage:
1167
+ app42 startWordPress
1168
+
1169
+ Start the WordPress setup
1170
+
1171
+ Example:
1172
+ $app42 startWordPress
1173
+ Enter Setup Name: demo
1174
+ Starting WordPress Setup demo... OK
1175
+
1176
+ Operation is in progress, Please wait...|
1177
+ Setup started successfully.
1094
1178
 
1095
1179
  DESC
1096
1180
  end
1097
1181
 
1182
+ def stopwordpress
1183
+ print <<-DESC
1184
+ Usage:
1185
+ app42 stopWordPress
1186
+
1187
+ Stop the WordPress setup
1188
+
1189
+ Example:
1190
+ $app42 stopWordPress
1191
+ Enter Setup Name: demo
1192
+ Stopping WordPress Setup demo... OK
1193
+
1194
+ Operation is in progress, Please wait...|
1195
+ Setup stopped successfully.
1196
+
1197
+ DESC
1198
+ end
1199
+
1200
+ def upgradewordpress
1201
+ print <<-DESC
1202
+ Usage:
1203
+ app42 upgradeWordpress
1204
+
1205
+ Upgrade WordPress by choosing required configuration
1206
+
1207
+ Example:
1208
+ $app42 upgradeWordPress
1209
+ Enter Setup Name: demo
1210
+
1211
+ 1: Light
1212
+ 2: Medium
1213
+ 3: Heavy
1214
+ Select Flavour [Light]: 2
1215
+
1216
+ Upgrading Setup... OK
1217
+
1218
+ Operation is in progress, Please wait...-
1219
+
1220
+ WordPress setup demo upgraded successfully.
1221
+ DESC
1222
+ end
1223
+
1224
+ def downgradewordpress
1225
+ print <<-DESC
1226
+ Usage:
1227
+ app42 downgradeWordpress
1228
+
1229
+ Downgrade WordPress by choosing required configuration
1230
+
1231
+ Example:
1232
+ $app42 upgradeWordPress
1233
+ Enter Setup Name: demo
1234
+
1235
+ 1: Light
1236
+ 2: Medium
1237
+ Select Flavour [Light]: 2
1238
+
1239
+ Downgrading Setup... OK
1240
+
1241
+ Operation is in progress, Please wait...-
1242
+
1243
+ WordPress setup demo downgraded successfully.
1244
+ DESC
1245
+ end
1246
+
1247
+ def deletewordpress
1248
+ print <<-DESC
1249
+ Usage:
1250
+ app42 deleteWordPress
1251
+
1252
+ Delete the WordPress setup
1253
+
1254
+ Example:
1255
+ $app42 deleteWordPress
1256
+ Enter Setup Name: demo
1257
+ Deleting Setup... OK
1258
+
1259
+ Operation is in progress, Please wait...-
1260
+ Setup deleted successfully.
1261
+ DESC
1262
+ end
1263
+
1264
+ def wordpressinfo
1265
+ print <<-DESC
1266
+
1267
+ Usage:
1268
+ app42 wordPressInfo
1269
+
1270
+ Show WordPress setup information
1271
+
1272
+ Options:
1273
+ [--setup SETUP] # Name of setup, you want to info
1274
+
1275
+ Example:
1276
+ $app42 wordPressInfo
1277
+ Enter Setup Name: demo
1278
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1279
+ | === demo Details === |
1280
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1281
+ | Created On | Api Server Url | Setup Name | Iaas Provider | Setup Type | Vm Type | Setup Flavour | Setup Status |
1282
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1283
+ | 2014-01-02 10:10:38.0 | http://demowordpress.iaa.app42paas.com | demo | Amazon (Northern Virginia) | WP | Shared | medium | RUNNING |
1284
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1285
+
1286
+ DESC
1287
+ end
1288
+
1289
+ def wordpresssetups
1290
+ print <<-DESC
1291
+ Usage:
1292
+ app42 wordPressSetups
1293
+
1294
+ List all the WordPress setups
1295
+
1296
+ Example:
1297
+ $app42 wordPressSetups
1298
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1299
+ | === Setups List === |
1300
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1301
+ | Created On | App Url | Setup Name | Iaas Provider | Setup Type | Vm Type | Setup Flavour | Setup Status |
1302
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1303
+ | 2014-01-02 10:10:38.0 | http://demowordpress.iaa.app42paas.com | demo | Amazon (Northern Virginia) | WP | Shared | medium | RUNNING |
1304
+ +-----------------------+----------------------------------------+------------+----------------------------+------------+---------+---------------+--------------+
1305
+
1306
+ DESC
1307
+ end
1308
+
1098
1309
  def version
1099
1310
  print <<-DESC
1100
1311
  Usage:
@@ -35,4 +35,8 @@ module Message
35
35
  NW_CONNECTION_ERROR = "Please check your n/w connection."
36
36
  TIME_OUT_ERROR = "Request Timed Out. Please try after some time."
37
37
  BAD_RESPONSE_ERROR = "Received bad HTTP response from"
38
+
39
+ # BPaaS and WordPress
40
+ HIGHLY_CONF = "Sorry, You are already at highest configuration."
41
+ LOW_CONF = "Sorry, You are already at lowest configuration."
38
42
  end
@@ -44,10 +44,19 @@ module App42
44
44
  'setupbpaas',
45
45
  'startbpaas',
46
46
  'upgradebpaas',
47
+ 'downgradebpaas',
47
48
  'stopbpaas',
48
49
  'deletesetup',
49
50
  'setupinfo',
50
- 'setups'
51
+ 'setups',
52
+ 'setupwordpress',
53
+ 'deletewordpress',
54
+ 'upgradewordpress',
55
+ 'downgradewordpress',
56
+ 'startwordpress',
57
+ 'stopwordpress',
58
+ 'wordpresssetups',
59
+ 'wordpressinfo'
51
60
  ]
52
61
 
53
62
  end
@@ -300,7 +300,7 @@ module App42
300
300
  # Check whether +uploadbackup+ path is valid OR not
301
301
  # predefined extension are allowed only like .sql, .zip, .dump etc
302
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')
303
+ if path.include?('.zip') || path.include?('.sql') || path.include?('.tar.gz') || path.include?('.gzip') || path.include?('.dump') || path.include?('.rdb')
304
304
  return path
305
305
  else
306
306
  message "Please provide valid file.", true, 'red'
@@ -405,6 +405,50 @@ module App42
405
405
  end
406
406
  end
407
407
 
408
+ # Get flavour for upgrade
409
+ def get_flavour_upgrade setup_name
410
+ flavour_hash = {}
411
+ flavour_type = App42::Command::Config.new.get_flavour_type_fm_server
412
+ flavour_type['flavours'].select {|each_flavour| flavour_hash["#{each_flavour['id']}"] = each_flavour['name']}
413
+
414
+ query_params = params
415
+ query_params.store('setupName', setup_name)
416
+ wordpress_info = build_get_request query_params, 'setup', "#{setup_name}"
417
+
418
+ flavour_hash.delete 'light' if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE.first
419
+ ['light','medium'].each{|f| flavour_hash.delete f} if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE[1]
420
+ message "#{Message::HIGHLY_CONF}", true, 'red' if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE[2]
421
+ exit! if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE[2]
422
+
423
+ flavour = input "Select Flavour", flavour_hash.values, true
424
+
425
+ flavour_id = nil
426
+ flavour_hash.each_pair{|fl| flavour_id = fl[0] if fl[1] == flavour}
427
+ return flavour_id
428
+ end
429
+
430
+ # Get flavour for downgrade
431
+ def get_flavour_downgrade setup_name
432
+ flavour_hash = {}
433
+ flavour_type = App42::Command::Config.new.get_flavour_type_fm_server
434
+ flavour_type['flavours'].select {|each_flavour| flavour_hash["#{each_flavour['id']}"] = each_flavour['name']}
435
+
436
+ query_params = params
437
+ query_params.store('setupName', setup_name)
438
+ wordpress_info = build_get_request query_params, 'setup', "#{setup_name}"
439
+
440
+ message "#{Message::LOW_CONF}", true, 'red' if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE.first
441
+ exit! if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE.first
442
+ ['heavy','medium'].each{|f| flavour_hash.delete f} if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE[1]
443
+ ['heavy'].each{|f| flavour_hash.delete f} if wordpress_info['setupInfo']['setupFlavour'] == App42::FLAVOUR_TYPE[2]
444
+
445
+ flavour = input "Select Flavour", flavour_hash.values, true
446
+
447
+ flavour_id = nil
448
+ flavour_hash.each_pair{|fl| flavour_id = fl[0] if fl[1] == flavour}
449
+ return flavour_id
450
+ end
451
+
408
452
  end
409
453
  end
410
454
  end
@@ -44,6 +44,17 @@ module App42
44
44
  setup_name = get_setup_name
45
45
  available = setup_url_availability setup_name
46
46
  return available if available
47
+ end
48
+
49
+ # collect wordpress name from user
50
+ # if wordpress name will not available
51
+ # User can try 3 more times with different wordpress name
52
+ def get_wordpress_name_and_check_wordpress_url_availability
53
+ @aa_retry ||= 1
54
+ exit! if (@aa_retry += 1 ) >= 5
55
+ wordpress_name = get_wordpress_name
56
+ available = wordpress_url_availability wordpress_name
57
+ return available if available
47
58
  end
48
59
 
49
60
  # get supported virtual machine type by app42paas
@@ -79,6 +90,14 @@ module App42
79
90
  valid_app_name ? (return valid_app_name) : get_app_name
80
91
  end
81
92
 
93
+ # Ask wordpress name from user and
94
+ # will wait for user response (user will enter wordpress name)
95
+ def get_wordpress_name
96
+ wordpress_name = input "Enter Wordpress Name", [], true
97
+ valid_wordpress_name = validate_app_and_service_name "Wordpress name", wordpress_name.strip
98
+ valid_wordpress_name ? (return valid_wordpress_name) : get_wordpress_name
99
+ end
100
+
82
101
  # Ask setup name from user and
83
102
  # will wait for user response (user will enter setup name)
84
103
  def get_setup_name(prompt = Paint['Enter Setup Name', :cyan])
@@ -230,6 +249,25 @@ module App42
230
249
 
231
250
  end
232
251
 
252
+ # check wordpress name availabilities
253
+ def wordpress_url_availability wordpress_name
254
+ query_params = params
255
+ query_params.store('setupName', wordpress_name)
256
+
257
+ response = with_progress(Paint["Checking WordPress Name Availability", :yellow]) do |s|
258
+ build_get_request query_params, 'wordpress', 'availability'
259
+ end
260
+
261
+ if response["success"]
262
+ print_new_line
263
+ return wordpress_name
264
+ else
265
+ message "#{response['description']}", true, 'red'
266
+ get_wordpress_name_and_check_wordpress_url_availability
267
+ end
268
+
269
+ end
270
+
233
271
  # check service availabilities
234
272
  def service_name_availability service_name
235
273
  query_params = params
@@ -305,7 +343,7 @@ module App42
305
343
  query_params = params
306
344
  query_params.store('body', body)
307
345
 
308
- response = with_progress(Paint["Setting up the infrastructure", :yellow]) do |s|
346
+ response = with_progress(Paint["Setting up the BPaaS infrastructure", :yellow]) do |s|
309
347
  build_post_request body, query_params, 'setup', nil
310
348
  end
311
349
 
@@ -331,6 +369,46 @@ module App42
331
369
  end
332
370
  end
333
371
 
372
+ # setup wordpress
373
+ def create_wordpress_setup wordpress_name, iaas, vm_type, flavour
374
+ begin
375
+ body = {'app42' => {"request"=> {
376
+ "setupName" => wordpress_name,
377
+ "iaas" => iaas,
378
+ "vmType" => vm_type,
379
+ "setupType" => "setupWordPress",
380
+ "flavour" => flavour
381
+ }}}.to_json
382
+
383
+ query_params = params
384
+ query_params.store('body', body)
385
+
386
+ response = with_progress(Paint["Setting up the wordpress infrastructure", :yellow]) do |s|
387
+ build_post_request body, query_params, 'wordpress', nil
388
+ end
389
+
390
+ if response["success"] == true && response["transactionId"]
391
+ transaction_success = check_transaction_status_of_setup response["transactionId"], previous_completed = 0, 'created'
392
+ end
393
+
394
+ if transaction_success
395
+ transaction_params = params
396
+ transaction_params.store('setupName', wordpress_name)
397
+ host_response = build_get_request transaction_params, "setup", "#{wordpress_name}"
398
+ end
399
+
400
+ if host_response['success']
401
+ puts Paint["Your wordpress setup has been completed successfully, For details, Login to AppHQ console.", :green]
402
+ return true
403
+ else
404
+ puts Paint["#{response['description']}", :red]
405
+ end
406
+ rescue Interrupt
407
+ puts Paint[" Command cancelled.", :red]
408
+ exit!
409
+ end
410
+ end
411
+
334
412
  # upgrade setup cloud API, as a
335
413
  #
336
414
  # ==== Parameters
@@ -341,9 +419,9 @@ module App42
341
419
  # true:: if cloud setup upgraded
342
420
  # OR
343
421
  # ERROR message in case failed
344
- def upgrade_clouldapi setup_name, flavour
422
+ def upgrade_or_downgrade_clouldapi action, setup_name, flavour
345
423
  begin
346
- response = with_progress(Paint["Upgrading Setup", :yellow]) do |s|
424
+ response = with_progress(Paint[ action.to_s == "upgrade" ? "Upgrading Setup" : "Downgrading Setup", :yellow]) do |s|
347
425
  query_params = params
348
426
  body = {'app42' => {"request"=> {
349
427
  "setupName" => setup_name,
@@ -361,6 +439,38 @@ module App42
361
439
  rescue Exception => e
362
440
  puts e
363
441
  end
442
+ end
443
+
444
+ # upgrade Wordpress, as a
445
+ #
446
+ # ==== Parameters
447
+ # wordpress_name = wordpress_name provided by user
448
+ # flavour = flavour provided by user
449
+ #
450
+ # ==== return
451
+ # true:: if cloud setup upgraded
452
+ # OR
453
+ # ERROR message in case failed
454
+ def upgrade_or_downgrade_wordpress action, wordpress_name, flavour
455
+ begin
456
+ response = with_progress(Paint[ action.to_s == "upgrade" ? "Upgrading Wordpress" : "Downgrading Wordpress", :yellow]) do |s|
457
+ query_params = params
458
+ body = {'app42' => {"request"=> {
459
+ "setupName" => wordpress_name,
460
+ "flavour" => flavour
461
+ }}}.to_json
462
+
463
+ query_params.store('body', body)
464
+ build_put_request body, query_params, 'wordpress/upgrade', nil
465
+ end
466
+ transaction_success = check_transaction_status response["transactionId"], previous_completed = 0, 'deleted' if response["success"] == true && response["transactionId"]
467
+ response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
468
+ rescue Interrupt
469
+ puts Paint[" Command cancelled.", :red]
470
+ exit!
471
+ rescue Exception => e
472
+ puts e
473
+ end
364
474
  end
365
475
 
366
476
 
@@ -752,6 +862,34 @@ module App42
752
862
  end
753
863
  end
754
864
 
865
+ # delete wordpress setup, as a
866
+ #
867
+ # ==== Parameters
868
+ # wordpress_name = wordpress_name provided by user
869
+ #
870
+ # ==== return
871
+ # true:: if wordpress setup deleted
872
+ # OR
873
+ # ERROR message in case failed
874
+ def delete_wordpress wordpress_name
875
+ begin
876
+ response = with_progress(Paint["Deleting WordPress Setup", :yellow]) do |s|
877
+ query_params = params
878
+ query_params.store('setupName', wordpress_name)
879
+ build_delete_request query_params, "setup", "#{wordpress_name}"
880
+ end
881
+
882
+ transaction_success = check_transaction_status response["transactionId"], previous_completed = 0, 'deleted' if response["success"] == true && response["transactionId"]
883
+
884
+ response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
885
+ rescue Interrupt
886
+ puts Paint[" Command cancelled.", :red]
887
+ exit!
888
+ rescue Exception => e
889
+ puts e
890
+ end
891
+ end
892
+
755
893
  # All application operation will take placed like app start, stop etc.
756
894
  # expect +what+ as operation and +setup_name+ as BPaaS name.
757
895
  def clouldapi_operation what, setup_name
@@ -793,6 +931,47 @@ module App42
793
931
  end
794
932
  end
795
933
 
934
+ # All wordpress operation will take placed like app start, stop etc.
935
+ # expect +what+ as operation and +wordpress_name+ as wordpress name.
936
+ def wordpress_operation what, setup_name
937
+ begin
938
+ if what.to_s == 'stop'
939
+ response = with_progress(Paint[ "Stopping Wordpress Setup #{setup_name}", :yellow]) do |s|
940
+ body = {'app42' => {"request"=> {
941
+ "setupName" => setup_name
942
+ }}}.to_json
943
+
944
+ query_params = params
945
+ query_params.store('body', body)
946
+ build_put_request body, query_params, "setup", "#{what}" if what.to_s == 'stop'
947
+ end
948
+ else
949
+ response = with_progress(Paint["#{what.capitalize}ing Wordpress Setup #{setup_name}", :yellow]) do |s|
950
+ body = {'app42' => {"request"=> {
951
+ "setupName" => setup_name
952
+ }}}.to_json
953
+
954
+ query_params = params
955
+ query_params.store('body', body)
956
+ build_put_request body, query_params, "setup", "#{what}" if what.to_s == 'restart' || what.to_s == 'start'
957
+ end
958
+ end
959
+
960
+ if response["success"] == true && response["transactionId"]
961
+ if what.to_s == 'stop'
962
+ check_transaction_status response["transactionId"], previous_completed = 0, "#{what}ped"
963
+ else
964
+ check_transaction_status response["transactionId"], previous_completed = 0, "#{what}ed"
965
+ end
966
+ end
967
+
968
+ response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
969
+ rescue Interrupt
970
+ puts Paint[" Command cancelled.", :red]
971
+ exit!
972
+ end
973
+ end
974
+
796
975
  # reset service password and fetch service latest details
797
976
  #
798
977
  # ==== Parameters
@@ -79,6 +79,9 @@ module App42
79
79
  opts.on('--setup SETUP') { |setup| @options[:setup] = setup }
80
80
  opts.on('-s SETUP') { |setup| @options[:setup] = setup }
81
81
 
82
+ opts.on('--wordpress WORDPRESS') { |setup| @options[:wordpress] = wordpress }
83
+ opts.on('-wp WORDPRESSNAME') { |setup| @options[:wordpress] = wordpress }
84
+
82
85
  opts.on('-h', '--help') { puts "#{App42::Base::Help.usage(command)}\n"; exit! }
83
86
  end
84
87
  opts_parser.parse!(args)
@@ -247,7 +250,10 @@ module App42
247
250
  set_cmd(:setup, :stop)
248
251
 
249
252
  when 'upgradebpaas'
250
- set_cmd(:setup, :upgrade_cloud_api)
253
+ set_cmd(:setup, :upgrade)
254
+
255
+ when 'downgradebpaas'
256
+ set_cmd(:setup, :downgrade)
251
257
 
252
258
  when 'deletesetup'
253
259
  set_cmd(:setup, :delete_cloud_api)
@@ -256,7 +262,31 @@ module App42
256
262
  set_cmd(:setup, :info)
257
263
 
258
264
  when 'setups'
259
- set_cmd(:setup, :setups)
265
+ set_cmd(:setup, :setups)
266
+
267
+ when 'setupwordpress'
268
+ set_cmd(:wordpress, :setup)
269
+
270
+ when 'deletewordpress'
271
+ set_cmd(:wordpress, :delete)
272
+
273
+ when 'upgradewordpress'
274
+ set_cmd(:wordpress, :upgrade)
275
+
276
+ when 'downgradewordpress'
277
+ set_cmd(:wordpress, :downgrade)
278
+
279
+ when 'startwordpress'
280
+ set_cmd(:wordpress, :start)
281
+
282
+ when 'stopwordpress'
283
+ set_cmd(:wordpress, :stop)
284
+
285
+ when 'wordpresssetups'
286
+ set_cmd(:wordpress, :wordpresssetups)
287
+
288
+ when 'wordpressinfo'
289
+ set_cmd(:wordpress, :info)
260
290
 
261
291
  else
262
292
  puts Paint["app42: Unknown command [#{action}]", :red]
@@ -83,7 +83,9 @@ module App42::Command
83
83
 
84
84
  service = get_service
85
85
 
86
- database = ask_database_name
86
+ database = ask_database_name unless service == 'redis283'
87
+
88
+ database = '0' if service == 'redis283'
87
89
 
88
90
  vm_type = get_vm_types
89
91
 
@@ -39,11 +39,20 @@ module App42
39
39
  end
40
40
 
41
41
  # collect BPaaS setup name from user and proceed BPaaS upgrade request
42
- def upgrade_cloud_api
42
+ def upgrade
43
43
  @options[:setup] = get_setup_name if @options[:setup].nil?
44
44
  print_new_line
45
- flavour = get_flavour
46
- response = upgrade_clouldapi @options[:setup], flavour if is_setup_name_exist? @options[:setup]
45
+ flavour = get_flavour_upgrade @options[:setup]
46
+ response = upgrade_or_downgrade_clouldapi __method__, @options[:setup], flavour if is_setup_name_exist? @options[:setup]
47
+ exit! if response
48
+ end
49
+
50
+ # collect BPaaS setup name from user and proceed BPaaS downgrade request
51
+ def downgrade
52
+ @options[:setup] = get_setup_name if @options[:setup].nil?
53
+ print_new_line
54
+ flavour = get_flavour_downgrade @options[:setup]
55
+ response = upgrade_or_downgrade_clouldapi __method__, @options[:setup], flavour if is_setup_name_exist? @options[:setup]
47
56
  exit! if response
48
57
  end
49
58
 
@@ -58,7 +67,7 @@ module App42
58
67
 
59
68
  # return flavour
60
69
  def get_flavour
61
- flavour_hash = {}
70
+ flavour_hash = {}
62
71
  flavour_type = App42::Command::Config.new.get_flavour_type_fm_server
63
72
  flavour_type['flavours'].select {|each_flavour| flavour_hash["#{each_flavour['id']}"] = each_flavour['name']}
64
73
  flavour = input "Select Flavour", flavour_hash.values, true
@@ -0,0 +1,105 @@
1
+ require 'app42/command/base'
2
+ require 'terminal-table'
3
+
4
+ module App42
5
+ module Command
6
+ class Wordpress < Base
7
+
8
+ # Collect all required attributes for new wordpress setup spawn
9
+ # required inputs are wordpress_name, vm_type, iaas, setup_type and flavour
10
+ def setup
11
+ wordpress_name = get_wordpress_name_and_check_wordpress_url_availability
12
+ vm_type = get_vm_types
13
+ iaas = get_iaas_providers
14
+ flavour = get_flavour
15
+ setup_cloud_api_res = App42::Command::Base.new.create_wordpress_setup wordpress_name, iaas, vm_type, flavour
16
+ exit! if setup_cloud_api_res
17
+ end
18
+
19
+ # Delete wordpress setup, return true or error code/message
20
+ def delete
21
+ @options[:wordpress] = get_wordpress_name if @options[:wordpress].nil?
22
+ response = delete_wordpress @options[:wordpress] if is_setup_name_exist? @options[:wordpress]
23
+ exit! if response
24
+ end
25
+
26
+ # collect wordpress setup name from user and proceed wordpress start request
27
+ def start
28
+ @options[:wordpress] = get_wordpress_name if @options[:wordpress].nil?
29
+ response = wordpress_operation __method__, @options[:wordpress] if is_setup_name_exist? @options[:wordpress]
30
+ exit! if response
31
+ end
32
+
33
+ # collect wordpress setup name from user and proceed wordpress stop request
34
+ def stop
35
+ @options[:wordpress] = get_wordpress_name if @options[:wordpress].nil?
36
+ response = wordpress_operation __method__, @options[:wordpress] if is_setup_name_exist? @options[:wordpress]
37
+ exit! if response
38
+ end
39
+
40
+ # collect Wordpress setup name from user and proceed Wordpress upgrade request
41
+ def upgrade
42
+ @options[:wordpress] = get_wordpress_name if @options[:wordpress].nil?
43
+ flavour = get_flavour_upgrade @options[:wordpress]
44
+ response = upgrade_or_downgrade_wordpress __method__, @options[:wordpress], flavour if is_setup_name_exist? @options[:wordpress]
45
+ exit! if response
46
+ end
47
+
48
+ # collect Wordpress setup name from user and proceed Wordpress downgrade request
49
+ def downgrade
50
+ @options[:wordpress] = get_wordpress_name if @options[:wordpress].nil?
51
+ flavour = get_flavour_downgrade @options[:wordpress]
52
+ response = upgrade_or_downgrade_wordpress __method__, @options[:wordpress], flavour if is_setup_name_exist? @options[:wordpress]
53
+ exit! if response
54
+ end
55
+
56
+ # return flavour
57
+ def get_flavour
58
+ flavour_hash = {}
59
+ flavour_type = App42::Command::Config.new.get_flavour_type_fm_server
60
+ flavour_type['flavours'].select {|each_flavour| flavour_hash["#{each_flavour['id']}"] = each_flavour['name']}
61
+ flavour = input "Select Flavour", flavour_hash.values, true
62
+
63
+ flavour_id = nil
64
+ flavour_hash.each_pair{|fl| flavour_id = fl[0] if fl[1] == flavour}
65
+ return flavour_id
66
+ end
67
+
68
+ # get details information of App42 Wordpress setup
69
+ def info
70
+ @options[:wordpress] = get_wordpress_name if @options[:wordpress].nil?
71
+ query_params = params
72
+ query_params.store('setupName', @options[:wordpress])
73
+ setup_info = build_get_request query_params, 'setup', "#{@options[:wordpress]}"
74
+ rows, rows_header_final, rows_header = [], [], nil
75
+ if setup_info && setup_info['setupInfo']
76
+ rows_header = setup_info['setupInfo'].keys
77
+ rows << setup_info['setupInfo'].values
78
+
79
+ rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) }
80
+
81
+ table = Terminal::Table.new :title => Paint["=== #{@options[:wordpress]} Details ===", :green], :headings => rows_header_final, :rows => rows
82
+ puts table
83
+ end
84
+ end
85
+
86
+ # List all Wordpress setups
87
+ def wordpresssetups
88
+ query_params = params
89
+ setups = build_get_request query_params, 'wordpress', nil
90
+ rows, rows_header_final, rows_header = [], [], nil
91
+ if setups && setups['setups']
92
+ setups['setups'].each do |e|
93
+ rows_header = e.keys
94
+ rows << e.values
95
+ end
96
+
97
+ rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) }
98
+
99
+ table = Terminal::Table.new :title => Paint["=== Wordpress Setups List ===", :green], :headings => rows_header_final, :rows => rows
100
+ puts table
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
data/lib/app42/version.rb CHANGED
@@ -2,8 +2,8 @@ module App42
2
2
  module Version
3
3
  module VERSION
4
4
  MAJOR = 0
5
- MINOR = 5
6
- TINY = 10
5
+ MINOR = 6
6
+ TINY = 0
7
7
  PRE = "alpha"
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
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.10
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShepHertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-17 00:00:00.000000000 Z
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -213,6 +213,7 @@ files:
213
213
  - lib/app42/command/setup.rb
214
214
  - lib/app42/command/user.rb
215
215
  - lib/app42/command/user_key.rb
216
+ - lib/app42/command/wordpress.rb
216
217
  - lib/app42/version.rb
217
218
  - spec/app42/base/constants_spec.rb
218
219
  - spec/app42/command/app_spec.rb