berta 2.0.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f303b270d4d0dd7c702ed6aef25ce65d0819be0b
4
- data.tar.gz: e1ea28fdb1e5be5a1435b51b574eb76f6fca1d3e
3
+ metadata.gz: 82c2cf0ec358add6bb0761c552826a77786f56e9
4
+ data.tar.gz: c1361678b6f0207229a8c02683313c753bf2a467
5
5
  SHA512:
6
- metadata.gz: '09648726d9344859d11820f357cb99393d65ba33a2dd1120198417b73d9f8a45199df01fe26288e5f6a5e1baceeae525eace70cf4f801b6ee13ea0e159fe005e'
7
- data.tar.gz: fd7ba4a8c48194ef9768f7522d3d8be46d664ec88e74c0acd45d2e70af472a363ba9a466de07b9be4209951621364fd6963a3e15fc965ee9907e73c487b08696
6
+ metadata.gz: 823f3e32829e096a4ac82f0a2a1de3da87759aae0133cb9639c1d9ffbae2f6cf1d61a8e8a8229efdc507dd7a7f31282b9d463b4d076f3c4ae7af21d8c5084845
7
+ data.tar.gz: 41fc6aea27a9662444ba370aaf161ad756bc66fbaad307cb704b722f0ad21dea5a4443038e71dca3f634e3d3cdf0eb95af62d842e12cede84ed9e94f6b4de95a
@@ -19,3 +19,7 @@ berta:
19
19
  dry-run: false # Berta won't change anything on running instance of OpenNebula
20
20
  debug: false # Debug mode
21
21
  email-template: # Email template to use for notification
22
+ email-type: smtp # What delivery method to use
23
+ smtp:
24
+ address:
25
+ port:
@@ -64,6 +64,16 @@ module Berta
64
64
  required: true,
65
65
  default: safe_fetch(%w[email-template]),
66
66
  type: :string
67
+ class_option :'email-type',
68
+ required: true,
69
+ default: safe_fetch(%w[email-type]),
70
+ type: :string
71
+ class_option :'smtp-address',
72
+ default: safe_fetch(%w[smtp address]),
73
+ type: :string
74
+ class_option :'smtp-port',
75
+ default: safe_fetch(%w[smtp port]),
76
+ type: :numeric
67
77
 
68
78
  desc 'cleanup', 'Task that sets all expiration to all vms and notifies users'
69
79
  def cleanup
@@ -105,6 +115,9 @@ module Berta
105
115
  settings['logging']['file'] = options['logging-file']
106
116
  settings['logging']['level'] = options['logging-level']
107
117
  settings['email-template'] = options['email-template']
118
+ settings['email-type'] = options['email-type']
119
+ settings['smtp']['address'] = options['smtp-address']
120
+ settings['smtp']['port'] = options['smtp-port']
108
121
  Berta::Settings.merge!(settings)
109
122
  end
110
123
 
@@ -129,7 +142,10 @@ module Berta
129
142
  end
130
143
 
131
144
  def initialize_email
132
- Mail.defaults { delivery_method :sendmail }
145
+ email_type = Berta::Settings['email-type']
146
+ params = {}
147
+ params = Berta::Settings[email_type].each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if Berta::Settings[email_type]
148
+ Mail.defaults { delivery_method email_type.to_sym, params }
133
149
  end
134
150
  end
135
151
  end
@@ -20,7 +20,7 @@ module Berta
20
20
  text = template.render(Object.new, name: name, email: email, type: type, vms: vms_hash(vms))
21
21
  logger.info "Sending mail to entity: #{name} on email: #{email}"
22
22
  logger.debug { text }
23
- Mail.new(text).deliver unless Berta::Settings['dry-run']
23
+ Mail.deliver(text) unless Berta::Settings['dry-run']
24
24
  end
25
25
 
26
26
  def vms_hash(vms)
@@ -21,9 +21,7 @@ module Berta
21
21
  # @raise [Berta::Errors::OpenNebula::ResourceStateError]
22
22
  # @raise [Berta::Errors::OpenNebula::ResourceRetrievalError]
23
23
  def handle_error
24
- unless block_given?
25
- raise Berta::Errors::OpenNebula::StubError, 'OpenNebula service-wrapper was called without a block!'
26
- end
24
+ raise Berta::Errors::OpenNebula::StubError, 'OpenNebula service-wrapper was called without a block!' unless block_given?
27
25
  return_value = yield
28
26
  return return_value unless ::OpenNebula.is_error?(return_value)
29
27
  raise decode_error(return_value.errno), return_value.message
@@ -1,3 +1,3 @@
1
1
  module Berta
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berta
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dusan Baran
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-11-13 00:00:00.000000000 Z
13
+ date: 2018-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler