occi 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/occi/version.rb +1 -1
- metadata +1 -17
- data/lib/occi/backend/dummy.rb +0 -232
- data/lib/occi/backend/ec2/Compute.rb +0 -310
- data/lib/occi/backend/ec2/compute.rb +0 -310
- data/lib/occi/backend/ec2/ec2.rb +0 -215
- data/lib/occi/backend/manager.rb +0 -131
- data/lib/occi/backend/opennebula/compute.rb +0 -360
- data/lib/occi/backend/opennebula/network.rb +0 -143
- data/lib/occi/backend/opennebula/opennebula.rb +0 -188
- data/lib/occi/backend/opennebula/storage.rb +0 -175
- data/lib/occi/extensions/monitoring/cpu.rb +0 -51
- data/lib/occi/extensions/monitoring/memory.rb +0 -49
- data/lib/occi/extensions/monitoring/metric.rb +0 -54
- data/lib/occi/extensions/monitoring/netrx.rb +0 -49
- data/lib/occi/extensions/monitoring/nettx.rb +0 -55
- data/lib/occi/extensions/one/VNC.rb +0 -58
- data/lib/occi/extensions/one/vnc.rb +0 -58
@@ -1,143 +0,0 @@
|
|
1
|
-
##############################################################################
|
2
|
-
# Copyright 2011 Service Computing group, TU Dortmund
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain 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
|
-
# Description: OpenNebula Backend
|
19
|
-
# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
|
20
|
-
##############################################################################
|
21
|
-
|
22
|
-
require 'occi/log'
|
23
|
-
require 'erubis'
|
24
|
-
require 'ipaddr'
|
25
|
-
|
26
|
-
module OCCI
|
27
|
-
module Backend
|
28
|
-
module OpenNebula
|
29
|
-
|
30
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
31
|
-
module Network
|
32
|
-
|
33
|
-
TEMPLATENETWORKRAWFILE = 'network.erb'
|
34
|
-
|
35
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
36
|
-
# private
|
37
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
38
|
-
|
39
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
40
|
-
def network_parse_backend_object(backend_object)
|
41
|
-
|
42
|
-
# get information on storage object from OpenNebula backend
|
43
|
-
backend_object.info
|
44
|
-
|
45
|
-
network_kind = OCCI::Registry.get_by_id("http://schemas.ogf.org/occi/infrastructure#network")
|
46
|
-
|
47
|
-
network = Hashie::Mash.new
|
48
|
-
|
49
|
-
network.kind = storage_kind.type_identifier
|
50
|
-
network.mixins = %w|http://opennebula.org/occi/infrastructure#network http://schemas.ogf.org/occi/infrastructure#ipnetwork|
|
51
|
-
network.id = self.generate_occi_id(network_kind, backend_object.id.to_s)
|
52
|
-
network.title = backend_object['NAME']
|
53
|
-
network.summary = backend_object['TEMPLATE/DESCRIPTION'] if backend_object['TEMPLATE/DESCRIPTION']
|
54
|
-
|
55
|
-
network.attributes!.occi!.network!.address = backend_object['TEMPLATE/NETWORK_ADDRESS'] if backend_object['TEMPLATE/NETWORK_ADDRESS']
|
56
|
-
network.attributes!.occi!.network!.gateway = backend_object['TEMPLATE/GATEWAY'] if backend_object['TEMPLATE/GATEWAY']
|
57
|
-
network.attributes!.occi!.network!.vlan = backend_object['TEMPLATE/VLAN_ID'] if backend_object['TEMPLATE/VLAN_ID']
|
58
|
-
network.attributes!.occi!.network!.allocation = "static" if backend_object['TEMPLATE/TYPE'].downcase == "fixed"
|
59
|
-
network.attributes!.occi!.network!.allocation = "dynamic" if backend_object['TEMPLATE/TYPE'].downcase == "ranged"
|
60
|
-
|
61
|
-
network.attributes!.org!.opennebula!.network!.vlan = backend_object['TEMPLATE/VLAN'] if backend_object['TEMPLATE/VLAN']
|
62
|
-
network.attributes!.org!.opennebula!.network!.phydev = backend_object['TEMPLATE/PHYDEV'] if backend_object['TEMPLATE/PHYDEV']
|
63
|
-
network.attributes!.org!.opennebula!.network!.bridge = backend_object['TEMPLATE/BRIDGE'] if backend_object['TEMPLATE/BRIDGE']
|
64
|
-
|
65
|
-
network.attributes!.org!.opennebula!.network!.ip_start = backend_object['TEMPLATE/IP_START'] if backend_object['TEMPLATE/IP_START']
|
66
|
-
network.attributes!.org!.opennebula!.network!.ip_end = backend_object['TEMPLATE/IP_END'] if backend_object['TEMPLATE/IP_END']
|
67
|
-
|
68
|
-
network = OCCI::Core::Resource.new(network)
|
69
|
-
|
70
|
-
network_set_state(backend_object, network)
|
71
|
-
|
72
|
-
network_kind.entities << network
|
73
|
-
end
|
74
|
-
|
75
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
76
|
-
public
|
77
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
78
|
-
|
79
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
80
|
-
def network_deploy(network)
|
81
|
-
|
82
|
-
backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(), @one_client)
|
83
|
-
|
84
|
-
template_location = OCCI::Server.config["TEMPLATE_LOCATION"] + TEMPLATENETWORKRAWFILE
|
85
|
-
template = Erubis::Eruby.new(File.read(template_raw)).evaluate(network)
|
86
|
-
|
87
|
-
OCCI::Log.debug("Parsed template #{template}")
|
88
|
-
rc = backend_object.allocate(template)
|
89
|
-
check_rc(rc)
|
90
|
-
|
91
|
-
backend_object.info
|
92
|
-
network.id = self.generate_occi_id(OCCI::Registry.get_by_id(network.kind), backend_object['ID'].to_s)
|
93
|
-
|
94
|
-
network_set_state(backend_object, network)
|
95
|
-
|
96
|
-
OCCI::Log.debug("OpenNebula ID of virtual network: #{network.backend[:id]}")
|
97
|
-
end
|
98
|
-
|
99
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
100
|
-
def network_set_state(backend_object, network)
|
101
|
-
network.attributes!.occi!.network!.state = "active"
|
102
|
-
end
|
103
|
-
|
104
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
105
|
-
def network_delete(network)
|
106
|
-
backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(network.backend[:id]), @one_client)
|
107
|
-
rc = backend_object.delete
|
108
|
-
check_rc(rc)
|
109
|
-
end
|
110
|
-
|
111
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
112
|
-
def network_register_all_instances
|
113
|
-
occi_objects = []
|
114
|
-
backend_object_pool=VirtualNetworkPool.new(@one_client, OCCI::Backend::OpenNebula::OpenNebula::INFO_ACL)
|
115
|
-
backend_object_pool.info
|
116
|
-
backend_object_pool.each { |backend_object| network_parse_backend_object(backend_object) }
|
117
|
-
end
|
118
|
-
|
119
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
120
|
-
# STORAGE ACTIONS
|
121
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
122
|
-
|
123
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
124
|
-
def network_action_dummy(network, parameters)
|
125
|
-
end
|
126
|
-
|
127
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
128
|
-
def network_up(network, parameters)
|
129
|
-
backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(network.backend[:id]), @one_client)
|
130
|
-
# not implemented in OpenNebula
|
131
|
-
end
|
132
|
-
|
133
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
134
|
-
def network_down(network, parameters)
|
135
|
-
backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(network.backend[:id]), @one_client)
|
136
|
-
# not implemented in OpenNebula
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
@@ -1,188 +0,0 @@
|
|
1
|
-
##############################################################################
|
2
|
-
# Copyright 2011 Service Computing group, TU Dortmund
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain 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
|
-
# Description: OpenNebula Backend
|
19
|
-
# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
|
20
|
-
##############################################################################
|
21
|
-
|
22
|
-
require 'rubygems'
|
23
|
-
require 'uuidtools'
|
24
|
-
require 'OpenNebula/OpenNebula'
|
25
|
-
require 'occi/registry'
|
26
|
-
|
27
|
-
# OpenNebula backend
|
28
|
-
require 'occi/backend/opennebula/compute'
|
29
|
-
require 'occi/backend/opennebula/network'
|
30
|
-
require 'occi/backend/opennebula/storage'
|
31
|
-
|
32
|
-
# OpenNebula backend based mixins
|
33
|
-
#require 'occi/extensions/one/Image'
|
34
|
-
#require 'occi/extensions/one/Network'
|
35
|
-
#require 'occi/extensions/one/VirtualMachine'
|
36
|
-
#require 'occi/extensions/one/VNC'
|
37
|
-
|
38
|
-
#require 'occi/extensions/Reservation'
|
39
|
-
|
40
|
-
require 'occi/log'
|
41
|
-
|
42
|
-
include OpenNebula
|
43
|
-
|
44
|
-
module OCCI
|
45
|
-
module Backend
|
46
|
-
module OpenNebula
|
47
|
-
|
48
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
49
|
-
class OpenNebula
|
50
|
-
|
51
|
-
# The ACL level to be used when querying resource in OpenNebula:
|
52
|
-
# - INFO_ALL returns all resources and works only when running under the oneadmin account
|
53
|
-
# - INFO_GROUP returns the resources of the account + his group (= default)
|
54
|
-
# - INFO_MINE returns only the resources of the account
|
55
|
-
INFO_ACL = OpenNebula::Pool::INFO_GROUP
|
56
|
-
|
57
|
-
include Compute
|
58
|
-
include Network
|
59
|
-
include Storage
|
60
|
-
|
61
|
-
|
62
|
-
# Operation mappings
|
63
|
-
|
64
|
-
OPERATIONS = {}
|
65
|
-
|
66
|
-
OPERATIONS["http://schemas.ogf.org/occi/infrastructure#compute"] = {
|
67
|
-
|
68
|
-
# Generic resource operations
|
69
|
-
:deploy => :compute_deploy,
|
70
|
-
:update_state => :compute_update_state,
|
71
|
-
:delete => :compute_delete,
|
72
|
-
|
73
|
-
# Compute specific resource operations
|
74
|
-
:start => :compute_start,
|
75
|
-
:stop => :compute_stop,
|
76
|
-
:restart => :compute_restart,
|
77
|
-
:suspend => :compute_suspend
|
78
|
-
}
|
79
|
-
|
80
|
-
OPERATIONS["http://schemas.ogf.org/occi/infrastructure#network"] = {
|
81
|
-
|
82
|
-
# Generic resource operations
|
83
|
-
:deploy => :network_deploy,
|
84
|
-
:update_state => :network_update_state,
|
85
|
-
:delete => :network_delete,
|
86
|
-
|
87
|
-
# Network specific resource operations
|
88
|
-
:up => :network_up,
|
89
|
-
:down => :network_down
|
90
|
-
}
|
91
|
-
|
92
|
-
OPERATIONS["http://schemas.ogf.org/occi/infrastructure#storage"] = {
|
93
|
-
|
94
|
-
# Generic resource operations
|
95
|
-
:deploy => :storage_deploy,
|
96
|
-
:update_state => :storage_update_state,
|
97
|
-
:delete => :storage_delete,
|
98
|
-
|
99
|
-
# Network specific resource operations
|
100
|
-
:online => :storage_online,
|
101
|
-
:offline => :storage_offline,
|
102
|
-
:backup => :storage_backup,
|
103
|
-
:snapshot => :storage_snapshot,
|
104
|
-
:resize => :storage_resize
|
105
|
-
}
|
106
|
-
|
107
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
108
|
-
# Register backend specific mixins
|
109
|
-
begin
|
110
|
-
#OCCI::CategoryRegistry.register(OCCI::Backend::ONE::Image::MIXIN)
|
111
|
-
#OCCI::CategoryRegistry.register(OCCI::Backend::ONE::Network::MIXIN)
|
112
|
-
#OCCI::CategoryRegistry.register(OCCI::Backend::ONE::VirtualMachine::MIXIN)
|
113
|
-
#OCCI::CategoryRegistry.register(OCCI::Mixins::Reservation::MIXIN)
|
114
|
-
end
|
115
|
-
|
116
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
117
|
-
# private
|
118
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
119
|
-
|
120
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
121
|
-
def check_rc(rc)
|
122
|
-
if rc.class == Error
|
123
|
-
raise OCCI::BackendError, "Error message from OpenNebula: #{rc.to_str}"
|
124
|
-
# TODO: return failed!
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
129
|
-
# Generate a new occi id for resources created directly in OpenNebula using a seed id and the kind identifier
|
130
|
-
def generate_occi_id(kind, seed_id)
|
131
|
-
# Use strings as kind ids
|
132
|
-
kind = kind.type_identifier if kind.kind_of?(OCCI::Core::Kind)
|
133
|
-
return UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, "#{kind}:#{seed_id}").to_s
|
134
|
-
end
|
135
|
-
|
136
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
137
|
-
public
|
138
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
139
|
-
|
140
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
141
|
-
def initialize(user, password)
|
142
|
-
|
143
|
-
# TODO: create mixins from existing templates
|
144
|
-
|
145
|
-
# initialize OpenNebula connection
|
146
|
-
OCCI::Log.debug("### Initializing connection with OpenNebula")
|
147
|
-
|
148
|
-
# TODO: check for error!
|
149
|
-
# @one_client = Client.new(OCCI::Server.config['one_user'] + ':' + OCCI::Server.config['one_password'], OCCI::Server.config['one_xmlrpc'])
|
150
|
-
@one_client = Client.new(user + ':' + password, OCCI::Server.config['one_xmlrpc'])
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
155
|
-
def register_existing_resources
|
156
|
-
# get all compute objects
|
157
|
-
resource_template_register
|
158
|
-
os_template_register
|
159
|
-
compute_register_all_instances
|
160
|
-
network_register_all_instances
|
161
|
-
storage_register_all_instances
|
162
|
-
end
|
163
|
-
|
164
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
165
|
-
def resource_template_register
|
166
|
-
# currently not directly supported by OpenNebula
|
167
|
-
end
|
168
|
-
|
169
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
170
|
-
def os_template_register
|
171
|
-
backend_object_pool=TemplatePool.new(@one_client, INFO_ACL)
|
172
|
-
backend_object_pool.info
|
173
|
-
backend_object_pool.each do |backend_object|
|
174
|
-
related = OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure#os_tpl')
|
175
|
-
term = backend_object['NAME'].downcase.chomp.gsub(/\W/, '_')
|
176
|
-
# TODO: implement correct schema for service provider
|
177
|
-
scheme = "http://schemas.opennebula.org/occi/infrastructure/os_tpl#"
|
178
|
-
title = backend_object['NAME']
|
179
|
-
mixin = OCCI::Core::Mixin.new(:related => related, :term=>term, :scheme=>scheme,:title=>title)
|
180
|
-
OCCI::CategoryRegistry.register(mixin)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
@@ -1,175 +0,0 @@
|
|
1
|
-
##############################################################################
|
2
|
-
# Copyright 2011 Service Computing group, TU Dortmund
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain 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
|
-
# Description: OpenNebula Backend
|
19
|
-
# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
|
20
|
-
##############################################################################
|
21
|
-
|
22
|
-
require 'occi/log'
|
23
|
-
require 'erubis'
|
24
|
-
|
25
|
-
module OCCI
|
26
|
-
module Backend
|
27
|
-
module OpenNebula
|
28
|
-
|
29
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
30
|
-
module Storage
|
31
|
-
|
32
|
-
TEMPLATESTORAGERAWFILE = 'storage.erb'
|
33
|
-
|
34
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
35
|
-
# private
|
36
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
37
|
-
|
38
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
39
|
-
def storage_parse_backend_object(backend_object)
|
40
|
-
|
41
|
-
# get information on storage object from OpenNebula backend
|
42
|
-
backend_object.info
|
43
|
-
|
44
|
-
storage_kind = OCCI::Registry.get_by_id("http://schemas.ogf.org/occi/infrastructure#storage")
|
45
|
-
|
46
|
-
storage = Hashie::Mash.new
|
47
|
-
|
48
|
-
storage.kind = storage_kind.type_identifier
|
49
|
-
storage.mixins = %w|http://opennebula.org/occi/infrastructure#storage|
|
50
|
-
storage.id = self.generate_occi_id(storage_kind, backend_object.id.to_s)
|
51
|
-
storage.title = backend_object['NAME']
|
52
|
-
storage.summary = backend_object['TEMPLATE/DESCRIPTION'] if backend_object['TEMPLATE/DESCRIPTION']
|
53
|
-
|
54
|
-
storage.attributes!.occi!.storage!.size = backend_object['TEMPLATE/SIZE'].to_f/1000 if backend_object['TEMPLATE/SIZE']
|
55
|
-
|
56
|
-
storage.attributes!.org!.opennebula!.storage!.type = backend_object['TEMPLATE/TYPE'] if backend_object['TEMPLATE/TYPE']
|
57
|
-
storage.attributes!.org!.opennebula!.storage!.persistent = backend_object['TEMPLATE/PERSISTENT'] if backend_object['TEMPLATE/PERSISTENT']
|
58
|
-
storage.attributes!.org!.opennebula!.storage!.dev_prefix = backend_object['TEMPLATE/DEV_PREFIX'] if backend_object['TEMPLATE/DEV_PREFIX']
|
59
|
-
storage.attributes!.org!.opennebula!.storage!.bus = backend_object['TEMPLATE/BUS'] if backend_object['TEMPLATE/BUS']
|
60
|
-
storage.attributes!.org!.opennebula!.storage!.driver = backend_object['TEMPLATE/DRIVER'] if backend_object['TEMPLATE/DRIVER']
|
61
|
-
|
62
|
-
storage = OCCI::Core::Resource.new(storage)
|
63
|
-
|
64
|
-
storage_set_state(backend_object, storage)
|
65
|
-
|
66
|
-
storage_kind.entities << storage
|
67
|
-
end
|
68
|
-
|
69
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
70
|
-
public
|
71
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
72
|
-
|
73
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
74
|
-
def storage_deploy(storage)
|
75
|
-
|
76
|
-
backend_object = Image.new(Image.build_xml, @one_client)
|
77
|
-
|
78
|
-
template_location = OCCI::Server.config["TEMPLATE_LOCATION"] + TEMPLATESTORAGERAWFILE
|
79
|
-
template = Erubis::Eruby.new(File.read(template_raw)).evaluate(storage)
|
80
|
-
|
81
|
-
OCCI::Log.debug("Parsed template #{template}")
|
82
|
-
rc = backend_object.allocate(template)
|
83
|
-
check_rc(rc)
|
84
|
-
OCCI::Log.debug("OpenNebula ID of image: #{storage.backend[:id]}")
|
85
|
-
|
86
|
-
backend_object.info
|
87
|
-
storage.id = self.generate_occi_id(OCCI::Registry.get_by_id(storage.kind), backend_object['ID'].to_s)
|
88
|
-
|
89
|
-
storage_set_state(backend_object, storage)
|
90
|
-
end
|
91
|
-
|
92
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
93
|
-
def storage_set_state(backend_object, storage)
|
94
|
-
OCCI::Log.debug("current Image state is: #{backend_object.state_str}")
|
95
|
-
storage.links = []
|
96
|
-
case backend_object.state_str
|
97
|
-
when "READY", "USED", "LOCKED" then
|
98
|
-
storage.attributes!.occi!.storage!.state = "online"
|
99
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=offline',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#offline')
|
100
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=backup',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#backup')
|
101
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=snapshot',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot')
|
102
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=resize',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#resize')
|
103
|
-
when "ERROR" then
|
104
|
-
storage.attributes!.occi!.storage!.state = "degraded"
|
105
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=online',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#online')
|
106
|
-
else
|
107
|
-
storage.attributes!.occi!.storage!.state = "offline"
|
108
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=online',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#online')
|
109
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=backup',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#backup')
|
110
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=snapshot',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot')
|
111
|
-
storage.links << OCCI::Core::Link.new(:target=>storage.location + '?action=resize',:rel=>'http://schemas.ogf.org/occi/infrastructure/storage/action#resize')
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
116
|
-
def storage_delete(storage)
|
117
|
-
backend_object = Image.new(Image.build_xml(storage.backend.id), @one_client)
|
118
|
-
rc = backend_object.delete
|
119
|
-
check_rc(rc)
|
120
|
-
end
|
121
|
-
|
122
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
123
|
-
def storage_register_all_instances
|
124
|
-
occi_objects = []
|
125
|
-
backend_object_pool=ImagePool.new(@one_client, OCCI::Backend::OpenNebula::OpenNebula::INFO_ACL)
|
126
|
-
backend_object_pool.info
|
127
|
-
backend_object_pool.each { |backend_object| storage_parse_backend_object(backend_object) }
|
128
|
-
end
|
129
|
-
|
130
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
131
|
-
# STORAGE ACTIONS
|
132
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
133
|
-
|
134
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
135
|
-
def storage_action_dummy(storage, parameters)
|
136
|
-
end
|
137
|
-
|
138
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
139
|
-
# Action online
|
140
|
-
def storage_online(network, parameters)
|
141
|
-
backend_object = Image.new(Image.build_xml(network.backend.id), @one_client)
|
142
|
-
rc = backend_object.enable
|
143
|
-
check_rc(rc)
|
144
|
-
end
|
145
|
-
|
146
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
147
|
-
# Action offline
|
148
|
-
def storage_offline(network, parameters)
|
149
|
-
backend_object = Image.new(Image.build_xml(network.backend.id), @one_client)
|
150
|
-
rc = backend_object.disable
|
151
|
-
check_rc(rc)
|
152
|
-
end
|
153
|
-
|
154
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
155
|
-
# Action backup
|
156
|
-
def storage_backup(network, parameters)
|
157
|
-
OCCI::Log.debug("not yet implemented")
|
158
|
-
end
|
159
|
-
|
160
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
161
|
-
# Action snapshot
|
162
|
-
def storage_snapshot(network, parameters)
|
163
|
-
OCCI::Log.debug("not yet implemented")
|
164
|
-
end
|
165
|
-
|
166
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
167
|
-
# Action resize
|
168
|
-
def storage_resize(network, parameters)
|
169
|
-
OCCI::Log.debug("not yet implemented")
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|