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
@@ -0,0 +1,22 @@
|
|
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::VolumeConfigurationCreate < CIMI::Model::Base
|
17
|
+
|
18
|
+
href :type
|
19
|
+
text :format
|
20
|
+
text :capacity, :required => true
|
21
|
+
|
22
|
+
end
|
@@ -17,42 +17,4 @@ class CIMI::Model::VolumeCreate < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
ref :volume_template, :required => true
|
19
19
|
|
20
|
-
def create(context)
|
21
|
-
validate!
|
22
|
-
|
23
|
-
if volume_template.href?
|
24
|
-
template = volume_template.find(context)
|
25
|
-
else
|
26
|
-
template = CIMI::Model::VolumeTemplate.from_xml(volume_template.to_xml)
|
27
|
-
end
|
28
|
-
|
29
|
-
volume_image = template.volume_image.href? ?
|
30
|
-
template.volume_image.find(context) : template.volume_image
|
31
|
-
|
32
|
-
volume_config = template.volume_config.href? ?
|
33
|
-
template.volume_config.find(context) : template.volume_config
|
34
|
-
|
35
|
-
params = {
|
36
|
-
:name => name,
|
37
|
-
:capacity => volume_config.capacity,
|
38
|
-
:snapshot_id => ref_id(volume_image.id),
|
39
|
-
}
|
40
|
-
|
41
|
-
unless context.driver.respond_to? :create_storage_volume
|
42
|
-
raise Deltacloud::Exceptions.exception_from_status(
|
43
|
-
501,
|
44
|
-
"Creating Volume is not supported by the current driver"
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
volume = context.driver.create_storage_volume(context.credentials, params)
|
49
|
-
|
50
|
-
result = CIMI::Model::Volume.from_storage_volume(volume, context)
|
51
|
-
result.name = name if result.name.nil?
|
52
|
-
result.description = description if description
|
53
|
-
result.property = property if property
|
54
|
-
result.save
|
55
|
-
result
|
56
|
-
end
|
57
|
-
|
58
20
|
end
|
@@ -24,34 +24,4 @@ class CIMI::Model::VolumeImage < CIMI::Model::Base
|
|
24
24
|
array :operations do
|
25
25
|
scalar :rel, :href
|
26
26
|
end
|
27
|
-
|
28
|
-
def self.find(id, context)
|
29
|
-
creds = context.credentials
|
30
|
-
if id == :all
|
31
|
-
snapshots = context.driver.storage_snapshots(creds)
|
32
|
-
snapshots.collect{ |snapshot| from_storage_snapshot(snapshot, context) }
|
33
|
-
else
|
34
|
-
snapshot = context.driver.storage_snapshots(creds, id => :id).first
|
35
|
-
raise CIMI::Model::NotFound unless snapshot
|
36
|
-
from_storage_snapshot(snapshot, context)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.all(context); find(:all, context); end
|
41
|
-
|
42
|
-
def self.delete!(vol_image_id, context)
|
43
|
-
context.driver.destroy_storage_snapshot(context.credentials, {:id=>vol_image_id})
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.from_storage_snapshot(snapshot, context)
|
47
|
-
self.new( {
|
48
|
-
:name => snapshot.name,
|
49
|
-
:description => snapshot.description,
|
50
|
-
:created => snapshot.created.nil? ? nil : Time.parse(snapshot.created).xmlschema,
|
51
|
-
:id => context.volume_image_url(snapshot.id),
|
52
|
-
:image_location => {:href=>context.volume_url(snapshot.storage_volume_id)},
|
53
|
-
:bootable => "false" #FIXME
|
54
|
-
} )
|
55
|
-
end
|
56
|
-
|
57
27
|
end
|
@@ -19,29 +19,4 @@ class CIMI::Model::VolumeImageCreate < CIMI::Model::Base
|
|
19
19
|
text :image_data
|
20
20
|
text :bootable, :required => true
|
21
21
|
|
22
|
-
def create(context)
|
23
|
-
validate!
|
24
|
-
|
25
|
-
params = {
|
26
|
-
:volume_id => context.href_id(image_location.href, :volumes),
|
27
|
-
:name => name,
|
28
|
-
:description => description
|
29
|
-
}
|
30
|
-
|
31
|
-
unless context.driver.respond_to? :create_storage_snapshot
|
32
|
-
raise Deltacloud::Exceptions.exception_from_status(
|
33
|
-
501,
|
34
|
-
'Creating VolumeImage is not supported by the current driver'
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
new_snapshot = context.driver.create_storage_snapshot(context.credentials, params)
|
39
|
-
result = CIMI::Model::VolumeImage.from_storage_snapshot(new_snapshot, context)
|
40
|
-
result.name= name unless new_snapshot.name
|
41
|
-
result.description = description unless new_snapshot.description
|
42
|
-
result.property = property if property
|
43
|
-
result.save
|
44
|
-
result
|
45
|
-
end
|
46
|
-
|
47
22
|
end
|
@@ -17,8 +17,8 @@ class CIMI::Model::VolumeTemplate < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
acts_as_root_entity
|
19
19
|
|
20
|
-
ref :volume_config, :required => true
|
21
|
-
ref :volume_image
|
20
|
+
ref :volume_config, :required => true, :class => CIMI::Model::VolumeConfiguration
|
21
|
+
ref :volume_image
|
22
22
|
|
23
23
|
array :meter_templates do
|
24
24
|
end
|
@@ -29,45 +29,4 @@ class CIMI::Model::VolumeTemplate < CIMI::Model::Base
|
|
29
29
|
scalar :rel, :href
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.find(id, context)
|
33
|
-
if id==:all
|
34
|
-
if context.driver.respond_to? :volume_templates
|
35
|
-
context.driver.volume_templates(context.credentials, {:env=>context})
|
36
|
-
else
|
37
|
-
current_db.volume_templates.map { |t| from_db(t, context) }
|
38
|
-
end
|
39
|
-
else
|
40
|
-
if context.driver.respond_to? :volume_template
|
41
|
-
context.driver.volume_template(context.credentials, id, :env=>context)
|
42
|
-
else
|
43
|
-
template = current_db.volume_templates_dataset.first(:id => id)
|
44
|
-
raise CIMI::Model::NotFound unless template
|
45
|
-
from_db(template, context)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.delete!(id, context)
|
51
|
-
current_db.volume_templates.first(:id => id).destroy
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.from_db(model, context)
|
55
|
-
self.new(
|
56
|
-
:id => context.volume_template_url(model.id),
|
57
|
-
:name => model.name,
|
58
|
-
:description => model.description,
|
59
|
-
:volume_config => {:href => model.volume_config},
|
60
|
-
:volume_image => {:href => model.volume_image},
|
61
|
-
:property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil),
|
62
|
-
:operations => [
|
63
|
-
{
|
64
|
-
:href => context.destroy_volume_template_url(model.id),
|
65
|
-
:rel => 'http://schemas.dmtf.org/cimi/1/action/delete'
|
66
|
-
}
|
67
|
-
]
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
32
|
end
|
@@ -18,16 +18,4 @@ class CIMI::Model::VolumeTemplateCreate < CIMI::Model::Base
|
|
18
18
|
ref :volume_config, :required => true
|
19
19
|
ref :volume_image, :required => true
|
20
20
|
|
21
|
-
def create(context)
|
22
|
-
validate!
|
23
|
-
new_template = self.class.current_db.add_volume_template(
|
24
|
-
:name => name,
|
25
|
-
:description => description,
|
26
|
-
:volume_config => volume_config.href,
|
27
|
-
:volume_image => volume_image.href,
|
28
|
-
:ent_properties => property.to_json
|
29
|
-
)
|
30
|
-
CIMI::Model::VolumeTemplate.from_db(new_template, context)
|
31
|
-
end
|
32
|
-
|
33
21
|
end
|
data/lib/cimi/service.rb
ADDED
@@ -0,0 +1,82 @@
|
|
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 require_relatived 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
|
+
|
17
|
+
module CIMI
|
18
|
+
module Service
|
19
|
+
def self.root_entities
|
20
|
+
CIMI::Model::root_entities.map do |m|
|
21
|
+
CIMI::Service.const_get(m.name.split('::').last)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
require_relative './models'
|
28
|
+
require_relative './../db/provider'
|
29
|
+
require_relative './../db/entity'
|
30
|
+
require_relative './../db/machine_template'
|
31
|
+
require_relative './../db/address_template'
|
32
|
+
require_relative './../db/volume_configuration'
|
33
|
+
require_relative './../db/volume_template'
|
34
|
+
|
35
|
+
require_relative './service/base'
|
36
|
+
require_relative './service/machine'
|
37
|
+
require_relative './service/machine_image'
|
38
|
+
require_relative './service/volume_image'
|
39
|
+
require_relative './service/system_template'
|
40
|
+
require_relative './service/network_port_configuration'
|
41
|
+
require_relative './service/credential_create'
|
42
|
+
require_relative './service/machine_template_create'
|
43
|
+
require_relative './service/volume_create'
|
44
|
+
require_relative './service/network_create'
|
45
|
+
require_relative './service/network'
|
46
|
+
require_relative './service/forwarding_group'
|
47
|
+
require_relative './service/volume_template_create'
|
48
|
+
require_relative './service/system_machine'
|
49
|
+
require_relative './service/system_volume'
|
50
|
+
require_relative './service/system_network'
|
51
|
+
require_relative './service/system_forwarding_group'
|
52
|
+
require_relative './service/system_network_port'
|
53
|
+
require_relative './service/system_address'
|
54
|
+
require_relative './service/system_credential'
|
55
|
+
require_relative './service/system_system'
|
56
|
+
require_relative './service/system'
|
57
|
+
require_relative './service/system_create'
|
58
|
+
require_relative './service/address_template_create'
|
59
|
+
require_relative './service/volume'
|
60
|
+
require_relative './service/volume_image_create'
|
61
|
+
require_relative './service/machine_configuration'
|
62
|
+
require_relative './service/volume_template'
|
63
|
+
require_relative './service/machine_template'
|
64
|
+
require_relative './service/network_port'
|
65
|
+
require_relative './service/forwarding_group_template'
|
66
|
+
require_relative './service/credential_template'
|
67
|
+
require_relative './service/volume_configuration'
|
68
|
+
require_relative './service/volume_configuration_create'
|
69
|
+
require_relative './service/cloud_entry_point'
|
70
|
+
require_relative './service/network_configuration'
|
71
|
+
require_relative './service/address_template'
|
72
|
+
require_relative './service/action'
|
73
|
+
require_relative './service/machine_create'
|
74
|
+
require_relative './service/address'
|
75
|
+
require_relative './service/credential'
|
76
|
+
require_relative './service/network_port_template'
|
77
|
+
require_relative './service/machine_image_create'
|
78
|
+
require_relative './service/address_create'
|
79
|
+
require_relative './service/network_template'
|
80
|
+
require_relative './service/disk'
|
81
|
+
require_relative './service/machine_volume'
|
82
|
+
require_relative './service/resource_metadata'
|
@@ -0,0 +1,21 @@
|
|
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::Service::Action < CIMI::Service::Base
|
17
|
+
|
18
|
+
def operation
|
19
|
+
action.split('/').last.strip.intern
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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::Service::Address < CIMI::Service::Base
|
17
|
+
|
18
|
+
def self.find(id, context)
|
19
|
+
if id==:all
|
20
|
+
addresses = context.driver.addresses(context.credentials)
|
21
|
+
addresses.map{|addr| from_address(addr, context)}
|
22
|
+
else
|
23
|
+
address = context.driver.address(context.credentials, {:id=>id})
|
24
|
+
from_address(address, context)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.delete!(id, context)
|
29
|
+
context.driver.delete_address(context.credentials, id)
|
30
|
+
self.new(context, :values => { :id => id }).destroy
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.from_address(address, context)
|
36
|
+
self.new(context, :values => {
|
37
|
+
:name => address.id,
|
38
|
+
:id => context.address_url(address.id),
|
39
|
+
:description => "Address #{address.id}",
|
40
|
+
:ip => address.id,
|
41
|
+
:allocation => "dynamic",
|
42
|
+
:default_gateway => "unknown",
|
43
|
+
:dns => "unknown",
|
44
|
+
:protocol => protocol_from_address(address.id),
|
45
|
+
:mask => "unknown",
|
46
|
+
:resource => (address.instance_id) ? {:href=> context.machine_url(address.instance_id)} : nil,
|
47
|
+
:network => nil
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.protocol_from_address(address)
|
52
|
+
addr = IPAddr.new(address)
|
53
|
+
addr.ipv4? ? "ipv4" : "ipv6"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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::Service::AddressCreate < CIMI::Service::Base
|
17
|
+
|
18
|
+
def create
|
19
|
+
template = resolve(address_template)
|
20
|
+
|
21
|
+
params = {
|
22
|
+
:name => name,
|
23
|
+
:description => description,
|
24
|
+
:address_template => template,
|
25
|
+
:env => context # FIXME: We should not pass the context to the driver (!)
|
26
|
+
}
|
27
|
+
|
28
|
+
unless context.driver.respond_to? :create_address
|
29
|
+
raise Deltacloud::Exceptions.exception_from_status(
|
30
|
+
501,
|
31
|
+
"Creating Address is not supported by the current driver"
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
address = context.driver.create_address(context.credentials, params)
|
36
|
+
|
37
|
+
result = CIMI::Service::Address.from_address(address, context)
|
38
|
+
result.name = name if name
|
39
|
+
result.description = description if description
|
40
|
+
result.property = property if property
|
41
|
+
result.save
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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::Service::AddressTemplate < CIMI::Service::Base
|
17
|
+
|
18
|
+
def self.find(id, context)
|
19
|
+
if id==:all
|
20
|
+
if context.driver.respond_to? :address_templates
|
21
|
+
context.driver.address_templates(context.credentials, {:env=>context})
|
22
|
+
else
|
23
|
+
current_db.address_templates.map { |t| from_db(t, context) }
|
24
|
+
end
|
25
|
+
else
|
26
|
+
if context.driver.respond_to? :address_templates
|
27
|
+
context.driver.address_templates(context.credentials, :id => id, :env=>context)
|
28
|
+
else
|
29
|
+
template = current_db.address_templates_dataset.first(:id => id)
|
30
|
+
raise CIMI::Model::NotFound unless template
|
31
|
+
from_db(template, context)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.delete!(id, context)
|
37
|
+
current_db.address_templates.first(:id => id).destroy
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def attributes_to_copy
|
42
|
+
super + [ :ip, :hostname, :allocation, :default_gateway,
|
43
|
+
:dns, :protocol, :mask ]
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def self.from_db(model, context)
|
49
|
+
self.new(context, :values => {
|
50
|
+
:id => context.address_template_url(model.id),
|
51
|
+
:name => model.name,
|
52
|
+
:description => model.description,
|
53
|
+
:ip => model.ip,
|
54
|
+
:hostname => model.hostname,
|
55
|
+
:allocation => model.allocation,
|
56
|
+
:default_gateway => model.default_gateway,
|
57
|
+
:dns => model.dns,
|
58
|
+
:protocol => model.protocol,
|
59
|
+
:mask => model.mask,
|
60
|
+
:property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil),
|
61
|
+
:operations => [
|
62
|
+
{
|
63
|
+
:href => context.destroy_address_template_url(model.id),
|
64
|
+
:rel => 'http://schemas.dmtf.org/cimi/1/action/delete'
|
65
|
+
}
|
66
|
+
]
|
67
|
+
})
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|