Class: Berta::CommandExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/berta/command_executor.rb

Overview

Class for executing main berta commands

Instance Method Summary collapse

Instance Method Details

#cleanupObject

Function that performs clean up operation. Connects to opennebula database, runs expiration update process and notifies users about upcoming expirations.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/berta/command_executor.rb', line 8

def cleanup
  service = Berta::Service.new(Berta::Settings['opennebula']['secret'],
                               Berta::Settings['opennebula']['endpoint'])
  vms = service.running_vms
  users = service.users
  groups = service.groups
  vms.each(&:update)
  users.each { |user| user.notify(service.user_vms(user)) }
  groups.each { |group| group.notify(service.group_vms(group)) }
rescue Berta::Errors::BackendError => e
  logger.error e.message
end