opennebula 3.9.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.
- data/LICENSE +202 -0
- data/NOTICE +47 -0
- data/lib/opennebula.rb +58 -0
- data/lib/opennebula/acl.rb +266 -0
- data/lib/opennebula/acl_pool.rb +55 -0
- data/lib/opennebula/client.rb +119 -0
- data/lib/opennebula/cluster.rb +249 -0
- data/lib/opennebula/cluster_pool.rb +58 -0
- data/lib/opennebula/datastore.rb +171 -0
- data/lib/opennebula/datastore_pool.rb +55 -0
- data/lib/opennebula/document.rb +261 -0
- data/lib/opennebula/document_json.rb +131 -0
- data/lib/opennebula/document_pool.rb +102 -0
- data/lib/opennebula/document_pool_json.rb +58 -0
- data/lib/opennebula/error.rb +52 -0
- data/lib/opennebula/group.rb +163 -0
- data/lib/opennebula/group_pool.rb +56 -0
- data/lib/opennebula/host.rb +201 -0
- data/lib/opennebula/host_pool.rb +93 -0
- data/lib/opennebula/image.rb +297 -0
- data/lib/opennebula/image_pool.rb +79 -0
- data/lib/opennebula/ldap_auth.rb +99 -0
- data/lib/opennebula/ldap_auth_spec.rb +70 -0
- data/lib/opennebula/pool.rb +160 -0
- data/lib/opennebula/pool_element.rb +269 -0
- data/lib/opennebula/server_cipher_auth.rb +148 -0
- data/lib/opennebula/server_x509_auth.rb +104 -0
- data/lib/opennebula/ssh_auth.rb +139 -0
- data/lib/opennebula/system.rb +141 -0
- data/lib/opennebula/template.rb +213 -0
- data/lib/opennebula/template_pool.rb +79 -0
- data/lib/opennebula/user.rb +174 -0
- data/lib/opennebula/user_pool.rb +55 -0
- data/lib/opennebula/virtual_machine.rb +560 -0
- data/lib/opennebula/virtual_machine_pool.rb +323 -0
- data/lib/opennebula/virtual_network.rb +249 -0
- data/lib/opennebula/virtual_network_pool.rb +79 -0
- data/lib/opennebula/x509_auth.rb +288 -0
- data/lib/opennebula/xml_element.rb +427 -0
- data/lib/opennebula/xml_pool.rb +45 -0
- data/lib/opennebula/xml_utils.rb +34 -0
- metadata +118 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
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
|
+
require 'json'
|
18
|
+
|
19
|
+
module OpenNebula
|
20
|
+
class DocumentJSON < Document
|
21
|
+
|
22
|
+
TEMPLATE_TAG = "BODY"
|
23
|
+
|
24
|
+
# Allocate a new Document containing the json inside the TEMPLATE
|
25
|
+
#
|
26
|
+
# @param [String] template_json json to be inserted in the TEMPLATE
|
27
|
+
# of the new resource
|
28
|
+
# @param [String, nil] name name of the object, this value will be
|
29
|
+
# processed by the OpenNebula core
|
30
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
31
|
+
# otherwise
|
32
|
+
#
|
33
|
+
def allocate(template_json, name=nil)
|
34
|
+
text = build_template_xml(template_json, name)
|
35
|
+
|
36
|
+
super(text)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Retrieves the information of the Service and all its Nodes.
|
40
|
+
#
|
41
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
42
|
+
# otherwise
|
43
|
+
#
|
44
|
+
def info
|
45
|
+
rc = super
|
46
|
+
if OpenNebula.is_error?(rc)
|
47
|
+
return rc
|
48
|
+
end
|
49
|
+
|
50
|
+
load_body
|
51
|
+
end
|
52
|
+
|
53
|
+
alias_method :info!, :info
|
54
|
+
|
55
|
+
# Updates the current state of this Service in the OpenNebula DB
|
56
|
+
#
|
57
|
+
# @params [String, nil] template_json string to be inserted in the
|
58
|
+
# template. If nil @body will be used instead
|
59
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
60
|
+
# otherwise
|
61
|
+
#
|
62
|
+
def update(template_json=nil)
|
63
|
+
template_json ||= @body.to_json
|
64
|
+
|
65
|
+
text = build_template_xml(template_json)
|
66
|
+
|
67
|
+
super(text)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Generates a json representing the object
|
71
|
+
#
|
72
|
+
# @param [true, false] pretty_generate
|
73
|
+
# @return [String] json representing the object
|
74
|
+
#
|
75
|
+
def to_json(pretty_generate=true)
|
76
|
+
hash = self.to_hash
|
77
|
+
|
78
|
+
body = hash['DOCUMENT']['TEMPLATE']["#{TEMPLATE_TAG}"]
|
79
|
+
if body
|
80
|
+
body_hash = JSON.parse(body)
|
81
|
+
hash['DOCUMENT']['TEMPLATE']["#{TEMPLATE_TAG}"] = body_hash
|
82
|
+
end
|
83
|
+
|
84
|
+
if pretty_generate
|
85
|
+
JSON.pretty_generate hash
|
86
|
+
else
|
87
|
+
hash.to_json
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# Fill the @body hash with the values of the template
|
93
|
+
def load_body
|
94
|
+
body_str = self["TEMPLATE/#{TEMPLATE_TAG}"]
|
95
|
+
|
96
|
+
if body_str
|
97
|
+
begin
|
98
|
+
@body = JSON.parse(body_str)
|
99
|
+
rescue JSON::JSONError
|
100
|
+
return OpenNebula::Error.new($!)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
return nil
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
# Build an xml string incluiding the provided json
|
110
|
+
#
|
111
|
+
# @param [String] template_json The template to be inserted
|
112
|
+
# @param [String, nil] name The string to be inserted as name
|
113
|
+
# @return [String] The xml containing the json
|
114
|
+
#
|
115
|
+
def build_template_xml(template_json, name=nil)
|
116
|
+
template_json ||= ""
|
117
|
+
|
118
|
+
text = "<TEMPLATE>"
|
119
|
+
|
120
|
+
text << "<NAME>#{name}</NAME>" if name
|
121
|
+
|
122
|
+
text << "<#{TEMPLATE_TAG}>"
|
123
|
+
text << "<![CDATA[#{template_json}]]>"
|
124
|
+
text << "</#{TEMPLATE_TAG}>"
|
125
|
+
|
126
|
+
text << "</TEMPLATE>"
|
127
|
+
|
128
|
+
text
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
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
|
+
require 'opennebula/pool'
|
18
|
+
|
19
|
+
module OpenNebula
|
20
|
+
|
21
|
+
# All subclasses must define the DOCUMENT_TYPE constant
|
22
|
+
# and the factory method.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# require 'opennebuña/document_pool'
|
26
|
+
#
|
27
|
+
# module OpenNebula
|
28
|
+
# class CustomObjectPool < DocumentPool
|
29
|
+
#
|
30
|
+
# DOCUMENT_TYPE = 400
|
31
|
+
#
|
32
|
+
# def factory(element_xml)
|
33
|
+
# OpenNebula::CustomObject.new(element_xml, @client)
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
class DocumentPool < Pool
|
38
|
+
|
39
|
+
#######################################################################
|
40
|
+
# Constants and Class attribute accessors
|
41
|
+
#######################################################################
|
42
|
+
|
43
|
+
DOCUMENT_POOL_METHODS = {
|
44
|
+
:info => "documentpool.info"
|
45
|
+
}
|
46
|
+
|
47
|
+
#######################################################################
|
48
|
+
# Class constructor & Pool Methods
|
49
|
+
#######################################################################
|
50
|
+
|
51
|
+
# Class constructor
|
52
|
+
#
|
53
|
+
# @param [OpenNebula::Client] client the xml-rpc client
|
54
|
+
# @param [Integer] user_id the filter flag, see
|
55
|
+
# http://opennebula.org/documentation:rel3.6:api
|
56
|
+
#
|
57
|
+
# @return [DocumentPool] the new object
|
58
|
+
def initialize(client, user_id=-1)
|
59
|
+
super('DOCUMENT_POOL','DOCUMENT',client)
|
60
|
+
|
61
|
+
@user_id = user_id
|
62
|
+
end
|
63
|
+
|
64
|
+
#######################################################################
|
65
|
+
# XML-RPC Methods for the Document Object
|
66
|
+
#######################################################################
|
67
|
+
|
68
|
+
# Retrieves all or part of the Documents in the pool.
|
69
|
+
#
|
70
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
71
|
+
# otherwise
|
72
|
+
def info(*args)
|
73
|
+
case args.size
|
74
|
+
when 0
|
75
|
+
info_filter(DOCUMENT_POOL_METHODS[:info],@user_id,-1,-1, document_type)
|
76
|
+
when 3
|
77
|
+
info_filter(DOCUMENT_POOL_METHODS[:info],args[0],args[1],args[2], document_type)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def info_all()
|
82
|
+
return super(DOCUMENT_POOL_METHODS[:info], document_type)
|
83
|
+
end
|
84
|
+
|
85
|
+
def info_mine()
|
86
|
+
return super(DOCUMENT_POOL_METHODS[:info], document_type)
|
87
|
+
end
|
88
|
+
|
89
|
+
def info_group()
|
90
|
+
return super(DOCUMENT_POOL_METHODS[:info], document_type)
|
91
|
+
end
|
92
|
+
|
93
|
+
alias_method :info!, :info
|
94
|
+
alias_method :info_all!, :info_all
|
95
|
+
alias_method :info_mine!, :info_mine
|
96
|
+
alias_method :info_group!, :info_group
|
97
|
+
|
98
|
+
def document_type
|
99
|
+
self.class::DOCUMENT_TYPE
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
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
|
+
module OpenNebula
|
18
|
+
class DocumentPoolJSON < DocumentPool
|
19
|
+
|
20
|
+
TEMPLATE_TAG = "BODY"
|
21
|
+
|
22
|
+
def factory(element_xml)
|
23
|
+
doc = OpenNebula::DocumentJSON.new(element_xml, @client)
|
24
|
+
doc.load_body
|
25
|
+
doc
|
26
|
+
end
|
27
|
+
|
28
|
+
# Generates a json representing the object
|
29
|
+
#
|
30
|
+
# @param [true, false] pretty_generate
|
31
|
+
# @return [String] json representing the object
|
32
|
+
#
|
33
|
+
def to_json(pretty_generate=true)
|
34
|
+
hash = self.to_hash
|
35
|
+
|
36
|
+
if hash['DOCUMENT_POOL'] && hash['DOCUMENT_POOL']['DOCUMENT']
|
37
|
+
if !hash['DOCUMENT_POOL']['DOCUMENT'].instance_of?(Array)
|
38
|
+
array = [hash['DOCUMENT_POOL']['DOCUMENT']]
|
39
|
+
hash['DOCUMENT_POOL']['DOCUMENT'] = array.compact
|
40
|
+
end
|
41
|
+
|
42
|
+
hash['DOCUMENT_POOL']['DOCUMENT'].each { |doc|
|
43
|
+
body = doc['TEMPLATE']["#{TEMPLATE_TAG}"]
|
44
|
+
if body
|
45
|
+
b_hash = JSON.parse(body)
|
46
|
+
doc['TEMPLATE']["#{TEMPLATE_TAG}"] = b_hash
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
if pretty_generate
|
52
|
+
JSON.pretty_generate hash
|
53
|
+
else
|
54
|
+
hash.to_json
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
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
|
+
# The Error Class represents a generic error in the OpenNebula
|
20
|
+
# library. It contains a readable representation of the error.
|
21
|
+
# Any function in the OpenNebula module will return an Error
|
22
|
+
# object in case of error.
|
23
|
+
class Error
|
24
|
+
ESUCCESS = 0x0000
|
25
|
+
EAUTHENTICATION = 0x0100
|
26
|
+
EAUTHORIZATION = 0x0200
|
27
|
+
ENO_EXISTS = 0x0400
|
28
|
+
EACTION = 0x0800
|
29
|
+
EXML_RPC_API = 0x1000
|
30
|
+
EINTERNAL = 0x2000
|
31
|
+
ENOTDEFINED = 0x1111
|
32
|
+
|
33
|
+
attr_reader :message, :errno
|
34
|
+
|
35
|
+
# +message+ Description of the error
|
36
|
+
# +errno+ OpenNebula code error
|
37
|
+
def initialize(message=nil, errno=0x1111)
|
38
|
+
@message = message
|
39
|
+
@errno = errno
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_str()
|
43
|
+
@message
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns true if the object returned by a method of the OpenNebula
|
48
|
+
# library is an Error
|
49
|
+
def self.is_error?(value)
|
50
|
+
value.class==OpenNebula::Error
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
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_element'
|
19
|
+
|
20
|
+
module OpenNebula
|
21
|
+
class Group < PoolElement
|
22
|
+
#######################################################################
|
23
|
+
# Constants and Class Methods
|
24
|
+
#######################################################################
|
25
|
+
|
26
|
+
GROUP_METHODS = {
|
27
|
+
:info => "group.info",
|
28
|
+
:allocate => "group.allocate",
|
29
|
+
:delete => "group.delete",
|
30
|
+
:quota => "group.quota"
|
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, "Cannot 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
|
+
alias_method :info!, :info
|
112
|
+
|
113
|
+
# Allocates a new Group in OpenNebula
|
114
|
+
#
|
115
|
+
# +groupname+ A string containing the name of the Group.
|
116
|
+
def allocate(groupname)
|
117
|
+
super(GROUP_METHODS[:allocate], groupname)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Deletes the Group
|
121
|
+
def delete()
|
122
|
+
super(GROUP_METHODS[:delete])
|
123
|
+
end
|
124
|
+
|
125
|
+
# Sets the group quota limits
|
126
|
+
# @param quota [String] a template (XML or txt) with the new quota limits
|
127
|
+
#
|
128
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
129
|
+
# otherwise
|
130
|
+
def set_quota(quota)
|
131
|
+
return Error.new('ID not defined') if !@pe_id
|
132
|
+
|
133
|
+
rc = @client.call(GROUP_METHODS[:quota],@pe_id, quota)
|
134
|
+
rc = nil if !OpenNebula.is_error?(rc)
|
135
|
+
|
136
|
+
return rc
|
137
|
+
end
|
138
|
+
|
139
|
+
# ---------------------------------------------------------------------
|
140
|
+
# Helpers to get information
|
141
|
+
# ---------------------------------------------------------------------
|
142
|
+
|
143
|
+
# Returns whether or not the user with id 'uid' is part of this group
|
144
|
+
def contains(uid)
|
145
|
+
#This doesn't work in ruby 1.8.5
|
146
|
+
#return self["USERS/ID[.=#{uid}]"] != nil
|
147
|
+
|
148
|
+
id_array = retrieve_elements('USERS/ID')
|
149
|
+
return id_array != nil && id_array.include?(uid.to_s)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns an array with the numeric user ids
|
153
|
+
def user_ids
|
154
|
+
array = Array.new
|
155
|
+
|
156
|
+
self.each("USERS/ID") do |id|
|
157
|
+
array << id.text.to_i
|
158
|
+
end
|
159
|
+
|
160
|
+
return array
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|