oca 3.0.1 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/OpenNebula.rb +28 -35
- data/lib/OpenNebula/Acl.rb +9 -19
- data/lib/OpenNebula/AclPool.rb +4 -3
- data/lib/OpenNebula/Group.rb +14 -15
- data/lib/OpenNebula/GroupPool.rb +10 -8
- data/lib/OpenNebula/Host.rb +12 -11
- data/lib/OpenNebula/HostPool.rb +5 -2
- data/lib/OpenNebula/Image.rb +53 -11
- data/lib/OpenNebula/ImagePool.rb +5 -3
- data/lib/OpenNebula/Pool.rb +46 -6
- data/lib/OpenNebula/Template.rb +42 -15
- data/lib/OpenNebula/TemplatePool.rb +10 -7
- data/lib/OpenNebula/User.rb +53 -13
- data/lib/OpenNebula/UserPool.rb +9 -8
- data/lib/OpenNebula/VirtualMachine.rb +39 -9
- data/lib/OpenNebula/VirtualMachinePool.rb +8 -5
- data/lib/OpenNebula/VirtualNetwork.rb +77 -14
- data/lib/OpenNebula/VirtualNetworkPool.rb +5 -3
- data/lib/OpenNebula/XMLUtils.rb +4 -7
- metadata +1 -1
data/lib/OpenNebula.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
begin # require 'rubygems'
|
18
19
|
require 'rubygems'
|
19
20
|
rescue Exception
|
@@ -44,18 +45,27 @@ require 'OpenNebula/AclPool'
|
|
44
45
|
|
45
46
|
module OpenNebula
|
46
47
|
|
47
|
-
# -------------------------------------------------------------------------
|
48
48
|
# The Error Class represents a generic error in the OpenNebula
|
49
49
|
# library. It contains a readable representation of the error.
|
50
50
|
# Any function in the OpenNebula module will return an Error
|
51
51
|
# object in case of error.
|
52
|
-
# -------------------------------------------------------------------------
|
53
52
|
class Error
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
ESUCCESS = 0x0000
|
54
|
+
EAUTHENTICATION = 0x0100
|
55
|
+
EAUTHORIZATION = 0x0200
|
56
|
+
ENO_EXISTS = 0x0400
|
57
|
+
EACTION = 0x0800
|
58
|
+
EXML_RPC_API = 0x1000
|
59
|
+
EINTERNAL = 0x2000
|
60
|
+
ENOTDEFINED = 0x1111
|
61
|
+
|
62
|
+
attr_reader :message, :errno
|
63
|
+
|
64
|
+
# +message+ Description of the error
|
65
|
+
# +errno+ OpenNebula code error
|
66
|
+
def initialize(message=nil, errno=0x1111)
|
67
|
+
@message = message
|
68
|
+
@errno = errno
|
59
69
|
end
|
60
70
|
|
61
71
|
def to_str()
|
@@ -63,18 +73,14 @@ module OpenNebula
|
|
63
73
|
end
|
64
74
|
end
|
65
75
|
|
66
|
-
# -------------------------------------------------------------------------
|
67
76
|
# Returns true if the object returned by a method of the OpenNebula
|
68
77
|
# library is an Error
|
69
|
-
# -------------------------------------------------------------------------
|
70
78
|
def self.is_error?(value)
|
71
79
|
value.class==OpenNebula::Error
|
72
80
|
end
|
73
81
|
|
74
|
-
# -------------------------------------------------------------------------
|
75
82
|
# The client class, represents the connection with the core and handles the
|
76
83
|
# xml-rpc calls.
|
77
|
-
# -------------------------------------------------------------------------
|
78
84
|
class Client
|
79
85
|
attr_accessor :one_auth
|
80
86
|
|
@@ -85,41 +91,28 @@ module OpenNebula
|
|
85
91
|
XMLPARSER=false
|
86
92
|
end
|
87
93
|
|
88
|
-
def initialize(secret=nil, endpoint=nil
|
94
|
+
def initialize(secret=nil, endpoint=nil)
|
89
95
|
if secret
|
90
|
-
|
96
|
+
@one_auth = secret
|
91
97
|
elsif ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"])
|
92
|
-
|
98
|
+
@one_auth = File.read(ENV["ONE_AUTH"])
|
93
99
|
elsif File.file?(ENV["HOME"]+"/.one/one_auth")
|
94
|
-
|
100
|
+
@one_auth = File.read(ENV["HOME"]+"/.one/one_auth")
|
95
101
|
else
|
96
102
|
raise "ONE_AUTH file not present"
|
97
103
|
end
|
98
104
|
|
99
|
-
|
100
|
-
|
101
|
-
if tokens.length > 2
|
102
|
-
@one_auth = one_secret
|
103
|
-
elsif tokens.length == 2
|
104
|
-
if hash
|
105
|
-
pass = Digest::SHA1.hexdigest(tokens[1])
|
106
|
-
else
|
107
|
-
pass = tokens[1]
|
108
|
-
end
|
109
|
-
@one_auth = "#{tokens[0]}:#{pass}"
|
110
|
-
else
|
111
|
-
raise "Authorization file malformed"
|
112
|
-
end
|
105
|
+
@one_auth.rstrip!
|
113
106
|
|
114
107
|
if endpoint
|
115
|
-
@one_endpoint=endpoint
|
108
|
+
@one_endpoint = endpoint
|
116
109
|
elsif ENV["ONE_XMLRPC"]
|
117
|
-
@one_endpoint=ENV["ONE_XMLRPC"]
|
110
|
+
@one_endpoint = ENV["ONE_XMLRPC"]
|
118
111
|
else
|
119
|
-
@one_endpoint="http://localhost:2633/RPC2"
|
112
|
+
@one_endpoint = "http://localhost:2633/RPC2"
|
120
113
|
end
|
121
114
|
|
122
|
-
@server=XMLRPC::Client.new2(@one_endpoint)
|
115
|
+
@server = XMLRPC::Client.new2(@one_endpoint)
|
123
116
|
end
|
124
117
|
|
125
118
|
def call(action, *args)
|
@@ -132,7 +125,7 @@ module OpenNebula
|
|
132
125
|
response = @server.call_async("one."+action, @one_auth, *args)
|
133
126
|
|
134
127
|
if response[0] == false
|
135
|
-
Error.new(response[1])
|
128
|
+
Error.new(response[1], response[2])
|
136
129
|
else
|
137
130
|
response[1] #response[1..-1]
|
138
131
|
end
|
data/lib/OpenNebula/Acl.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,7 +14,9 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
module OpenNebula
|
19
|
+
|
18
20
|
# Abstract rules of the type USER RESOURCE RIGHTS
|
19
21
|
# which are:
|
20
22
|
# USER -> #<num>
|
@@ -30,16 +32,10 @@ module OpenNebula
|
|
30
32
|
# GROUP
|
31
33
|
# ACL
|
32
34
|
# RIGHTS -> + separated list
|
33
|
-
# CREATE
|
34
|
-
# DELETE
|
35
35
|
# USE
|
36
36
|
# MANAGE
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# INFO_POOL_MINE
|
40
|
-
# INSTANTIATE
|
41
|
-
# CHOWN
|
42
|
-
# DEPLOY
|
37
|
+
# ADMIN
|
38
|
+
# CREATE
|
43
39
|
class Acl < PoolElement
|
44
40
|
|
45
41
|
USERS = {
|
@@ -61,16 +57,10 @@ module OpenNebula
|
|
61
57
|
|
62
58
|
RIGHTS =
|
63
59
|
{
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"INFO" => 0x10, # Auth. to view an object
|
69
|
-
"INFO_POOL" => 0x20, # Auth. to view any object in the pool
|
70
|
-
"INFO_POOL_MINE"=> 0x40, # Auth. to view user and/or group objects
|
71
|
-
"INSTANTIATE" => 0x80, # Auth. to instantiate a VM from a TEMPLATE
|
72
|
-
"CHOWN" => 0x100,# Auth. to change ownership of an object
|
73
|
-
"DEPLOY" => 0x200 # Auth. to deploy a VM in a Host
|
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
|
74
64
|
}
|
75
65
|
|
76
66
|
# Constructor
|
data/lib/OpenNebula/AclPool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
require 'OpenNebula/Pool'
|
18
19
|
|
19
20
|
module OpenNebula
|
@@ -22,15 +23,15 @@ module OpenNebula
|
|
22
23
|
#######################################################################
|
23
24
|
# Constants and Class Methods
|
24
25
|
#######################################################################
|
26
|
+
|
27
|
+
|
25
28
|
ACL_POOL_METHODS = {
|
26
29
|
:info => "acl.info",
|
27
30
|
:addrule => "acl.addrule",
|
28
31
|
:delrule => "acl.delrule"
|
29
32
|
}
|
30
33
|
|
31
|
-
#######################################################################
|
32
34
|
# Class constructor
|
33
|
-
#######################################################################
|
34
35
|
def initialize(client)
|
35
36
|
super('ACL_POOL','ACL',client)
|
36
37
|
end
|
data/lib/OpenNebula/Group.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,13 +14,16 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
require 'OpenNebula/Pool'
|
18
19
|
|
19
20
|
module OpenNebula
|
20
21
|
class Group < PoolElement
|
21
|
-
|
22
|
+
#######################################################################
|
22
23
|
# Constants and Class Methods
|
23
|
-
|
24
|
+
#######################################################################
|
25
|
+
|
26
|
+
|
24
27
|
GROUP_METHODS = {
|
25
28
|
:info => "group.info",
|
26
29
|
:allocate => "group.allocate",
|
@@ -54,18 +57,14 @@ module OpenNebula
|
|
54
57
|
XMLElement.build_xml(group_xml,'GROUP')
|
55
58
|
end
|
56
59
|
|
57
|
-
# ---------------------------------------------------------------------
|
58
60
|
# Class constructor
|
59
|
-
# ---------------------------------------------------------------------
|
60
61
|
def initialize(xml, client)
|
61
62
|
super(xml,client)
|
62
|
-
|
63
|
-
@client = client
|
64
63
|
end
|
65
|
-
|
66
|
-
|
64
|
+
|
65
|
+
#######################################################################
|
67
66
|
# Group utils
|
68
|
-
|
67
|
+
#######################################################################
|
69
68
|
|
70
69
|
# Creates ACLs for the group. The ACL rules are described in a file
|
71
70
|
def create_acls(filename = GROUP_DEFAULT)
|
@@ -74,7 +73,7 @@ module OpenNebula
|
|
74
73
|
end
|
75
74
|
|
76
75
|
msg = String.new
|
77
|
-
|
76
|
+
|
78
77
|
File.open(filename).each_line{ |l|
|
79
78
|
next if l.match(/^#/)
|
80
79
|
|
@@ -100,9 +99,9 @@ module OpenNebula
|
|
100
99
|
return 0, msg
|
101
100
|
end
|
102
101
|
|
103
|
-
|
102
|
+
#######################################################################
|
104
103
|
# XML-RPC Methods for the Group Object
|
105
|
-
|
104
|
+
#######################################################################
|
106
105
|
|
107
106
|
# Retrieves the information of the given Group.
|
108
107
|
def info()
|
@@ -127,8 +126,8 @@ module OpenNebula
|
|
127
126
|
|
128
127
|
# Returns whether or not the user with id 'uid' is part of this group
|
129
128
|
def contains(uid)
|
130
|
-
#
|
131
|
-
#
|
129
|
+
#This doesn't work in ruby 1.8.5
|
130
|
+
#return self["USERS/ID[.=#{uid}]"] != nil
|
132
131
|
|
133
132
|
id_array = retrieve_elements('USERS/ID')
|
134
133
|
return id_array != nil && id_array.include?(uid.to_s)
|
data/lib/OpenNebula/GroupPool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,21 +14,23 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
require 'OpenNebula/Pool'
|
18
19
|
|
19
20
|
module OpenNebula
|
20
21
|
class GroupPool < Pool
|
21
|
-
|
22
|
+
#######################################################################
|
22
23
|
# Constants and Class attribute accessors
|
23
|
-
|
24
|
+
#######################################################################
|
25
|
+
|
24
26
|
|
25
27
|
GROUP_POOL_METHODS = {
|
26
28
|
:info => "grouppool.info"
|
27
29
|
}
|
28
30
|
|
29
|
-
|
31
|
+
#######################################################################
|
30
32
|
# Class constructor & Pool Methods
|
31
|
-
|
33
|
+
#######################################################################
|
32
34
|
|
33
35
|
# +client+ a Client object that represents a XML-RPC connection
|
34
36
|
def initialize(client)
|
@@ -40,13 +42,13 @@ module OpenNebula
|
|
40
42
|
OpenNebula::Group.new(element_xml,@client)
|
41
43
|
end
|
42
44
|
|
43
|
-
|
45
|
+
#######################################################################
|
44
46
|
# XML-RPC Methods for the User Object
|
45
|
-
|
47
|
+
#######################################################################
|
46
48
|
|
47
49
|
# Retrieves all the Groups in the pool.
|
48
50
|
def info()
|
49
51
|
super(GROUP_POOL_METHODS[:info])
|
50
52
|
end
|
51
53
|
end
|
52
|
-
end
|
54
|
+
end
|
data/lib/OpenNebula/Host.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
require 'OpenNebula/Pool'
|
18
19
|
|
19
20
|
module OpenNebula
|
@@ -21,6 +22,8 @@ module OpenNebula
|
|
21
22
|
#######################################################################
|
22
23
|
# Constants and Class Methods
|
23
24
|
#######################################################################
|
25
|
+
|
26
|
+
|
24
27
|
HOST_METHODS = {
|
25
28
|
:info => "host.info",
|
26
29
|
:allocate => "host.allocate",
|
@@ -56,9 +59,7 @@ module OpenNebula
|
|
56
59
|
XMLElement.build_xml(host_xml, 'HOST')
|
57
60
|
end
|
58
61
|
|
59
|
-
#######################################################################
|
60
62
|
# Class constructor
|
61
|
-
#######################################################################
|
62
63
|
def initialize(xml, client)
|
63
64
|
super(xml,client)
|
64
65
|
|
@@ -77,15 +78,15 @@ module OpenNebula
|
|
77
78
|
|
78
79
|
# Allocates a new Host in OpenNebula
|
79
80
|
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
# +vmm+ A string containing the name of the vmm_driver
|
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
85
|
#
|
86
|
-
#
|
87
|
-
|
88
|
-
|
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)
|
89
90
|
end
|
90
91
|
|
91
92
|
# Deletes the Host
|
data/lib/OpenNebula/HostPool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
require 'OpenNebula/Pool'
|
18
19
|
|
19
20
|
module OpenNebula
|
@@ -22,6 +23,7 @@ module OpenNebula
|
|
22
23
|
# Constants and Class attribute accessors
|
23
24
|
#######################################################################
|
24
25
|
|
26
|
+
|
25
27
|
HOST_POOL_METHODS = {
|
26
28
|
:info => "hostpool.info"
|
27
29
|
}
|
@@ -29,7 +31,8 @@ module OpenNebula
|
|
29
31
|
#######################################################################
|
30
32
|
# Class constructor & Pool Methods
|
31
33
|
#######################################################################
|
32
|
-
|
34
|
+
|
35
|
+
|
33
36
|
# +client+ a Client object that represents a XML-RPC connection
|
34
37
|
def initialize(client)
|
35
38
|
super('HOST_POOL','HOST',client)
|
data/lib/OpenNebula/Image.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
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 #
|
@@ -14,23 +14,27 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
|
17
18
|
require 'OpenNebula/Pool'
|
18
19
|
require 'fileutils'
|
19
20
|
|
20
21
|
module OpenNebula
|
21
22
|
class Image < PoolElement
|
22
|
-
|
23
|
+
#######################################################################
|
23
24
|
# Constants and Class Methods
|
24
|
-
|
25
|
+
#######################################################################
|
26
|
+
|
27
|
+
|
25
28
|
IMAGE_METHODS = {
|
26
29
|
:info => "image.info",
|
27
30
|
:allocate => "image.allocate",
|
28
31
|
:update => "image.update",
|
29
32
|
:enable => "image.enable",
|
30
|
-
:publish => "image.publish",
|
31
33
|
:persistent => "image.persistent",
|
32
34
|
:delete => "image.delete",
|
33
|
-
:chown => "image.chown"
|
35
|
+
:chown => "image.chown",
|
36
|
+
:chmod => "image.chmod",
|
37
|
+
:chtype => "image.chtype"
|
34
38
|
}
|
35
39
|
|
36
40
|
IMAGE_STATES=%w{INIT READY USED DISABLED LOCKED ERROR}
|
@@ -118,7 +122,7 @@ module OpenNebula
|
|
118
122
|
def unpublish
|
119
123
|
set_publish(false)
|
120
124
|
end
|
121
|
-
|
125
|
+
|
122
126
|
# Makes the Image persistent
|
123
127
|
def persistent
|
124
128
|
set_persistent(true)
|
@@ -142,6 +146,39 @@ module OpenNebula
|
|
142
146
|
super(IMAGE_METHODS[:chown], uid, gid)
|
143
147
|
end
|
144
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
|
+
|
145
182
|
#######################################################################
|
146
183
|
# Helpers to get Image information
|
147
184
|
#######################################################################
|
@@ -182,6 +219,14 @@ module OpenNebula
|
|
182
219
|
self['GID'].to_i
|
183
220
|
end
|
184
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
|
+
|
185
230
|
private
|
186
231
|
|
187
232
|
def set_enabled(enabled)
|
@@ -194,12 +239,9 @@ module OpenNebula
|
|
194
239
|
end
|
195
240
|
|
196
241
|
def set_publish(published)
|
197
|
-
|
242
|
+
group_u = published ? 1 : 0
|
198
243
|
|
199
|
-
|
200
|
-
rc = nil if !OpenNebula.is_error?(rc)
|
201
|
-
|
202
|
-
return rc
|
244
|
+
chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1)
|
203
245
|
end
|
204
246
|
|
205
247
|
def set_persistent(persistence)
|