lib/app42/command/base.rb in app42-0.5.9 vs lib/app42/command/base.rb in app42-0.5.10
- old
+ new
@@ -327,10 +327,42 @@
end
rescue Interrupt
puts Paint[" Command cancelled.", :red]
exit!
end
+ end
+
+ # upgrade setup cloud API, as a
+ #
+ # ==== Parameters
+ # setup_name = setup_name provided by user
+ # flavour = flavour provided by user
+ #
+ # ==== return
+ # true:: if cloud setup upgraded
+ # OR
+ # ERROR message in case failed
+ def upgrade_clouldapi setup_name, flavour
+ begin
+ response = with_progress(Paint["Upgrading Setup", :yellow]) do |s|
+ query_params = params
+ body = {'app42' => {"request"=> {
+ "setupName" => setup_name,
+ "flavour" => flavour
+ }}}.to_json
+
+ query_params.store('body', body)
+ build_put_request body, query_params, 'setup/upgrade', nil
+ end
+ transaction_success = check_transaction_status response["transactionId"], previous_completed = 0, 'deleted' if response["success"] == true && response["transactionId"]
+ response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
+ rescue Interrupt
+ puts Paint[" Command cancelled.", :red]
+ exit!
+ rescue Exception => e
+ puts e
+ end
end
# Binary upload call
def upload_binary app_name, app_source, source_url
@@ -500,16 +532,40 @@
}}}.to_json
query_params = params
query_params.store('body', body)
- 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|
+ 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|
build_post_request body, query_params, "app", what
end
check_transaction_status response["transactionId"], previous_completed = 0, "#{what}d" if response["success"] == true && response["transactionId"]
response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
+ rescue Interrupt
+ puts Paint[" Command cancelled.", :red]
+ exit!
+ rescue Exception => e
+ puts e
+ exit!
+ end
+ end
+
+ # vertical scale or descale service by no of kontena,
+ # expect +what+ as operation and kontena as no of kontena
+ def vscale_or_vdescale_service what, kontena, service_name
+ begin
+ body = {'app42' => {"request"=> {
+ 'serviceName' => service_name,
+ "kontenaPower" => kontena.to_s
+ }}}.to_json
+ query_params = params
+ query_params.store('body', body)
+ response = with_progress( Paint[ what.to_s == 'vscale' ? "Scaling Service '#{service_name}' by kontena #{kontena}" : "Descaling Service '#{service_name}' by kontena #{kontena}", :yellow]) do |s|
+ build_post_request body, query_params, "service", what
+ end
+ check_transaction_status response["transactionId"], previous_completed = 0, "#{what}d" if response["success"] == true && response["transactionId"]
+ response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
rescue Interrupt
puts Paint[" Command cancelled.", :red]
exit!
rescue Exception => e
puts e
\ No newline at end of file