deltacloud-core 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +63 -7
- data/bin/deltacloudd +29 -17
- data/config.ru +5 -3
- data/config/drivers/ec2.yaml +9 -0
- data/config/drivers/google.yaml +3 -0
- data/config/drivers/openstack.yaml +3 -0
- data/deltacloud-core.gemspec +1 -1
- data/lib/cimi/dependencies.rb +62 -0
- data/lib/cimi/helpers/cimi_helper.rb +50 -0
- data/lib/cimi/model.rb +52 -0
- data/lib/cimi/model/action.rb +24 -0
- data/lib/cimi/model/base.rb +249 -0
- data/lib/cimi/model/cloud_entry_point.rb +48 -0
- data/lib/cimi/model/entity_metadata.rb +83 -0
- data/lib/cimi/model/entity_metadata_collection.rb +31 -0
- data/lib/cimi/model/errors.rb +40 -0
- data/lib/cimi/model/machine.rb +227 -0
- data/lib/cimi/model/machine_admin.rb +59 -0
- data/lib/cimi/model/machine_admin_collection.rb +34 -0
- data/lib/cimi/model/machine_collection.rb +34 -0
- data/lib/cimi/model/machine_configuration.rb +67 -0
- data/lib/cimi/model/machine_configuration_collection.rb +34 -0
- data/lib/cimi/model/machine_image.rb +46 -0
- data/lib/cimi/model/machine_image_collection.rb +34 -0
- data/lib/cimi/model/machine_template.rb +41 -0
- data/lib/cimi/model/machine_template_collection.rb +34 -0
- data/lib/cimi/model/network.rb +69 -0
- data/lib/cimi/model/network_collection.rb +34 -0
- data/lib/cimi/model/network_configuration.rb +50 -0
- data/lib/cimi/model/network_configuration_collection.rb +34 -0
- data/lib/cimi/model/network_template.rb +26 -0
- data/lib/cimi/model/schema.rb +277 -0
- data/lib/cimi/model/volume.rb +103 -0
- data/lib/cimi/model/volume_collection.rb +34 -0
- data/lib/cimi/model/volume_configuration.rb +60 -0
- data/lib/cimi/model/volume_configuration_collection.rb +34 -0
- data/lib/cimi/model/volume_image.rb +49 -0
- data/lib/cimi/model/volume_image_collection.rb +34 -0
- data/lib/cimi/model/volume_template.rb +23 -0
- data/lib/cimi/model/volume_template_collection.rb +34 -0
- data/lib/cimi/server.rb +575 -0
- data/lib/deltacloud/base_driver/base_driver.rb +11 -1
- data/lib/deltacloud/core_ext.rb +2 -0
- data/lib/deltacloud/core_ext/array.rb +25 -0
- data/lib/deltacloud/core_ext/hash.rb +7 -0
- data/lib/deltacloud/core_ext/proc.rb +31 -0
- data/lib/deltacloud/core_ext/string.rb +15 -0
- data/lib/deltacloud/drivers/condor/condor_driver.rb +2 -1
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +32 -10
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
- data/lib/deltacloud/drivers/google/google_driver.rb +233 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +7 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +7 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +7 -2
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +82 -8
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +1 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +47 -0
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +8 -8
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +122 -49
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +42 -22
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -2
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +2 -2
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +25 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +35 -12
- data/lib/deltacloud/hardware_profile.rb +34 -10
- data/lib/deltacloud/helpers/application_helper.rb +3 -28
- data/lib/deltacloud/helpers/blob_stream.rb +2 -1
- data/lib/deltacloud/models.rb +2 -0
- data/lib/deltacloud/models/bucket.rb +1 -1
- data/lib/deltacloud/models/image.rb +1 -1
- data/lib/deltacloud/models/instance.rb +2 -1
- data/lib/deltacloud/models/instance_address.rb +56 -0
- data/lib/deltacloud/models/provider.rb +27 -0
- data/{server.rb → lib/deltacloud/server.rb} +72 -14
- data/lib/deltacloud/validation.rb +31 -10
- data/lib/sinatra/rabbit.rb +34 -26
- data/lib/sinatra/rack_accept.rb +5 -5
- data/lib/sinatra/rack_matrix_params.rb +6 -2
- data/lib/sinatra/rack_syslog.rb +3 -3
- data/lib/sinatra/static_assets.rb +1 -1
- data/lib/sinatra/url_for.rb +1 -7
- data/public/images/bread-bg.png +0 -0
- data/public/images/logo-wide.png +0 -0
- data/public/images/topbar-bg.png +0 -0
- data/public/javascripts/application.js +5 -0
- data/public/javascripts/cmwgapp.js +249 -0
- data/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +170 -0
- data/public/stylesheets/images/icons-18-black.png +0 -0
- data/public/stylesheets/images/icons-18-white.png +0 -0
- data/public/stylesheets/images/icons-36-black.png +0 -0
- data/public/stylesheets/images/icons-36-white.png +0 -0
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +12 -0
- data/public/stylesheets/new.css +4 -0
- data/support/fedora/deltacloud-core.init +20 -13
- data/tests/cimi/features/step_definitions/common_steps.rb +59 -0
- data/tests/cimi/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/cimi/features/step_definitions/machines_steps.rb +99 -0
- data/tests/cimi/features/step_definitions/volumes_steps.rb +115 -0
- data/tests/cimi/features/support/env.rb +53 -0
- data/tests/common.rb +89 -11
- data/tests/core_ext/string.rb +31 -0
- data/tests/drivers/google/api_test.rb +35 -0
- data/tests/drivers/google/buckets_test.rb +116 -0
- data/tests/drivers/google/setup.rb +38 -0
- data/tests/drivers/mock/instances_test.rb +20 -5
- data/tests/drivers/openstack/api_test.rb +41 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +53 -0
- data/tests/drivers/openstack/images_test.rb +40 -0
- data/tests/drivers/openstack/instances_test.rb +163 -0
- data/tests/drivers/openstack/realms_test.rb +36 -0
- data/tests/drivers/openstack/setup.rb +20 -0
- data/tests/drivers/rackspace/buckets_test.rb +145 -0
- data/tests/drivers/rackspace/setup.rb +3 -3
- data/tests/drivers/rhevm/api_test.rb +1 -1
- data/tests/drivers/rhevm/images_test.rb +2 -2
- data/tests/drivers/rhevm/instances_test.rb +10 -12
- data/tests/drivers/rhevm/realms_test.rb +4 -4
- data/tests/drivers/rhevm/setup.rb +3 -3
- data/tests/rabbit_test.rb +1 -1
- data/views/api/show.html.haml +13 -0
- data/views/cimi/cloudEntryPoint/index.html.haml +5 -0
- data/views/cimi/cloudEntryPoint/index.xml.haml +9 -0
- data/views/cimi/collection/index.html.haml +45 -0
- data/views/cimi/collection/response.xml.haml +3 -0
- data/views/cimi/error.html.haml +31 -0
- data/views/cimi/errors/400.html.haml +41 -0
- data/views/cimi/errors/400.xml.haml +3 -0
- data/views/cimi/errors/401.html.haml +41 -0
- data/views/cimi/errors/401.xml.haml +2 -0
- data/views/cimi/errors/403.html.haml +42 -0
- data/views/cimi/errors/403.xml.haml +2 -0
- data/views/cimi/errors/404.html.haml +29 -0
- data/views/cimi/errors/404.xml.haml +2 -0
- data/views/cimi/errors/405.html.haml +29 -0
- data/views/cimi/errors/405.xml.haml +5 -0
- data/views/cimi/errors/500.html.haml +43 -0
- data/views/cimi/errors/500.xml.haml +6 -0
- data/views/cimi/errors/502.html.haml +43 -0
- data/views/cimi/errors/502.xml.haml +7 -0
- data/views/cimi/errors/backend_capability_failure.html.haml +29 -0
- data/views/cimi/layout.html.haml +32 -0
- data/views/cimi/machine_configurations/show.html.haml +159 -0
- data/views/cimi/machine_configurations/show.xml.haml +27 -0
- data/views/cimi/machine_images/show.html.haml +79 -0
- data/views/cimi/machine_images/show.xml.haml +17 -0
- data/views/cimi/machines/show.html.haml +177 -0
- data/views/cimi/machines/show.xml.haml +28 -0
- data/views/cimi/volumes/show.html.haml +68 -0
- data/views/cimi/volumes/show.xml.haml +17 -0
- data/views/drivers/show.html.haml +10 -5
- data/views/drivers/show.xml.haml +9 -4
- data/views/error.html.haml +2 -2
- data/views/errors/500.xml.haml +7 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +19 -16
- data/views/instances/show.html.haml +7 -2
- data/views/instances/show.xml.haml +8 -7
- data/views/layout.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +1 -1
- metadata +296 -204
- data/public/javascripts/jquery.mobile-1.0b1.min.js +0 -146
- data/public/stylesheets/jquery.mobile-1.0b1.min.css +0 -8
@@ -0,0 +1,227 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. 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, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
require 'deltacloud/models/instance_address'
|
17
|
+
|
18
|
+
class CIMI::Model::Machine < CIMI::Model::Base
|
19
|
+
|
20
|
+
text :state
|
21
|
+
text :cpu
|
22
|
+
|
23
|
+
struct :memory do
|
24
|
+
scalar :quantity
|
25
|
+
scalar :units
|
26
|
+
end
|
27
|
+
|
28
|
+
href :event_log
|
29
|
+
|
30
|
+
array :disks do
|
31
|
+
struct :capacity do
|
32
|
+
scalar :quantity
|
33
|
+
scalar :units
|
34
|
+
end
|
35
|
+
scalar :format
|
36
|
+
scalar :attachment_point
|
37
|
+
end
|
38
|
+
|
39
|
+
array :volumes do
|
40
|
+
scalar :href
|
41
|
+
scalar :protocol
|
42
|
+
scalar :attachment_point
|
43
|
+
end
|
44
|
+
|
45
|
+
array :network_interfaces do
|
46
|
+
href :vsp
|
47
|
+
text :hostname, :mac_address, :state, :protocol, :allocation
|
48
|
+
text :address, :default_gateway, :dns, :max_transmission_unit
|
49
|
+
end
|
50
|
+
|
51
|
+
array :meters do
|
52
|
+
scalar :href
|
53
|
+
end
|
54
|
+
|
55
|
+
array :operations do
|
56
|
+
scalar :rel, :href
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.find(id, context)
|
60
|
+
instances = []
|
61
|
+
if id == :all
|
62
|
+
instances = context.driver.instances(context.credentials)
|
63
|
+
instances.map { |instance| from_instance(instance, context) }.compact
|
64
|
+
else
|
65
|
+
instance = context.driver.instance(context.credentials, :id => id)
|
66
|
+
raise CIMI::Model::NotFound unless instance
|
67
|
+
from_instance(instance, context)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.create_from_json(body, context)
|
72
|
+
json = JSON.parse(body)
|
73
|
+
hardware_profile_id = xml['machineTemplate']['machineConfig']["href"].split('/').last
|
74
|
+
image_id = xml['machineTemplate']['machineImage']["href"].split('/').last
|
75
|
+
instance = context.create_instance(context.credentials, image_id, { :hwp_id => hardware_profile_id })
|
76
|
+
from_instance(instance, context)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.create_from_xml(body, context)
|
80
|
+
xml = XmlSimple.xml_in(body)
|
81
|
+
machine_template = xml['machineTemplate'][0]
|
82
|
+
hardware_profile_id = machine_template['machineConfig'][0]["href"].split('/').last
|
83
|
+
image_id = machine_template['machineImage'][0]["href"].split('/').last
|
84
|
+
additional_params = {}
|
85
|
+
if machine_template.has_key? 'machineAdmin'
|
86
|
+
additional_params[:keyname] = machine_template['machineAdmin'][0]["href"].split('/').last
|
87
|
+
end
|
88
|
+
instance = context.driver.create_instance(context.credentials, image_id, {
|
89
|
+
:hwp_id => hardware_profile_id
|
90
|
+
}.merge(additional_params))
|
91
|
+
from_instance(instance, context)
|
92
|
+
end
|
93
|
+
|
94
|
+
def perform(action, context, &block)
|
95
|
+
begin
|
96
|
+
if context.driver.send(:"#{action.name}_instance", context.credentials, self.name)
|
97
|
+
block.callback :success
|
98
|
+
else
|
99
|
+
raise "Operation failed to execute on given Machine"
|
100
|
+
end
|
101
|
+
rescue => e
|
102
|
+
block.callback :failure, e.message
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.delete!(id, context)
|
107
|
+
context.driver.destroy_instance(context.credentials, id)
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.create_entity_metadata(context)
|
111
|
+
cimi_entity = self.name.split("::").last
|
112
|
+
metadata = EntityMetadata.metadata_from_deltacloud_features(cimi_entity, :instances, context)
|
113
|
+
unless metadata.includes_attribute?(:name)
|
114
|
+
metadata.attributes << {:name=>"name", :required=>"false",
|
115
|
+
:constraints=>"Determined by the cloud provider", :type=>"xs:string"}
|
116
|
+
end
|
117
|
+
metadata
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.attach_volumes(volumes, context)
|
121
|
+
volumes.each do |vol|
|
122
|
+
context.driver.attach_storage_volume(context.credentials,
|
123
|
+
{:id=>vol[:volume].name, :instance_id=>context.params[:id], :device=>vol[:attachment_point]})
|
124
|
+
end
|
125
|
+
self.find(context.params[:id], context)
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.detach_volumes(volumes, context)
|
129
|
+
volumes.each do |vol|
|
130
|
+
context.driver.detach_storage_volume(context.credentials, {:id=>vol[:volume].name, :instance_id => context.params[:id]})
|
131
|
+
end
|
132
|
+
self.find(context.params[:id], context)
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def self.from_instance(instance, context)
|
138
|
+
self.new(
|
139
|
+
:name => instance.id,
|
140
|
+
:description => instance.name,
|
141
|
+
:created => instance.launch_time,
|
142
|
+
:uri => context.machine_url(instance.id),
|
143
|
+
:state => convert_instance_state(instance.state),
|
144
|
+
:cpu => convert_instance_cpu(instance.instance_profile, context),
|
145
|
+
:memory => convert_instance_memory(instance.instance_profile, context),
|
146
|
+
:disks => convert_instance_storage(instance.instance_profile, context),
|
147
|
+
:network_interfaces => convert_instance_addresses(instance),
|
148
|
+
:operations => convert_instance_actions(instance, context),
|
149
|
+
:volumes=>convert_storage_volumes(instance, context),
|
150
|
+
:property => convert_instance_properties(instance, context)
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# FIXME: This will convert 'RUNNING' state to 'STARTED'
|
155
|
+
# which is defined in CIMI (p65)
|
156
|
+
#
|
157
|
+
def self.convert_instance_state(state)
|
158
|
+
('RUNNING' == state) ? 'STARTED' : state
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.convert_instance_properties(instance, context)
|
162
|
+
properties = []
|
163
|
+
properties << { :name => :machine_image, :value => context.machine_image_url(instance.image_id) }
|
164
|
+
if instance.respond_to? :keyname
|
165
|
+
properties << { :name => :machine_admin, :value => context.machine_admin_url(instance.keyname) }
|
166
|
+
end
|
167
|
+
properties
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.convert_instance_cpu(profile, context)
|
171
|
+
cpu_override = profile.overrides.find { |p, v| p == :cpu }
|
172
|
+
if cpu_override.nil?
|
173
|
+
MachineConfiguration.find(profile.id, context).cpu
|
174
|
+
else
|
175
|
+
cpu_override[1]
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.convert_instance_memory(profile, context)
|
180
|
+
machine_conf = MachineConfiguration.find(profile.name, context)
|
181
|
+
memory_override = profile.overrides.find { |p, v| p == :memory }
|
182
|
+
{
|
183
|
+
:quantity => memory_override.nil? ? machine_conf.memory[:quantity] : memory_override[1],
|
184
|
+
:units => machine_conf.memory[:units]
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.convert_instance_storage(profile, context)
|
189
|
+
machine_conf = MachineConfiguration.find(profile.name, context)
|
190
|
+
storage_override = profile.overrides.find { |p, v| p == :storage }
|
191
|
+
[
|
192
|
+
{ :capacity => {
|
193
|
+
:quantity => storage_override.nil? ? machine_conf.disks.first[:capacity][:quantity] : storage_override[1],
|
194
|
+
:units => machine_conf.disks.first[:capacity][:units]
|
195
|
+
}
|
196
|
+
}
|
197
|
+
]
|
198
|
+
end
|
199
|
+
|
200
|
+
def self.convert_instance_addresses(instance)
|
201
|
+
(instance.public_addresses + instance.private_addresses).collect do |address|
|
202
|
+
{
|
203
|
+
:hostname => address.is_hostname? ? address : nil,
|
204
|
+
:mac_address => address.is_mac? ? address : nil,
|
205
|
+
:state => 'Active',
|
206
|
+
:protocol => 'IPv4',
|
207
|
+
:address => address.is_ipv4? ? address : nil,
|
208
|
+
:allocation => 'Static'
|
209
|
+
}
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def self.convert_instance_actions(instance, context)
|
214
|
+
instance.actions.collect do |action|
|
215
|
+
action = :destroy if action == :delete # In CIMI destroy operation become delete
|
216
|
+
action = :restart if action == :reboot # In CIMI reboot operation become restart
|
217
|
+
{ :href => context.send(:"#{action}_machine_url", instance.id), :rel => "http://www.dmtf.org/cimi/action/#{action}" }
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def self.convert_storage_volumes(instance, context)
|
222
|
+
instance.storage_volumes ||= [] #deal with nilpointers
|
223
|
+
instance.storage_volumes.map{|vol| {:href=>context.volume_url(vol.keys.first),
|
224
|
+
:attachment_point=>vol.values.first} }
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. 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, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::MachineAdmin < CIMI::Model::Base
|
17
|
+
|
18
|
+
text :username
|
19
|
+
text :password
|
20
|
+
text :key
|
21
|
+
|
22
|
+
array :operations do
|
23
|
+
scalar :rel, :href
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.find(id, context)
|
27
|
+
if id == :all
|
28
|
+
keys = context.driver.keys(context.credentials)
|
29
|
+
keys.map { |key| from_key(key, context) }
|
30
|
+
else
|
31
|
+
key = context.driver.key(context.credentials, :id => id)
|
32
|
+
from_key(key, context)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.create_from_xml(body, context)
|
37
|
+
machine_admin = MachineAdmin.from_xml(body)
|
38
|
+
key = context.driver.create_key(context.credentials, :key_name => machine_admin.name)
|
39
|
+
from_key(key, context)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.delete!(id, context)
|
43
|
+
context.driver.destroy_key(context.credentials, :id => id)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def self.from_key(key, context)
|
49
|
+
self.new(
|
50
|
+
:name => key.id,
|
51
|
+
:username => key.username,
|
52
|
+
:password => key.is_password? ? key.password : key.fingerprint,
|
53
|
+
:key => key.is_key? ? key.pem_rsa_key : nil,
|
54
|
+
:uri => context.machine_admin_url(key.id),
|
55
|
+
:created => Time.now
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. 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, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::MachineAdminCollection < CIMI::Model::Base
|
17
|
+
|
18
|
+
act_as_root_entity :machine_admin
|
19
|
+
|
20
|
+
array :machine_admins do
|
21
|
+
scalar :href
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default(context)
|
25
|
+
self.new(
|
26
|
+
:uri => context.machine_admins_url,
|
27
|
+
:name => 'default',
|
28
|
+
:created => Time.now,
|
29
|
+
:description => "#{context.driver.name.capitalize} MachineAdminCollection",
|
30
|
+
:machine_admins => MachineAdmin.all_uri(context)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. 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, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::MachineCollection < CIMI::Model::Base
|
17
|
+
|
18
|
+
act_as_root_entity :machine
|
19
|
+
|
20
|
+
array :machines do
|
21
|
+
scalar :href
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default(context)
|
25
|
+
self.new(
|
26
|
+
:uri => context.machines_url,
|
27
|
+
:name => 'default',
|
28
|
+
:created => Time.now,
|
29
|
+
:description => "#{context.driver.name.capitalize} MachineCollection",
|
30
|
+
:machines => Machine.all_uri(context)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. 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, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::MachineConfiguration < CIMI::Model::Base
|
17
|
+
|
18
|
+
struct :memory do
|
19
|
+
scalar :quantity
|
20
|
+
scalar :units
|
21
|
+
end
|
22
|
+
|
23
|
+
text :cpu
|
24
|
+
|
25
|
+
array :disks do
|
26
|
+
struct :capacity do
|
27
|
+
scalar :quantity
|
28
|
+
scalar :units
|
29
|
+
end
|
30
|
+
scalar :format
|
31
|
+
scalar :attachment_point
|
32
|
+
end
|
33
|
+
|
34
|
+
array :operations do
|
35
|
+
scalar :rel, :href
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.find(id, context)
|
39
|
+
profiles = []
|
40
|
+
if id == :all
|
41
|
+
profiles = context.driver.hardware_profiles(context.credentials)
|
42
|
+
profiles.map { |profile| from_hardware_profile(profile, context) }.compact
|
43
|
+
else
|
44
|
+
profile = context.driver.hardware_profile(context.credentials, id)
|
45
|
+
from_hardware_profile(profile, context)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def self.from_hardware_profile(profile, context)
|
52
|
+
# We accept just profiles with all properties set
|
53
|
+
return unless profile.memory or profile.cpu or profile.storage
|
54
|
+
machine_hash = {
|
55
|
+
:name => profile.name,
|
56
|
+
:description => "Machine Configuration with #{profile.memory.value} #{profile.memory.unit} "+
|
57
|
+
"of memory and #{profile.cpu.value} CPU",
|
58
|
+
:cpu => profile.cpu.value,
|
59
|
+
:created => Time.now.to_s, # FIXME: DC hardware_profile has no mention about created_at
|
60
|
+
:memory => { :quantity => profile.memory.value, :units => profile.memory.unit },
|
61
|
+
:disks => [ { :capacity => { :quantity => profile.storage.value, :units => profile.storage.unit } } ],
|
62
|
+
:uri => context.machine_configuration_url(profile.name)
|
63
|
+
}
|
64
|
+
self.new(machine_hash)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. 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, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::MachineConfigurationCollection < CIMI::Model::Base
|
17
|
+
|
18
|
+
act_as_root_entity :machine_configuration
|
19
|
+
|
20
|
+
array :machine_configurations do
|
21
|
+
scalar :href
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default(context)
|
25
|
+
self.new(
|
26
|
+
:uri => context.machine_configurations_url,
|
27
|
+
:name => 'default',
|
28
|
+
:created => Time.now,
|
29
|
+
:description => "#{context.driver.name.capitalize} MachineConfigurationCollection",
|
30
|
+
:machine_configurations => MachineConfiguration.all_uri(context)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|