deltacloud-core 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/deltacloud-core.gemspec +4 -7
- data/lib/cimi/collections/address_templates.rb +4 -42
- data/lib/cimi/collections/addresses.rb +5 -43
- data/lib/cimi/collections/base.rb +11 -3
- data/lib/cimi/collections/cloud_entry_point.rb +1 -1
- data/lib/cimi/collections/credentials.rb +4 -43
- data/lib/cimi/collections/forwarding_group_templates.rb +2 -20
- data/lib/cimi/collections/forwarding_groups.rb +2 -21
- data/lib/cimi/collections/machine_configurations.rb +2 -20
- data/lib/cimi/collections/machine_images.rb +4 -42
- data/lib/cimi/collections/machine_templates.rb +4 -42
- data/lib/cimi/collections/machines.rb +14 -64
- data/lib/cimi/collections/network_configurations.rb +2 -20
- data/lib/cimi/collections/network_port_configurations.rb +2 -21
- data/lib/cimi/collections/network_port_templates.rb +2 -23
- data/lib/cimi/collections/network_ports.rb +6 -46
- data/lib/cimi/collections/network_templates.rb +2 -21
- data/lib/cimi/collections/networks.rb +4 -40
- data/lib/cimi/collections/resource_metadata.rb +2 -21
- data/lib/cimi/collections/system_templates.rb +4 -45
- data/lib/cimi/collections/systems.rb +65 -82
- data/lib/cimi/collections/volume_configurations.rb +4 -45
- data/lib/cimi/collections/volume_images.rb +4 -42
- data/lib/cimi/collections/volume_templates.rb +5 -44
- data/lib/cimi/collections/volumes.rb +4 -48
- data/lib/cimi/helpers.rb +1 -0
- data/lib/cimi/helpers/cimi_helper.rb +1 -1
- data/lib/cimi/helpers/cimi_rabbit_helper.rb +113 -0
- data/lib/cimi/helpers/database_helper.rb +1 -2
- data/lib/cimi/models.rb +12 -11
- data/lib/cimi/models/action.rb +0 -4
- data/lib/cimi/models/address.rb +0 -38
- data/lib/cimi/models/address_create.rb +0 -31
- data/lib/cimi/models/address_template.rb +0 -47
- data/lib/cimi/models/address_template_create.rb +0 -16
- data/lib/cimi/models/base.rb +2 -74
- data/lib/cimi/models/cloud_entry_point.rb +2 -30
- data/lib/cimi/models/collection.rb +8 -25
- data/lib/cimi/models/credential.rb +0 -34
- data/lib/cimi/models/credential_create.rb +0 -26
- data/lib/cimi/models/credential_template.rb +0 -2
- data/lib/cimi/models/disk.rb +0 -56
- data/lib/cimi/models/forwarding_group.rb +0 -8
- data/lib/cimi/models/forwarding_group_template.rb +0 -8
- data/lib/cimi/models/machine.rb +4 -129
- data/lib/cimi/models/machine_configuration.rb +0 -31
- data/lib/cimi/models/machine_create.rb +1 -29
- data/lib/cimi/models/machine_image.rb +0 -28
- data/lib/cimi/models/machine_image_create.rb +0 -19
- data/lib/cimi/models/machine_template.rb +5 -39
- data/lib/cimi/models/machine_template_create.rb +0 -12
- data/lib/cimi/models/machine_volume.rb +0 -65
- data/lib/cimi/models/network.rb +0 -32
- data/lib/cimi/models/network_configuration.rb +0 -15
- data/lib/cimi/models/network_create.rb +0 -23
- data/lib/cimi/models/network_port.rb +0 -73
- data/lib/cimi/models/network_port_configuration.rb +0 -8
- data/lib/cimi/models/network_port_template.rb +0 -8
- data/lib/cimi/models/network_template.rb +2 -12
- data/lib/cimi/models/resource.rb +0 -6
- data/lib/cimi/models/resource_metadata.rb +1 -95
- data/lib/cimi/models/schema.rb +28 -32
- data/lib/cimi/models/system.rb +15 -39
- data/lib/cimi/models/system_address.rb +26 -0
- data/lib/cimi/models/system_create.rb +20 -0
- data/lib/cimi/models/system_credential.rb +26 -0
- data/lib/cimi/models/system_forwarding_group.rb +26 -0
- data/lib/cimi/models/system_machine.rb +26 -0
- data/lib/cimi/models/system_network.rb +26 -0
- data/lib/cimi/models/system_network_port.rb +26 -0
- data/lib/cimi/models/system_system.rb +26 -0
- data/lib/cimi/models/system_template.rb +15 -31
- data/lib/cimi/models/system_volume.rb +26 -0
- data/lib/cimi/models/volume.rb +0 -59
- data/lib/cimi/models/volume_configuration.rb +1 -64
- data/lib/cimi/models/volume_configuration_create.rb +22 -0
- data/lib/cimi/models/volume_create.rb +0 -38
- data/lib/cimi/models/volume_image.rb +0 -30
- data/lib/cimi/models/volume_image_create.rb +0 -25
- data/lib/cimi/models/volume_template.rb +2 -43
- data/lib/cimi/models/volume_template_create.rb +0 -12
- data/lib/cimi/service.rb +82 -0
- data/lib/cimi/service/action.rb +21 -0
- data/lib/cimi/service/address.rb +56 -0
- data/lib/cimi/service/address_create.rb +45 -0
- data/lib/cimi/service/address_template.rb +71 -0
- data/lib/cimi/service/address_template_create.rb +34 -0
- data/lib/cimi/service/base.rb +266 -0
- data/lib/cimi/service/cloud_entry_point.rb +53 -0
- data/lib/cimi/service/credential.rb +52 -0
- data/lib/cimi/service/credential_create.rb +38 -0
- data/lib/cimi/service/credential_template.rb +20 -0
- data/lib/cimi/service/disk.rb +75 -0
- data/lib/cimi/service/forwarding_group.rb +26 -0
- data/lib/cimi/service/forwarding_group_template.rb +26 -0
- data/lib/cimi/service/machine.rb +154 -0
- data/lib/cimi/service/machine_configuration.rb +54 -0
- data/lib/cimi/service/machine_create.rb +49 -0
- data/lib/cimi/service/machine_image.rb +47 -0
- data/lib/cimi/service/machine_image_create.rb +35 -0
- data/lib/cimi/service/machine_template.rb +61 -0
- data/lib/cimi/service/machine_template_create.rb +29 -0
- data/lib/cimi/service/machine_volume.rb +74 -0
- data/lib/cimi/service/network.rb +51 -0
- data/lib/cimi/service/network_configuration.rb +36 -0
- data/lib/cimi/service/network_create.rb +39 -0
- data/lib/cimi/service/network_port.rb +97 -0
- data/lib/cimi/service/network_port_configuration.rb +26 -0
- data/lib/cimi/service/network_port_template.rb +26 -0
- data/lib/cimi/service/network_template.rb +28 -0
- data/lib/cimi/service/resource_metadata.rb +44 -0
- data/lib/cimi/service/system.rb +45 -0
- data/lib/cimi/service/system_address.rb +34 -0
- data/lib/cimi/service/system_create.rb +39 -0
- data/lib/cimi/service/system_credential.rb +34 -0
- data/lib/cimi/service/system_forwarding_group.rb +34 -0
- data/lib/cimi/service/system_machine.rb +34 -0
- data/lib/cimi/service/system_network.rb +34 -0
- data/lib/cimi/service/system_network_port.rb +34 -0
- data/lib/cimi/service/system_system.rb +34 -0
- data/lib/cimi/service/system_template.rb +32 -0
- data/lib/cimi/service/system_volume.rb +34 -0
- data/lib/cimi/service/volume.rb +81 -0
- data/lib/cimi/service/volume_configuration.rb +92 -0
- data/lib/cimi/service/volume_configuration_create.rb +29 -0
- data/lib/cimi/service/volume_create.rb +47 -0
- data/lib/cimi/service/volume_image.rb +44 -0
- data/lib/cimi/service/volume_image_create.rb +42 -0
- data/lib/cimi/service/volume_template.rb +61 -0
- data/lib/cimi/service/volume_template_create.rb +29 -0
- data/lib/db/entity.rb +16 -1
- data/lib/deltacloud/collections/addresses.rb +2 -2
- data/lib/deltacloud/collections/buckets.rb +16 -18
- data/lib/deltacloud/collections/drivers.rb +4 -4
- data/lib/deltacloud/collections/firewalls.rb +5 -5
- data/lib/deltacloud/collections/images.rb +3 -3
- data/lib/deltacloud/collections/instance_states.rb +4 -4
- data/lib/deltacloud/collections/instances.rb +22 -13
- data/lib/deltacloud/collections/keys.rb +2 -2
- data/lib/deltacloud/collections/load_balancers.rb +16 -13
- data/lib/deltacloud/collections/storage_snapshots.rb +3 -3
- data/lib/deltacloud/collections/storage_volumes.rb +5 -5
- data/lib/deltacloud/core_ext/ordered_hash.rb +0 -4
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +8 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +4 -3
- data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +266 -19
- data/lib/deltacloud/drivers/google/google_driver.rb +6 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +2 -2
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +166 -54
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +2 -0
- data/lib/deltacloud/helpers/blob_stream_helper.rb +0 -2
- data/lib/deltacloud/helpers/deltacloud_helper.rb +22 -22
- data/lib/deltacloud/helpers/driver_helper.rb +4 -7
- data/lib/deltacloud/helpers/rabbit_helper.rb +5 -0
- data/lib/deltacloud/server.rb +4 -4
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +6 -1
- data/lib/ec2/server.rb +6 -1
- data/tests/cimi/collections/common.rb +33 -0
- data/tests/cimi/collections/machines_test.rb +19 -0
- data/tests/cimi/collections/system_templates_test.rb +47 -0
- data/tests/cimi/collections/volumes_test.rb +42 -0
- data/tests/cimi/db/database_helper_test.rb +7 -4
- data/tests/deltacloud/drivers_test.rb +1 -1
- data/tests/drivers/ec2/common.rb +4 -1
- data/tests/drivers/fgcp/common.rb +1 -2
- data/tests/drivers/gogrid/common.rb +1 -2
- data/tests/drivers/google/common.rb +1 -1
- data/tests/drivers/models/address_test.rb +2 -2
- data/tests/drivers/models/base_test.rb +2 -2
- data/tests/drivers/models/blob_test.rb +2 -2
- data/tests/drivers/models/instance_address_test.rb +8 -8
- data/tests/drivers/models/instance_profile_test.rb +2 -2
- data/tests/drivers/models/keys_test.rb +4 -4
- data/tests/drivers/models/metrics_test.rb +3 -3
- data/tests/drivers/openstack/common.rb +1 -2
- data/views/addresses/_address.html.haml +3 -3
- data/views/addresses/associate.html.haml +3 -3
- data/views/addresses/index.html.haml +2 -2
- data/views/addresses/index.xml.haml +2 -2
- data/views/addresses/show.html.haml +7 -7
- data/views/addresses/show.xml.haml +9 -9
- data/views/api/show.html.haml +2 -2
- data/views/api/show.xml.haml +1 -1
- data/views/blobs/new.html.haml +1 -1
- data/views/blobs/show.html.haml +8 -8
- data/views/blobs/show.xml.haml +7 -7
- data/views/buckets/index.html.haml +1 -1
- data/views/buckets/index.xml.haml +2 -2
- data/views/buckets/show.html.haml +7 -7
- data/views/buckets/show.xml.haml +6 -6
- data/views/drivers/index.html.haml +1 -1
- data/views/drivers/index.xml.haml +1 -1
- data/views/drivers/show.html.haml +6 -6
- data/views/drivers/show.xml.haml +5 -5
- data/views/error.html.haml +2 -2
- data/views/errors/backend_capability_failure.xml.haml +3 -3
- data/views/errors/common.html.haml +7 -7
- data/views/errors/common.xml.haml +5 -5
- data/views/firewalls/index.html.haml +1 -1
- data/views/firewalls/index.xml.haml +1 -1
- data/views/firewalls/new_rule.html.haml +1 -1
- data/views/firewalls/show.html.haml +8 -8
- data/views/firewalls/show.xml.haml +9 -9
- data/views/hardware_profiles/index.html.haml +1 -1
- data/views/hardware_profiles/index.xml.haml +2 -2
- data/views/hardware_profiles/show.html.haml +3 -3
- data/views/hardware_profiles/show.xml.haml +4 -4
- data/views/images/index.html.haml +1 -1
- data/views/images/index.xml.haml +2 -2
- data/views/images/new.html.haml +2 -2
- data/views/images/show.html.haml +14 -14
- data/views/images/show.xml.haml +14 -14
- data/views/instance_states/show.html.haml +1 -1
- data/views/instance_states/show.png.erb +2 -2
- data/views/instance_states/show.xml.haml +1 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/index.xml.haml +2 -2
- data/views/instances/new.html.haml +22 -14
- data/views/instances/run.html.haml +2 -2
- data/views/instances/run.xml.haml +3 -3
- data/views/instances/run_command.html.haml +4 -4
- data/views/instances/show.html.haml +27 -27
- data/views/instances/show.xml.haml +37 -37
- data/views/keys/index.html.haml +1 -1
- data/views/keys/index.xml.haml +2 -2
- data/views/keys/show.html.haml +10 -10
- data/views/keys/show.xml.haml +12 -12
- data/views/load_balancers/index.html.haml +1 -1
- data/views/load_balancers/index.xml.haml +2 -2
- data/views/load_balancers/new.html.haml +1 -8
- data/views/load_balancers/show.html.haml +10 -10
- data/views/load_balancers/show.xml.haml +9 -9
- data/views/metrics/index.html.haml +1 -1
- data/views/metrics/index.xml.haml +2 -2
- data/views/metrics/show.html.haml +2 -2
- data/views/metrics/show.xml.haml +3 -3
- data/views/realms/index.html.haml +1 -1
- data/views/realms/index.xml.haml +2 -2
- data/views/realms/show.html.haml +6 -6
- data/views/realms/show.xml.haml +5 -5
- data/views/storage_snapshots/index.html.haml +1 -1
- data/views/storage_snapshots/index.xml.haml +2 -2
- data/views/storage_snapshots/show.html.haml +6 -6
- data/views/storage_snapshots/show.xml.haml +4 -4
- data/views/storage_volumes/attach.html.haml +2 -2
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/index.xml.haml +2 -2
- data/views/storage_volumes/show.html.haml +19 -19
- data/views/storage_volumes/show.xml.haml +21 -21
- metadata +77 -65
- data/views/cimi/cloudEntryPoint/index.html.haml +0 -5
- data/views/cimi/cloudEntryPoint/index.xml.haml +0 -9
- data/views/cimi/collection/index.html.haml +0 -45
- data/views/cimi/collection/response.xml.haml +0 -3
- data/views/cimi/error.html.haml +0 -31
- data/views/cimi/errors/400.xml.haml +0 -3
- data/views/cimi/errors/401.xml.haml +0 -2
- data/views/cimi/errors/403.xml.haml +0 -2
- data/views/cimi/errors/404.xml.haml +0 -2
- data/views/cimi/errors/405.xml.haml +0 -5
- data/views/cimi/errors/500.xml.haml +0 -6
- data/views/cimi/errors/502.xml.haml +0 -7
- data/views/cimi/layout.html.haml +0 -32
- data/views/cimi/machine_configurations/show.html.haml +0 -159
- data/views/cimi/machine_configurations/show.xml.haml +0 -27
- data/views/cimi/machine_images/show.html.haml +0 -79
- data/views/cimi/machine_images/show.xml.haml +0 -17
- data/views/cimi/machines/show.html.haml +0 -177
- data/views/cimi/machines/show.xml.haml +0 -28
- data/views/cimi/volumes/show.html.haml +0 -68
- data/views/cimi/volumes/show.xml.haml +0 -17
- data/views/docs/collection.html.haml +0 -26
- data/views/docs/collection.xml.haml +0 -14
- data/views/docs/index.html.haml +0 -11
- data/views/docs/index.xml.haml +0 -5
- data/views/docs/operation.html.haml +0 -33
- data/views/docs/operation.xml.haml +0 -10
- data/views/root/index.html.haml +0 -4
data/lib/cimi/models/disk.rb
CHANGED
@@ -22,60 +22,4 @@ class CIMI::Model::Disk < CIMI::Model::Base
|
|
22
22
|
scalar :rel, :href
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.find(instance, machine_config, context, id=:all)
|
26
|
-
if id == :all
|
27
|
-
name = instance.id+"_disk_" #assuming one disk for now...
|
28
|
-
|
29
|
-
if machine_config
|
30
|
-
mach_config_disks = machine_config.disks
|
31
|
-
return mach_config_disks.map do |d|
|
32
|
-
self.new(
|
33
|
-
:id => context.machine_url(instance.id) + "/disks/#{name}#{d[:capacity]}",
|
34
|
-
:name => "#{name}#{d[:capacity]}",
|
35
|
-
:description => "Disk for Machine #{instance.id}",
|
36
|
-
:created => instance.launch_time.nil? ? Time.now.xmlschema : Time.parse(instance.launch_time).xmlschema,
|
37
|
-
:capacity => d[:capacity]
|
38
|
-
)
|
39
|
-
end
|
40
|
-
else
|
41
|
-
if instance.instance_profile.override? :storage
|
42
|
-
capacity = context.to_kibibyte(instance.instance_profile.storage, 'MB')
|
43
|
-
else
|
44
|
-
hw_profile = context.driver.hardware_profile(context.credentials, :id => instance.instance_profile.name)
|
45
|
-
if hw_profile.storage
|
46
|
-
capacity = context.to_kibibyte(hw_profile.storage.value, 'MB')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
return [] unless capacity
|
51
|
-
|
52
|
-
[self.new(
|
53
|
-
:id => context.machine_url(instance.id)+"/disks/#{name}#{capacity}",
|
54
|
-
:name => name + capacity.to_s,
|
55
|
-
:description => "Disk for Machine #{instance.id}",
|
56
|
-
:created => instance.launch_time.nil? ? Time.now.xmlschema : Time.parse(instance.launch_time).xmlschema,
|
57
|
-
:capacity => capacity
|
58
|
-
)]
|
59
|
-
end
|
60
|
-
else
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.collection_for_instance(instance_id, context)
|
65
|
-
instance = context.driver.instance(context.credentials, :id => instance_id)
|
66
|
-
disks = find(instance, nil, context)
|
67
|
-
unless CIMI::Model.const_defined?('DiskCollection')
|
68
|
-
collection_class = CIMI::Model::Collection.generate(self)
|
69
|
-
else
|
70
|
-
collection_class = CIMI::Model::DiskCollection
|
71
|
-
end
|
72
|
-
collection_class.new(
|
73
|
-
:id => context.url("/machines/#{instance_id}/disks"),
|
74
|
-
:name => 'default',
|
75
|
-
:count => disks.size,
|
76
|
-
:description => "Disk collection for Machine #{instance_id}",
|
77
|
-
:entries => disks
|
78
|
-
)
|
79
|
-
end
|
80
|
-
|
81
25
|
end
|
@@ -25,12 +25,4 @@ class CIMI::Model::ForwardingGroup < CIMI::Model::Base
|
|
25
25
|
scalar :rel, :href
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.find(id, context)
|
29
|
-
if id==:all
|
30
|
-
context.driver.forwarding_groups(context.credentials, {:env=>context})
|
31
|
-
else
|
32
|
-
context.driver.forwarding_groups(context.credentials, {:env=>context, :id=>id})
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
28
|
end
|
@@ -25,12 +25,4 @@ class CIMI::Model::ForwardingGroupTemplate < CIMI::Model::Base
|
|
25
25
|
scalar :rel, :href
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.find(id, context)
|
29
|
-
if id==:all
|
30
|
-
context.driver.forwarding_group_templates(context.credentials, {:env=>context})
|
31
|
-
else
|
32
|
-
context.driver.forwarding_group_templates(context.credentials, {:env=>context, :id=>id})
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
28
|
end
|
data/lib/cimi/models/machine.rb
CHANGED
@@ -17,10 +17,10 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
acts_as_root_entity
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
# DC-specific Extension
|
21
|
+
text :realm, :required => false
|
22
|
+
# DC-specific extension
|
23
|
+
href :machine_image, :required => false
|
24
24
|
|
25
25
|
text :state
|
26
26
|
text :cpu
|
@@ -38,129 +38,4 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
38
38
|
scalar :rel, :href
|
39
39
|
end
|
40
40
|
|
41
|
-
def self.find(id, context)
|
42
|
-
instances = []
|
43
|
-
if id == :all
|
44
|
-
instances = context.driver.instances(context.credentials)
|
45
|
-
instances.map { |instance| from_instance(instance, context) }.compact
|
46
|
-
else
|
47
|
-
instance = context.driver.instance(context.credentials, :id => id)
|
48
|
-
raise CIMI::Model::NotFound unless instance
|
49
|
-
from_instance(instance, context)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def perform(action, context, &block)
|
54
|
-
begin
|
55
|
-
if context.driver.send(:"#{action.name}_instance", context.credentials, self.id.split("/").last)
|
56
|
-
block.callback :success
|
57
|
-
else
|
58
|
-
raise "Operation failed to execute on given Machine"
|
59
|
-
end
|
60
|
-
rescue => e
|
61
|
-
block.callback :failure, e.message
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.delete!(id, context)
|
66
|
-
context.driver.destroy_instance(context.credentials, id)
|
67
|
-
new(:id => id).destroy
|
68
|
-
end
|
69
|
-
|
70
|
-
#returns the newly attach machine_volume
|
71
|
-
def self.attach_volume(volume, location, context)
|
72
|
-
context.driver.attach_storage_volume(context.credentials,
|
73
|
-
{:id=>volume, :instance_id=>context.params[:id], :device=>location})
|
74
|
-
CIMI::Model::MachineVolume.find(context.params[:id], context, volume)
|
75
|
-
end
|
76
|
-
|
77
|
-
#returns the machine_volume_collection for the given machine
|
78
|
-
def self.detach_volume(volume, location, context)
|
79
|
-
context.driver.detach_storage_volume(context.credentials,
|
80
|
-
{:id=>volume, :instance_id=>context.params[:id], :device=>location})
|
81
|
-
CIMI::Model::MachineVolume.collection_for_instance(context.params[:id], context)
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.from_instance(instance, context)
|
85
|
-
cpu = memory = (instance.instance_profile.id == "opaque")? "n/a" : nil
|
86
|
-
machine_conf = CIMI::Model::MachineConfiguration.find(instance.instance_profile.name, context)
|
87
|
-
machine_spec = {
|
88
|
-
:name => instance.name,
|
89
|
-
:created => instance.launch_time.nil? ? Time.now.xmlschema : Time.parse(instance.launch_time.to_s).xmlschema,
|
90
|
-
:description => "No description set for Machine #{instance.name}",
|
91
|
-
:id => context.machine_url(instance.id),
|
92
|
-
:state => convert_instance_state(instance.state),
|
93
|
-
:cpu => cpu || convert_instance_cpu(instance.instance_profile, context),
|
94
|
-
:memory => memory || convert_instance_memory(instance.instance_profile, context),
|
95
|
-
:disks => { :href => context.machine_url(instance.id)+"/disks"},
|
96
|
-
:volumes => { :href=>context.machine_url(instance.id)+"/volumes"},
|
97
|
-
:operations => convert_instance_actions(instance, context)
|
98
|
-
}
|
99
|
-
if context.expand? :disks
|
100
|
-
machine_spec[:disks] = CIMI::Model::Disk.find(instance, machine_conf, context, :all)
|
101
|
-
end
|
102
|
-
if context.expand? :volumes
|
103
|
-
machine_spec[:volumes] = CIMI::Model::MachineVolume.find(instance.id, context, :all)
|
104
|
-
end
|
105
|
-
machine_spec[:realm] = instance.realm_id if instance.realm_id
|
106
|
-
machine_spec[:machine_image] = { :href => context.machine_image_url(instance.image_id) } if instance.image_id
|
107
|
-
self.new(machine_spec)
|
108
|
-
end
|
109
|
-
|
110
|
-
# FIXME: This will convert 'RUNNING' state to 'STARTED'
|
111
|
-
# which is defined in CIMI (p65)
|
112
|
-
#
|
113
|
-
def self.convert_instance_state(state)
|
114
|
-
case state
|
115
|
-
when "RUNNING" then "STARTED"
|
116
|
-
when "PENDING" then "CREATING" #aruba only exception... could be "STARTING" here
|
117
|
-
else state
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.convert_instance_cpu(profile, context)
|
122
|
-
cpu_override = profile.overrides.find { |p, v| p == :cpu }
|
123
|
-
if cpu_override.nil?
|
124
|
-
CIMI::Model::MachineConfiguration.find(profile.id, context).cpu
|
125
|
-
else
|
126
|
-
cpu_override[1]
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def self.convert_instance_memory(profile, context)
|
131
|
-
machine_conf = CIMI::Model::MachineConfiguration.find(profile.name, context)
|
132
|
-
memory_override = profile.overrides.find { |p, v| p == :memory }
|
133
|
-
memory_override.nil? ? machine_conf.memory.to_i : context.to_kibibyte(memory_override[1].to_i,"MB")
|
134
|
-
end
|
135
|
-
|
136
|
-
def self.convert_instance_addresses(instance)
|
137
|
-
(instance.public_addresses + instance.private_addresses).collect do |address|
|
138
|
-
{
|
139
|
-
:hostname => address.is_hostname? ? address : nil,
|
140
|
-
:mac_address => address.is_mac? ? address : nil,
|
141
|
-
:state => 'Active',
|
142
|
-
:protocol => 'IPv4',
|
143
|
-
:address => address.is_ipv4? ? address : nil,
|
144
|
-
:allocation => 'Static'
|
145
|
-
}
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def self.convert_instance_actions(instance, context)
|
150
|
-
actions = instance.actions.collect do |action|
|
151
|
-
action = :restart if action == :reboot
|
152
|
-
name = action
|
153
|
-
name = :delete if action == :destroy # In CIMI destroy operation become delete
|
154
|
-
{ :href => context.send(:"#{action}_machine_url", instance.id), :rel => "http://schemas.dmtf.org/cimi/1/action/#{name}" }
|
155
|
-
end
|
156
|
-
actions << { :href => context.send(:"machine_images_url"), :rel => "http://schemas.dmtf.org/cimi/1/action/capture" } if instance.can_create_image?
|
157
|
-
actions
|
158
|
-
end
|
159
|
-
|
160
|
-
def self.convert_storage_volumes(instance, context)
|
161
|
-
instance.storage_volumes ||= [] #deal with nilpointers
|
162
|
-
instance.storage_volumes.map{|vol| {:href=>context.volume_url(vol.keys.first),
|
163
|
-
:initial_location=>vol.values.first} }
|
164
|
-
end
|
165
|
-
|
166
41
|
end
|
@@ -30,35 +30,4 @@ class CIMI::Model::MachineConfiguration < CIMI::Model::Base
|
|
30
30
|
scalar :rel, :href
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.find(id, context)
|
34
|
-
profiles = []
|
35
|
-
if id == :all
|
36
|
-
profiles = context.driver.hardware_profiles(context.credentials)
|
37
|
-
profiles.map { |profile| from_hardware_profile(profile, context) }.compact
|
38
|
-
else
|
39
|
-
profile = context.driver.hardware_profile(context.credentials, id)
|
40
|
-
from_hardware_profile(profile, context)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def self.from_hardware_profile(profile, context)
|
46
|
-
# We accept just profiles with all properties set
|
47
|
-
return unless profile.memory or profile.cpu or profile.storage
|
48
|
-
memory = profile.memory ? context.to_kibibyte((profile.memory.value || profile.memory.default), profile.memory.unit) : nil
|
49
|
-
cpu = (profile.cpu ? (profile.cpu.value || profile.cpu.default) : nil )
|
50
|
-
storage = profile.storage ? context.to_kibibyte((profile.storage.value || profile.storage.default), profile.storage.unit) : nil
|
51
|
-
machine_hash = {
|
52
|
-
:name => profile.name,
|
53
|
-
:description => "Machine Configuration with #{memory} KiB "+
|
54
|
-
"of memory and #{cpu} CPU",
|
55
|
-
:cpu => ( cpu.to_i.to_s if cpu ) ,
|
56
|
-
:created => Time.now.xmlschema, # FIXME: DC hardware_profile has no mention about created_at
|
57
|
-
:memory => (memory if memory),
|
58
|
-
:disks => ( [ { :capacity => storage, :format => (profile.storage.respond_to?(:format) ? profile.storage.format : "unknown") } ] if storage ), #no format attr for hwp - may be added if providers support...,
|
59
|
-
:id => context.machine_configuration_url(profile.id)
|
60
|
-
}
|
61
|
-
self.new(machine_hash)
|
62
|
-
end
|
63
|
-
|
64
33
|
end
|
@@ -14,36 +14,8 @@
|
|
14
14
|
# under the License.
|
15
15
|
|
16
16
|
class CIMI::Model::MachineCreate < CIMI::Model::Base
|
17
|
+
|
17
18
|
ref :machine_template
|
18
19
|
text :realm
|
19
20
|
|
20
|
-
def create(ctx)
|
21
|
-
params = {}
|
22
|
-
if machine_template.href
|
23
|
-
template = machine_template.find(ctx)
|
24
|
-
params[:hwp_id] = template.machine_config.ref_id(ctx)
|
25
|
-
params[:initial_state] = template.initial_state
|
26
|
-
image_id = template.machine_image.ref_id(ctx)
|
27
|
-
else
|
28
|
-
# FIXME: What if either of these href's isn't there ? What if the user
|
29
|
-
# tries to override some aspect of the machine_config/machine_image ?
|
30
|
-
params[:hwp_id] = machine_template.machine_config.href.split('/').last
|
31
|
-
params[:initial_state] = machine_template.initial_state
|
32
|
-
image_id = machine_template.machine_image.href.split('/').last
|
33
|
-
if machine_template.credential.href
|
34
|
-
params[:keyname] = machine_template.credential.href.split('/').last
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
params[:name] = name if name
|
39
|
-
params[:realm_id] = realm if realm
|
40
|
-
instance = ctx.driver.create_instance(ctx.credentials, image_id, params)
|
41
|
-
|
42
|
-
result = CIMI::Model::Machine::from_instance(instance, ctx)
|
43
|
-
result.name = name if name
|
44
|
-
result.description = description if description
|
45
|
-
result.property = property if property
|
46
|
-
result.save
|
47
|
-
result
|
48
|
-
end
|
49
21
|
end
|
@@ -26,32 +26,4 @@ class CIMI::Model::MachineImage < CIMI::Model::Base
|
|
26
26
|
scalar :rel, :href
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.find(id, context)
|
30
|
-
images = []
|
31
|
-
if id == :all
|
32
|
-
images = context.driver.images(context.credentials)
|
33
|
-
images.map { |image| from_image(image, context) }
|
34
|
-
else
|
35
|
-
image = context.driver.image(context.credentials, :id => id)
|
36
|
-
from_image(image, context)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.from_image(image, context)
|
41
|
-
self.new(
|
42
|
-
:id => context.machine_image_url(image.id),
|
43
|
-
:name => image.id,
|
44
|
-
:description => image.description,
|
45
|
-
:state => image.state || 'UNKNOWN',
|
46
|
-
:type => "IMAGE",
|
47
|
-
:created => image.creation_time.nil? ?
|
48
|
-
Time.now.xmlschema : Time.parse(image.creation_time.to_s).xmlschema
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.delete!(image_id, context)
|
53
|
-
context.driver.destroy_image(context.credentials, image_id)
|
54
|
-
new(:id => image_id).destroy
|
55
|
-
end
|
56
|
-
|
57
29
|
end
|
@@ -19,23 +19,4 @@ class CIMI::Model::MachineImageCreate < CIMI::Model::Base
|
|
19
19
|
text :image_location, :required => true
|
20
20
|
href :related_image
|
21
21
|
|
22
|
-
def create(context)
|
23
|
-
validate!
|
24
|
-
|
25
|
-
params = {
|
26
|
-
:id => context.href_id(image_location, :machines),
|
27
|
-
:name => name,
|
28
|
-
:description => description
|
29
|
-
}
|
30
|
-
|
31
|
-
img = context.driver.create_image(context.credentials, params)
|
32
|
-
|
33
|
-
result = CIMI::Model::MachineImage.from_image(img, context)
|
34
|
-
result.name = name if name
|
35
|
-
result.description = description if description
|
36
|
-
result.property = property if property
|
37
|
-
result.save
|
38
|
-
result
|
39
|
-
end
|
40
|
-
|
41
22
|
end
|
@@ -22,17 +22,18 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base
|
|
22
22
|
ref :machine_image
|
23
23
|
ref :credential
|
24
24
|
|
25
|
-
|
26
|
-
:constraints => lambda { |c| c.driver.realms(c.credentials).map { |r| r.id }}
|
25
|
+
text :realm, :required => false
|
27
26
|
|
28
27
|
array :volumes do
|
29
28
|
scalar :href, :initial_location
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
class CIMI::Model::VolumeTemplateWithLocation < CIMI::Model::VolumeTemplate
|
32
|
+
text :initial_location
|
34
33
|
end
|
35
34
|
|
35
|
+
array :volume_templates, :ref => CIMI::Model::VolumeTemplateWithLocation
|
36
|
+
|
36
37
|
array :network_interfaces do
|
37
38
|
href :vsp
|
38
39
|
text :hostname, :mac_address, :state, :protocol, :allocation
|
@@ -43,39 +44,4 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base
|
|
43
44
|
scalar :rel, :href
|
44
45
|
end
|
45
46
|
|
46
|
-
class << self
|
47
|
-
def find(id, context)
|
48
|
-
if id == :all
|
49
|
-
current_db.machine_templates.map { |t| from_db(t, context) }
|
50
|
-
else
|
51
|
-
template = current_db.machine_templates_dataset.first(:id => id)
|
52
|
-
raise CIMI::Model::NotFound unless template
|
53
|
-
from_db(template, context)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def delete!(id, context)
|
58
|
-
current_db.machine_templates.first(:id => id).destroy
|
59
|
-
end
|
60
|
-
|
61
|
-
def from_db(model, context)
|
62
|
-
self.new(
|
63
|
-
:id => context.machine_template_url(model.id),
|
64
|
-
:name => model.name,
|
65
|
-
:description => model.description,
|
66
|
-
:machine_config => { :href => model.machine_config },
|
67
|
-
:machine_image => { :href => model.machine_image },
|
68
|
-
:realm => model.realm,
|
69
|
-
:property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil),
|
70
|
-
:created => Time.parse(model.created_at.to_s).xmlschema,
|
71
|
-
:operations => [
|
72
|
-
{
|
73
|
-
:href => context.destroy_machine_template_url(model.id),
|
74
|
-
:rel => 'http://schemas.dmtf.org/cimi/1/action/delete'
|
75
|
-
}
|
76
|
-
]
|
77
|
-
)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
47
|
end
|
@@ -18,16 +18,4 @@ class CIMI::Model::MachineTemplateCreate < CIMI::Model::Base
|
|
18
18
|
href :machine_config, :required => true
|
19
19
|
href :machine_image, :required => true
|
20
20
|
|
21
|
-
def create(context)
|
22
|
-
validate!
|
23
|
-
new_template = self.class.current_db.add_machine_template(
|
24
|
-
:name => name,
|
25
|
-
:description => description,
|
26
|
-
:machine_config => machine_config.href,
|
27
|
-
:machine_image => machine_image.href,
|
28
|
-
:ent_properties => property.to_json
|
29
|
-
)
|
30
|
-
CIMI::Model::MachineTemplate.from_db(new_template, context)
|
31
|
-
end
|
32
|
-
|
33
21
|
end
|