opennebula 4.4.0 → 4.5.80.beta
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/NOTICE +1 -1
- data/lib/opennebula.rb +4 -2
- data/lib/opennebula/acl.rb +36 -8
- data/lib/opennebula/acl_pool.rb +1 -1
- data/lib/opennebula/client.rb +52 -4
- data/lib/opennebula/cluster.rb +1 -1
- data/lib/opennebula/cluster_pool.rb +1 -1
- data/lib/opennebula/datastore.rb +1 -1
- data/lib/opennebula/datastore_pool.rb +1 -1
- data/lib/opennebula/document.rb +1 -1
- data/lib/opennebula/document_json.rb +1 -1
- data/lib/opennebula/document_pool.rb +1 -1
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +1 -1
- data/lib/opennebula/group.rb +227 -43
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/host.rb +1 -1
- data/lib/opennebula/host_pool.rb +1 -1
- data/lib/opennebula/image.rb +1 -1
- data/lib/opennebula/image_pool.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +1 -1
- data/lib/opennebula/pool.rb +57 -1
- data/lib/opennebula/pool_element.rb +1 -1
- data/lib/opennebula/server_cipher_auth.rb +1 -1
- data/lib/opennebula/server_x509_auth.rb +1 -1
- data/lib/opennebula/ssh_auth.rb +1 -1
- data/lib/opennebula/system.rb +1 -1
- data/lib/opennebula/template.rb +1 -1
- data/lib/opennebula/template_pool.rb +1 -1
- data/lib/opennebula/user.rb +10 -3
- data/lib/opennebula/user_pool.rb +1 -1
- data/lib/opennebula/virtual_machine.rb +1 -1
- data/lib/opennebula/virtual_machine_pool.rb +1 -1
- data/lib/opennebula/virtual_network.rb +1 -1
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/x509_auth.rb +1 -1
- data/lib/opennebula/xml_element.rb +1 -1
- data/lib/opennebula/xml_pool.rb +2 -1
- data/lib/opennebula/xml_utils.rb +104 -1
- data/lib/opennebula/zone.rb +107 -0
- data/lib/opennebula/zone_pool.rb +58 -0
- metadata +21 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5feec17aea93ff26ef9c4ca5d190709ba5b12c3b
|
4
|
+
data.tar.gz: 218fa42198d3b3165ec54bd43fa20028402c8b7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed7c74a0a4e33a5f23075db69be3d5d8c947f24b1257389ffd8f388fd4463c78f80bdb9dd9d921668a3b02a3647ae8074103b74a6f35553617dbfeffdc3f05a
|
7
|
+
data.tar.gz: 11736f325b3b49d35916d0a000a2519de8ea1b925720897914890bd0d9b8d35812bf7634d35b1e6333017106585e00f5ad59526fbb48fafeb4b7ee0e101c03f8
|
data/NOTICE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
OpenNebula Open Source Project
|
2
2
|
--------------------------------------------------------------------------------
|
3
|
-
Copyright 2002-
|
3
|
+
Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs
|
4
4
|
--------------------------------------------------------------------------------
|
5
5
|
|
6
6
|
You can find more information about the project, release notes and
|
data/lib/opennebula.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -49,10 +49,12 @@ require 'opennebula/cluster'
|
|
49
49
|
require 'opennebula/cluster_pool'
|
50
50
|
require 'opennebula/document'
|
51
51
|
require 'opennebula/document_pool'
|
52
|
+
require 'opennebula/zone'
|
53
|
+
require 'opennebula/zone_pool'
|
52
54
|
require 'opennebula/system'
|
53
55
|
|
54
56
|
module OpenNebula
|
55
57
|
|
56
58
|
# OpenNebula version
|
57
|
-
VERSION = '4.
|
59
|
+
VERSION = '4.5.80'
|
58
60
|
end
|
data/lib/opennebula/acl.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -56,7 +56,8 @@ module OpenNebula
|
|
56
56
|
"GROUP" => 0x40000000000,
|
57
57
|
"DATASTORE" => 0x100000000000,
|
58
58
|
"CLUSTER" => 0x200000000000,
|
59
|
-
"DOCUMENT" => 0x400000000000
|
59
|
+
"DOCUMENT" => 0x400000000000,
|
60
|
+
"ZONE" => 0x800000000000
|
60
61
|
}
|
61
62
|
|
62
63
|
RIGHTS =
|
@@ -99,14 +100,24 @@ module OpenNebula
|
|
99
100
|
# A string containing a hex number, e.g. 0x2100000001
|
100
101
|
# @param rights [String]
|
101
102
|
# A string containing a hex number, e.g. 0x10
|
103
|
+
# @param zone [String]
|
104
|
+
# A string containing a hex number, e.g. 0x100000001
|
102
105
|
#
|
103
106
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
104
107
|
# otherwise
|
105
|
-
def allocate(user, resource, rights)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
def allocate(user, resource, rights, zone=nil)
|
109
|
+
if !zone.nil?
|
110
|
+
return super( AclPool::ACL_POOL_METHODS[:addrule],
|
111
|
+
user,
|
112
|
+
resource,
|
113
|
+
rights,
|
114
|
+
zone )
|
115
|
+
else
|
116
|
+
return super( AclPool::ACL_POOL_METHODS[:addrule],
|
117
|
+
user,
|
118
|
+
resource,
|
119
|
+
rights)
|
120
|
+
end
|
110
121
|
end
|
111
122
|
|
112
123
|
# Deletes the Acl rule
|
@@ -138,7 +149,7 @@ module OpenNebula
|
|
138
149
|
|
139
150
|
rule_str = rule_str.split(" ")
|
140
151
|
|
141
|
-
if rule_str.length != 3
|
152
|
+
if rule_str.length != 3 && rule_str.length != 4
|
142
153
|
return OpenNebula::Error.new(
|
143
154
|
"String needs three components: User, Resource, Rights")
|
144
155
|
end
|
@@ -147,6 +158,10 @@ module OpenNebula
|
|
147
158
|
ret << parse_resources(rule_str[1])
|
148
159
|
ret << parse_rights(rule_str[2])
|
149
160
|
|
161
|
+
if rule_str.length > 3
|
162
|
+
ret << parse_zone(rule_str[3])
|
163
|
+
end
|
164
|
+
|
150
165
|
errors=ret.map do |arg|
|
151
166
|
if OpenNebula.is_error?(arg)
|
152
167
|
arg.message
|
@@ -230,6 +245,19 @@ private
|
|
230
245
|
end
|
231
246
|
end
|
232
247
|
|
248
|
+
# Converts a string in the form [#<id>, *] to a hex. number
|
249
|
+
#
|
250
|
+
# @param zone [String] Zone component string
|
251
|
+
#
|
252
|
+
# @return [String] A string containing a hex number
|
253
|
+
def self.parse_zone(zone)
|
254
|
+
begin
|
255
|
+
return calculate_ids(zone).to_i.to_s(16)
|
256
|
+
rescue Exception => e
|
257
|
+
return OpenNebula::Error.new(e.message)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
233
261
|
# Calculates the numeric value for a String containing an individual
|
234
262
|
# (#<id>), group (@<id>) or all (*) ID component
|
235
263
|
#
|
data/lib/opennebula/acl_pool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/client.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -15,9 +15,34 @@
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
17
|
require 'xmlrpc/client'
|
18
|
+
require 'bigdecimal'
|
19
|
+
require 'stringio'
|
20
|
+
|
18
21
|
|
19
22
|
module OpenNebula
|
20
|
-
|
23
|
+
attr_accessor :pool_page_size
|
24
|
+
|
25
|
+
if OpenNebula::OX
|
26
|
+
class OxStreamParser < XMLRPC::XMLParser::AbstractStreamParser
|
27
|
+
def initialize
|
28
|
+
@parser_class = OxParser
|
29
|
+
end
|
30
|
+
|
31
|
+
class OxParser < Ox::Sax
|
32
|
+
include XMLRPC::XMLParser::StreamParserMixin
|
33
|
+
|
34
|
+
alias :text :character
|
35
|
+
alias :end_element :endElement
|
36
|
+
alias :start_element :startElement
|
37
|
+
|
38
|
+
def parse(str)
|
39
|
+
Ox.sax_parse(self, StringIO.new(str),
|
40
|
+
:symbolize => false,
|
41
|
+
:convert_special => true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
elsif OpenNebula::NOKOGIRI
|
21
46
|
class NokogiriStreamParser < XMLRPC::XMLParser::AbstractStreamParser
|
22
47
|
def initialize
|
23
48
|
@parser_class = NokogiriParser
|
@@ -39,10 +64,24 @@ module OpenNebula
|
|
39
64
|
end
|
40
65
|
end
|
41
66
|
|
67
|
+
DEFAULT_POOL_PAGE_SIZE = 2000
|
68
|
+
|
69
|
+
if size=ENV['ONE_POOL_PAGE_SIZE']
|
70
|
+
if size.strip.match(/^\d+$/) && size.to_i >= 2
|
71
|
+
@pool_page_size = size.to_i
|
72
|
+
else
|
73
|
+
@pool_page_size = nil
|
74
|
+
end
|
75
|
+
else
|
76
|
+
@pool_page_size = DEFAULT_POOL_PAGE_SIZE
|
77
|
+
end
|
78
|
+
|
79
|
+
|
42
80
|
# The client class, represents the connection with the core and handles the
|
43
81
|
# xml-rpc calls.
|
44
82
|
class Client
|
45
83
|
attr_accessor :one_auth
|
84
|
+
attr_reader :one_endpoint
|
46
85
|
|
47
86
|
begin
|
48
87
|
require 'xmlparser'
|
@@ -62,6 +101,8 @@ module OpenNebula
|
|
62
101
|
# @param [Hash] options
|
63
102
|
# @option params [Integer] :timeout connection timeout in seconds,
|
64
103
|
# defaults to 30
|
104
|
+
# @option params [String] :http_proxy HTTP proxy string used for
|
105
|
+
# connecting to the endpoint; defaults to no proxy
|
65
106
|
#
|
66
107
|
# @return [OpenNebula::Client]
|
67
108
|
def initialize(secret=nil, endpoint=nil, options={})
|
@@ -82,6 +123,8 @@ module OpenNebula
|
|
82
123
|
@one_endpoint = endpoint
|
83
124
|
elsif ENV["ONE_XMLRPC"]
|
84
125
|
@one_endpoint = ENV["ONE_XMLRPC"]
|
126
|
+
elsif File.exists?(ENV['HOME']+"/.one/one_endpoint")
|
127
|
+
@one_endpoint = File.read(ENV['HOME']+"/.one/one_endpoint")
|
85
128
|
else
|
86
129
|
@one_endpoint = "http://localhost:2633/RPC2"
|
87
130
|
end
|
@@ -89,9 +132,14 @@ module OpenNebula
|
|
89
132
|
timeout=nil
|
90
133
|
timeout=options[:timeout] if options[:timeout]
|
91
134
|
|
92
|
-
|
135
|
+
http_proxy=nil
|
136
|
+
http_proxy=options[:http_proxy] if options[:http_proxy]
|
137
|
+
|
138
|
+
@server = XMLRPC::Client.new2(@one_endpoint, http_proxy, timeout)
|
93
139
|
|
94
|
-
if
|
140
|
+
if defined?(OxStreamParser)
|
141
|
+
@server.set_parser(OxStreamParser.new)
|
142
|
+
elsif OpenNebula::NOKOGIRI
|
95
143
|
@server.set_parser(NokogiriStreamParser.new)
|
96
144
|
elsif XMLPARSER
|
97
145
|
@server.set_parser(XMLRPC::XMLParser::XMLStreamParser.new)
|
data/lib/opennebula/cluster.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/datastore.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/document.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/error.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/group.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -24,21 +24,25 @@ module OpenNebula
|
|
24
24
|
#######################################################################
|
25
25
|
|
26
26
|
GROUP_METHODS = {
|
27
|
-
:info
|
28
|
-
:allocate
|
29
|
-
:
|
30
|
-
:
|
27
|
+
:info => "group.info",
|
28
|
+
:allocate => "group.allocate",
|
29
|
+
:update => "group.update",
|
30
|
+
:delete => "group.delete",
|
31
|
+
:quota => "group.quota",
|
32
|
+
:add_provider => "group.addprovider",
|
33
|
+
:del_provider => "group.delprovider"
|
31
34
|
}
|
32
35
|
|
33
36
|
# Flag for requesting connected user's group info
|
34
37
|
SELF = -1
|
35
38
|
|
36
|
-
#Default
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
# Default resource ACL's for group users (create)
|
40
|
+
GROUP_DEFAULT_ACLS = "VM+IMAGE+NET+TEMPLATE+DOCUMENT"
|
41
|
+
ALL_CLUSTERS_IN_ZONE = 10
|
42
|
+
|
43
|
+
# The default view for group and group admins, must be defined in
|
44
|
+
# sunstone_views.yaml
|
45
|
+
GROUP_ADMIN_SUNSTONE_VIEWS = "vdcadmin"
|
42
46
|
|
43
47
|
# Creates a Group description with just its identifier
|
44
48
|
# this method should be used to create plain Group objects.
|
@@ -62,53 +66,82 @@ module OpenNebula
|
|
62
66
|
super(xml,client)
|
63
67
|
end
|
64
68
|
|
69
|
+
|
65
70
|
#######################################################################
|
66
|
-
# Group
|
71
|
+
# XML-RPC Methods for the Group Object
|
67
72
|
#######################################################################
|
68
73
|
|
69
|
-
#
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
+
# Retrieves the information of the given Group.
|
75
|
+
def info()
|
76
|
+
super(GROUP_METHODS[:info], 'GROUP')
|
77
|
+
end
|
74
78
|
|
75
|
-
|
79
|
+
alias_method :info!, :info
|
76
80
|
|
77
|
-
|
78
|
-
|
81
|
+
# Creates a group based in a group definition hash
|
82
|
+
# group_hash[:name]
|
83
|
+
# group_hash[:admin_group]
|
84
|
+
# group_hash[:user][:name]
|
85
|
+
# group_hash[:user][:password]
|
86
|
+
# group_hash[:resource_providers]
|
87
|
+
# group_hash[:resource_providers][:zone_id]
|
88
|
+
# group_hash[:resource_providers][:cluster_id]
|
89
|
+
#
|
90
|
+
def create(group_hash)
|
91
|
+
# Check arguments
|
92
|
+
return -1, "Group name not defined" if !group_hash[:name]
|
79
93
|
|
80
|
-
|
81
|
-
|
94
|
+
if group_hash[:user]
|
95
|
+
if group_hash[:user][:name] and !group_hash[:admin_group]
|
96
|
+
return -1, "Admin user defined but not admin group"
|
97
|
+
end
|
82
98
|
|
83
|
-
if
|
84
|
-
return -1, "
|
99
|
+
if group_hash[:user][:name] and !group_hash[:user][:password]
|
100
|
+
return -1, "Admin user password not defined"
|
85
101
|
end
|
102
|
+
end
|
86
103
|
|
87
|
-
|
88
|
-
|
104
|
+
# Allocate group
|
105
|
+
rc = self.allocate(group_hash[:name])
|
89
106
|
|
90
|
-
|
107
|
+
if OpenNebula.is_error?(rc)
|
108
|
+
return -1, "Error allocating group: #{rc.message}"
|
109
|
+
end
|
91
110
|
|
92
|
-
|
93
|
-
|
111
|
+
# Handle resource providers
|
112
|
+
group_hash[:resource_providers].each { |rp|
|
113
|
+
next if rp[:zone_id].nil? && rp[:cluster_id].nil?
|
114
|
+
|
115
|
+
if rp[:cluster_id].class == String && rp[:cluster_id] == "ALL"
|
116
|
+
add_provider(rp[:zone_id],ALL_CLUSTERS_IN_ZONE)
|
94
117
|
else
|
95
|
-
|
118
|
+
add_provider(rp[:zone_id],rp[:cluster_id])
|
96
119
|
end
|
97
|
-
}
|
120
|
+
} if !group_hash[:resource_providers].nil?
|
98
121
|
|
99
|
-
|
100
|
-
|
122
|
+
# Set group ACLs to create resources
|
123
|
+
rc, msg = create_default_acls(group_hash[:resources])
|
101
124
|
|
102
|
-
|
103
|
-
|
104
|
-
|
125
|
+
if OpenNebula.is_error?(rc)
|
126
|
+
self.delete
|
127
|
+
return -1, "Error creating group ACL's: #{rc.message}"
|
128
|
+
end
|
105
129
|
|
106
|
-
|
107
|
-
|
108
|
-
super(GROUP_METHODS[:info], 'GROUP')
|
109
|
-
end
|
130
|
+
# Create associated admin group if needed
|
131
|
+
rc = create_group_admin(group_hash)
|
110
132
|
|
111
|
-
|
133
|
+
if OpenNebula.is_error?(rc)
|
134
|
+
self.delete
|
135
|
+
return -1, "Error creating admin group: #{rc.message}"
|
136
|
+
end
|
137
|
+
|
138
|
+
# Add default Sunstone views for the group
|
139
|
+
if group_hash[:views]
|
140
|
+
self.update("SUNSTONE_VIEWS=\"#{group_hash[:views].join(",")}\"\n")
|
141
|
+
end
|
142
|
+
|
143
|
+
return 0, ""
|
144
|
+
end
|
112
145
|
|
113
146
|
# Allocates a new Group in OpenNebula
|
114
147
|
#
|
@@ -117,14 +150,26 @@ module OpenNebula
|
|
117
150
|
super(GROUP_METHODS[:allocate], groupname)
|
118
151
|
end
|
119
152
|
|
153
|
+
# Replaces the template contents
|
154
|
+
#
|
155
|
+
# @param new_template [String] New template contents
|
156
|
+
# @param append [true, false] True to append new attributes instead of
|
157
|
+
# replace the whole template
|
158
|
+
#
|
159
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
160
|
+
# otherwise
|
161
|
+
def update(new_template=nil, append=false)
|
162
|
+
super(GROUP_METHODS[:update], new_template, append ? 1 : 0)
|
163
|
+
end
|
164
|
+
|
120
165
|
# Deletes the Group
|
121
166
|
def delete()
|
122
167
|
super(GROUP_METHODS[:delete])
|
123
168
|
end
|
124
169
|
|
125
170
|
# Sets the group quota limits
|
126
|
-
# @param quota [String] a template (XML or txt) with the new quota limits
|
127
|
-
#
|
171
|
+
# @param quota [String] a template (XML or txt) with the new quota limits
|
172
|
+
#
|
128
173
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
129
174
|
# otherwise
|
130
175
|
def set_quota(quota)
|
@@ -136,6 +181,26 @@ module OpenNebula
|
|
136
181
|
return rc
|
137
182
|
end
|
138
183
|
|
184
|
+
# Adds a resource provider to this group
|
185
|
+
# @param zone_id [Integer] Zone ID
|
186
|
+
# @param cluster_id [Integer] Cluster ID
|
187
|
+
#
|
188
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
189
|
+
# otherwise
|
190
|
+
def add_provider(zone_id, cluster_id)
|
191
|
+
return call(GROUP_METHODS[:add_provider], @pe_id, zone_id.to_i, cluster_id.to_i)
|
192
|
+
end
|
193
|
+
|
194
|
+
# Deletes a resource provider from this group
|
195
|
+
# @param zone_id [Integer] Zone ID
|
196
|
+
# @param cluster_id [Integer] Cluster ID
|
197
|
+
#
|
198
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
199
|
+
# otherwise
|
200
|
+
def del_provider(zone_id, cluster_id)
|
201
|
+
return call(GROUP_METHODS[:del_provider], @pe_id, zone_id.to_i, cluster_id.to_i)
|
202
|
+
end
|
203
|
+
|
139
204
|
# ---------------------------------------------------------------------
|
140
205
|
# Helpers to get information
|
141
206
|
# ---------------------------------------------------------------------
|
@@ -159,5 +224,124 @@ module OpenNebula
|
|
159
224
|
|
160
225
|
return array
|
161
226
|
end
|
227
|
+
|
228
|
+
private
|
229
|
+
#######################################################################
|
230
|
+
#######################################################################
|
231
|
+
# Creates an acl array of acl strings. Returns true or error and
|
232
|
+
# a qrray with the new acl ids
|
233
|
+
def create_group_acls(acls)
|
234
|
+
acls_ids = Array.new
|
235
|
+
|
236
|
+
acls.each{|rule|
|
237
|
+
|
238
|
+
acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,@client)
|
239
|
+
|
240
|
+
rule_ast = "#{rule} *" #Add all zone id's
|
241
|
+
|
242
|
+
parsed_acl = OpenNebula::Acl.parse_rule(rule_ast)
|
243
|
+
|
244
|
+
return parsed_acl, [] if OpenNebula.is_error?(parsed_acl)
|
245
|
+
|
246
|
+
rc = acl.allocate(*parsed_acl)
|
247
|
+
|
248
|
+
return rc, "" if OpenNebula.is_error?(rc)
|
249
|
+
|
250
|
+
acls_ids << acl.id
|
251
|
+
}
|
252
|
+
|
253
|
+
return true, acls_ids
|
254
|
+
end
|
255
|
+
|
256
|
+
def create_default_acls(resources=nil)
|
257
|
+
resources = GROUP_DEFAULT_ACLS if !resources
|
258
|
+
|
259
|
+
acls = Array.new
|
260
|
+
acls << "@#{self.id} #{resources}/* CREATE"
|
261
|
+
|
262
|
+
create_group_acls(acls)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Creates a group admin and user based on the group definition hash
|
266
|
+
# @param gdef [Hash] keys are ruby sumbols
|
267
|
+
# gdef[:admin_group] the group name
|
268
|
+
# gdef[:user][:name] of admin user for the admin group
|
269
|
+
# gdef[:user][:password] of admin user
|
270
|
+
# gdef[:user][:auth_driver] of the admin user
|
271
|
+
# gdef[:admin_resources]
|
272
|
+
# gdef[:resources]
|
273
|
+
#
|
274
|
+
#
|
275
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
276
|
+
def create_group_admin(gdef)
|
277
|
+
|
278
|
+
return nil if gdef[:admin_group].nil?
|
279
|
+
|
280
|
+
# Create the admin group
|
281
|
+
gadmin = Group.new(Group.build_xml, @client)
|
282
|
+
rc = gadmin.allocate(gdef[:admin_group])
|
283
|
+
|
284
|
+
return rc if OpenNebula.is_error?(rc)
|
285
|
+
|
286
|
+
# Create group admin user
|
287
|
+
uadmin = gdef[:user][:name] if gdef[:user]
|
288
|
+
upasswd = gdef[:user][:password] if gdef[:user]
|
289
|
+
udriver = gdef[:user][:auth_driver] if gdef[:user]
|
290
|
+
|
291
|
+
if !uadmin.nil? && !upasswd.nil?
|
292
|
+
|
293
|
+
user = OpenNebula::User.new(OpenNebula::User.build_xml,
|
294
|
+
@client)
|
295
|
+
|
296
|
+
if udriver
|
297
|
+
rc = user.allocate(uadmin, upasswd, udriver)
|
298
|
+
else
|
299
|
+
rc = user.allocate(uadmin, upasswd)
|
300
|
+
end
|
301
|
+
|
302
|
+
if OpenNebula.is_error?(rc)
|
303
|
+
gadmin.delete
|
304
|
+
return rc
|
305
|
+
end
|
306
|
+
|
307
|
+
# Set admin user groups to admin group and self
|
308
|
+
rc = user.chgrp(self.id)
|
309
|
+
rc = user.addgroup(gadmin.id) if !OpenNebula.is_error?(rc)
|
310
|
+
|
311
|
+
if OpenNebula.is_error?(rc)
|
312
|
+
user.delete
|
313
|
+
gadmin.delete
|
314
|
+
return rc
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
#Create admin group acls
|
319
|
+
acls = Array.new
|
320
|
+
|
321
|
+
acls_str = gdef[:admin_resources] || gdef[:resources] || GROUP_DEFAULT_ACLS
|
322
|
+
|
323
|
+
manage_users = gdef[:admin_manage_users] || "YES"
|
324
|
+
|
325
|
+
if manage_users.upcase == "YES"
|
326
|
+
acls << "@#{gadmin.id} USER/* CREATE"
|
327
|
+
acls << "@#{gadmin.id} USER/@#{self.id} USE+MANAGE+ADMIN"
|
328
|
+
end
|
329
|
+
|
330
|
+
acls << "@#{gadmin.id} #{acls_str}/@#{self.id} CREATE+USE+MANAGE"
|
331
|
+
|
332
|
+
rc, tmp = create_group_acls(acls)
|
333
|
+
|
334
|
+
if OpenNebula.is_error?(rc)
|
335
|
+
user.delete
|
336
|
+
gadmin.delete
|
337
|
+
return rc
|
338
|
+
end
|
339
|
+
|
340
|
+
#Set Sunstone Views for the group
|
341
|
+
gadmin.update("SUNSTONE_VIEWS=#{GROUP_ADMIN_SUNSTONE_VIEWS}\n")
|
342
|
+
|
343
|
+
return nil
|
344
|
+
end
|
162
345
|
end
|
163
346
|
end
|
347
|
+
|