lib/app42/command/service.rb in app42-0.5.8 vs lib/app42/command/service.rb in app42-0.5.9
- old
+ new
@@ -21,10 +21,16 @@
def get_user_services#:nodoc:
build_get_request params, 'service', nil
end
+ def get_uploadbackup_path #:nodoc:
+ path = ask(Paint["\nEnter Backup File Path", :cyan])
+ valid_path = validate_upload_backup_path path.strip
+ valid_path ? (return valid_path) : get_uploadbackup_path
+ end
+
# ask service name to user
def ask_service_name
service_name = ask Paint["Enter Service Name", :cyan]
valid_service_name = validate_app_and_service_name "Service name", service_name.strip
valid_service_name ? (return valid_service_name) : ask_service_name
@@ -37,12 +43,13 @@
# ask source id to user which he want to bind to service
def ask_source_ip what
ip = input "#{Message::BIND_NOTE}", [], true if what.to_s == 'bind'
ip = input "#{Message::UNBIND_NOTE}", [], true if what.to_s == 'unbind'
- if ip_address_valid? ip
- return ip
+ ip_address = ip.strip
+ if ip_address_valid? ip_address
+ return ip_address
else
message "#{Message::IP_NOT_VALID}", true, 'red'
ask_source_ip what
end
end
@@ -113,9 +120,23 @@
# collect service name from user and proceed service stop request
def stop
@options[:service] = ask_service_name if @options[:service].nil?
response = service_operation __method__, @options[:service] if is_service_exist? @options[:service]
exit! if response
+ end
+
+ # read +app name+ and number of +instance+ from user
+ # then vertically descale app by no of instance
+ def uploadbackup
+ @options[:service] = ask_service_name if @options[:service].nil?
+ path = get_uploadbackup_path if is_service_exist? @options[:service]
+ restore = ask(
+ Paint["\nDo you also want to restore uploaded backup?", :cyan],
+ :default => true
+ )
+
+ status = upload_service_backup @options[:service], path, restore
+ return status
end
# collect service name from user and proceed service resetPassword request
def reset_pass
@options[:service] = ask_service_name if @options[:service].nil?
\ No newline at end of file