nifty 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/nifty.yml +1 -0
- data/lib/nifty/backends/opennebula.rb +4 -0
- data/lib/nifty/backends/utils/opennebula/image_handler.rb +6 -2
- data/lib/nifty/backends/utils/opennebula/template_handler.rb +3 -1
- data/lib/nifty/events/opennebula/utils/events_common.rb +9 -9
- data/lib/nifty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a37f362a5274415d81b8d55bf69284e1f34d88c0
|
4
|
+
data.tar.gz: b07d5c991ab1c91d8fae23d1295787983e776f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab2a37a5fe4643d3149263db7c9feac04c069b8ae8d615d2ff85cf47efff4b8d6daef1a58d20a7aa2d51860be78a1fa13f05588d45d37393c69ca68591fe27b1
|
7
|
+
data.tar.gz: c721a2292eec5c0148ea0967d77ebe23a2e5d513363cd1830abbc216bb344a96421c70c51bcde0225f8ea13094ccdc29807c29f984b54b59d04bd5bda5942b14
|
data/config/nifty.yml
CHANGED
@@ -18,6 +18,7 @@ production:
|
|
18
18
|
disk-expiration: true # Will expire old disks before the new one is registered
|
19
19
|
permissions: "640" # UNIX-like image and template permissions in OpenNebula, MUST be a string
|
20
20
|
groups: # Array of groups. If set, groups in appliance descriptor will be ignored and these groups will be used instead
|
21
|
+
users: # Handle only images/templates of specified users
|
21
22
|
logging:
|
22
23
|
level: ERROR # Logging level
|
23
24
|
file: /var/log/nifty/nifty.log # File to write log to. To turn off file logging leave this field empty.
|
@@ -71,6 +71,10 @@ class Nifty::Backends::Opennebula < Nifty::Backend
|
|
71
71
|
:groups => {
|
72
72
|
:type => :array,
|
73
73
|
:desc => 'Names of groups appliances will be registred to in OpenNebula'
|
74
|
+
},
|
75
|
+
:users => {
|
76
|
+
:type => :array,
|
77
|
+
:desc => 'Handle only images/templates of specified users'
|
74
78
|
}
|
75
79
|
}
|
76
80
|
end
|
@@ -28,9 +28,11 @@ class Nifty::Backends::Utils::Opennebula::ImageHandler < Nifty::Backends::Utils:
|
|
28
28
|
#
|
29
29
|
# @param [String] appliance_id
|
30
30
|
# @return [Array] array of images
|
31
|
-
def images(appliance_id)
|
31
|
+
def images(appliance_id, users = [])
|
32
32
|
reload!
|
33
33
|
|
34
|
+
return pool.find_all { |image| image["TEMPLATE/#{ATTRIBUTE_APPLIANCE_ID}"] == appliance_id && users.include?(image['UNAME']) } unless users.blank?
|
35
|
+
|
34
36
|
pool.find_all { |image| image["TEMPLATE/#{ATTRIBUTE_APPLIANCE_ID}"] == appliance_id }
|
35
37
|
end
|
36
38
|
|
@@ -49,9 +51,11 @@ class Nifty::Backends::Utils::Opennebula::ImageHandler < Nifty::Backends::Utils:
|
|
49
51
|
pool.find_all { |image| image["TEMPLATE/#{ATTRIBUTE_APPLIANCE_ID}"].nil? && image["TEMPLATE/#{Nifty::Backends::Opennebula::VMCATCHER_APPLIANCE_ID}"] }
|
50
52
|
end
|
51
53
|
|
52
|
-
def images_by_version(version)
|
54
|
+
def images_by_version(version, users = [])
|
53
55
|
reload!
|
54
56
|
|
57
|
+
return pool.find_all { |image| image["TEMPLATE/#{ATTRIBUTE_APPLIANCE_VERSION}"] == version && users.include?(image['UNAME']) } unless users.blank?
|
58
|
+
|
55
59
|
pool.find_all { |image| image["TEMPLATE/#{ATTRIBUTE_APPLIANCE_VERSION}"] == version }
|
56
60
|
end
|
57
61
|
|
@@ -20,9 +20,11 @@ class Nifty::Backends::Utils::Opennebula::TemplateHandler < Nifty::Backends::Uti
|
|
20
20
|
#
|
21
21
|
# @param [String] appliance_id
|
22
22
|
# @return [Array] array of templates
|
23
|
-
def templates(appliance_id)
|
23
|
+
def templates(appliance_id, users = [])
|
24
24
|
reload!
|
25
25
|
|
26
|
+
return pool.find_all { |template| template["TEMPLATE/#{ATTRIBUTE_APPLIANCE_ID}"] == appliance_id && users.include?(template['UNAME']) } unless users.blank?
|
27
|
+
|
26
28
|
pool.find_all { |template| template["TEMPLATE/#{ATTRIBUTE_APPLIANCE_ID}"] == appliance_id }
|
27
29
|
end
|
28
30
|
|
@@ -7,9 +7,9 @@ module Nifty::Events::Opennebula::Utils::EventsCommon
|
|
7
7
|
# @param [Cloud::Appliance::Descriptor::Appliance] appliance
|
8
8
|
# @param [Hash] parameters
|
9
9
|
def expire_appliance(template_handler, image_handler, appliance, parameters)
|
10
|
-
delete_appliance(template_handler, appliance.identifier)
|
11
|
-
outdate_disks(image_handler, appliance.identifier)
|
12
|
-
expire_disks(image_handler, appliance, parameters[:"disk-expiration"])
|
10
|
+
delete_appliance(template_handler, appliance.identifier, parameters[:users])
|
11
|
+
outdate_disks(image_handler, appliance.identifier, parameters[:users])
|
12
|
+
expire_disks(image_handler, appliance, parameters[:"disk-expiration"], parameters[:users])
|
13
13
|
end
|
14
14
|
|
15
15
|
# Returns OpenNebula groups specified in appliance
|
@@ -37,8 +37,8 @@ module Nifty::Events::Opennebula::Utils::EventsCommon
|
|
37
37
|
#
|
38
38
|
# @param [Nifty::Backends::Utils::Opennebula::ImageHandler] image_handler
|
39
39
|
# @param [String] appliance_id
|
40
|
-
def outdate_disks(image_handler, appliance_id)
|
41
|
-
registered_disks = image_handler.images(appliance_id)
|
40
|
+
def outdate_disks(image_handler, appliance_id, users)
|
41
|
+
registered_disks = image_handler.images(appliance_id, users)
|
42
42
|
logger.debug('Outdating registered disks...')
|
43
43
|
registered_disks.each { |disk| image_handler.outdate_image(disk) }
|
44
44
|
end
|
@@ -49,8 +49,8 @@ module Nifty::Events::Opennebula::Utils::EventsCommon
|
|
49
49
|
# @param [Nifty::Backends::Utils::Opennebula::ImageHandler] image_handler
|
50
50
|
# @param [Cloud::Appliance::Descriptor::Appliance] appliance
|
51
51
|
# @param [TrueClass,FalseClass] disk_expiration whether expire all disks or just outdated ones
|
52
|
-
def expire_disks(image_handler, appliance, disk_expiration)
|
53
|
-
registered_disks = disk_expiration ? image_handler.images(appliance.identifier) : image_handler.images_by_version(appliance.version)
|
52
|
+
def expire_disks(image_handler, appliance, disk_expiration, users)
|
53
|
+
registered_disks = disk_expiration ? image_handler.images(appliance.identifier, users) : image_handler.images_by_version(appliance.version, users)
|
54
54
|
logger.debug('Expiring registered disks...')
|
55
55
|
registered_disks.each do |disk|
|
56
56
|
image_handler.expire_image(disk)
|
@@ -63,8 +63,8 @@ module Nifty::Events::Opennebula::Utils::EventsCommon
|
|
63
63
|
#
|
64
64
|
# @param [Nifty::Backends::Utils::Opennebula::TemplateHandler] template_handler
|
65
65
|
# @param [String] appliance_id
|
66
|
-
def delete_appliance(template_handler, appliance_id)
|
67
|
-
registered_appliances = template_handler.templates(appliance_id)
|
66
|
+
def delete_appliance(template_handler, appliance_id, users)
|
67
|
+
registered_appliances = template_handler.templates(appliance_id, users)
|
68
68
|
logger.debug('Deleting registered templates...')
|
69
69
|
registered_appliances.each { |template| template_handler.delete_template template }
|
70
70
|
end
|
data/lib/nifty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Kimle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|