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/lib/OpenNebula/GroupPool.rb
DELETED
@@ -1,54 +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 GroupPool < Pool
|
22
|
-
#######################################################################
|
23
|
-
# Constants and Class attribute accessors
|
24
|
-
#######################################################################
|
25
|
-
|
26
|
-
|
27
|
-
GROUP_POOL_METHODS = {
|
28
|
-
:info => "grouppool.info"
|
29
|
-
}
|
30
|
-
|
31
|
-
#######################################################################
|
32
|
-
# Class constructor & Pool Methods
|
33
|
-
#######################################################################
|
34
|
-
|
35
|
-
# +client+ a Client object that represents a XML-RPC connection
|
36
|
-
def initialize(client)
|
37
|
-
super('GROUP_POOL','GROUP',client)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Factory method to create User objects
|
41
|
-
def factory(element_xml)
|
42
|
-
OpenNebula::Group.new(element_xml,@client)
|
43
|
-
end
|
44
|
-
|
45
|
-
#######################################################################
|
46
|
-
# XML-RPC Methods for the User Object
|
47
|
-
#######################################################################
|
48
|
-
|
49
|
-
# Retrieves all the Groups in the pool.
|
50
|
-
def info()
|
51
|
-
super(GROUP_POOL_METHODS[:info])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/lib/OpenNebula/Host.rb
DELETED
@@ -1,143 +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 Host < PoolElement
|
22
|
-
#######################################################################
|
23
|
-
# Constants and Class Methods
|
24
|
-
#######################################################################
|
25
|
-
|
26
|
-
|
27
|
-
HOST_METHODS = {
|
28
|
-
:info => "host.info",
|
29
|
-
:allocate => "host.allocate",
|
30
|
-
:delete => "host.delete",
|
31
|
-
:enable => "host.enable",
|
32
|
-
:update => "host.update"
|
33
|
-
}
|
34
|
-
|
35
|
-
HOST_STATES=%w{INIT MONITORING MONITORED ERROR DISABLED}
|
36
|
-
|
37
|
-
SHORT_HOST_STATES={
|
38
|
-
"INIT" => "on",
|
39
|
-
"MONITORING" => "on",
|
40
|
-
"MONITORED" => "on",
|
41
|
-
"ERROR" => "err",
|
42
|
-
"DISABLED" => "off"
|
43
|
-
}
|
44
|
-
|
45
|
-
# Creates a Host description with just its identifier
|
46
|
-
# this method should be used to create plain Host objects.
|
47
|
-
# +id+ the id of the host
|
48
|
-
#
|
49
|
-
# Example:
|
50
|
-
# host = Host.new(Host.build_xml(3),rpc_client)
|
51
|
-
#
|
52
|
-
def Host.build_xml(pe_id=nil)
|
53
|
-
if pe_id
|
54
|
-
host_xml = "<HOST><ID>#{pe_id}</ID></HOST>"
|
55
|
-
else
|
56
|
-
host_xml = "<HOST></HOST>"
|
57
|
-
end
|
58
|
-
|
59
|
-
XMLElement.build_xml(host_xml, 'HOST')
|
60
|
-
end
|
61
|
-
|
62
|
-
# Class constructor
|
63
|
-
def initialize(xml, client)
|
64
|
-
super(xml,client)
|
65
|
-
|
66
|
-
@client = client
|
67
|
-
@pe_id = self['ID'].to_i if self['ID']
|
68
|
-
end
|
69
|
-
|
70
|
-
#######################################################################
|
71
|
-
# XML-RPC Methods for the Host
|
72
|
-
#######################################################################
|
73
|
-
|
74
|
-
# Retrieves the information of the given Host.
|
75
|
-
def info()
|
76
|
-
super(HOST_METHODS[:info], 'HOST')
|
77
|
-
end
|
78
|
-
|
79
|
-
# Allocates a new Host in OpenNebula
|
80
|
-
#
|
81
|
-
# @param hostname [String] Name of the new Host.
|
82
|
-
# @param im [String] Name of the im_driver
|
83
|
-
# @param vmm [String] Name of the vmm_driver
|
84
|
-
# @param tm [String] Name of the tm_driver
|
85
|
-
#
|
86
|
-
# @return [Integer, OpenNebula::Error] the new VM ID in case of
|
87
|
-
# success, error otherwise
|
88
|
-
def allocate(hostname,im,vmm,vnm,tm)
|
89
|
-
super(HOST_METHODS[:allocate],hostname,im,vmm,vnm,tm)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Deletes the Host
|
93
|
-
def delete()
|
94
|
-
super(HOST_METHODS[:delete])
|
95
|
-
end
|
96
|
-
|
97
|
-
# Enables the Host
|
98
|
-
def enable()
|
99
|
-
set_enabled(true)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Disables the Host
|
103
|
-
def disable()
|
104
|
-
set_enabled(false)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Replaces the template contents
|
108
|
-
#
|
109
|
-
# +new_template+ New template contents
|
110
|
-
def update(new_template)
|
111
|
-
super(HOST_METHODS[:update], new_template)
|
112
|
-
end
|
113
|
-
|
114
|
-
#######################################################################
|
115
|
-
# Helpers to get Host information
|
116
|
-
#######################################################################
|
117
|
-
|
118
|
-
# Returns the state of the Host (numeric value)
|
119
|
-
def state
|
120
|
-
self['STATE'].to_i
|
121
|
-
end
|
122
|
-
|
123
|
-
# Returns the state of the Host (string value)
|
124
|
-
def state_str
|
125
|
-
HOST_STATES[state]
|
126
|
-
end
|
127
|
-
|
128
|
-
# Returns the state of the Host (string value)
|
129
|
-
def short_state_str
|
130
|
-
SHORT_HOST_STATES[state_str]
|
131
|
-
end
|
132
|
-
|
133
|
-
private
|
134
|
-
def set_enabled(enabled)
|
135
|
-
return Error.new('ID not defined') if !@pe_id
|
136
|
-
|
137
|
-
rc = @client.call(HOST_METHODS[:enable], @pe_id, enabled)
|
138
|
-
rc = nil if !OpenNebula.is_error?(rc)
|
139
|
-
|
140
|
-
return rc
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
data/lib/OpenNebula/HostPool.rb
DELETED
@@ -1,55 +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 HostPool < Pool
|
22
|
-
#######################################################################
|
23
|
-
# Constants and Class attribute accessors
|
24
|
-
#######################################################################
|
25
|
-
|
26
|
-
|
27
|
-
HOST_POOL_METHODS = {
|
28
|
-
:info => "hostpool.info"
|
29
|
-
}
|
30
|
-
|
31
|
-
#######################################################################
|
32
|
-
# Class constructor & Pool Methods
|
33
|
-
#######################################################################
|
34
|
-
|
35
|
-
|
36
|
-
# +client+ a Client object that represents a XML-RPC connection
|
37
|
-
def initialize(client)
|
38
|
-
super('HOST_POOL','HOST',client)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Factory Method for the Host Pool
|
42
|
-
def factory(element_xml)
|
43
|
-
OpenNebula::Host.new(element_xml,@client)
|
44
|
-
end
|
45
|
-
|
46
|
-
#######################################################################
|
47
|
-
# XML-RPC Methods for the Host Pool
|
48
|
-
#######################################################################
|
49
|
-
|
50
|
-
# Retrieves all the Hosts in the pool.
|
51
|
-
def info()
|
52
|
-
super(HOST_POOL_METHODS[:info])
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/OpenNebula/Image.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
|
-
require 'OpenNebula/Pool'
|
19
|
-
require 'fileutils'
|
20
|
-
|
21
|
-
module OpenNebula
|
22
|
-
class Image < PoolElement
|
23
|
-
#######################################################################
|
24
|
-
# Constants and Class Methods
|
25
|
-
#######################################################################
|
26
|
-
|
27
|
-
|
28
|
-
IMAGE_METHODS = {
|
29
|
-
:info => "image.info",
|
30
|
-
:allocate => "image.allocate",
|
31
|
-
:update => "image.update",
|
32
|
-
:enable => "image.enable",
|
33
|
-
:persistent => "image.persistent",
|
34
|
-
:delete => "image.delete",
|
35
|
-
:chown => "image.chown",
|
36
|
-
:chmod => "image.chmod",
|
37
|
-
:chtype => "image.chtype"
|
38
|
-
}
|
39
|
-
|
40
|
-
IMAGE_STATES=%w{INIT READY USED DISABLED LOCKED ERROR}
|
41
|
-
|
42
|
-
SHORT_IMAGE_STATES={
|
43
|
-
"INIT" => "init",
|
44
|
-
"READY" => "rdy",
|
45
|
-
"USED" => "used",
|
46
|
-
"DISABLED" => "disa",
|
47
|
-
"LOCKED" => "lock",
|
48
|
-
"ERROR" => "err"
|
49
|
-
}
|
50
|
-
|
51
|
-
IMAGE_TYPES=%w{OS CDROM DATABLOCK}
|
52
|
-
|
53
|
-
SHORT_IMAGE_TYPES={
|
54
|
-
"OS" => "OS",
|
55
|
-
"CDROM" => "CD",
|
56
|
-
"DATABLOCK" => "DB"
|
57
|
-
}
|
58
|
-
|
59
|
-
# Creates an Image description with just its identifier
|
60
|
-
# this method should be used to create plain Image objects.
|
61
|
-
# +id+ the id of the image
|
62
|
-
#
|
63
|
-
# Example:
|
64
|
-
# image = Image.new(Image.build_xml(3),rpc_client)
|
65
|
-
#
|
66
|
-
def Image.build_xml(pe_id=nil)
|
67
|
-
if pe_id
|
68
|
-
image_xml = "<IMAGE><ID>#{pe_id}</ID></IMAGE>"
|
69
|
-
else
|
70
|
-
image_xml = "<IMAGE></IMAGE>"
|
71
|
-
end
|
72
|
-
|
73
|
-
XMLElement.build_xml(image_xml,'IMAGE')
|
74
|
-
end
|
75
|
-
|
76
|
-
# Class constructor
|
77
|
-
def initialize(xml, client)
|
78
|
-
super(xml,client)
|
79
|
-
|
80
|
-
@client = client
|
81
|
-
end
|
82
|
-
|
83
|
-
#######################################################################
|
84
|
-
# XML-RPC Methods for the Image Object
|
85
|
-
#######################################################################
|
86
|
-
|
87
|
-
# Retrieves the information of the given Image.
|
88
|
-
def info()
|
89
|
-
super(IMAGE_METHODS[:info], 'IMAGE')
|
90
|
-
end
|
91
|
-
|
92
|
-
# Allocates a new Image in OpenNebula
|
93
|
-
#
|
94
|
-
# +description+ A string containing the template of the Image.
|
95
|
-
def allocate(description)
|
96
|
-
super(IMAGE_METHODS[:allocate],description)
|
97
|
-
end
|
98
|
-
|
99
|
-
# Replaces the template contents
|
100
|
-
#
|
101
|
-
# +new_template+ New template contents
|
102
|
-
def update(new_template)
|
103
|
-
super(IMAGE_METHODS[:update], new_template)
|
104
|
-
end
|
105
|
-
|
106
|
-
# Enables an Image
|
107
|
-
def enable
|
108
|
-
set_enabled(true)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Disables an Image
|
112
|
-
def disable
|
113
|
-
set_enabled(false)
|
114
|
-
end
|
115
|
-
|
116
|
-
# Publishes the Image, to be used by other users
|
117
|
-
def publish
|
118
|
-
set_publish(true)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Unplubishes the Image
|
122
|
-
def unpublish
|
123
|
-
set_publish(false)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Makes the Image persistent
|
127
|
-
def persistent
|
128
|
-
set_persistent(true)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Makes the Image non persistent
|
132
|
-
def nonpersistent
|
133
|
-
set_persistent(false)
|
134
|
-
end
|
135
|
-
|
136
|
-
# Deletes the Image
|
137
|
-
def delete()
|
138
|
-
super(IMAGE_METHODS[:delete])
|
139
|
-
end
|
140
|
-
|
141
|
-
# Changes the owner/group
|
142
|
-
# uid:: _Integer_ the new owner id. Set to -1 to leave the current one
|
143
|
-
# gid:: _Integer_ the new group id. Set to -1 to leave the current one
|
144
|
-
# [return] nil in case of success or an Error object
|
145
|
-
def chown(uid, gid)
|
146
|
-
super(IMAGE_METHODS[:chown], uid, gid)
|
147
|
-
end
|
148
|
-
|
149
|
-
# Changes the Image permissions.
|
150
|
-
#
|
151
|
-
# @param octet [String] Permissions octed , e.g. 640
|
152
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
153
|
-
# otherwise
|
154
|
-
def chmod_octet(octet)
|
155
|
-
super(IMAGE_METHODS[:chmod], octet)
|
156
|
-
end
|
157
|
-
|
158
|
-
# Changes the Image permissions.
|
159
|
-
# Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
|
160
|
-
#
|
161
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
162
|
-
# otherwise
|
163
|
-
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
164
|
-
other_m, other_a)
|
165
|
-
super(IMAGE_METHODS[:chmod], owner_u, owner_m, owner_a, group_u,
|
166
|
-
group_m, group_a, other_u, other_m, other_a)
|
167
|
-
end
|
168
|
-
|
169
|
-
# Changes the Image type
|
170
|
-
# @param type [String] new Image type
|
171
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
172
|
-
# otherwise
|
173
|
-
def chtype(type)
|
174
|
-
return Error.new('ID not defined') if !@pe_id
|
175
|
-
|
176
|
-
rc = @client.call(IMAGE_METHODS[:chtype], @pe_id, type)
|
177
|
-
rc = nil if !OpenNebula.is_error?(rc)
|
178
|
-
|
179
|
-
return rc
|
180
|
-
end
|
181
|
-
|
182
|
-
#######################################################################
|
183
|
-
# Helpers to get Image information
|
184
|
-
#######################################################################
|
185
|
-
|
186
|
-
# Returns the state of the Image (numeric value)
|
187
|
-
def state
|
188
|
-
self['STATE'].to_i
|
189
|
-
end
|
190
|
-
|
191
|
-
# Returns the state of the Image (string value)
|
192
|
-
def state_str
|
193
|
-
IMAGE_STATES[state]
|
194
|
-
end
|
195
|
-
|
196
|
-
# Returns the state of the Image (string value)
|
197
|
-
def short_state_str
|
198
|
-
SHORT_IMAGE_STATES[state_str]
|
199
|
-
end
|
200
|
-
|
201
|
-
# Returns the type of the Image (numeric value)
|
202
|
-
def type
|
203
|
-
self['TYPE'].to_i
|
204
|
-
end
|
205
|
-
|
206
|
-
# Returns the type of the Image (string value)
|
207
|
-
def type_str
|
208
|
-
IMAGE_TYPES[type]
|
209
|
-
end
|
210
|
-
|
211
|
-
# Returns the state of the Image (string value)
|
212
|
-
def short_type_str
|
213
|
-
SHORT_IMAGE_TYPES[type_str]
|
214
|
-
end
|
215
|
-
|
216
|
-
# Returns the group identifier
|
217
|
-
# [return] _Integer_ the element's group ID
|
218
|
-
def gid
|
219
|
-
self['GID'].to_i
|
220
|
-
end
|
221
|
-
|
222
|
-
def public?
|
223
|
-
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
224
|
-
true
|
225
|
-
else
|
226
|
-
false
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
private
|
231
|
-
|
232
|
-
def set_enabled(enabled)
|
233
|
-
return Error.new('ID not defined') if !@pe_id
|
234
|
-
|
235
|
-
rc = @client.call(IMAGE_METHODS[:enable], @pe_id, enabled)
|
236
|
-
rc = nil if !OpenNebula.is_error?(rc)
|
237
|
-
|
238
|
-
return rc
|
239
|
-
end
|
240
|
-
|
241
|
-
def set_publish(published)
|
242
|
-
group_u = published ? 1 : 0
|
243
|
-
|
244
|
-
chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1)
|
245
|
-
end
|
246
|
-
|
247
|
-
def set_persistent(persistence)
|
248
|
-
return Error.new('ID not defined') if !@pe_id
|
249
|
-
|
250
|
-
rc = @client.call(IMAGE_METHODS[:persistent], @pe_id, persistence)
|
251
|
-
rc = nil if !OpenNebula.is_error?(rc)
|
252
|
-
|
253
|
-
return rc
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|