deltacloud-core 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/bin/deltacloudd +11 -5
- data/config.ru +3 -3
- data/deltacloud-core.gemspec +24 -18
- data/lib/cimi/collections/address_templates.rb +3 -3
- data/lib/cimi/collections/addresses.rb +6 -5
- data/lib/cimi/collections/entity_metadata.rb +0 -2
- data/lib/cimi/collections/machine_admins.rb +5 -5
- data/lib/cimi/collections/machine_configurations.rb +2 -2
- data/lib/cimi/collections/machine_images.rb +3 -3
- data/lib/cimi/collections/machines.rb +32 -10
- data/lib/cimi/collections/network_configurations.rb +4 -3
- data/lib/cimi/collections/network_templates.rb +4 -3
- data/lib/cimi/collections/networks.rb +8 -8
- data/lib/cimi/collections/routing_group_templates.rb +4 -3
- data/lib/cimi/collections/routing_groups.rb +4 -3
- data/lib/cimi/collections/volume_configurations.rb +3 -3
- data/lib/cimi/collections/volume_images.rb +3 -3
- data/lib/cimi/collections/volumes.rb +4 -3
- data/lib/cimi/collections/vsp_configurations.rb +4 -3
- data/lib/cimi/collections/vsp_templates.rb +4 -3
- data/lib/cimi/collections/vsps.rb +8 -7
- data/lib/cimi/helpers.rb +1 -1
- data/lib/cimi/helpers/cimi_helper.rb +11 -1
- data/lib/cimi/models.rb +4 -0
- data/lib/cimi/models/base.rb +11 -1
- data/lib/cimi/models/cloud_entry_point.rb +7 -14
- data/lib/cimi/models/disk.rb +40 -0
- data/lib/cimi/models/disk_collection.rb +38 -0
- data/lib/cimi/models/machine.rb +9 -43
- data/lib/cimi/models/machine_collection.rb +7 -4
- data/lib/cimi/models/machine_configuration.rb +8 -15
- data/lib/cimi/models/machine_configuration_collection.rb +6 -4
- data/lib/cimi/models/machine_image_collection.rb +6 -4
- data/lib/cimi/models/machine_template_collection.rb +6 -4
- data/lib/cimi/models/machine_volume.rb +42 -0
- data/lib/cimi/models/machine_volume_collection.rb +34 -0
- data/lib/cimi/models/network.rb +5 -9
- data/lib/cimi/models/network_collection.rb +6 -5
- data/lib/cimi/models/schema.rb +20 -0
- data/lib/cimi/models/volume_collection.rb +6 -4
- data/lib/cimi/models/volume_configuration_collection.rb +6 -4
- data/lib/cimi/models/volume_image_collection.rb +6 -4
- data/lib/cimi/models/volume_template_collection.rb +6 -4
- data/lib/deltacloud/api.rb +3 -3
- data/lib/deltacloud/collections/addresses.rb +1 -1
- data/lib/deltacloud/collections/firewalls.rb +4 -2
- data/lib/deltacloud/collections/keys.rb +1 -1
- data/lib/deltacloud/collections/load_balancers.rb +1 -1
- data/lib/deltacloud/collections/storage_volumes.rb +4 -4
- data/lib/deltacloud/drivers/base_driver.rb +12 -20
- data/lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb +294 -0
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +38 -6
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +4 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +40 -4
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +8 -7
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +422 -416
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +30 -16
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +1 -0
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +3 -9
- data/lib/deltacloud/helpers/deltacloud_helper.rb +0 -2
- data/lib/deltacloud/models/firewall_rule.rb +2 -0
- data/lib/deltacloud/models/hardware_profile.rb +61 -59
- data/{tests/deprecated/core_ext/string.rb → lib/deltacloud/version.rb} +3 -15
- data/lib/deltacloud_rack.rb +1 -0
- data/lib/ec2/server.rb +5 -3
- data/lib/sinatra/rack_accept.rb +53 -53
- data/lib/sinatra/rack_etag.rb +1 -1
- data/tests/cimi/collections/cloud_entry_point_test.rb +11 -2
- data/tests/deltacloud/common.rb +1 -1
- data/tests/deltacloud/rack_test.rb +3 -3
- data/tests/drivers/base/base_driver_test.rb +6 -2
- data/tests/drivers/base/common.rb +1 -0
- data/tests/drivers/base/library_test.rb +6 -2
- data/tests/drivers/ec2/common.rb +34 -15
- data/tests/drivers/ec2/images_test.rb +2 -3
- data/tests/drivers/ec2/instance_test.rb +12 -2
- data/tests/drivers/ec2/keys_test.rb +2 -2
- data/tests/drivers/ec2/realms_test.rb +7 -3
- data/tests/drivers/ec2/storage_snapshots_test.rb +2 -3
- data/tests/drivers/gogrid/common.rb +24 -0
- data/tests/drivers/gogrid/hardware_profiles_test.rb +51 -0
- data/tests/drivers/gogrid/images_test.rb +57 -0
- data/tests/drivers/gogrid/instances_test.rb +92 -0
- data/tests/drivers/gogrid/realms_test.rb +45 -0
- data/tests/drivers/google/buckets_test.rb +105 -0
- data/tests/drivers/google/common.rb +20 -0
- data/tests/drivers/mock/common.rb +1 -0
- data/tests/drivers/mock/images_test.rb +3 -2
- data/tests/drivers/mock/instances_test.rb +3 -2
- data/tests/drivers/mock/keys_test.rb +3 -2
- data/tests/drivers/mock/realms_test.rb +3 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +3 -2
- data/tests/drivers/mock/storage_volumes_test.rb +3 -2
- data/tests/drivers/models/address_test.rb +3 -3
- data/tests/drivers/models/base_test.rb +4 -2
- data/tests/drivers/models/blob_test.rb +3 -3
- data/tests/drivers/models/common.rb +3 -0
- data/tests/drivers/models/hardware_profile_test.rb +5 -4
- data/tests/drivers/models/instance_address_test.rb +3 -3
- data/tests/drivers/models/instance_profile_test.rb +3 -3
- data/tests/drivers/models/instance_test.rb +3 -3
- data/tests/drivers/models/keys_test.rb +3 -3
- data/tests/drivers/models/metrics_test.rb +3 -3
- data/tests/drivers/openstack/common.rb +26 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +46 -0
- data/tests/drivers/openstack/images_test.rb +50 -0
- data/tests/drivers/openstack/instances_test.rb +66 -0
- data/tests/drivers/openstack/keys_test.rb +61 -0
- data/tests/drivers/openstack/realms_test.rb +46 -0
- data/tests/drivers/rhevm/common.rb +2 -0
- data/tests/drivers/rhevm/images_test.rb +3 -4
- data/tests/drivers/rhevm/instance_test.rb +2 -2
- data/tests/drivers/rhevm/provider_test.rb +2 -2
- data/tests/drivers/rhevm/realms_test.rb +2 -3
- data/tests/ec2/common.rb +5 -4
- data/tests/ec2/server_test.rb +3 -2
- data/tests/helpers/rack/common.rb +3 -0
- data/tests/helpers/rack/rack_accept_test.rb +65 -0
- data/tests/helpers/rack/rack_date_test.rb +27 -0
- data/tests/helpers/rack/rack_driver_select_test.rb +53 -0
- data/tests/helpers/rack/rack_etag_test.rb +29 -0
- data/tests/helpers/rack/rack_matrix_params_test.rb +72 -0
- data/tests/test_helper.rb +44 -36
- data/views/hardware_profiles/index.html.haml +1 -1
- data/views/hardware_profiles/show.html.haml +2 -2
- data/views/hardware_profiles/show.xml.haml +2 -1
- data/views/images/show.html.haml +6 -5
- metadata +74 -117
- data/tests/deprecated/api/common.rb +0 -1
- data/tests/deprecated/api/driver_test.rb +0 -79
- data/tests/deprecated/api/library_test.rb +0 -6
- data/tests/deprecated/cimi/features/step_definitions/common_steps.rb +0 -59
- data/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/deprecated/cimi/features/step_definitions/machines_steps.rb +0 -100
- data/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb +0 -115
- data/tests/deprecated/cimi/features/support/env.rb +0 -75
- data/tests/deprecated/common.rb +0 -279
- data/tests/deprecated/drivers/ec2/api_test.rb +0 -19
- data/tests/deprecated/drivers/ec2/common.rb +0 -23
- data/tests/deprecated/drivers/ec2/drivers_test.rb +0 -120
- data/tests/deprecated/drivers/ec2/hardware_profiles_test.rb +0 -224
- data/tests/deprecated/drivers/ec2/images_test.rb +0 -230
- data/tests/deprecated/drivers/ec2/instances_test.rb +0 -356
- data/tests/deprecated/drivers/ec2/keys_test.rb +0 -181
- data/tests/deprecated/drivers/ec2/realms_test.rb +0 -146
- data/tests/deprecated/drivers/fgcp/api_test.rb +0 -47
- data/tests/deprecated/drivers/fgcp/hardware_profiles_test.rb +0 -54
- data/tests/deprecated/drivers/fgcp/realms_test.rb +0 -42
- data/tests/deprecated/drivers/fgcp/setup.rb +0 -13
- data/tests/deprecated/drivers/google/api_test.rb +0 -19
- data/tests/deprecated/drivers/google/buckets_test.rb +0 -100
- data/tests/deprecated/drivers/google/common.rb +0 -54
- data/tests/deprecated/drivers/mock/api_test.rb +0 -10
- data/tests/deprecated/drivers/mock/buckets_test.rb +0 -195
- data/tests/deprecated/drivers/mock/common.rb +0 -7
- data/tests/deprecated/drivers/mock/drivers_test.rb +0 -123
- data/tests/deprecated/drivers/mock/hardware_profiles_test.rb +0 -224
- data/tests/deprecated/drivers/mock/images_test.rb +0 -197
- data/tests/deprecated/drivers/mock/instances_test.rb +0 -343
- data/tests/deprecated/drivers/mock/keys_test.rb +0 -161
- data/tests/deprecated/drivers/mock/realms_test.rb +0 -132
- data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +0 -114
- data/tests/deprecated/drivers/mock/storage_volumes_test.rb +0 -122
- data/tests/deprecated/drivers/openstack/api_test.rb +0 -46
- data/tests/deprecated/drivers/openstack/common.rb +0 -21
- data/tests/deprecated/drivers/openstack/hardware_profiles_test.rb +0 -64
- data/tests/deprecated/drivers/openstack/images_test.rb +0 -46
- data/tests/deprecated/drivers/openstack/instances_test.rb +0 -208
- data/tests/deprecated/drivers/openstack/realms_test.rb +0 -40
- data/tests/deprecated/drivers/rackspace/api_test.rb +0 -46
- data/tests/deprecated/drivers/rackspace/buckets_test.rb +0 -150
- data/tests/deprecated/drivers/rackspace/common.rb +0 -16
- data/tests/deprecated/drivers/rackspace/hardware_profiles_test.rb +0 -58
- data/tests/deprecated/drivers/rackspace/images_test.rb +0 -45
- data/tests/deprecated/drivers/rackspace/instances_test.rb +0 -166
- data/tests/deprecated/drivers/rackspace/realms_test.rb +0 -41
- data/tests/deprecated/drivers/rhevm/api_test.rb +0 -45
- data/tests/deprecated/drivers/rhevm/common.rb +0 -21
- data/tests/deprecated/drivers/rhevm/hardware_profiles_test.rb +0 -58
- data/tests/deprecated/drivers/rhevm/images_test.rb +0 -48
- data/tests/deprecated/drivers/rhevm/instances_test.rb +0 -182
- data/tests/deprecated/drivers/rhevm/realms_test.rb +0 -40
- data/tests/deprecated/minitest_common.rb +0 -58
- data/tests/deprecated/minitest_common_api_test.rb +0 -115
- data/tests/deprecated/rabbit_test.rb +0 -52
@@ -0,0 +1,38 @@
|
|
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
|
+
class CIMI::Model::DiskCollection < CIMI::Model::Base
|
16
|
+
text :count
|
17
|
+
|
18
|
+
#add disks array:
|
19
|
+
self.schema.add_collection_member_array(CIMI::Model::Disk)
|
20
|
+
|
21
|
+
array :operations do
|
22
|
+
scalar :rel, :href
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.default(instance_id, context)
|
26
|
+
instance = context.driver.instance(context.credentials, :id=>instance_id)
|
27
|
+
machine_conf = CIMI::Model::MachineConfiguration.find(instance.instance_profile.name, context)
|
28
|
+
disks = CIMI::Model::Disk.find(instance, machine_conf, context, :all)
|
29
|
+
storage_override = instance.instance_profile.overrides.find { |p, v| p == :storage }
|
30
|
+
self.new(
|
31
|
+
:id => context.machine_url(instance_id)+"/disks",
|
32
|
+
:description => "DiskCollection for Machine #{instance_id}",
|
33
|
+
:created => instance.launch_time,
|
34
|
+
:count => disks.size,
|
35
|
+
:disks => disks
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
data/lib/cimi/models/machine.rb
CHANGED
@@ -18,33 +18,15 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
18
18
|
text :state
|
19
19
|
text :cpu
|
20
20
|
|
21
|
-
|
22
|
-
scalar :quantity
|
23
|
-
scalar :units
|
24
|
-
end
|
21
|
+
text :memory
|
25
22
|
|
26
23
|
href :event_log
|
27
24
|
|
28
|
-
|
29
|
-
struct :capacity do
|
30
|
-
scalar :quantity
|
31
|
-
scalar :units
|
32
|
-
end
|
33
|
-
scalar :format
|
34
|
-
scalar :attachment_point
|
35
|
-
end
|
25
|
+
href :disks
|
36
26
|
|
37
|
-
|
38
|
-
scalar :href
|
39
|
-
scalar :protocol
|
40
|
-
scalar :attachment_point
|
41
|
-
end
|
27
|
+
href :volumes
|
42
28
|
|
43
|
-
|
44
|
-
href :vsp
|
45
|
-
text :hostname, :mac_address, :state, :protocol, :allocation
|
46
|
-
text :address, :default_gateway, :dns, :max_transmission_unit
|
47
|
-
end
|
29
|
+
href :network_interfaces
|
48
30
|
|
49
31
|
array :meters do
|
50
32
|
scalar :href
|
@@ -133,7 +115,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
133
115
|
|
134
116
|
private
|
135
117
|
def self.from_instance(instance, context)
|
136
|
-
cpu = memory =
|
118
|
+
cpu = memory = (instance.instance_profile.id == "opaque")? "n/a" : nil
|
137
119
|
self.new(
|
138
120
|
:name => instance.id,
|
139
121
|
:description => instance.name,
|
@@ -142,10 +124,10 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
142
124
|
:state => convert_instance_state(instance.state),
|
143
125
|
:cpu => cpu || convert_instance_cpu(instance.instance_profile, context),
|
144
126
|
:memory => memory || convert_instance_memory(instance.instance_profile, context),
|
145
|
-
:disks =>
|
146
|
-
:network_interfaces =>
|
127
|
+
:disks => {:href => context.machine_url(instance.id)+"/disks"},
|
128
|
+
:network_interfaces => {:href => context.machine_url(instance.id+"/network_interfaces")},
|
147
129
|
:operations => convert_instance_actions(instance, context),
|
148
|
-
:volumes=>
|
130
|
+
:volumes=>{:href=>context.machine_url(instance.id)+"/volumes"},
|
149
131
|
:property => convert_instance_properties(instance, context)
|
150
132
|
)
|
151
133
|
end
|
@@ -178,23 +160,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
178
160
|
def self.convert_instance_memory(profile, context)
|
179
161
|
machine_conf = CIMI::Model::MachineConfiguration.find(profile.name, context)
|
180
162
|
memory_override = profile.overrides.find { |p, v| p == :memory }
|
181
|
-
|
182
|
-
:quantity => memory_override.nil? ? machine_conf.memory[:quantity] : memory_override[1],
|
183
|
-
:units => machine_conf.memory[:units]
|
184
|
-
}
|
185
|
-
end
|
186
|
-
|
187
|
-
def self.convert_instance_storage(profile, context)
|
188
|
-
machine_conf = CIMI::Model::MachineConfiguration.find(profile.name, context)
|
189
|
-
return nil unless machine_conf.disks
|
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
|
-
]
|
163
|
+
memory_override.nil? ? machine_conf.memory : context.to_kibibyte(memory_override[1].to_i,"MB")
|
198
164
|
end
|
199
165
|
|
200
166
|
def self.convert_instance_addresses(instance)
|
@@ -17,17 +17,20 @@ class CIMI::Model::MachineCollection < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
act_as_root_entity :machine
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
text :count
|
21
|
+
|
22
|
+
#add machines array:
|
23
|
+
self.schema.add_collection_member_array(CIMI::Model::Machine)
|
23
24
|
|
24
25
|
def self.default(context)
|
26
|
+
machines = CIMI::Model::Machine.all(context)
|
25
27
|
self.new(
|
26
28
|
:id => context.machines_url,
|
27
29
|
:name => 'default',
|
28
30
|
:created => Time.now,
|
29
31
|
:description => "#{context.driver.name.capitalize} MachineCollection",
|
30
|
-
:
|
32
|
+
:count => machines.size,
|
33
|
+
:machines => machines
|
31
34
|
)
|
32
35
|
end
|
33
36
|
|
@@ -15,20 +15,13 @@
|
|
15
15
|
|
16
16
|
class CIMI::Model::MachineConfiguration < CIMI::Model::Base
|
17
17
|
|
18
|
-
|
19
|
-
scalar :quantity
|
20
|
-
scalar :units
|
21
|
-
end
|
22
|
-
|
18
|
+
text :memory
|
23
19
|
text :cpu
|
24
20
|
|
25
21
|
array :disks do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
scalar :format
|
31
|
-
scalar :attachment_point
|
22
|
+
text :capacity
|
23
|
+
text :format
|
24
|
+
text :attachment_point
|
32
25
|
end
|
33
26
|
|
34
27
|
array :operations do
|
@@ -51,17 +44,17 @@ class CIMI::Model::MachineConfiguration < CIMI::Model::Base
|
|
51
44
|
def self.from_hardware_profile(profile, context)
|
52
45
|
# We accept just profiles with all properties set
|
53
46
|
return unless profile.memory or profile.cpu or profile.storage
|
54
|
-
memory = profile.memory.value || profile.memory.default
|
47
|
+
memory = profile.memory ? context.to_kibibyte((profile.memory.value || profile.memory.default), profile.memory.unit) : nil
|
55
48
|
cpu = (profile.cpu ? (profile.cpu.value || profile.cpu.default) : nil )
|
56
|
-
storage =
|
49
|
+
storage = profile.storage ? context.to_kibibyte((profile.storage.value || profile.storage.default), profile.storage.unit) : nil
|
57
50
|
machine_hash = {
|
58
51
|
:name => profile.name,
|
59
52
|
:description => "Machine Configuration with #{memory} #{profile.memory.unit} "+
|
60
53
|
"of memory and #{cpu} CPU",
|
61
54
|
:cpu => ( cpu if cpu ) ,
|
62
55
|
:created => Time.now.to_s, # FIXME: DC hardware_profile has no mention about created_at
|
63
|
-
:memory =>
|
64
|
-
:disks => ( [ { :capacity =>
|
56
|
+
:memory => (memory if memory),
|
57
|
+
:disks => ( [ { :capacity => storage } ] if storage ),
|
65
58
|
:id => context.machine_configuration_url(profile.name)
|
66
59
|
}
|
67
60
|
self.new(machine_hash)
|
@@ -17,17 +17,19 @@ class CIMI::Model::MachineConfigurationCollection < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
act_as_root_entity :machine_configuration
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
text :count
|
21
|
+
|
22
|
+
self.schema.add_collection_member_array(CIMI::Model::MachineConfiguration)
|
23
23
|
|
24
24
|
def self.default(context)
|
25
|
+
machine_configurations = CIMI::Model::MachineConfiguration.all(context)
|
25
26
|
self.new(
|
26
27
|
:id => context.machine_configurations_url,
|
27
28
|
:name => 'default',
|
28
29
|
:created => Time.now,
|
29
30
|
:description => "#{context.driver.name.capitalize} MachineConfigurationCollection",
|
30
|
-
:
|
31
|
+
:count => machine_configurations.count,
|
32
|
+
:machine_configurations => machine_configurations
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
@@ -17,17 +17,19 @@ class CIMI::Model::MachineImageCollection < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
act_as_root_entity :machine_image
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
text :count
|
21
|
+
|
22
|
+
self.schema.add_collection_member_array(CIMI::Model::MachineImage)
|
23
23
|
|
24
24
|
def self.default(context)
|
25
|
+
machine_images = CIMI::Model::MachineImage.all(context)
|
25
26
|
self.new(
|
26
27
|
:id => context.machine_images_url,
|
27
28
|
:name => 'default',
|
28
29
|
:created => Time.now,
|
29
30
|
:description => "#{context.driver.name.capitalize} MachineImageCollection",
|
30
|
-
:
|
31
|
+
:count => machine_images.count,
|
32
|
+
:machine_images => machine_images
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
@@ -17,17 +17,19 @@ class CIMI::Model::MachineTemplateCollection < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
act_as_root_entity :machine_template
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
text :count
|
21
|
+
|
22
|
+
self.schema.add_collection_member_array(CIMI::Model::MachineTemplate)
|
23
23
|
|
24
24
|
def self.default(context)
|
25
|
+
machine_templates = CIMI::Model::MachineTemplate.all(context)
|
25
26
|
self.new(
|
26
27
|
:id => context.machine_template_url,
|
27
28
|
:name => 'default',
|
28
29
|
:created => Time.now,
|
29
30
|
:description => "#{context.driver.name.capitalize} MachineTemplateCollection",
|
30
|
-
:
|
31
|
+
:count => machine_templates.size,
|
32
|
+
:machine_templates => machine_templates
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
@@ -0,0 +1,42 @@
|
|
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::MachineVolume < CIMI::Model::Base
|
17
|
+
|
18
|
+
text :initial_location
|
19
|
+
href :volume
|
20
|
+
|
21
|
+
array :operations do
|
22
|
+
scalar :rel, :href
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.find(instance_id, context, id=:all)
|
26
|
+
if id == :all
|
27
|
+
volumes = context.driver.storage_volumes(context.credentials)
|
28
|
+
volumes.inject([]) do |attached, vol|
|
29
|
+
attached << self.new(
|
30
|
+
:id => context.machine_url(instance_id)+"/volumes/#{vol.id}",
|
31
|
+
:name => vol.id,
|
32
|
+
:description => "MachineVolume #{vol.id} for Machine #{instance_id}",
|
33
|
+
:created => vol.created,
|
34
|
+
:initial_location => vol.device,
|
35
|
+
:volume => {:href=>context.volume_url(vol.id)}
|
36
|
+
) if vol.instance_id == instance_id
|
37
|
+
attached
|
38
|
+
end
|
39
|
+
else
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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
|
+
class CIMI::Model::MachineVolumeCollection < CIMI::Model::Base
|
16
|
+
|
17
|
+
text :count
|
18
|
+
|
19
|
+
self.schema.add_collection_member_array(CIMI::Model::MachineVolume)
|
20
|
+
|
21
|
+
array :operations do
|
22
|
+
scalar :rel, :href
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.default(instance_id, context)
|
26
|
+
volumes = CIMI::Model::MachineVolume.find(instance_id, context)
|
27
|
+
self.new(
|
28
|
+
:id => context.machine_url(instance_id)+"/volumes",
|
29
|
+
:description => "MachineVolumeCollection for Machine #{instance_id}",
|
30
|
+
:count => volumes.size,
|
31
|
+
:machine_volumes => volumes
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
data/lib/cimi/models/network.rb
CHANGED
@@ -17,19 +17,15 @@ class CIMI::Model::Network < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
text :state
|
19
19
|
|
20
|
-
text :
|
20
|
+
text :network_type
|
21
21
|
|
22
|
-
text :
|
22
|
+
text :mtu
|
23
23
|
|
24
|
-
text :
|
24
|
+
text :class_of_service
|
25
25
|
|
26
|
-
|
26
|
+
href :network_ports
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
text :max_traffic_jitter
|
31
|
-
|
32
|
-
href :routing_group
|
28
|
+
href :forwarding_group
|
33
29
|
|
34
30
|
href :event_log
|
35
31
|
|
@@ -12,22 +12,23 @@
|
|
12
12
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
13
|
# License for the specific language governing permissions and limitations
|
14
14
|
# under the License.
|
15
|
-
|
16
15
|
class CIMI::Model::NetworkCollection < CIMI::Model::Base
|
17
16
|
|
18
17
|
act_as_root_entity :network
|
18
|
+
text :count
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
20
|
+
#add networks Array:
|
21
|
+
self.schema.add_collection_member_array(CIMI::Model::Network)
|
23
22
|
|
24
23
|
def self.default(context)
|
24
|
+
networks = CIMI::Model::Network.all(context)
|
25
25
|
self.new(
|
26
26
|
:id => context.networks_url,
|
27
27
|
:name => 'default',
|
28
28
|
:created => Time.now,
|
29
29
|
:description => "#{context.driver.name.capitalize} NetworkCollection",
|
30
|
-
:
|
30
|
+
:count => networks.size,
|
31
|
+
:networks => networks
|
31
32
|
)
|
32
33
|
end
|
33
34
|
|
data/lib/cimi/models/schema.rb
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
# under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require_relative "../../deltacloud/core_ext"
|
18
|
+
|
17
19
|
# The smarts of converting from XML and JSON into internal objects
|
18
20
|
class CIMI::Model::Schema
|
19
21
|
|
@@ -79,6 +81,9 @@ class CIMI::Model::Schema
|
|
79
81
|
end
|
80
82
|
|
81
83
|
class Struct < Attribute
|
84
|
+
|
85
|
+
attr_accessor :schema
|
86
|
+
|
82
87
|
def initialize(name, opts, &block)
|
83
88
|
content = opts[:content]
|
84
89
|
super(name, opts)
|
@@ -144,6 +149,9 @@ class CIMI::Model::Schema
|
|
144
149
|
end
|
145
150
|
|
146
151
|
class Array < Attribute
|
152
|
+
|
153
|
+
attr_accessor :struct
|
154
|
+
|
147
155
|
# For an array :funThings, we collect all <funThing/> elements (XmlSimple
|
148
156
|
# actually does the collecting)
|
149
157
|
def initialize(name, opts = {}, &block)
|
@@ -206,6 +214,9 @@ class CIMI::Model::Schema
|
|
206
214
|
#
|
207
215
|
# The actual Schema class
|
208
216
|
#
|
217
|
+
|
218
|
+
attr_accessor :attributes
|
219
|
+
|
209
220
|
def initialize
|
210
221
|
@attributes = []
|
211
222
|
end
|
@@ -228,6 +239,15 @@ class CIMI::Model::Schema
|
|
228
239
|
xml
|
229
240
|
end
|
230
241
|
|
242
|
+
#For MachineCollection, copy over the schema of Machine to hold
|
243
|
+
#each member of the collection - avoid duplicating the schemas
|
244
|
+
def add_collection_member_array(model)
|
245
|
+
member_symbol = model.name.split("::").last.underscore.pluralize.to_sym
|
246
|
+
members = CIMI::Model::Schema::Array.new(member_symbol)
|
247
|
+
members.struct.schema.attributes = model.schema.attributes
|
248
|
+
self.attributes << members
|
249
|
+
end
|
250
|
+
|
231
251
|
def to_json(model, json = {})
|
232
252
|
@attributes.freeze
|
233
253
|
@attributes.each { |attr| attr.to_json(model, json) }
|