berta 1.6.0 → 1.6.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: a8df6d853b8b26247ece5370a887b57f983f8680
4
- data.tar.gz: 6c643a92a154fd50bbee3e2fd306db34273d89f3
3
+ metadata.gz: 4e3d5595d6f87b950bd563bf4131046970d8697d
4
+ data.tar.gz: f05ff671fa9187a3b6f18a366b312e893ea50fe2
5
5
  SHA512:
6
- metadata.gz: 5e09339128c099ccbbf4ea5145e9c5f9a870a02a41912f0088a5d3b27f6f4f8df3b4a27a7b3ec0b1d72c9124add90de81f28d5e8c8ee222876d27e8660636860
7
- data.tar.gz: fb69818b1b5e4781d8c28bd3fc441e5f5853252a77fc991e36ceb7180d0ab23056eb183cffdddc697518c348b6c859508f38dac4d9d0a53bc50225b6f15251c7
6
+ metadata.gz: 21df07bb8eb98444a58e5c30fe78e38805ea9816411f912a418439571bc556e620460701c27cd833f97f3a4f3c6df745433dcc24e2b99d1c58ac04010b310bf2
7
+ data.tar.gz: 8f66e09d3f8e66e5b3870fc7c528fd9fcd79db8c7ec6aef49ea59419f30a0e5cfc5e8891e7db6994187d5dcd271e7f188fbb06b03f56bc4ae8136f18e8b0a154
@@ -3,11 +3,14 @@ sudo: false
3
3
  language: ruby
4
4
  rvm:
5
5
  - ruby-head
6
- - 2.2.0
6
+ - 2.3.4
7
+ - 2.2.7
8
+ - 2.1.10
7
9
 
8
10
  matrix:
9
11
  allow_failures:
10
12
  - rvm: ruby-head
13
+ - rvm: 2.1.10
11
14
  fast_finish: true
12
15
 
13
16
  branches:
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.email = 'dbaran@hotmail.sk'
14
14
  s.homepage = 'https://github.com/dudoslav/berta'
15
15
  s.license = 'Apache License, Version 2.0'
16
+ s.required_ruby_version = '>= 2.1'
16
17
 
17
18
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
19
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -1,3 +1,3 @@
1
1
  module Berta
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.6.1'.freeze
3
3
  end
@@ -18,15 +18,12 @@ module Berta
18
18
  # invalid expiration it will be deleted. Other expirations
19
19
  # are kept.
20
20
  def update
21
- exps = expirations.keep_if(&:in_expiration_interval?)
22
- exps << next_expiration unless default_expiration
23
- if exps == expirations
24
- logger.debug "No changes in expirations for vm #{handle['ID']}"
25
- else
26
- update_expirations(exps)
27
- end
21
+ exps = remove_invalid(expirations)
22
+ exps = add_default_expiration(exps)
23
+ return if exps == expirations
24
+ update_expirations(exps)
28
25
  rescue Berta::Errors::BackendError => e
29
- logger.error "#{e.message} on vm with id #{vm.handle['ID']}"
26
+ logger.error "#{e.message} on vm with id #{handle['ID']}"
30
27
  end
31
28
 
32
29
  # Sets notified flag value in USER_TEMPLATE to default expiration
@@ -99,6 +96,25 @@ module Berta
99
96
 
100
97
  private
101
98
 
99
+ def remove_invalid(exps)
100
+ valid = exps.select(&:in_expiration_interval?)
101
+ if valid.length != exps.length
102
+ logger.info "Removing #{exps.length - valid.length} invalid expirations on vm with" \
103
+ "id=#{handle['ID']} usr=#{handle['UNAME']} grp=#{handle['GNAME']}"
104
+ end
105
+ valid
106
+ end
107
+
108
+ def add_default_expiration(exps)
109
+ unless default_expiration
110
+ new_default = next_expiration
111
+ exps << new_default
112
+ logger.info "Adding default expiration on vm with id=#{handle['ID']} usr=#{handle['UNAME']} grp=#{handle['GNAME']}"\
113
+ ", expires at #{Time.at(new_default.time)}"
114
+ end
115
+ exps
116
+ end
117
+
102
118
  # Sets array of expirations to vm, rewrites all old ones.
103
119
  # Receiving empty array wont change anything.
104
120
  #
@@ -107,7 +123,6 @@ module Berta
107
123
  def update_expirations(exps)
108
124
  template = exps.inject('') { |temp, exp| temp + exp.template }
109
125
  return if template == ''
110
- logger.info "Setting expirations on vm with id=#{handle['ID']} usr=#{handle['UNAME']} grp=#{handle['GNAME']}"
111
126
  logger.debug template.delete("\n ")
112
127
  send_update(template)
113
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dusan Baran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -296,7 +296,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - ">="
298
298
  - !ruby/object:Gem::Version
299
- version: '0'
299
+ version: '2.1'
300
300
  required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  requirements:
302
302
  - - ">="