class Shelly::CLI::Maintenance

Public Instance Methods

finish() click to toggle source
# File lib/shelly/cli/maintenance.rb, line 54
def finish
  app = multiple_clouds(options[:cloud], 'finish')
  app.finish_maintenance
  say "Maintenance has been finished", :green
rescue Client::ValidationException => exception
  exception.each_error { |error| say_error error, :with_exit => false }
rescue Client::ConflictException => e
  say_error e[:message]
end
list() click to toggle source
# File lib/shelly/cli/maintenance.rb, line 15
def list
  app = multiple_clouds(options[:cloud], 'maintenance list')
  maintenances = app.maintenances

  if maintenances.any?
    say 'Recent application maintenance events', :green
    say_new_line

    maintenances.each do |maintenance|
      started_at = Time.parse(maintenance['created_at']).getlocal.
        strftime('%Y-%m-%d %H:%M:%S')
      finished_at = if maintenance['finished']
        Time.parse(maintenance['updated_at']).getlocal.
          strftime('%Y-%m-%d %H:%M:%S')
      else
        'in progress'
      end

      say " * #{started_at} - #{finished_at}"
      say "   #{maintenance['description']}"
      say_new_line
    end
  else
    say "There are no maintenance events for #{app}"
  end
end
start(description = nil) click to toggle source
# File lib/shelly/cli/maintenance.rb, line 43
def start(description = nil)
  app = multiple_clouds(options[:cloud], 'start')
  app.start_maintenance({:description => description})
  say "Maintenance has been started", :green
rescue Client::ValidationException => exception
  exception.each_error { |error| say_error error, :with_exit => false }
rescue Client::ConflictException => e
  say_error e[:message]
end