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.rb
CHANGED
@@ -37,15 +37,6 @@ end
|
|
37
37
|
|
38
38
|
require 'require_relative' if RUBY_VERSION < '1.9'
|
39
39
|
|
40
|
-
# Database entities
|
41
|
-
#
|
42
|
-
require_relative './../db/provider'
|
43
|
-
require_relative './../db/entity'
|
44
|
-
require_relative './../db/machine_template'
|
45
|
-
require_relative './../db/address_template'
|
46
|
-
require_relative './../db/volume_configuration'
|
47
|
-
require_relative './../db/volume_template'
|
48
|
-
|
49
40
|
require_relative './models/schema'
|
50
41
|
require_relative './models/resource'
|
51
42
|
require_relative './models/collection'
|
@@ -65,6 +56,7 @@ require_relative './models/credential_template'
|
|
65
56
|
require_relative './models/credential_create'
|
66
57
|
require_relative './models/volume'
|
67
58
|
require_relative './models/volume_configuration'
|
59
|
+
require_relative './models/volume_configuration_create'
|
68
60
|
require_relative './models/volume_image'
|
69
61
|
require_relative './models/volume_template'
|
70
62
|
require_relative './models/volume_create'
|
@@ -88,7 +80,16 @@ require_relative './models/address_template_create'
|
|
88
80
|
require_relative './models/address_create'
|
89
81
|
require_relative './models/forwarding_group'
|
90
82
|
require_relative './models/forwarding_group_template'
|
91
|
-
require_relative './models/system_template'
|
92
|
-
require_relative './models/system'
|
93
83
|
require_relative './models/network_template'
|
94
84
|
require_relative './models/network_create'
|
85
|
+
require_relative './models/system_template'
|
86
|
+
require_relative './models/system_network_port'
|
87
|
+
require_relative './models/system_network'
|
88
|
+
require_relative './models/system_address'
|
89
|
+
require_relative './models/system_forwarding_group'
|
90
|
+
require_relative './models/system_machine'
|
91
|
+
require_relative './models/system_volume'
|
92
|
+
require_relative './models/system_credential'
|
93
|
+
require_relative './models/system_system'
|
94
|
+
require_relative './models/system'
|
95
|
+
require_relative './models/system_create'
|
data/lib/cimi/models/action.rb
CHANGED
data/lib/cimi/models/address.rb
CHANGED
@@ -39,42 +39,4 @@ class CIMI::Model::Address < CIMI::Model::Base
|
|
39
39
|
scalar :rel, :href
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.find(id, context)
|
43
|
-
if id==:all
|
44
|
-
addresses = context.driver.addresses(context.credentials)
|
45
|
-
addresses.map{|addr| from_address(addr, context)}
|
46
|
-
else
|
47
|
-
address = context.driver.address(context.credentials, {:id=>id})
|
48
|
-
from_address(address, context)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.delete!(id, context)
|
53
|
-
context.driver.delete_address(context.credentials, id)
|
54
|
-
new(:id => id).destroy
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def self.from_address(address, context)
|
60
|
-
self.new(
|
61
|
-
:name => address.id,
|
62
|
-
:id => context.address_url(address.id),
|
63
|
-
:description => "Address #{address.id}",
|
64
|
-
:ip => address.id,
|
65
|
-
:allocation => "dynamic",
|
66
|
-
:default_gateway => "unknown",
|
67
|
-
:dns => "unknown",
|
68
|
-
:protocol => protocol_from_address(address.id),
|
69
|
-
:mask => "unknown",
|
70
|
-
:resource => (address.instance_id) ? {:href=> context.machine_url(address.instance_id)} : nil,
|
71
|
-
:network => nil
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.protocol_from_address(address)
|
76
|
-
addr = IPAddr.new(address)
|
77
|
-
addr.ipv4? ? "ipv4" : "ipv6"
|
78
|
-
end
|
79
|
-
|
80
42
|
end
|
@@ -17,35 +17,4 @@ class CIMI::Model::AddressCreate < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
ref :address_template, :required => true
|
19
19
|
|
20
|
-
def create(context)
|
21
|
-
validate!
|
22
|
-
|
23
|
-
if address_template.href?
|
24
|
-
template = address_template.find(context)
|
25
|
-
end
|
26
|
-
|
27
|
-
params = {
|
28
|
-
:name => name,
|
29
|
-
:description => description,
|
30
|
-
:address_template => template,
|
31
|
-
:env => context # FIXME: We should not pass the context to the driver (!)
|
32
|
-
}
|
33
|
-
|
34
|
-
unless context.driver.respond_to? :create_address
|
35
|
-
raise Deltacloud::Exceptions.exception_from_status(
|
36
|
-
501,
|
37
|
-
"Creating Address is not supported by the current driver"
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
address = context.driver.create_address(context.credentials, params)
|
42
|
-
|
43
|
-
result = CIMI::Model::Address.from_address(address, context)
|
44
|
-
result.name = name if name
|
45
|
-
result.description = description if description
|
46
|
-
result.property = property if property
|
47
|
-
result.save
|
48
|
-
result
|
49
|
-
end
|
50
|
-
|
51
20
|
end
|
@@ -24,51 +24,4 @@ class CIMI::Model::AddressTemplate < CIMI::Model::Base
|
|
24
24
|
array :operations do
|
25
25
|
scalar :rel, :href
|
26
26
|
end
|
27
|
-
|
28
|
-
def self.find(id, context)
|
29
|
-
if id==:all
|
30
|
-
if context.driver.respond_to? :address_templates
|
31
|
-
context.driver.address_templates(context.credentials, {:env=>context})
|
32
|
-
else
|
33
|
-
current_db.address_templates.map { |t| from_db(t, context) }
|
34
|
-
end
|
35
|
-
else
|
36
|
-
if context.driver.respond_to? :address_templates
|
37
|
-
context.driver.address_templates(context.credentials, {:id=>id, :env=>context})
|
38
|
-
else
|
39
|
-
template = current_db.address_templates_dataset.first(:id => id)
|
40
|
-
raise CIMI::Model::NotFound unless template
|
41
|
-
from_db(template, context)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.delete!(id, context)
|
47
|
-
current_db.address_templates.first(:id => id).destroy
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def self.from_db(model, context)
|
53
|
-
self.new(
|
54
|
-
:id => context.address_template_url(model.id),
|
55
|
-
:name => model.name,
|
56
|
-
:description => model.description,
|
57
|
-
:ip => model.ip,
|
58
|
-
:hostname => model.hostname,
|
59
|
-
:allocation => model.allocation,
|
60
|
-
:default_gateway => model.default_gateway,
|
61
|
-
:dns => model.dns,
|
62
|
-
:protocol => model.protocol,
|
63
|
-
:mask => model.mask,
|
64
|
-
:property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil),
|
65
|
-
:operations => [
|
66
|
-
{
|
67
|
-
:href => context.destroy_address_template_url(model.id),
|
68
|
-
:rel => 'http://schemas.dmtf.org/cimi/1/action/delete'
|
69
|
-
}
|
70
|
-
]
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
27
|
end
|
@@ -25,20 +25,4 @@ class CIMI::Model::AddressTemplateCreate < CIMI::Model::Base
|
|
25
25
|
|
26
26
|
href :network
|
27
27
|
|
28
|
-
def create(context)
|
29
|
-
validate!
|
30
|
-
new_template = context.current_db.add_address_template(
|
31
|
-
:name => name,
|
32
|
-
:description => description,
|
33
|
-
:hostname => hostname,
|
34
|
-
:ip => ip,
|
35
|
-
:allocation => allocation,
|
36
|
-
:default_gateway => default_gateway,
|
37
|
-
:dns => dns,
|
38
|
-
:protocol => protocol,
|
39
|
-
:mask => mask,
|
40
|
-
:ent_properties => property.to_json
|
41
|
-
)
|
42
|
-
CIMI::Model::AddressTemplate.from_db(new_template, context)
|
43
|
-
end
|
44
28
|
end
|
data/lib/cimi/models/base.rb
CHANGED
@@ -15,8 +15,6 @@
|
|
15
15
|
|
16
16
|
require 'xmlsimple'
|
17
17
|
|
18
|
-
require_relative '../helpers/database_helper'
|
19
|
-
|
20
18
|
# The base class for any CIMI object that we either read from a request or
|
21
19
|
# write as a response. This class handles serializing/deserializing XML and
|
22
20
|
# JSON into a common form.
|
@@ -109,86 +107,16 @@ module CIMI::Model
|
|
109
107
|
|
110
108
|
class Base < Resource
|
111
109
|
|
112
|
-
# Extend the base model with database methods
|
113
|
-
extend Deltacloud::Helpers::Database
|
114
|
-
|
115
110
|
# Extend the base model with the collection handling methods
|
116
111
|
extend CIMI::Model::CollectionMethods
|
117
112
|
|
118
113
|
# Include methods needed to handle the $select query parameter
|
119
114
|
include CIMI::Helpers::SelectBaseMethods
|
115
|
+
|
120
116
|
#
|
121
117
|
# Common attributes for all resources
|
122
118
|
#
|
123
119
|
text :id, :name, :description, :created, :updated
|
124
|
-
|
125
|
-
|
126
|
-
def initialize(values = {})
|
127
|
-
super(values)
|
128
|
-
retrieve_entity
|
129
|
-
end
|
130
|
-
|
131
|
-
def []=(a, v)
|
132
|
-
v = super
|
133
|
-
retrieve_entity if a == :id
|
134
|
-
v
|
135
|
-
end
|
136
|
-
|
137
|
-
# Save the common attributes name, description, and properties to the
|
138
|
-
# database
|
139
|
-
def save
|
140
|
-
if @entity
|
141
|
-
@entity.name = name
|
142
|
-
@entity.description = description
|
143
|
-
@entity.properties = property
|
144
|
-
@entity.save
|
145
|
-
end
|
146
|
-
self
|
147
|
-
end
|
148
|
-
|
149
|
-
# Destroy the database attributes for this model
|
150
|
-
def destroy
|
151
|
-
@entity.destroy
|
152
|
-
self
|
153
|
-
end
|
154
|
-
|
155
|
-
# FIXME: Kludge around the fact that we do not have proper *Create
|
156
|
-
# objects that deserialize properties by themselves
|
157
|
-
def extract_properties!(data)
|
158
|
-
h = {}
|
159
|
-
if data['property']
|
160
|
-
# Data came from XML
|
161
|
-
h = data['property'].inject({}) do |r,v|
|
162
|
-
r[v['key']] = v['content']
|
163
|
-
r
|
164
|
-
end
|
165
|
-
elsif data['properties']
|
166
|
-
h = data['properties']
|
167
|
-
end
|
168
|
-
property ||= {}
|
169
|
-
property.merge!(h)
|
170
|
-
end
|
171
|
-
|
172
|
-
def ref_id(ref_url)
|
173
|
-
ref_url.split('/').last if ref_url
|
174
|
-
end
|
175
|
-
|
176
|
-
private
|
177
|
-
|
178
|
-
# Load an existing database entity for this object, or create a new one
|
179
|
-
def retrieve_entity
|
180
|
-
if self.id
|
181
|
-
@entity = Deltacloud::Database::Entity::retrieve(self)
|
182
|
-
if @entity.exists?
|
183
|
-
self.name = @entity.name
|
184
|
-
self.description = @entity.description
|
185
|
-
self.property ||= {}
|
186
|
-
self.property.merge!(@entity.properties)
|
187
|
-
end
|
188
|
-
else
|
189
|
-
@entity = nil
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
120
|
+
hash_map :property
|
193
121
|
end
|
194
122
|
end
|
@@ -15,8 +15,8 @@
|
|
15
15
|
|
16
16
|
class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
text :driver, :required => true
|
19
|
+
text :provider, :required => true
|
20
20
|
|
21
21
|
# All possible CIMI collections, in the order in which they should appear
|
22
22
|
# in the CEP
|
@@ -37,34 +37,6 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
|
|
37
37
|
href coll.underscore
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.create(context)
|
41
|
-
self.new(entities(context).merge({
|
42
|
-
:name => context.driver.name,
|
43
|
-
:description => "Cloud Entry Point for the Deltacloud #{context.driver.name} driver",
|
44
|
-
:driver => context.driver.name,
|
45
|
-
:provider => context.current_provider,
|
46
|
-
:id => context.cloudEntryPoint_url,
|
47
|
-
:base_uri => context.base_uri + "/",
|
48
|
-
:created => Time.now.xmlschema
|
49
|
-
}))
|
50
|
-
end
|
51
|
-
|
52
|
-
# Return an Hash of the CIMI root entities used in CloudEntryPoint
|
53
|
-
def self.entities(context)
|
54
|
-
CIMI::Collections.modules(:cimi).inject({}) do |supported_entities, m|
|
55
|
-
m.collections.each do |c|
|
56
|
-
index_operation_capability = c.operation(:index).required_capability
|
57
|
-
next if m.settings.respond_to?(:capability) and !m.settings.capability(index_operation_capability)
|
58
|
-
supported_entities[c.collection_name.to_s] = { :href => context.send(:"#{c.collection_name}_url") }
|
59
|
-
end
|
60
|
-
supported_entities
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def entities
|
65
|
-
@attribute_values.clone.delete_if { |key, value| !value.respond_to? :href }
|
66
|
-
end
|
67
|
-
|
68
40
|
private
|
69
41
|
|
70
42
|
def self.href_defined?(resource)
|
@@ -120,32 +120,15 @@ module CIMI::Model
|
|
120
120
|
end
|
121
121
|
|
122
122
|
# Return a collection of entities
|
123
|
-
def list(
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
cimi_create = "create_#{cimi_entity}_url"
|
131
|
-
dcloud_create = context.deltacloud_create_method_for(cimi_entity)
|
132
|
-
if(context.respond_to?(cimi_create) &&
|
133
|
-
context.driver.respond_to?(dcloud_create)) ||
|
134
|
-
provides?(cimi_entity)
|
135
|
-
url = context.send(cimi_create)
|
136
|
-
ops << { :rel => "add", :href => url }
|
123
|
+
def list(id, entries, params = {})
|
124
|
+
params[:id] = id
|
125
|
+
params[:entries] = entries
|
126
|
+
params[:count] = params[:entries].size
|
127
|
+
if params[:add_url]
|
128
|
+
params[:operations] ||= []
|
129
|
+
params[:operations] << { :rel => "add", :href => params.delete(:add_url) }
|
137
130
|
end
|
138
|
-
collection_class.new(
|
139
|
-
:count => entries.size,
|
140
|
-
:entries => entries,
|
141
|
-
:operations => ops,
|
142
|
-
:description => desc)
|
131
|
+
collection_class.new(params)
|
143
132
|
end
|
144
|
-
|
145
|
-
def all(context)
|
146
|
-
find :all, context
|
147
|
-
end
|
148
|
-
|
149
133
|
end
|
150
|
-
|
151
134
|
end
|
@@ -25,38 +25,4 @@ class CIMI::Model::Credential < CIMI::Model::Base
|
|
25
25
|
scalar :rel, :href
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.find(id, context)
|
29
|
-
if id == :all
|
30
|
-
return [] unless context.driver.respond_to?(:keys)
|
31
|
-
keys = context.driver.keys(context.credentials)
|
32
|
-
keys.map { |key| from_key(key, context) }
|
33
|
-
else
|
34
|
-
key = context.driver.key(context.credentials, :id => id)
|
35
|
-
from_key(key, context)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.create_from_xml(body, context)
|
40
|
-
credential = Credential.from_xml(body)
|
41
|
-
key = context.driver.create_key(context.credentials, :key_name => credential.name)
|
42
|
-
from_key(key, context)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.delete!(id, context)
|
46
|
-
context.driver.destroy_key(context.credentials, :id => id)
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def self.from_key(key, context)
|
52
|
-
self.new(
|
53
|
-
:name => key.id,
|
54
|
-
:username => key.username,
|
55
|
-
:password => key.is_password? ? key.password : key.fingerprint,
|
56
|
-
:key => key.is_key? ? key.pem_rsa_key : nil,
|
57
|
-
:id => context.credential_url(key.id),
|
58
|
-
:created => Time.now.xmlschema
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
28
|
end
|
@@ -17,30 +17,4 @@ class CIMI::Model::CredentialCreate < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
ref :credential_template, :required => true
|
19
19
|
|
20
|
-
def create(context)
|
21
|
-
validate!
|
22
|
-
|
23
|
-
unless context.driver.respond_to? :create_key
|
24
|
-
raise Deltacloud::Exceptions.exception_from_status(
|
25
|
-
501,
|
26
|
-
"Creating Credential is not supported by the current driver"
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
if credential_template.href?
|
31
|
-
template = credential_template.find(ctx)
|
32
|
-
else
|
33
|
-
template = credential_template
|
34
|
-
end
|
35
|
-
|
36
|
-
key = context.driver.create_key(context.credentials, :key_name => name)
|
37
|
-
|
38
|
-
result = CIMI::Model::Credential.from_key(key, context)
|
39
|
-
result.name = name if name
|
40
|
-
result.description = description if description
|
41
|
-
result.property = property if property
|
42
|
-
result.save
|
43
|
-
result
|
44
|
-
|
45
|
-
end
|
46
20
|
end
|