lib/app42/command/base.rb in app42-0.6.3 vs lib/app42/command/base.rb in app42-0.6.4

- old
+ new

@@ -379,18 +379,19 @@ exit! end end # setup GPaaS - def create_gpaas_setup setup_name, iaas, vm_type, setup_type, flavour + def create_gpaas_setup setup_name, iaas, vm_type, setup_type, flavour, ans begin body = {'app42' => {"request"=> { "setupName" => setup_name, "iaas" => iaas, "vmType" => vm_type, "setupType" => 'setupGPaaS', - "flavour" => flavour + "flavour" => flavour, + "staticIP" => ans }}}.to_json query_params = params query_params.store('body', body) @@ -1121,9 +1122,75 @@ response['success'] ? (return true) : (message "#{response['description']}", true, 'red') rescue Interrupt puts Paint[" Command cancelled.", :red] exit! + end + end + + # Assign and Release static IP to App + # expect +what+ as operation and +app_name+ as App name. + def assign_release_static_ip what, app_name + begin + if what.to_s == 'assignstaticip' + response = with_progress(Paint[ "Assigning Static IP to App #{app_name}", :yellow]) do |s| + body = {'app42' => {"request"=> { + "appName" => app_name + }}}.to_json + + query_params = params + query_params.store('body', body) + build_put_request body, query_params, "app", "assignstaticip" + end + else + response = with_progress(Paint["Releasing Static IP from App #{app_name}", :yellow]) do |s| + body = {'app42' => {"request"=> { + "appName" => app_name + }}}.to_json + + query_params = params + query_params.store('body', body) + build_put_request body, query_params, "app", "releasestaticip" + end + end + + if response["success"] == true && response["transactionId"] + if what.to_s == 'assignstaticip' + check_transaction_status response["transactionId"], previous_completed = 0, "Assigned" + else + check_transaction_status response["transactionId"], previous_completed = 0, "Released" + end + end + + response['success'] ? (return true) : (message "#{response['description']}", true, 'red') + rescue Interrupt + puts Paint[" Command cancelled.", :red] + exit! + end + end + + # Udate GPaaS Dashboard + # expect +setup_name+ as GPaaS name. + def update_gpaas_dashboard setup_name + begin + response = with_progress(Paint["Upgrading GPaaS Setup", :yellow]) do |s| + body = {'app42' => {"request"=> { + "setupName" => setup_name + }}}.to_json + + query_params = params + query_params.store('body', body) + build_put_request body, query_params, "gpaas", "update/dashboard" + end + + transaction_success = check_transaction_status response["transactionId"], previous_completed = 0, 'upgraded' 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 # All wordpress operation will take placed like app start, stop etc. # expect +what+ as operation and +wordpress_name+ as wordpress name. \ No newline at end of file