berta 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/berta/user_handler.rb +6 -2
- data/lib/berta/version.rb +1 -1
- data/lib/berta/virtual_machine_handler.rb +15 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b7c4c208604f8f2f38e396c03dd8d0950626a9
|
4
|
+
data.tar.gz: 844a95982da959c7be4ba173095a7910c96e21cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fca088e770e144d0ad3027a54a36f4bf7b9e04a80aecc2533a7244a84ae03b88a4cfadc86fb635793a4463b5b5ef3437d6c6dee1b1d0fe53ea3b8a674a928fc
|
7
|
+
data.tar.gz: 63ea0386912c8a2ee7a6ba3d9d4fa5ea60521510f1614ab03a671c53547145f2bbb9d07f5b9c5268aea3e4a7e8f8a29f91474771df699205de53570f88ecc6de
|
data/lib/berta/user_handler.rb
CHANGED
@@ -22,7 +22,10 @@ module Berta
|
|
22
22
|
# @param email_template [Tilt::ERBTemplate] Email template
|
23
23
|
def notify(user_vms, email_template)
|
24
24
|
to_notify = user_vms.keep_if(&:should_notify?)
|
25
|
-
|
25
|
+
if to_notify.empty?
|
26
|
+
logger.debug "No notifications for user #{handle['NAME']}"
|
27
|
+
return
|
28
|
+
end
|
26
29
|
send_notification(to_notify, email_template)
|
27
30
|
user_vms.each(&:update_notified)
|
28
31
|
rescue ArgumentError, Berta::Errors::Entities::NoUserEmailError => e
|
@@ -35,7 +38,8 @@ module Berta
|
|
35
38
|
raise Berta::Errors::Entities::NoUserEmailError, "User: #{user_name} with id: #{handle['ID']} has no email set" \
|
36
39
|
unless user_email
|
37
40
|
email_text = email_template.render(Hash, user_email: user_email, user_name: user_name, vms: vms_data(user_vms))
|
38
|
-
logger.
|
41
|
+
logger.info "Sending mail to user: #{user_name} on email: #{user_email}"
|
42
|
+
logger.debug email_text
|
39
43
|
Mail.new(email_text).deliver unless Berta::Settings['dry-run']
|
40
44
|
end
|
41
45
|
|
data/lib/berta/version.rb
CHANGED
@@ -20,7 +20,11 @@ module Berta
|
|
20
20
|
def update
|
21
21
|
exps = expirations.keep_if(&:in_expiration_interval?)
|
22
22
|
exps << next_expiration unless default_expiration
|
23
|
-
|
23
|
+
if exps == expirations
|
24
|
+
logger.debug "No changes in expirations for vm #{handle['ID']}"
|
25
|
+
else
|
26
|
+
update_expirations(exps)
|
27
|
+
end
|
24
28
|
rescue Berta::Errors::BackendError => e
|
25
29
|
logger.error "#{e.message} on vm with id #{vm.handle['ID']}"
|
26
30
|
end
|
@@ -40,12 +44,8 @@ module Berta
|
|
40
44
|
exp = default_expiration
|
41
45
|
return unless exp
|
42
46
|
notify_time = exp.time
|
43
|
-
logger.
|
44
|
-
|
45
|
-
Berta::Utils::OpenNebula::Helper.handle_error do
|
46
|
-
handle.update("#{NOTIFIED_FLAG} = #{notify_time.to_i}", true)
|
47
|
-
handle.info
|
48
|
-
end
|
47
|
+
logger.info "Setting notified flag of VM with id #{handle['ID']} to #{notify_time}"
|
48
|
+
send_update("#{NOTIFIED_FLAG} = #{notify_time.to_i}")
|
49
49
|
end
|
50
50
|
|
51
51
|
# Determines if VM meets criteria to be notified.
|
@@ -105,11 +105,15 @@ module Berta
|
|
105
105
|
# @note This method modifies OpenNebula database
|
106
106
|
# @param exps [Array<Berta::Entities::Expiration>] Expirations to use
|
107
107
|
def update_expirations(exps)
|
108
|
-
template = ''
|
109
|
-
exps.each { |exp| template += exp.template }
|
108
|
+
template = exps.inject('') { |temp, exp| temp + exp.template }
|
110
109
|
return if template == ''
|
111
|
-
logger.
|
112
|
-
|
110
|
+
logger.info "Setting expirations on vm with id=#{handle['ID']} usr=#{handle['UNAME']} grp=#{handle['GNAME']}"
|
111
|
+
logger.debug template.delete("\n ")
|
112
|
+
send_update(template)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Sends data to opennebula service
|
116
|
+
def send_update(template)
|
113
117
|
return if Berta::Settings['dry-run']
|
114
118
|
Berta::Utils::OpenNebula::Helper.handle_error do
|
115
119
|
handle.update(template, true)
|