opennebula-oca 3.9.0.beta → 3.9.90.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README +1 -0
  2. metadata +35 -108
  3. data/LICENSE +0 -202
  4. data/NOTICE +0 -48
  5. data/lib/opennebula/acl.rb +0 -259
  6. data/lib/opennebula/acl_pool.rb +0 -53
  7. data/lib/opennebula/client.rb +0 -102
  8. data/lib/opennebula/cluster.rb +0 -247
  9. data/lib/opennebula/cluster_pool.rb +0 -56
  10. data/lib/opennebula/datastore.rb +0 -169
  11. data/lib/opennebula/datastore_pool.rb +0 -53
  12. data/lib/opennebula/document.rb +0 -259
  13. data/lib/opennebula/document_json.rb +0 -129
  14. data/lib/opennebula/document_pool.rb +0 -97
  15. data/lib/opennebula/document_pool_json.rb +0 -58
  16. data/lib/opennebula/error.rb +0 -52
  17. data/lib/opennebula/group.rb +0 -161
  18. data/lib/opennebula/group_pool.rb +0 -54
  19. data/lib/opennebula/host.rb +0 -199
  20. data/lib/opennebula/host_pool.rb +0 -91
  21. data/lib/opennebula/image.rb +0 -293
  22. data/lib/opennebula/image_pool.rb +0 -74
  23. data/lib/opennebula/ldap_auth.rb +0 -99
  24. data/lib/opennebula/ldap_auth_spec.rb +0 -70
  25. data/lib/opennebula/pool.rb +0 -157
  26. data/lib/opennebula/pool_element.rb +0 -269
  27. data/lib/opennebula/server_cipher_auth.rb +0 -148
  28. data/lib/opennebula/server_x509_auth.rb +0 -104
  29. data/lib/opennebula/ssh_auth.rb +0 -139
  30. data/lib/opennebula/system.rb +0 -141
  31. data/lib/opennebula/template.rb +0 -201
  32. data/lib/opennebula/template_pool.rb +0 -74
  33. data/lib/opennebula/user.rb +0 -172
  34. data/lib/opennebula/user_pool.rb +0 -53
  35. data/lib/opennebula/virtual_machine.rb +0 -426
  36. data/lib/opennebula/virtual_machine_pool.rb +0 -318
  37. data/lib/opennebula/virtual_network.rb +0 -247
  38. data/lib/opennebula/virtual_network_pool.rb +0 -74
  39. data/lib/opennebula/x509_auth.rb +0 -241
  40. data/lib/opennebula/xml_element.rb +0 -427
  41. data/lib/opennebula/xml_pool.rb +0 -45
  42. data/lib/opennebula/xml_utils.rb +0 -34
  43. data/lib/opennebula.rb +0 -58
