Class: Berta::CommandExecutor
- Inherits:
-
Object
- Object
- Berta::CommandExecutor
- Defined in:
- lib/berta/command_executor.rb
Overview
Class for executing main berta commands
Instance Method Summary collapse
-
#cleanup ⇒ Object
Function that performs clean up operation.
-
#initialize ⇒ CommandExecutor
constructor
A new instance of CommandExecutor.
Constructor Details
#initialize ⇒ CommandExecutor
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/berta/command_executor.rb', line 8 def initialize email_file = 'email.erb'.freeze email_template_path = "#{File.dirname(__FILE__)}/../../config/#{email_file}" email_template_path = "/etc/berta/#{email_file}" \ if File.exist?("/etc/berta/#{email_file}") email_template_path = "#{ENV['HOME']}/.berta/#{email_file}" \ if File.exist?("#{ENV['HOME']}/.berta/#{email_file}") @email_template = Tilt.new(email_template_path) Mail.defaults { delivery_method :sendmail } end |
Instance Method Details
#cleanup ⇒ Object
Function that performs clean up operation. Connects to opennebula database, runs expiration update process and notifies users about upcoming expirations.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/berta/command_executor.rb', line 23 def cleanup service = Berta::Service.new(Berta::Settings['opennebula']['secret'], Berta::Settings['opennebula']['endpoint']) vms = service.running_vms users = service.users vms.each(&:update) users.each { |user| user.notify(service.user_vms(user), @email_template) } rescue Berta::Errors::BackendError => e logger.error e. end |