occi 2.0.0 → 2.0.1
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.
- data/.travis.yml +1 -0
- data/README.md +3 -37
- data/lib/occi/version.rb +1 -1
- metadata +1 -22
- data/lib/OpenNebula/Acl.rb +0 -256
- data/lib/OpenNebula/AclPool.rb +0 -53
- data/lib/OpenNebula/Group.rb +0 -147
- data/lib/OpenNebula/GroupPool.rb +0 -54
- data/lib/OpenNebula/Host.rb +0 -143
- data/lib/OpenNebula/HostPool.rb +0 -55
- data/lib/OpenNebula/Image.rb +0 -256
- data/lib/OpenNebula/ImagePool.rb +0 -74
- data/lib/OpenNebula/OpenNebula.rb +0 -137
- data/lib/OpenNebula/Pool.rb +0 -285
- data/lib/OpenNebula/Template.rb +0 -173
- data/lib/OpenNebula/TemplatePool.rb +0 -74
- data/lib/OpenNebula/User.rb +0 -157
- data/lib/OpenNebula/UserPool.rb +0 -53
- data/lib/OpenNebula/VirtualMachine.rb +0 -319
- data/lib/OpenNebula/VirtualMachinePool.rb +0 -120
- data/lib/OpenNebula/VirtualNetwork.rb +0 -229
- data/lib/OpenNebula/VirtualNetworkPool.rb +0 -74
- data/lib/OpenNebula/XMLUtils.rb +0 -337
- data/lib/occi/configuration.rb +0 -118
- data/lib/occi/server.rb +0 -594
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -8,25 +8,14 @@ Requirements
|
|
8
8
|
|
9
9
|
The following setup is recommended
|
10
10
|
|
11
|
-
* usage of the Ruby Version Manger
|
11
|
+
* usage of the Ruby Version Manger recommended
|
12
12
|
* Ruby 1.9.3
|
13
|
-
*
|
13
|
+
* RubyGems installed
|
14
14
|
|
15
15
|
Installation
|
16
16
|
------------
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
Download the latest version from http://dev.opennebula.org/projects/ogf-occi/files
|
21
|
-
|
22
|
-
Extract file
|
23
|
-
|
24
|
-
tar xzf rOCCI-*.tar.bz
|
25
|
-
unzip rOCCI-*.zip
|
26
|
-
|
27
|
-
Install dependencies
|
28
|
-
|
29
|
-
bundle install --deployment
|
18
|
+
gem install occi
|
30
19
|
|
31
20
|
### Latest version
|
32
21
|
|
@@ -42,29 +31,6 @@ Install dependencies for deployment
|
|
42
31
|
|
43
32
|
bundle install --deployment
|
44
33
|
|
45
|
-
Configure
|
46
|
-
---------
|
47
|
-
|
48
|
-
Edit etc/occi-server.conf and adapt to your setting.
|
49
|
-
|
50
|
-
The default templates for the OpenNebula template are located at etc/one_templates .
|
51
|
-
|
52
|
-
The default templates for EC2 are located at etc/ec2_templates .
|
53
|
-
|
54
|
-
Usage
|
55
|
-
-----
|
56
|
-
|
57
|
-
Run Passenger
|
58
|
-
|
59
|
-
passenger start
|
60
|
-
|
61
|
-
Testing
|
62
|
-
-------
|
63
|
-
|
64
|
-
Use curl to request all categories
|
65
|
-
|
66
|
-
curl -X GET http://localhost:3000/-/
|
67
|
-
|
68
34
|
Development
|
69
35
|
-----------
|
70
36
|
|
data/lib/occi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -32,25 +32,6 @@ files:
|
|
32
32
|
- LICENSE
|
33
33
|
- README.md
|
34
34
|
- Rakefile
|
35
|
-
- lib/OpenNebula/Acl.rb
|
36
|
-
- lib/OpenNebula/AclPool.rb
|
37
|
-
- lib/OpenNebula/Group.rb
|
38
|
-
- lib/OpenNebula/GroupPool.rb
|
39
|
-
- lib/OpenNebula/Host.rb
|
40
|
-
- lib/OpenNebula/HostPool.rb
|
41
|
-
- lib/OpenNebula/Image.rb
|
42
|
-
- lib/OpenNebula/ImagePool.rb
|
43
|
-
- lib/OpenNebula/OpenNebula.rb
|
44
|
-
- lib/OpenNebula/Pool.rb
|
45
|
-
- lib/OpenNebula/Template.rb
|
46
|
-
- lib/OpenNebula/TemplatePool.rb
|
47
|
-
- lib/OpenNebula/User.rb
|
48
|
-
- lib/OpenNebula/UserPool.rb
|
49
|
-
- lib/OpenNebula/VirtualMachine.rb
|
50
|
-
- lib/OpenNebula/VirtualMachinePool.rb
|
51
|
-
- lib/OpenNebula/VirtualNetwork.rb
|
52
|
-
- lib/OpenNebula/VirtualNetworkPool.rb
|
53
|
-
- lib/OpenNebula/XMLUtils.rb
|
54
35
|
- lib/occi/antlr/.gitignore
|
55
36
|
- lib/occi/antlr/OCCI.g
|
56
37
|
- lib/occi/antlr/OCCI.tokens
|
@@ -66,7 +47,6 @@ files:
|
|
66
47
|
- lib/occi/backend/opennebula/network.rb
|
67
48
|
- lib/occi/backend/opennebula/opennebula.rb
|
68
49
|
- lib/occi/backend/opennebula/storage.rb
|
69
|
-
- lib/occi/configuration.rb
|
70
50
|
- lib/occi/core/action.rb
|
71
51
|
- lib/occi/core/attribute_properties.rb
|
72
52
|
- lib/occi/core/attributes.rb
|
@@ -88,7 +68,6 @@ files:
|
|
88
68
|
- lib/occi/log.rb
|
89
69
|
- lib/occi/parse.rb
|
90
70
|
- lib/occi/registry.rb
|
91
|
-
- lib/occi/server.rb
|
92
71
|
- lib/occi/version.rb
|
93
72
|
- occi.gemspec
|
94
73
|
- spec/occi/antlr/parser_spec.rb
|
data/lib/OpenNebula/Acl.rb
DELETED
@@ -1,256 +0,0 @@
|
|
1
|
-
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
-
# #
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
-
# not use this file except in compliance with the License. You may obtain #
|
6
|
-
# a copy of the License at #
|
7
|
-
# #
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
-
# #
|
10
|
-
# Unless required by applicable law or agreed to in writing, software #
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
-
# See the License for the specific language governing permissions and #
|
14
|
-
# limitations under the License. #
|
15
|
-
#--------------------------------------------------------------------------- #
|
16
|
-
|
17
|
-
|
18
|
-
module OpenNebula
|
19
|
-
|
20
|
-
# Abstract rules of the type USER RESOURCE RIGHTS
|
21
|
-
# which are:
|
22
|
-
# USER -> #<num>
|
23
|
-
# @<num>
|
24
|
-
# ALL
|
25
|
-
# RESOURCE -> + separated list and "/{#,@}<num>|ALL"
|
26
|
-
# VM,
|
27
|
-
# HOST
|
28
|
-
# NET
|
29
|
-
# IMAGE
|
30
|
-
# USER
|
31
|
-
# TEMPLATE
|
32
|
-
# GROUP
|
33
|
-
# ACL
|
34
|
-
# RIGHTS -> + separated list
|
35
|
-
# USE
|
36
|
-
# MANAGE
|
37
|
-
# ADMIN
|
38
|
-
# CREATE
|
39
|
-
class Acl < PoolElement
|
40
|
-
|
41
|
-
USERS = {
|
42
|
-
"UID" => 0x100000000,
|
43
|
-
"GID" => 0x200000000,
|
44
|
-
"ALL" => 0x400000000
|
45
|
-
}
|
46
|
-
|
47
|
-
RESOURCES =
|
48
|
-
{
|
49
|
-
"VM" => 0x1000000000,
|
50
|
-
"HOST" => 0x2000000000,
|
51
|
-
"NET" => 0x4000000000,
|
52
|
-
"IMAGE" => 0x8000000000,
|
53
|
-
"USER" => 0x10000000000,
|
54
|
-
"TEMPLATE" => 0x20000000000,
|
55
|
-
"GROUP" => 0x40000000000
|
56
|
-
}
|
57
|
-
|
58
|
-
RIGHTS =
|
59
|
-
{
|
60
|
-
"USE" => 0x1, # Auth. to use an object
|
61
|
-
"MANAGE" => 0x2, # Auth. to perform management actions
|
62
|
-
"ADMIN" => 0x4, # Auth. to perform administrative actions
|
63
|
-
"CREATE" => 0x8 # Auth. to create an object
|
64
|
-
}
|
65
|
-
|
66
|
-
# Constructor
|
67
|
-
#
|
68
|
-
# @param xml [String] must be an xml built with {#build_xml}
|
69
|
-
# @param client [Client] represents an XML-RPC connection
|
70
|
-
def initialize(xml, client)
|
71
|
-
super(xml,client)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Creates an empty XML representation. It contains the id, if it is
|
75
|
-
# specified.
|
76
|
-
#
|
77
|
-
# @param pe_id [Integer] rule ID
|
78
|
-
# @param client [Client] represents an XML-RPC connection
|
79
|
-
#
|
80
|
-
# @return [String] an empty XML representation
|
81
|
-
def self.build_xml(pe_id=nil)
|
82
|
-
if pe_id
|
83
|
-
acl_xml = "<ACL><ID>#{pe_id}</ID></ACL>"
|
84
|
-
else
|
85
|
-
acl_xml = "<ACL></ACL>"
|
86
|
-
end
|
87
|
-
|
88
|
-
XMLElement.build_xml(acl_xml,'ACL')
|
89
|
-
end
|
90
|
-
|
91
|
-
# Creates a new ACL rule.
|
92
|
-
#
|
93
|
-
# @param user [String]
|
94
|
-
# A string containing a hex number, e.g. 0x100000001
|
95
|
-
# @param resource [String]
|
96
|
-
# A string containing a hex number, e.g. 0x2100000001
|
97
|
-
# @param rights [String]
|
98
|
-
# A string containing a hex number, e.g. 0x10
|
99
|
-
#
|
100
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
101
|
-
# otherwise
|
102
|
-
def allocate(user, resource, rights)
|
103
|
-
return super( AclPool::ACL_POOL_METHODS[:addrule],
|
104
|
-
user,
|
105
|
-
resource,
|
106
|
-
rights )
|
107
|
-
end
|
108
|
-
|
109
|
-
# Deletes the Acl rule
|
110
|
-
#
|
111
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
112
|
-
# otherwise
|
113
|
-
def delete()
|
114
|
-
super(AclPool::ACL_POOL_METHODS[:delrule])
|
115
|
-
end
|
116
|
-
|
117
|
-
# Does nothing, individual ACL rules info can't be retrieved from
|
118
|
-
# OpenNebula
|
119
|
-
#
|
120
|
-
# @return [nil] nil
|
121
|
-
def info()
|
122
|
-
return nil
|
123
|
-
end
|
124
|
-
|
125
|
-
# Parses a rule string, e.g. "#5 HOST+VM/@12 INFO+CREATE+DELETE"
|
126
|
-
#
|
127
|
-
# @param rule_str [String] an ACL rule in string format
|
128
|
-
#
|
129
|
-
# @return [Array] an Array containing 3 strings (hex 64b numbers),
|
130
|
-
# or OpenNebula::Error objects
|
131
|
-
def self.parse_rule(rule_str)
|
132
|
-
ret = Array.new
|
133
|
-
|
134
|
-
rule_str = rule_str.split(" ")
|
135
|
-
|
136
|
-
if rule_str.length != 3
|
137
|
-
return OpenNebula::Error.new(
|
138
|
-
"String needs three components: User, Resource, Rights")
|
139
|
-
end
|
140
|
-
|
141
|
-
ret << parse_users(rule_str[0])
|
142
|
-
ret << parse_resources(rule_str[1])
|
143
|
-
ret << parse_rights(rule_str[2])
|
144
|
-
|
145
|
-
errors=ret.map do |arg|
|
146
|
-
if OpenNebula.is_error?(arg)
|
147
|
-
arg.message
|
148
|
-
else
|
149
|
-
nil
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
errors.compact!
|
154
|
-
|
155
|
-
if errors.length>0
|
156
|
-
return OpenNebula::Error.new(errors.join(', '))
|
157
|
-
end
|
158
|
-
|
159
|
-
return ret
|
160
|
-
end
|
161
|
-
|
162
|
-
private
|
163
|
-
|
164
|
-
# Converts a string in the form [#<id>, @<id>, *] to a hex. number
|
165
|
-
#
|
166
|
-
# @param users [String] Users component string
|
167
|
-
#
|
168
|
-
# @return [String] A string containing a hex number
|
169
|
-
def self.parse_users(users)
|
170
|
-
begin
|
171
|
-
return calculate_ids(users).to_i.to_s(16)
|
172
|
-
rescue Exception => e
|
173
|
-
return OpenNebula::Error.new(e.message)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# Converts a resources string to a hex. number
|
178
|
-
#
|
179
|
-
# @param resources [String] Resources component string
|
180
|
-
#
|
181
|
-
# @return [String] A string containing a hex number
|
182
|
-
def self.parse_resources(resources)
|
183
|
-
begin
|
184
|
-
ret = 0
|
185
|
-
resources = resources.split("/")
|
186
|
-
|
187
|
-
if resources.size != 2
|
188
|
-
raise "Resource '#{resources}' malformed"
|
189
|
-
end
|
190
|
-
|
191
|
-
resources[0].split("+").each{ |resource|
|
192
|
-
if !RESOURCES[resource.upcase]
|
193
|
-
raise "Resource '#{resource}' does not exist"
|
194
|
-
end
|
195
|
-
ret += RESOURCES[resource.upcase]
|
196
|
-
}
|
197
|
-
|
198
|
-
ret += calculate_ids(resources[1])
|
199
|
-
|
200
|
-
return ret.to_i.to_s(16)
|
201
|
-
rescue Exception => e
|
202
|
-
return OpenNebula::Error.new(e.message)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
# Converts a rights string to a hex. number
|
207
|
-
#
|
208
|
-
# @param rights [String] Rights component string
|
209
|
-
#
|
210
|
-
# @return [String] A string containing a hex number
|
211
|
-
def self.parse_rights(rights)
|
212
|
-
begin
|
213
|
-
ret = 0
|
214
|
-
rights = rights.split("+")
|
215
|
-
|
216
|
-
rights.each{ |right|
|
217
|
-
raise "Right '#{right}' does not exist" if !RIGHTS[right.upcase]
|
218
|
-
|
219
|
-
ret += RIGHTS[right.upcase]
|
220
|
-
}
|
221
|
-
|
222
|
-
return ret.to_i.to_s(16)
|
223
|
-
rescue Exception => e
|
224
|
-
return OpenNebula::Error.new(e.message)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
# Calculates the numeric value for a String containing an individual
|
229
|
-
# (#<id>), group (@<id>) or all (*) ID component
|
230
|
-
#
|
231
|
-
# @param id_str [String] Rule Id string
|
232
|
-
#
|
233
|
-
# @return [Integer] the numeric value for the given id_str
|
234
|
-
def self.calculate_ids(id_str)
|
235
|
-
raise "ID string '#{id_str}' malformed" if
|
236
|
-
!id_str.match(/^([\#@]\d+|\*)$/)
|
237
|
-
|
238
|
-
value = 0
|
239
|
-
|
240
|
-
case id_str[0..0]
|
241
|
-
when "#"
|
242
|
-
value = USERS["UID"]
|
243
|
-
users_value = id_str[1..-1].to_i + value
|
244
|
-
|
245
|
-
when "@"
|
246
|
-
value = USERS["GID"]
|
247
|
-
users_value = id_str[1..-1].to_i + value
|
248
|
-
|
249
|
-
when "*"
|
250
|
-
users_value = USERS["ALL"]
|
251
|
-
end
|
252
|
-
|
253
|
-
return users_value
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
data/lib/OpenNebula/AclPool.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
-
# #
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
-
# not use this file except in compliance with the License. You may obtain #
|
6
|
-
# a copy of the License at #
|
7
|
-
# #
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
-
# #
|
10
|
-
# Unless required by applicable law or agreed to in writing, software #
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
-
# See the License for the specific language governing permissions and #
|
14
|
-
# limitations under the License. #
|
15
|
-
#--------------------------------------------------------------------------- #
|
16
|
-
|
17
|
-
|
18
|
-
require 'OpenNebula/Pool'
|
19
|
-
|
20
|
-
module OpenNebula
|
21
|
-
class AclPool < Pool
|
22
|
-
|
23
|
-
#######################################################################
|
24
|
-
# Constants and Class Methods
|
25
|
-
#######################################################################
|
26
|
-
|
27
|
-
|
28
|
-
ACL_POOL_METHODS = {
|
29
|
-
:info => "acl.info",
|
30
|
-
:addrule => "acl.addrule",
|
31
|
-
:delrule => "acl.delrule"
|
32
|
-
}
|
33
|
-
|
34
|
-
# Class constructor
|
35
|
-
def initialize(client)
|
36
|
-
super('ACL_POOL','ACL',client)
|
37
|
-
end
|
38
|
-
|
39
|
-
def factory(element_xml)
|
40
|
-
OpenNebula::Acl.new(element_xml, @client)
|
41
|
-
end
|
42
|
-
|
43
|
-
#######################################################################
|
44
|
-
# XML-RPC Methods
|
45
|
-
#######################################################################
|
46
|
-
|
47
|
-
# Retrieves the ACL Pool
|
48
|
-
def info()
|
49
|
-
# Retrieves all the Acls in the pool.
|
50
|
-
super(ACL_POOL_METHODS[:info])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/OpenNebula/Group.rb
DELETED
@@ -1,147 +0,0 @@
|
|
1
|
-
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
-
# #
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
-
# not use this file except in compliance with the License. You may obtain #
|
6
|
-
# a copy of the License at #
|
7
|
-
# #
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
-
# #
|
10
|
-
# Unless required by applicable law or agreed to in writing, software #
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
-
# See the License for the specific language governing permissions and #
|
14
|
-
# limitations under the License. #
|
15
|
-
#--------------------------------------------------------------------------- #
|
16
|
-
|
17
|
-
|
18
|
-
require 'OpenNebula/Pool'
|
19
|
-
|
20
|
-
module OpenNebula
|
21
|
-
class Group < PoolElement
|
22
|
-
#######################################################################
|
23
|
-
# Constants and Class Methods
|
24
|
-
#######################################################################
|
25
|
-
|
26
|
-
|
27
|
-
GROUP_METHODS = {
|
28
|
-
:info => "group.info",
|
29
|
-
:allocate => "group.allocate",
|
30
|
-
:delete => "group.delete"
|
31
|
-
}
|
32
|
-
|
33
|
-
# Flag for requesting connected user's group info
|
34
|
-
SELF = -1
|
35
|
-
|
36
|
-
#Default location for group ACL's
|
37
|
-
if ENV['ONE_LOCATION']
|
38
|
-
GROUP_DEFAULT = ENV['ONE_LOCATION'] + "/etc/group.default"
|
39
|
-
else
|
40
|
-
GROUP_DEFAULT = "/etc/one/group.default"
|
41
|
-
end
|
42
|
-
|
43
|
-
# Creates a Group description with just its identifier
|
44
|
-
# this method should be used to create plain Group objects.
|
45
|
-
# +id+ the id of the user
|
46
|
-
#
|
47
|
-
# Example:
|
48
|
-
# group = Group.new(Group.build_xml(3),rpc_client)
|
49
|
-
#
|
50
|
-
def Group.build_xml(pe_id=nil)
|
51
|
-
if pe_id
|
52
|
-
group_xml = "<GROUP><ID>#{pe_id}</ID></GROUP>"
|
53
|
-
else
|
54
|
-
group_xml = "<GROUP></GROUP>"
|
55
|
-
end
|
56
|
-
|
57
|
-
XMLElement.build_xml(group_xml,'GROUP')
|
58
|
-
end
|
59
|
-
|
60
|
-
# Class constructor
|
61
|
-
def initialize(xml, client)
|
62
|
-
super(xml,client)
|
63
|
-
end
|
64
|
-
|
65
|
-
#######################################################################
|
66
|
-
# Group utils
|
67
|
-
#######################################################################
|
68
|
-
|
69
|
-
# Creates ACLs for the group. The ACL rules are described in a file
|
70
|
-
def create_acls(filename = GROUP_DEFAULT)
|
71
|
-
if !File.readable?(filename)
|
72
|
-
return -1, "Can not read deafult ACL file for group"
|
73
|
-
end
|
74
|
-
|
75
|
-
msg = String.new
|
76
|
-
|
77
|
-
File.open(filename).each_line{ |l|
|
78
|
-
next if l.match(/^#/)
|
79
|
-
|
80
|
-
rule = "@#{@pe_id} #{l}"
|
81
|
-
parse = OpenNebula::Acl.parse_rule(rule)
|
82
|
-
|
83
|
-
if OpenNebula.is_error?(parse)
|
84
|
-
return -1, "Error parsing rule #{rule}: #{parse.message}"
|
85
|
-
end
|
86
|
-
|
87
|
-
xml = OpenNebula::Acl.build_xml
|
88
|
-
acl = OpenNebula::Acl.new(xml, @client)
|
89
|
-
|
90
|
-
rc = acl.allocate(*parse)
|
91
|
-
|
92
|
-
if OpenNebula.is_error?(rc)
|
93
|
-
return -1, "Error creating rule #{rule}: #{rc.message}"
|
94
|
-
else
|
95
|
-
msg << "ACL_ID: #{acl.id}\n"
|
96
|
-
end
|
97
|
-
}
|
98
|
-
|
99
|
-
return 0, msg
|
100
|
-
end
|
101
|
-
|
102
|
-
#######################################################################
|
103
|
-
# XML-RPC Methods for the Group Object
|
104
|
-
#######################################################################
|
105
|
-
|
106
|
-
# Retrieves the information of the given Group.
|
107
|
-
def info()
|
108
|
-
super(GROUP_METHODS[:info], 'GROUP')
|
109
|
-
end
|
110
|
-
|
111
|
-
# Allocates a new Group in OpenNebula
|
112
|
-
#
|
113
|
-
# +groupname+ A string containing the name of the Group.
|
114
|
-
def allocate(groupname)
|
115
|
-
super(GROUP_METHODS[:allocate], groupname)
|
116
|
-
end
|
117
|
-
|
118
|
-
# Deletes the Group
|
119
|
-
def delete()
|
120
|
-
super(GROUP_METHODS[:delete])
|
121
|
-
end
|
122
|
-
|
123
|
-
# ---------------------------------------------------------------------
|
124
|
-
# Helpers to get information
|
125
|
-
# ---------------------------------------------------------------------
|
126
|
-
|
127
|
-
# Returns whether or not the user with id 'uid' is part of this group
|
128
|
-
def contains(uid)
|
129
|
-
#This doesn't work in ruby 1.8.5
|
130
|
-
#return self["USERS/ID[.=#{uid}]"] != nil
|
131
|
-
|
132
|
-
id_array = retrieve_elements('USERS/ID')
|
133
|
-
return id_array != nil && id_array.include?(uid.to_s)
|
134
|
-
end
|
135
|
-
|
136
|
-
# Returns an array with the numeric user ids
|
137
|
-
def user_ids
|
138
|
-
array = Array.new
|
139
|
-
|
140
|
-
self.each("USERS/ID") do |id|
|
141
|
-
array << id.text.to_i
|
142
|
-
end
|
143
|
-
|
144
|
-
return array
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|