deltacloud-core 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTICE +1 -1
- data/Rakefile +63 -21
- data/bin/deltacloudd +10 -6
- data/config.ru +62 -6
- data/config/drivers/ec2.yaml +8 -0
- data/config/drivers/fgcp.yaml +13 -0
- data/deltacloud-core.gemspec +10 -2
- data/lib/cimi/collections.rb +58 -0
- data/lib/cimi/collections/address_templates.rb +49 -0
- data/lib/cimi/collections/addresses.rb +74 -0
- data/lib/cimi/collections/cloud_entry_point.rb +37 -0
- data/lib/{deltacloud/helpers/conversion_helper.rb → cimi/collections/entity_metadata.rb} +24 -16
- data/lib/cimi/collections/machine_admins.rb +74 -0
- data/lib/cimi/collections/machine_configurations.rb +49 -0
- data/lib/cimi/collections/machine_images.rb +50 -0
- data/lib/cimi/collections/machines.rb +157 -0
- data/lib/cimi/collections/network_configurations.rb +47 -0
- data/lib/cimi/collections/network_templates.rb +48 -0
- data/lib/cimi/collections/networks.rb +125 -0
- data/lib/cimi/collections/routing_group_templates.rb +47 -0
- data/lib/cimi/collections/routing_groups.rb +48 -0
- data/lib/cimi/collections/volume_configurations.rb +48 -0
- data/lib/cimi/collections/volume_images.rb +50 -0
- data/lib/cimi/collections/volumes.rb +80 -0
- data/lib/cimi/collections/vsp_configurations.rb +48 -0
- data/lib/cimi/collections/vsp_templates.rb +50 -0
- data/lib/cimi/collections/vsps.rb +108 -0
- data/lib/cimi/dependencies.rb +1 -0
- data/lib/cimi/helpers.rb +116 -0
- data/lib/cimi/helpers/cimi_helper.rb +6 -2
- data/lib/cimi/models.rb +72 -0
- data/lib/cimi/{model → models}/action.rb +1 -1
- data/lib/cimi/models/address.rb +72 -0
- data/lib/cimi/models/address_collection.rb +34 -0
- data/lib/cimi/models/address_template.rb +54 -0
- data/lib/cimi/models/address_template_collection.rb +34 -0
- data/lib/cimi/{model → models}/base.rb +2 -2
- data/lib/cimi/{model → models}/cloud_entry_point.rb +3 -5
- data/lib/cimi/{model → models}/entity_metadata.rb +7 -6
- data/lib/cimi/{model → models}/entity_metadata_collection.rb +2 -2
- data/lib/cimi/{model → models}/errors.rb +8 -0
- data/lib/cimi/{model → models}/machine.rb +10 -10
- data/lib/cimi/{model → models}/machine_admin.rb +1 -1
- data/lib/cimi/{model → models}/machine_admin_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_configuration.rb +9 -6
- data/lib/cimi/{model → models}/machine_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_image.rb +1 -1
- data/lib/cimi/{model → models}/machine_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_template.rb +0 -0
- data/lib/cimi/{model → models}/machine_template_collection.rb +2 -2
- data/lib/cimi/models/network.rb +109 -0
- data/lib/cimi/{model → models}/network_collection.rb +2 -2
- data/lib/cimi/{model → models}/network_configuration.rb +3 -4
- data/lib/cimi/{model → models}/network_configuration_collection.rb +2 -2
- data/lib/cimi/models/network_template.rb +36 -0
- data/lib/cimi/models/network_template_collection.rb +35 -0
- data/lib/cimi/models/routing_group.rb +34 -0
- data/lib/cimi/models/routing_group_collection.rb +34 -0
- data/lib/cimi/models/routing_group_template.rb +34 -0
- data/lib/cimi/models/routing_group_template_collection.rb +35 -0
- data/lib/cimi/{model → models}/schema.rb +0 -0
- data/lib/cimi/{model → models}/volume.rb +4 -4
- data/lib/cimi/{model → models}/volume_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_configuration.rb +1 -1
- data/lib/cimi/{model → models}/volume_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_image.rb +1 -1
- data/lib/cimi/{model → models}/volume_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_template.rb +0 -0
- data/lib/cimi/{model → models}/volume_template_collection.rb +2 -2
- data/lib/cimi/models/vsp.rb +102 -0
- data/lib/cimi/models/vsp_collection.rb +34 -0
- data/lib/cimi/models/vsp_configuration.rb +40 -0
- data/lib/cimi/models/vsp_configuration_collection.rb +34 -0
- data/lib/cimi/models/vsp_template.rb +34 -0
- data/lib/cimi/models/vsp_template_collection.rb +34 -0
- data/lib/cimi/server.rb +27 -549
- data/lib/deltacloud/api.rb +79 -0
- data/lib/deltacloud/collections.rb +54 -0
- data/lib/deltacloud/collections/addresses.rb +91 -0
- data/lib/deltacloud/collections/buckets.rb +273 -0
- data/lib/deltacloud/collections/drivers.rb +51 -0
- data/lib/deltacloud/collections/firewalls.rb +116 -0
- data/lib/deltacloud/collections/hardware_profiles.rb +29 -0
- data/lib/deltacloud/collections/images.rb +73 -0
- data/lib/deltacloud/collections/instance_states.rb +59 -0
- data/lib/deltacloud/collections/instances.rb +113 -0
- data/lib/deltacloud/collections/keys.rb +61 -0
- data/lib/deltacloud/collections/load_balancers.rb +102 -0
- data/lib/deltacloud/collections/metrics.rb +28 -0
- data/lib/deltacloud/collections/realms.rb +28 -0
- data/lib/deltacloud/collections/storage_snapshots.rb +51 -0
- data/lib/deltacloud/collections/storage_volumes.rb +99 -0
- data/lib/deltacloud/core_ext.rb +14 -6
- data/lib/deltacloud/core_ext/string.rb +17 -5
- data/lib/deltacloud/drivers.rb +6 -42
- data/lib/deltacloud/drivers/azure/azure_driver.rb +0 -4
- data/lib/deltacloud/{base_driver → drivers}/base_driver.rb +56 -18
- data/lib/deltacloud/drivers/condor/condor_driver.rb +1 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +142 -33
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +2 -6
- data/lib/deltacloud/{base_driver → drivers}/exceptions.rb +25 -2
- data/lib/deltacloud/drivers/features.rb +154 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +387 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1435 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +8 -11
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -5
- data/lib/deltacloud/drivers/mock/data/keys/test-key.yml +28 -0
- data/lib/deltacloud/drivers/mock/mock_client.rb +2 -2
- data/lib/deltacloud/drivers/mock/mock_driver.rb +58 -40
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +145 -0
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +107 -73
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +285 -145
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +189 -126
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +427 -8
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +7 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +48 -66
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +44 -51
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +7 -8
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -3
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +8 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +39 -13
- data/lib/deltacloud/drivers/vsphere/vsphere_filemanager.rb +1 -0
- data/lib/deltacloud/helpers.rb +79 -7
- data/lib/{sinatra/lazy_auth.rb → deltacloud/helpers/auth_helper.rb} +5 -9
- data/lib/deltacloud/helpers/{blob_stream.rb → blob_stream_helper.rb} +7 -7
- data/lib/deltacloud/helpers/deltacloud_helper.rb +286 -0
- data/lib/deltacloud/helpers/driver_helper.rb +58 -0
- data/lib/deltacloud/helpers/rabbit_helper.rb +34 -0
- data/lib/{sinatra/url_for.rb → deltacloud/helpers/url_helper.rb} +31 -9
- data/lib/deltacloud/models.rb +19 -17
- data/lib/deltacloud/models/bucket.rb +4 -0
- data/lib/deltacloud/{hardware_profile.rb → models/hardware_profile.rb} +4 -2
- data/lib/deltacloud/models/image.rb +1 -0
- data/lib/deltacloud/models/instance.rb +4 -2
- data/lib/deltacloud/models/instance_address.rb +4 -0
- data/lib/deltacloud/models/key.rb +4 -0
- data/lib/deltacloud/models/metric.rb +40 -0
- data/lib/deltacloud/{state_machine.rb → models/state_machine.rb} +18 -1
- data/lib/deltacloud/server.rb +41 -1222
- data/lib/deltacloud_rack.rb +79 -0
- data/lib/{cimi/model/network_template.rb → ec2/helpers.rb} +7 -10
- data/lib/{deltacloud/backend_capability.rb → ec2/helpers/errors.rb} +24 -29
- data/lib/ec2/helpers/result.rb +31 -0
- data/lib/ec2/query_parser.rb +152 -0
- data/lib/ec2/server.rb +70 -0
- data/lib/{deltacloud.rb → sinatra.rb} +7 -12
- data/lib/sinatra/rack_accept.rb +13 -7
- data/lib/sinatra/rack_driver_select.rb +1 -1
- data/lib/sinatra/rack_matrix_params.rb +1 -3
- data/public/images/metric.png +0 -0
- data/public/javascripts/jquery.mobile-1.0.1.min.js +177 -0
- data/public/stylesheets/jquery.mobile-1.0.1.min.css +2 -0
- data/public/stylesheets/new.css +10 -0
- data/support/fedora/deltacloud-core.spec +1 -1
- data/tests/api/common.rb +1 -0
- data/tests/api/driver_test.rb +79 -0
- data/tests/api/library_test.rb +48 -0
- data/tests/cimi/features/step_definitions/common_steps.rb +2 -2
- data/tests/cimi/features/step_definitions/machines_steps.rb +5 -4
- data/tests/cimi/features/step_definitions/volumes_steps.rb +8 -8
- data/tests/cimi/features/support/env.rb +33 -11
- data/tests/common.rb +7 -8
- data/tests/drivers/ec2/api_test.rb +19 -0
- data/tests/drivers/ec2/common.rb +23 -0
- data/tests/drivers/ec2/drivers_test.rb +120 -0
- data/tests/drivers/ec2/hardware_profiles_test.rb +224 -0
- data/tests/drivers/ec2/images_test.rb +230 -0
- data/tests/drivers/ec2/instances_test.rb +356 -0
- data/tests/drivers/ec2/keys_test.rb +181 -0
- data/tests/drivers/ec2/realms_test.rb +146 -0
- data/tests/drivers/fgcp/api_test.rb +47 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +54 -0
- data/tests/drivers/fgcp/realms_test.rb +42 -0
- data/tests/drivers/{rackspace → fgcp}/setup.rb +5 -6
- data/tests/drivers/google/api_test.rb +10 -26
- data/tests/drivers/google/buckets_test.rb +79 -95
- data/tests/drivers/google/common.rb +54 -0
- data/tests/drivers/mock/api_test.rb +4 -127
- data/tests/drivers/mock/buckets_test.rb +195 -0
- data/tests/drivers/mock/common.rb +7 -0
- data/tests/drivers/mock/drivers_test.rb +123 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +190 -100
- data/tests/drivers/mock/images_test.rb +162 -103
- data/tests/drivers/mock/instances_test.rb +310 -220
- data/tests/drivers/mock/keys_test.rb +161 -0
- data/tests/drivers/mock/realms_test.rb +109 -70
- data/tests/drivers/mock/storage_snapshots_test.rb +114 -0
- data/tests/drivers/mock/storage_volumes_test.rb +122 -0
- data/tests/drivers/openstack/api_test.rb +8 -3
- data/tests/drivers/openstack/common.rb +21 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +20 -9
- data/tests/drivers/openstack/images_test.rb +11 -5
- data/tests/drivers/openstack/instances_test.rb +61 -16
- data/tests/drivers/openstack/realms_test.rb +11 -7
- data/tests/drivers/rackspace/api_test.rb +7 -2
- data/tests/drivers/rackspace/buckets_test.rb +7 -2
- data/tests/drivers/rackspace/common.rb +16 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rackspace/images_test.rb +7 -2
- data/tests/drivers/rackspace/instances_test.rb +10 -5
- data/tests/drivers/rackspace/realms_test.rb +7 -2
- data/tests/drivers/rhevm/api_test.rb +12 -6
- data/tests/drivers/rhevm/{setup.rb → common.rb} +8 -1
- data/tests/drivers/rhevm/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rhevm/images_test.rb +8 -2
- data/tests/drivers/rhevm/instances_test.rb +7 -2
- data/tests/drivers/rhevm/realms_test.rb +7 -2
- data/tests/minitest_common.rb +58 -0
- data/tests/minitest_common_api_test.rb +115 -0
- data/views/addresses/associate.html.haml +1 -1
- data/views/addresses/index.html.haml +1 -1
- data/views/addresses/show.html.haml +2 -3
- data/views/api/show.html.haml +22 -9
- data/views/api/show.xml.haml +8 -7
- data/views/blobs/show.xml.haml +7 -4
- data/views/buckets/new.html.haml +2 -2
- data/views/cimi/errors/401.xml.haml +1 -1
- data/views/error.html.haml +3 -3
- data/views/errors/400.html.haml +1 -1
- data/views/errors/400.xml.haml +1 -2
- data/views/errors/401.html.haml +8 -7
- data/views/errors/401.xml.haml +1 -1
- data/views/errors/404.xml.haml +1 -0
- data/views/errors/500.xml.haml +4 -2
- data/views/{cimi/errors/403.html.haml → errors/501.html.haml} +4 -2
- data/views/errors/501.xml.haml +1 -0
- data/views/errors/502.xml.haml +1 -7
- data/views/{cimi/errors/500.html.haml → errors/504.html.haml} +0 -0
- data/views/errors/504.xml.haml +1 -0
- data/views/firewalls/new.html.haml +2 -2
- data/views/firewalls/new_rule.html.haml +1 -1
- data/views/firewalls/show.html.haml +1 -1
- data/views/hardware_profiles/index.html.haml +3 -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 +3 -3
- data/views/images/show.html.haml +5 -0
- data/views/images/show.xml.haml +6 -1
- data/views/instance_states/show.html.haml +1 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +54 -39
- data/views/instances/run_command.html.haml +24 -15
- data/views/instances/show.html.haml +7 -3
- data/views/instances/show.xml.haml +2 -2
- data/views/keys/show.xml.haml +1 -0
- data/views/layout.html.haml +5 -9
- data/views/load_balancers/show.html.haml +12 -6
- data/views/metrics/index.html.haml +13 -0
- data/views/metrics/index.xml.haml +5 -0
- data/views/metrics/show.html.haml +23 -0
- data/views/metrics/show.xml.haml +9 -0
- data/views/realms/show.xml.haml +2 -1
- data/views/root/index.html.haml +1 -1
- data/views/storage_snapshots/show.html.haml +1 -1
- data/views/storage_snapshots/show.xml.haml +1 -0
- data/views/storage_volumes/attach.html.haml +1 -2
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +22 -16
- data/views/storage_volumes/show.html.haml +10 -4
- data/views/storage_volumes/show.xml.haml +3 -4
- metadata +547 -519
- data/DISCLAIMER +0 -8
- data/lib/cimi/model.rb +0 -52
- data/lib/cimi/model/network.rb +0 -69
- data/lib/deltacloud/base_driver.rb +0 -18
- data/lib/deltacloud/base_driver/features.rb +0 -262
- data/lib/deltacloud/base_driver/mock_driver.rb +0 -78
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -186
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +0 -521
- data/lib/deltacloud/helpers/application_helper.rb +0 -267
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -50
- data/lib/deltacloud/helpers/json_helper.rb +0 -31
- data/lib/deltacloud/method_serializer.rb +0 -83
- data/lib/deltacloud/validation.rb +0 -107
- data/lib/sinatra/rabbit.rb +0 -441
- data/lib/sinatra/rack_runtime.rb +0 -47
- data/lib/sinatra/rack_syslog.rb +0 -86
- data/lib/sinatra/sinatra_verbose.rb +0 -73
- data/lib/sinatra/static_assets.rb +0 -99
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +0 -170
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +0 -12
- data/tests/drivers/google/setup.rb +0 -38
- data/tests/drivers/mock/instance_states_test.rb +0 -71
- data/tests/drivers/mock/setup.rb +0 -3
- data/tests/drivers/mock/url_for_test.rb +0 -67
- data/tests/drivers/openstack/setup.rb +0 -20
- data/views/cimi/errors/400.html.haml +0 -41
- data/views/cimi/errors/401.html.haml +0 -41
- data/views/cimi/errors/404.html.haml +0 -29
- data/views/cimi/errors/405.html.haml +0 -29
- data/views/cimi/errors/502.html.haml +0 -43
- data/views/cimi/errors/backend_capability_failure.html.haml +0 -29
@@ -0,0 +1,34 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::AddressCollection < CIMI::Model::Base
|
17
|
+
|
18
|
+
act_as_root_entity :address
|
19
|
+
|
20
|
+
array :addresses do
|
21
|
+
scalar :href
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default(context)
|
25
|
+
self.new(
|
26
|
+
:id => context.addresses_url,
|
27
|
+
:name => 'default',
|
28
|
+
:created => Time.now,
|
29
|
+
:description => "#{context.driver.name.capitalize} AddressCollection",
|
30
|
+
:addresses => CIMI::Model::Address.all(context).map { |addr| { :href => addr.id } }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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::AddressTemplate < CIMI::Model::Base
|
17
|
+
|
18
|
+
text :ip
|
19
|
+
|
20
|
+
text :hostname
|
21
|
+
|
22
|
+
text :allocation
|
23
|
+
|
24
|
+
text :default_gateway
|
25
|
+
|
26
|
+
text :dns
|
27
|
+
|
28
|
+
text :mac_address
|
29
|
+
|
30
|
+
text :protocol
|
31
|
+
|
32
|
+
text :mask
|
33
|
+
|
34
|
+
href :network
|
35
|
+
|
36
|
+
array :operations do
|
37
|
+
scalar :rel, :href
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.find(id, context)
|
41
|
+
if id==:all
|
42
|
+
context.driver.address_templates(context.credentials, {:env=>context})
|
43
|
+
else
|
44
|
+
context.driver.address_templates(context.credentials, {:id=>id, :env=>context})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.create(request_body, context, type)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.delete!(id, context)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
class CIMI::Model::AddressTemplateCollection < CIMI::Model::Base
|
17
|
+
|
18
|
+
act_as_root_entity :address_template
|
19
|
+
|
20
|
+
array :address_templates do
|
21
|
+
scalar :href
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default(context)
|
25
|
+
self.new(
|
26
|
+
:id => context.address_templates_url,
|
27
|
+
:name => 'default',
|
28
|
+
:created => Time.now,
|
29
|
+
:description => "#{context.driver.name.capitalize} AddressTemplateCollection",
|
30
|
+
:address_templates => CIMI::Model::AddressTemplate.all(context).map { |addr| { :href => addr.id } }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -131,7 +131,7 @@ class CIMI::Model::Base
|
|
131
131
|
|
132
132
|
# Return Array of links to current CIMI object
|
133
133
|
def all_uri(context)
|
134
|
-
self.all(context).map { |e| { :href => e.
|
134
|
+
self.all(context).map { |e| { :href => e.id } }
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -197,7 +197,7 @@ class CIMI::Model::Base
|
|
197
197
|
#
|
198
198
|
# Common attributes for all resources
|
199
199
|
#
|
200
|
-
text :
|
200
|
+
text :id, :name, :description, :created
|
201
201
|
|
202
202
|
# FIXME: this doesn't match with JSON
|
203
203
|
hash :property, :content => :value do
|
@@ -23,18 +23,16 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
|
|
23
23
|
self.new(entities(context).merge({
|
24
24
|
:name => context.driver.name,
|
25
25
|
:description => "Cloud Entry Point for the Deltacloud #{context.driver.name} driver",
|
26
|
-
:
|
26
|
+
:id => context.cloudEntryPoint_url,
|
27
27
|
:created => Time.now,
|
28
|
-
:entity_metadata => EntityMetadata.all_uri(context)
|
28
|
+
:entity_metadata => CIMI::Model::EntityMetadata.all_uri(context)
|
29
29
|
}))
|
30
30
|
end
|
31
31
|
|
32
32
|
# Return an Hash of the CIMI root entities used in CloudEntryPoint
|
33
33
|
def self.entities(context)
|
34
34
|
CIMI::Model.root_entities.inject({}) do |result, entity|
|
35
|
-
|
36
|
-
result[entity.underscore] = { :href => context.send(:"#{entity.underscore}_url") }
|
37
|
-
end
|
35
|
+
result[entity.underscore] = { :href => context.send(:"#{entity.underscore}_url") }
|
38
36
|
result
|
39
37
|
end
|
40
38
|
end
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
class CIMI::Model::EntityMetadata < CIMI::Model::Base
|
18
18
|
|
19
|
-
text :type_uri
|
19
|
+
text :type_uri
|
20
20
|
|
21
21
|
array :attributes do
|
22
22
|
scalar :name
|
@@ -52,7 +52,7 @@ text :type_uri
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.metadata_from_deltacloud_features(cimi_entity, dcloud_entity, context)
|
55
|
-
deltacloud_features = context.driver.features
|
55
|
+
deltacloud_features = context.driver.class.features[dcloud_entity]
|
56
56
|
metadata_attributes = deltacloud_features.map{|f| attributes_from_feature(f)}
|
57
57
|
from_feature(cimi_entity, context, metadata_attributes.flatten!)
|
58
58
|
end
|
@@ -64,11 +64,12 @@ text :type_uri
|
|
64
64
|
private
|
65
65
|
|
66
66
|
def self.attributes_from_feature(feature)
|
67
|
-
feature.
|
68
|
-
|
69
|
-
|
67
|
+
feature = CIMI::FakeCollection.feature(feature)
|
68
|
+
feature.operations.first.params_array.map do |p|
|
69
|
+
{
|
70
|
+
:name=> p.name,
|
70
71
|
:type=> "xs:string",
|
71
|
-
:required=>
|
72
|
+
:required=> p.required? ? "true" : "false",
|
72
73
|
:constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" : feature.description): feature.constraints)
|
73
74
|
}
|
74
75
|
end
|
@@ -21,10 +21,10 @@ class CIMI::Model::EntityMetadataCollection < CIMI::Model::Base
|
|
21
21
|
|
22
22
|
def self.default(context)
|
23
23
|
self.new(
|
24
|
-
:
|
24
|
+
:id => context.entity_metadata_url,
|
25
25
|
:name => 'default',
|
26
26
|
:created => Time.now,
|
27
|
-
:entity_metadata => EntityMetadata.all_uri(context)
|
27
|
+
:entity_metadata => CIMI::Model::EntityMetadata.all_uri(context)
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
@@ -13,8 +13,6 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations
|
14
14
|
# under the License.
|
15
15
|
|
16
|
-
require 'deltacloud/models/instance_address'
|
17
|
-
|
18
16
|
class CIMI::Model::Machine < CIMI::Model::Base
|
19
17
|
|
20
18
|
text :state
|
@@ -82,6 +80,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
82
80
|
hardware_profile_id = machine_template['machineConfig'][0]["href"].split('/').last
|
83
81
|
image_id = machine_template['machineImage'][0]["href"].split('/').last
|
84
82
|
additional_params = {}
|
83
|
+
additional_params[:name] =xml['name'][0] if xml['name']
|
85
84
|
if machine_template.has_key? 'machineAdmin'
|
86
85
|
additional_params[:keyname] = machine_template['machineAdmin'][0]["href"].split('/').last
|
87
86
|
end
|
@@ -109,7 +108,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
109
108
|
|
110
109
|
def self.create_entity_metadata(context)
|
111
110
|
cimi_entity = self.name.split("::").last
|
112
|
-
metadata = EntityMetadata.metadata_from_deltacloud_features(cimi_entity, :instances, context)
|
111
|
+
metadata = CIMI::Model::EntityMetadata.metadata_from_deltacloud_features(cimi_entity, :instances, context)
|
113
112
|
unless metadata.includes_attribute?(:name)
|
114
113
|
metadata.attributes << {:name=>"name", :required=>"false",
|
115
114
|
:constraints=>"Determined by the cloud provider", :type=>"xs:string"}
|
@@ -135,15 +134,16 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
135
134
|
private
|
136
135
|
|
137
136
|
def self.from_instance(instance, context)
|
137
|
+
cpu = memory = disks = (instance.instance_profile.id == "opaque")? "n/a" : nil
|
138
138
|
self.new(
|
139
139
|
:name => instance.id,
|
140
140
|
:description => instance.name,
|
141
141
|
:created => instance.launch_time,
|
142
|
-
:
|
142
|
+
:id => context.machine_url(instance.id),
|
143
143
|
:state => convert_instance_state(instance.state),
|
144
|
-
:cpu => convert_instance_cpu(instance.instance_profile, context),
|
145
|
-
:memory => convert_instance_memory(instance.instance_profile, context),
|
146
|
-
:disks => convert_instance_storage(instance.instance_profile, context),
|
144
|
+
:cpu => cpu || convert_instance_cpu(instance.instance_profile, context),
|
145
|
+
:memory => memory || convert_instance_memory(instance.instance_profile, context),
|
146
|
+
:disks => disks || convert_instance_storage(instance.instance_profile, context),
|
147
147
|
:network_interfaces => convert_instance_addresses(instance),
|
148
148
|
:operations => convert_instance_actions(instance, context),
|
149
149
|
:volumes=>convert_storage_volumes(instance, context),
|
@@ -170,14 +170,14 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
170
170
|
def self.convert_instance_cpu(profile, context)
|
171
171
|
cpu_override = profile.overrides.find { |p, v| p == :cpu }
|
172
172
|
if cpu_override.nil?
|
173
|
-
MachineConfiguration.find(profile.id, context).cpu
|
173
|
+
CIMI::Model::MachineConfiguration.find(profile.id, context).cpu
|
174
174
|
else
|
175
175
|
cpu_override[1]
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
def self.convert_instance_memory(profile, context)
|
180
|
-
machine_conf = MachineConfiguration.find(profile.name, context)
|
180
|
+
machine_conf = CIMI::Model::MachineConfiguration.find(profile.name, context)
|
181
181
|
memory_override = profile.overrides.find { |p, v| p == :memory }
|
182
182
|
{
|
183
183
|
:quantity => memory_override.nil? ? machine_conf.memory[:quantity] : memory_override[1],
|
@@ -186,7 +186,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
|
|
186
186
|
end
|
187
187
|
|
188
188
|
def self.convert_instance_storage(profile, context)
|
189
|
-
machine_conf = MachineConfiguration.find(profile.name, context)
|
189
|
+
machine_conf = CIMI::Model::MachineConfiguration.find(profile.name, context)
|
190
190
|
storage_override = profile.overrides.find { |p, v| p == :storage }
|
191
191
|
[
|
192
192
|
{ :capacity => {
|
@@ -51,7 +51,7 @@ class CIMI::Model::MachineAdmin < CIMI::Model::Base
|
|
51
51
|
:username => key.username,
|
52
52
|
:password => key.is_password? ? key.password : key.fingerprint,
|
53
53
|
:key => key.is_key? ? key.pem_rsa_key : nil,
|
54
|
-
:
|
54
|
+
:id => context.machine_admin_url(key.id),
|
55
55
|
:created => Time.now
|
56
56
|
)
|
57
57
|
end
|
@@ -23,11 +23,11 @@ class CIMI::Model::MachineAdminCollection < CIMI::Model::Base
|
|
23
23
|
|
24
24
|
def self.default(context)
|
25
25
|
self.new(
|
26
|
-
:
|
26
|
+
:id => context.machine_admins_url,
|
27
27
|
:name => 'default',
|
28
28
|
:created => Time.now,
|
29
29
|
:description => "#{context.driver.name.capitalize} MachineAdminCollection",
|
30
|
-
:machine_admins => MachineAdmin.all_uri(context)
|
30
|
+
:machine_admins => CIMI::Model::MachineAdmin.all_uri(context)
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
@@ -23,11 +23,11 @@ class CIMI::Model::MachineCollection < CIMI::Model::Base
|
|
23
23
|
|
24
24
|
def self.default(context)
|
25
25
|
self.new(
|
26
|
-
:
|
26
|
+
:id => context.machines_url,
|
27
27
|
:name => 'default',
|
28
28
|
:created => Time.now,
|
29
29
|
:description => "#{context.driver.name.capitalize} MachineCollection",
|
30
|
-
:machines => Machine.all_uri(context)
|
30
|
+
:machines => CIMI::Model::Machine.all_uri(context)
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
@@ -51,15 +51,18 @@ class CIMI::Model::MachineConfiguration < CIMI::Model::Base
|
|
51
51
|
def self.from_hardware_profile(profile, context)
|
52
52
|
# We accept just profiles with all properties set
|
53
53
|
return unless profile.memory or profile.cpu or profile.storage
|
54
|
+
memory = profile.memory.value || profile.memory.default
|
55
|
+
cpu = profile.cpu.value || profile.cpu.default
|
56
|
+
storage = profile.storage.value || profile.storage.default
|
54
57
|
machine_hash = {
|
55
58
|
:name => profile.name,
|
56
|
-
:description => "Machine Configuration with #{
|
57
|
-
"of memory and #{
|
58
|
-
:cpu =>
|
59
|
+
:description => "Machine Configuration with #{memory} #{profile.memory.unit} "+
|
60
|
+
"of memory and #{cpu} CPU",
|
61
|
+
:cpu => cpu,
|
59
62
|
:created => Time.now.to_s, # FIXME: DC hardware_profile has no mention about created_at
|
60
|
-
:memory => { :quantity => profile.memory.value, :units => profile.memory.unit },
|
61
|
-
:disks => [ { :capacity => { :quantity => profile.storage.value, :units => profile.storage.unit } } ],
|
62
|
-
:
|
63
|
+
:memory => { :quantity => profile.memory.value || profile.memory.default, :units => profile.memory.unit },
|
64
|
+
:disks => [ { :capacity => { :quantity => profile.storage.value || profile.storage.default, :units => profile.storage.unit } } ],
|
65
|
+
:id => context.machine_configuration_url(profile.name)
|
63
66
|
}
|
64
67
|
self.new(machine_hash)
|
65
68
|
end
|
@@ -23,11 +23,11 @@ class CIMI::Model::MachineConfigurationCollection < CIMI::Model::Base
|
|
23
23
|
|
24
24
|
def self.default(context)
|
25
25
|
self.new(
|
26
|
-
:
|
26
|
+
:id => context.machine_configurations_url,
|
27
27
|
:name => 'default',
|
28
28
|
:created => Time.now,
|
29
29
|
:description => "#{context.driver.name.capitalize} MachineConfigurationCollection",
|
30
|
-
:machine_configurations => MachineConfiguration.all_uri(context)
|
30
|
+
:machine_configurations => CIMI::Model::MachineConfiguration.all_uri(context)
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
@@ -36,7 +36,7 @@ class CIMI::Model::MachineImage < CIMI::Model::Base
|
|
36
36
|
def self.from_image(image, context)
|
37
37
|
self.new(
|
38
38
|
:name => image.id,
|
39
|
-
:
|
39
|
+
:id => context.machine_image_url(image.id),
|
40
40
|
:description => image.description,
|
41
41
|
:created => Time.now.to_s,
|
42
42
|
:image_location => { :href => "#{context.driver.name}://#{image.id}" } # FIXME
|
@@ -23,11 +23,11 @@ class CIMI::Model::MachineImageCollection < CIMI::Model::Base
|
|
23
23
|
|
24
24
|
def self.default(context)
|
25
25
|
self.new(
|
26
|
-
:
|
26
|
+
:id => context.machine_images_url,
|
27
27
|
:name => 'default',
|
28
28
|
:created => Time.now,
|
29
29
|
:description => "#{context.driver.name.capitalize} MachineImageCollection",
|
30
|
-
:machine_images => MachineImage.all_uri(context)
|
30
|
+
:machine_images => CIMI::Model::MachineImage.all_uri(context)
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
File without changes
|
@@ -23,11 +23,11 @@ class CIMI::Model::MachineTemplateCollection < CIMI::Model::Base
|
|
23
23
|
|
24
24
|
def self.default(context)
|
25
25
|
self.new(
|
26
|
-
:
|
26
|
+
:id => context.machine_template_url,
|
27
27
|
:name => 'default',
|
28
28
|
:created => Time.now,
|
29
29
|
:description => "#{context.driver.name.capitalize} MachineTemplateCollection",
|
30
|
-
:machine_templates => MachineTemplate.all_uri(context)
|
30
|
+
:machine_templates => CIMI::Model::MachineTemplate.all_uri(context)
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
@@ -0,0 +1,109 @@
|
|
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::Network < CIMI::Model::Base
|
17
|
+
|
18
|
+
text :state
|
19
|
+
|
20
|
+
text :access
|
21
|
+
|
22
|
+
text :bandwidth_limit
|
23
|
+
|
24
|
+
text :traffic_priority
|
25
|
+
|
26
|
+
text :max_traffic_delay
|
27
|
+
|
28
|
+
text :max_traffic_loss
|
29
|
+
|
30
|
+
text :max_traffic_jitter
|
31
|
+
|
32
|
+
href :routing_group
|
33
|
+
|
34
|
+
href :event_log
|
35
|
+
|
36
|
+
array :meters do
|
37
|
+
scalar :href
|
38
|
+
end
|
39
|
+
|
40
|
+
array :operations do
|
41
|
+
scalar :rel, :href
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.find(id, context)
|
45
|
+
networks=[]
|
46
|
+
if id==:all
|
47
|
+
networks = context.driver.networks(context.credentials, {:env=>context})
|
48
|
+
else
|
49
|
+
networks = context.driver.networks(context.credentials, {:id=>id, :env=>context})
|
50
|
+
end
|
51
|
+
networks
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.create(request_body, context, type)
|
55
|
+
input = (type == :xml)? XmlSimple.xml_in(request_body, {"ForceArray"=>false,"NormaliseSpace"=>2}) : JSON.parse(request_body)
|
56
|
+
if input["networkTemplate"]["href"] #template by reference
|
57
|
+
network_config, routing_group = get_by_reference(input, context)
|
58
|
+
else
|
59
|
+
if input["networkTemplate"]["networkConfig"]["href"] # configuration by reference
|
60
|
+
network_config = CIMI::Model::NetworkConfiguration.find(context.href_id(input["networkTemplate"]["networkConfig"]["href"],
|
61
|
+
:network_configurations), context)
|
62
|
+
else #configuration by value
|
63
|
+
network_config = get_by_value(request_body, type)
|
64
|
+
end
|
65
|
+
routing_group = CIMI::Model::RoutingGroup.find(context.href_id(input["networkTemplate"]["routingGroup"]["href"],
|
66
|
+
:routing_groups), context)
|
67
|
+
end
|
68
|
+
params = {:network_config => network_config, :routing_group => routing_group, :name=>input["name"],
|
69
|
+
:description=>input["description"], :env=>context}
|
70
|
+
raise CIMI::Model::BadRequest.new("Bad request - missing required parameters. Client sent: #{request_body} which produced #{params.inspect}") if params.has_value?(nil)
|
71
|
+
context.driver.create_network(context.credentials, params)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.delete!(id, context)
|
75
|
+
context.driver.delete_network(context.credentials, id)
|
76
|
+
end
|
77
|
+
|
78
|
+
def perform(action, context, &block)
|
79
|
+
begin
|
80
|
+
if context.driver.send(:"#{action.name}_network", context.credentials, self.name)
|
81
|
+
block.callback :success
|
82
|
+
else
|
83
|
+
raise "Operation #{action.name} failed to execute on the Network #{self.name} "
|
84
|
+
end
|
85
|
+
rescue => e
|
86
|
+
block.callback :failure, e.message
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def self.get_by_reference(input, context)
|
93
|
+
network_template = CIMI::Model::NetworkTemplate.find(context.href_id(input["networkTemplate"]["href"], :network_templates), context)
|
94
|
+
network_config = CIMI::Model::NetworkConfiguration.find(context.href_id(network_template.network_config.href, :network_configurations), context)
|
95
|
+
routing_group = CIMI::Model::RoutingGroup.find(context.href_id(network_template.routing_group.href, :routing_groups), context)
|
96
|
+
return network_config, routing_group
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.get_by_value(request_body, type)
|
100
|
+
if type == :xml
|
101
|
+
xml_arrays = XmlSimple.xml_in(request_body, {"NormaliseSpace"=>2})
|
102
|
+
network_config = CIMI::Model::NetworkConfiguration.from_xml(XmlSimple.xml_out(xml_arrays["networkTemplate"][0]["networkConfig"][0]))
|
103
|
+
else
|
104
|
+
json = JSON.parse(request_body)
|
105
|
+
network_config = CIMI::Model::NetworkConfiguration.from_json(JSON.generate(json["networkTemplate"]["networkConfig"]))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|