@@ -1,141 +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 System
22
- #######################################################################
23
- # Constants and Class attribute accessors
24
- #######################################################################
25
-
26
- SYSTEM_METHODS = {
27
- :userquotainfo => "userquota.info",
28
- :userquotaupdate => "userquota.update",
29
- :groupquotainfo => "groupquota.info",
30
- :groupquotaupdate => "groupquota.update",
31
- :version => "system.version",
32
- :config => "system.config"
33
- }
34
-
35
- #######################################################################
36
- # Class constructor
37
- #######################################################################
38
-
39
- # Constructor
40
- # @param [Client] client that represents a XML-RPC connection
41
- def initialize(client)
42
- @client = client
43
- end
44
-
45
- #######################################################################
46
- # XML-RPC Methods
47
- #######################################################################
48
-
49
- # Gets the oned version
50
- #
51
- # @return [String, OpenNebula::Error] the oned version in case
52
- # of success, Error otherwise
53
- def get_oned_version()
54
- return @client.call("system.version")
55
- end
56
-
57
- # Returns whether of not the oned version is the same as the OCA version
58
- #
59
- # @return [true, false, OpenNebula::Error] true if oned is the same
60
- # version
61
- def compatible_version()
62
- no_revision = VERSION[/^\d+\.\d+\./]
63
- oned_v = get_oned_version
64
-
65
- if OpenNebula.is_error?(oned_v)
66
- return oned_v
67
- end
68
-
69
- return (oned_v =~ /#{no_revision}/) != nil
70
- end
71
-
72
- # Gets the oned configuration
73
- #
74
- # @return [XMLElement, OpenNebula::Error] the oned configuration in case
75
- # of success, Error otherwise
76
- def get_configuration()
77
- rc = @client.call(SYSTEM_METHODS[:config])
78
-
79
- if OpenNebula.is_error?(rc)
80
- return rc
81
- end
82
-
83
- config = XMLElement.new
84
- config.initialize_xml(rc, 'TEMPLATE')
85
-
86
- return config
87
- end
88
-
89
- # Gets the default user quota limits
90
- #
91
- # @return [XMLElement, OpenNebula::Error] the default user quota in case
92
- # of success, Error otherwise
93
- def get_user_quotas()
94
- rc = @client.call(SYSTEM_METHODS[:userquotainfo])
95
-
96
- if OpenNebula.is_error?(rc)
97
- return rc
98
- end
99
-
100
- default_quotas = XMLElement.new
101
- default_quotas.initialize_xml(rc, 'DEFAULT_USER_QUOTAS')
102
-
103
- return default_quotas
104
- end
105
-
106
- # Sets the default user quota limits
107
- # @param quota [String] a template (XML or txt) with the new quota limits
108
- #
109
- # @return [nil, OpenNebula::Error] nil in case of success, Error
110
- # otherwise
111
- def set_user_quotas(quota)
112
- return @client.call(SYSTEM_METHODS[:userquotaupdate], quota)
113
- end
114
-
115
- # Gets the default group quota limits
116
- #
117
- # @return [XMLElement, OpenNebula::Error] the default group quota in case
118
- # of success, Error otherwise
119
- def get_group_quotas()
120
- rc = @client.call(SYSTEM_METHODS[:groupquotainfo])
121
-
122
- if OpenNebula.is_error?(rc)
123
- return rc
124
- end
125
-
126
- default_quotas = XMLElement.new
127
- default_quotas.initialize_xml(rc, 'DEFAULT_GROUP_QUOTAS')
128
-
129
- return default_quotas
130
- end
131
-
132
- # Sets the default group quota limits
133
- # @param quota [String] a template (XML or txt) with the new quota limits
134
- #
135
- # @return [nil, OpenNebula::Error] nil in case of success, Error
136
- # otherwise
137
- def set_group_quotas(quota)
138
- return @client.call(SYSTEM_METHODS[:groupquotaupdate], quota)
139
- end
140
- end
141
- end
@@ -1,201 +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_element'
19
-
20
- module OpenNebula
21
- class Template < PoolElement
22
- #######################################################################
23
- # Constants and Class Methods
24
- #######################################################################
25
-
26
-
27
- TEMPLATE_METHODS = {
28
- :allocate => "template.allocate",
29
- :instantiate => "template.instantiate",
30
- :info => "template.info",
31
- :update => "template.update",
32
- :delete => "template.delete",
33
- :chown => "template.chown",
34
- :chmod => "template.chmod",
35
- :clone => "template.clone",
36
- :rename => "template.rename"
37
- }
38
-
39
- # Creates a Template description with just its identifier
40
- # this method should be used to create plain Template objects.
41
- # +id+ the id of the user
42
- #
43
- # Example:
44
- # template = Template.new(Template.build_xml(3),rpc_client)
45
- #
46
- def Template.build_xml(pe_id=nil)
47
- if pe_id
48
- obj_xml = "<VMTEMPLATE><ID>#{pe_id}</ID></VMTEMPLATE>"
49
- else
50
- obj_xml = "<VMTEMPLATE></VMTEMPLATE>"
51
- end
52
-
53
- XMLElement.build_xml(obj_xml,'VMTEMPLATE')
54
- end
55
-
56
- # Class constructor
57
- def initialize(xml, client)
58
- super(xml,client)
59
-
60
- @client = client
61
- end
62
-
63
- #######################################################################
64
- # XML-RPC Methods for the Template Object
65
- #######################################################################
66
-
67
- # Retrieves the information of the given Template.
68
- def info()
69
- super(TEMPLATE_METHODS[:info], 'VMTEMPLATE')
70
- end
71
-
72
- # Allocates a new Template in OpenNebula
73
- #
74
- # @param description [String] The contents of the Template.
75
- #
76
- # @return [nil, OpenNebula::Error] nil in case of success, Error
77
- # otherwise
78
- def allocate(description)
79
- super(TEMPLATE_METHODS[:allocate], description)
80
- end
81
-
82
- # Deletes the Template
83
- def delete()
84
- super(TEMPLATE_METHODS[:delete])
85
- end
86
-
87
- # Creates a VM instance from a Template
88
- #
89
- # +name+ A string containing the name of the VM instance.
90
- # [return] The new VM Instance ID, or an Error object
91
- def instantiate(name="")
92
- return Error.new('ID not defined') if !@pe_id
93
-
94
- name ||= ""
95
- rc = @client.call(TEMPLATE_METHODS[:instantiate], @pe_id, name)
96
-
97
- return rc
98
- end
99
-
100
- # Replaces the template contents
101
- #
102
- # +new_template+ New template contents
103
- def update(new_template)
104
- return Error.new('ID not defined') if !@pe_id
105
-
106
- super(TEMPLATE_METHODS[:update], new_template)
107
- end
108
-
109
- # Publishes the Template, to be used by other users
110
- def publish
111
- set_publish(true)
112
- end
113
-
114
- # Unplubishes the Image
115
- def unpublish
116
- set_publish(false)
117
- end
118
-
119
- # Changes the owner/group
120
- # uid:: _Integer_ the new owner id. Set to -1 to leave the current one
121
- # gid:: _Integer_ the new group id. Set to -1 to leave the current one
122
- # [return] nil in case of success or an Error object
123
- def chown(uid, gid)
124
- super(TEMPLATE_METHODS[:chown], uid, gid)
125
- end
126
-
127
- # Changes the Template permissions.
128
- #
129
- # @param octet [String] Permissions octed , e.g. 640
130
- # @return [nil, OpenNebula::Error] nil in case of success, Error
131
- # otherwise
132
- def chmod_octet(octet)
133
- super(TEMPLATE_METHODS[:chmod], octet)
134
- end
135
-
136
- # Changes the Template permissions.
137
- # Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
138
- #
139
- # @return [nil, OpenNebula::Error] nil in case of success, Error
140
- # otherwise
141
- def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
142
- other_m, other_a)
143
- super(TEMPLATE_METHODS[:chmod], owner_u, owner_m, owner_a, group_u,
144
- group_m, group_a, other_u, other_m, other_a)
145
- end
146
-
147
- # Clones this Template into a new one
148
- #
149
- # @param [String] name for the new Template.
150
- #
151
- # @return [Integer, OpenNebula::Error] The new Template ID in case
152
- # of success, Error otherwise
153
- def clone(name)
154
- return Error.new('ID not defined') if !@pe_id
155
-
156
- rc = @client.call(TEMPLATE_METHODS[:clone], @pe_id, name)
157
-
158
- return rc
159
- end
160
-
161
- # Renames this Template
162
- #
163
- # @param name [String] New name for the Template.
164
- #
165
- # @return [nil, OpenNebula::Error] nil in case of success, Error
166
- # otherwise
167
- def rename(name)
168
- return call(TEMPLATE_METHODS[:rename], @pe_id, name)
169
- end
170
-
171
- #######################################################################
172
- # Helpers to get Template information
173
- #######################################################################
174
-
175
- # Returns the group identifier
176
- # [return] _Integer_ the element's group ID
177
- def gid
178
- self['GID'].to_i
179
- end
180
-
181
- def owner_id
182
- self['UID'].to_i
183
- end
184
-
185
- def public?
186
- if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
187
- true
188
- else
189
- false
190
- end
191
- end
192
-
193
- private
194
-
195
- def set_publish(published)
196
- group_u = published ? 1 : 0
197
-
198
- chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1)
199
- end
200
- end
201
- end
@@ -1,74 +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 TemplatePool < Pool
22
- #######################################################################
23
- # Constants and Class attribute accessors
24
- #######################################################################
25
-
26
-
27
- TEMPLATE_POOL_METHODS = {
28
- :info => "templatepool.info"
29
- }
30
-
31
- #######################################################################
32
- # Class constructor & Pool Methods
33
- #######################################################################
34
-
35
- # +client+ a Client object that represents an XML-RPC connection
36
- # +user_id+ used to refer to a Pool with Templates from that user
37
- def initialize(client, user_id=-1)
38
- super('VMTEMPLATE_POOL','VMTEMPLATE',client)
39
-
40
- @user_id = user_id
41
- end
42
-
43
- # Factory method to create Template objects
44
- def factory(element_xml)
45
- OpenNebula::Template.new(element_xml,@client)
46
- end
47
-
48
- #######################################################################
49
- # XML-RPC Methods for the Template Object
50
- #######################################################################
51
-
52
- # Retrieves all or part of the VirtualMachines in the pool.
53
- def info(*args)
54
- case args.size
55
- when 0
56
- info_filter(TEMPLATE_POOL_METHODS[:info],@user_id,-1,-1)
57
- when 3
58
- info_filter(TEMPLATE_POOL_METHODS[:info],args[0],args[1],args[2])
59
- end
60
- end
61
-
62
- def info_all()
63
- return super(TEMPLATE_POOL_METHODS[:info])
64
- end
65
-
66
- def info_mine()
67
- return super(TEMPLATE_POOL_METHODS[:info])
68
- end
69
-
70
- def info_group()
71
- return super(TEMPLATE_POOL_METHODS[:info])
72
- end
73
- end
74
- end
@@ -1,172 +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_element'
19
-
20
- module OpenNebula
21
- class User < PoolElement
22
- #######################################################################
23
- # Constants and Class Methods
24
- #######################################################################
25
-
26
- USER_METHODS = {
27
- :info => "user.info",
28
- :allocate => "user.allocate",
29
- :delete => "user.delete",
30
- :passwd => "user.passwd",
31
- :chgrp => "user.chgrp",
32
- :update => "user.update",
33
- :chauth => "user.chauth",
34
- :quota => "user.quota"
35
- }
36
-
37
- SELF = -1
38
-
39
- # Driver name for default core authentication
40
- CORE_AUTH = "core"
41
-
42
- # Driver name for default core authentication
43
- CIPHER_AUTH = "server_cipher"
44
-
45
- # Driver name for ssh authentication
46
- SSH_AUTH = "ssh"
47
-
48
- # Driver name for x509 authentication
49
- X509_AUTH = "x509"
50
-
51
- # Driver name for x509 proxy authentication
52
- X509_PROXY_AUTH = "x509_proxy"
53
-
54
- # Creates a User description with just its identifier
55
- # this method should be used to create plain User objects.
56
- # +id+ the id of the user
57
- #
58
- # Example:
59
- # user = User.new(User.build_xml(3),rpc_client)
60
- #
61
- def User.build_xml(pe_id=nil)
62
- if pe_id
63
- user_xml = "<USER><ID>#{pe_id}</ID></USER>"
64
- else
65
- user_xml = "<USER></USER>"
66
- end
67
-
68
- XMLElement.build_xml(user_xml, 'USER')
69
- end
70
-
71
- # Class constructor
72
- def initialize(xml, client)
73
- super(xml,client)
74
-
75
- @client = client
76
- end
77
-
78
- #######################################################################
79
- # XML-RPC Methods for the User Object
80
- #######################################################################
81
-
82
- # Retrieves the information of the given User.
83
- def info()
84
- super(USER_METHODS[:info], 'USER')
85
- end
86
-
87
- # Allocates a new User in OpenNebula
88
- #
89
- # +username+ Name of the new user.
90
- #
91
- # +password+ Password for the new user
92
- def allocate(username, password, driver=CORE_AUTH)
93
- super(USER_METHODS[:allocate], username, password, driver)
94
- end
95
-
96
- # Replaces the template contents
97
- #
98
- # +new_template+ New template contents
99
- def update(new_template)
100
- super(USER_METHODS[:update], new_template)
101
- end
102
-
103
- # Deletes the User
104
- def delete()
105
- super(USER_METHODS[:delete])
106
- end
107
-
108
- # Changes the password of the given User
109
- #
110
- # +password+ String containing the new password
111
- def passwd(password)
112
- return Error.new('ID not defined') if !@pe_id
113
-
114
- rc = @client.call(USER_METHODS[:passwd], @pe_id, password)
115
- rc = nil if !OpenNebula.is_error?(rc)
116
-
117
- return rc
118
- end
119
-
120
- # Changes the main group
121
- # gid:: _Integer_ the new group id. Set to -1 to leave the current one
122
- # [return] nil in case of success or an Error object
123
- def chgrp(gid)
124
- return Error.new('ID not defined') if !@pe_id
125
-
126
- rc = @client.call(USER_METHODS[:chgrp],@pe_id, gid)
127
- rc = nil if !OpenNebula.is_error?(rc)
128
-
129
- return rc
130
- end
131
-
132
- # Changes the auth driver and the password of the given User
133
- #
134
- # @param auth [String] the new auth driver
135
- # @param password [String] the new password. If it is an empty string,
136
- # the user password is not changed
137
- # @return [nil, OpenNebula::Error] nil in case of success, Error
138
- # otherwise
139
- def chauth(auth, password="")
140
- return Error.new('ID not defined') if !@pe_id
141
-
142
- rc = @client.call(USER_METHODS[:chauth],@pe_id, auth, password)
143
- rc = nil if !OpenNebula.is_error?(rc)
144
-
145
- return rc
146
- end
147
-
148
- # Sets the user quota limits
149
- # @param quota [String] a template (XML or txt) with the new quota limits
150
- #
151
- # @return [nil, OpenNebula::Error] nil in case of success, Error
152
- # otherwise
153
- def set_quota(quota)
154
- return Error.new('ID not defined') if !@pe_id
155
-
156
- rc = @client.call(USER_METHODS[:quota],@pe_id, quota)
157
- rc = nil if !OpenNebula.is_error?(rc)
158
-
159
- return rc
160
- end
161
-
162
- #######################################################################
163
- # Helpers to get User information
164
- #######################################################################
165
-
166
- # Returns the group identifier
167
- # [return] _Integer_ the element's group ID
168
- def gid
169
- self['GID'].to_i
170
- end
171
- end
172
- end
@@ -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 UserPool < Pool
22
- #######################################################################
23
- # Constants and Class attribute accessors
24
- #######################################################################
25
-
26
- USER_POOL_METHODS = {
27
- :info => "userpool.info"
28
- }
29
-
30
- #######################################################################
31
- # Class constructor & Pool Methods
32
- #######################################################################
33
-
34
- # +client+ a Client object that represents a XML-RPC connection
35
- def initialize(client)
36
- super('USER_POOL','USER',client)
37
- end
38
-
39
- # Factory method to create User objects
40
- def factory(element_xml)
41
- OpenNebula::User.new(element_xml,@client)
42
- end
43
-
44
- #######################################################################
45
- # XML-RPC Methods for the User Object
46
- #######################################################################
47
-
48
- # Retrieves all the Users in the pool.
49
- def info()
50
- super(USER_POOL_METHODS[:info])
51
- end
52
- end
53
- end