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,79 @@
|
|
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
|
+
require 'rubygems'
|
17
|
+
require 'ostruct'
|
18
|
+
|
19
|
+
load File.join(File.dirname(__FILE__), 'core_ext.rb')
|
20
|
+
require_relative 'models'
|
21
|
+
require_relative 'drivers'
|
22
|
+
require_relative 'helpers/driver_helper'
|
23
|
+
|
24
|
+
module Deltacloud
|
25
|
+
|
26
|
+
API_VERSION = '1.0.0'
|
27
|
+
|
28
|
+
def self.drivers
|
29
|
+
Drivers.driver_config
|
30
|
+
end
|
31
|
+
|
32
|
+
class Library
|
33
|
+
include Helpers::Drivers
|
34
|
+
|
35
|
+
attr_reader :backend, :credentials
|
36
|
+
|
37
|
+
def initialize(driver_name, opts={}, &block)
|
38
|
+
Thread.current[:driver] = driver_name.to_s
|
39
|
+
Thread.current[:provider] = opts[:provider]
|
40
|
+
@backend = driver
|
41
|
+
opts[:user] ||= 'mockuser'
|
42
|
+
opts[:password] ||= 'mockpassword'
|
43
|
+
@credentials = OpenStruct.new(:user => opts[:user], :password => opts[:password])
|
44
|
+
yield backend if block_given?
|
45
|
+
end
|
46
|
+
|
47
|
+
def version
|
48
|
+
Deltacloud::API_VERSION
|
49
|
+
end
|
50
|
+
|
51
|
+
def current_provider
|
52
|
+
Thread.current[:provider]
|
53
|
+
end
|
54
|
+
|
55
|
+
def current_driver
|
56
|
+
Thread.current[:driver]
|
57
|
+
end
|
58
|
+
|
59
|
+
def providers
|
60
|
+
Deltacloud.drivers[current_driver.to_sym]
|
61
|
+
end
|
62
|
+
|
63
|
+
def method_missing(name, *args)
|
64
|
+
return super unless backend.respond_to? name
|
65
|
+
begin
|
66
|
+
params = ([@credentials] + args).flatten
|
67
|
+
backend.send(name, *params)
|
68
|
+
rescue ArgumentError
|
69
|
+
backend.send(name, *args)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.new(driver_name, opts={}, &block)
|
76
|
+
Library.new(driver_name, opts, &block)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright ownership. The
|
5
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
6
|
+
# "License"); you may not use this file except in compliance with the
|
7
|
+
# License. You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
13
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
14
|
+
# License for the specific language governing permissions and limitations
|
15
|
+
# under the License.
|
16
|
+
|
17
|
+
module Deltacloud
|
18
|
+
|
19
|
+
def self.collection_names
|
20
|
+
@collections.map { |c| c.collection_name }
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.collections
|
24
|
+
@collections ||= []
|
25
|
+
end
|
26
|
+
|
27
|
+
module Collections
|
28
|
+
|
29
|
+
def self.collection(name)
|
30
|
+
Deltacloud.collections.find { |c| c.collection_name == name }
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.deltacloud_modules
|
34
|
+
@deltacloud_modules ||= []
|
35
|
+
end
|
36
|
+
|
37
|
+
Dir[File.join(File::dirname(__FILE__), "collections", "*.rb")].each do |collection|
|
38
|
+
require collection
|
39
|
+
base_collection_name = File.basename(collection).gsub('.rb', '')
|
40
|
+
deltacloud_module_class = Deltacloud::Collections.const_get(base_collection_name.camelize)
|
41
|
+
deltacloud_modules << deltacloud_module_class
|
42
|
+
deltacloud_module_class.collections.each do |c|
|
43
|
+
Deltacloud.collections << c
|
44
|
+
end unless deltacloud_module_class.collections.nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.included(klass)
|
48
|
+
klass.class_eval do
|
49
|
+
Deltacloud::Collections.deltacloud_modules.each { |c| use c }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,91 @@
|
|
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
|
+
module Deltacloud::Collections
|
17
|
+
class Addresses < Base
|
18
|
+
|
19
|
+
check_capability :for => lambda { |m| driver.respond_to? m }
|
20
|
+
|
21
|
+
get route_for('/addresses/:id/associate') do
|
22
|
+
@address = driver.address(credentials, params )
|
23
|
+
@instances = driver.instances(credentials)
|
24
|
+
respond_to do |format|
|
25
|
+
format.html {haml :"addresses/associate"}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
collection :addresses do
|
30
|
+
description "Pool of IP addresses allocated in cloud provider"
|
31
|
+
|
32
|
+
standard_index_operation
|
33
|
+
standard_show_operation
|
34
|
+
|
35
|
+
operation :create, :with_capability => :create_address do
|
36
|
+
description "Acquire a new IP address for use with your account."
|
37
|
+
control do
|
38
|
+
@address = driver.create_address(credentials, {})
|
39
|
+
status 201 # Created
|
40
|
+
response['Location'] = address_url(@address.id)
|
41
|
+
respond_to do |format|
|
42
|
+
format.xml { haml :"addresses/show", :ugly => true }
|
43
|
+
format.html { haml :"addresses/_address", :layout => false }
|
44
|
+
format.json { convert_to_json(:address, @address) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
operation :destroy, :with_capability => :destroy_address do
|
50
|
+
control do
|
51
|
+
driver.destroy_address(credentials, { :id => params[:id]})
|
52
|
+
status 204
|
53
|
+
respond_to do |format|
|
54
|
+
format.xml
|
55
|
+
format.json
|
56
|
+
format.html { redirect(addresses_url) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
action :associate, :with_capability => :associate_address do
|
62
|
+
description "Associate an IP address to an instance"
|
63
|
+
param :instance_id, :string, :required
|
64
|
+
control do
|
65
|
+
driver.associate_address(credentials, { :id => params[:id], :instance_id => params[:instance_id]})
|
66
|
+
status 202 # Accepted
|
67
|
+
respond_to do |format|
|
68
|
+
format.xml
|
69
|
+
format.json
|
70
|
+
format.html { redirect(address_url(params[:id])) }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
action :disassociate, :with_capability => :associate_address do
|
76
|
+
description "Disassociate an IP address from an instance"
|
77
|
+
control do
|
78
|
+
driver.disassociate_address(credentials, { :id => params[:id] })
|
79
|
+
status 202 # Accepted
|
80
|
+
respond_to do |format|
|
81
|
+
format.xml
|
82
|
+
format.json
|
83
|
+
format.html { redirect(address_url(params[:id])) }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,273 @@
|
|
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
|
+
module Deltacloud::Collections
|
17
|
+
class Buckets < Base
|
18
|
+
|
19
|
+
include Deltacloud::Features
|
20
|
+
|
21
|
+
check_capability :for => lambda { |m| driver.respond_to? m }
|
22
|
+
check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
|
23
|
+
|
24
|
+
new_route_for :buckets
|
25
|
+
|
26
|
+
get route_for('/buckets/:bucket/%s' % NEW_BLOB_FORM_ID) do
|
27
|
+
@bucket_id = params[:bucket]
|
28
|
+
respond_to do |format|
|
29
|
+
format.html {haml :"blobs/new"}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
head route_for('/buckets/:bucket/:blob') do
|
35
|
+
@blob_id = params[:blob]
|
36
|
+
@blob_metadata = driver.blob_metadata(credentials, {:id => params[:blob], 'bucket' => params[:bucket]})
|
37
|
+
if @blob_metadata
|
38
|
+
@blob_metadata.each do |k,v|
|
39
|
+
headers["X-Deltacloud-Blobmeta-#{k}"] = v
|
40
|
+
end
|
41
|
+
status 204
|
42
|
+
respond_to do |format|
|
43
|
+
format.xml
|
44
|
+
format.json
|
45
|
+
end
|
46
|
+
else
|
47
|
+
report_error(404)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
put route_for ("/buckets/:bucket/:blob") do
|
52
|
+
if(env["BLOB_SUCCESS"]) #ie got a 200ok after putting blob
|
53
|
+
content_type = env["CONTENT_TYPE"]
|
54
|
+
content_type ||= ""
|
55
|
+
@blob = driver.blob(credentials, {:id => params[:blob],
|
56
|
+
'bucket' => params[:bucket]})
|
57
|
+
respond_to do |format|
|
58
|
+
format.xml { haml :"blobs/show" }
|
59
|
+
format.html { haml :"blobs/show" }
|
60
|
+
format.json { convert_to_json(:blob, @blob) }
|
61
|
+
end
|
62
|
+
elsif(env["BLOB_FAIL"])
|
63
|
+
report_error(500) #OK?
|
64
|
+
else # small blobs - < 112kb dont hit the streaming monkey patch - use 'normal' create_blob
|
65
|
+
# also, if running under webrick don't hit the streaming patch (Thin specific)
|
66
|
+
bucket_id = params[:bucket]
|
67
|
+
blob_id = params[:blob]
|
68
|
+
temp_file = Tempfile.new("temp_blob_file")
|
69
|
+
temp_file.write(env['rack.input'].read)
|
70
|
+
temp_file.flush
|
71
|
+
content_type = env['CONTENT_TYPE'] || ""
|
72
|
+
blob_data = {:tempfile => temp_file, :type => content_type}
|
73
|
+
user_meta = BlobHelper::extract_blob_metadata_hash(request.env)
|
74
|
+
@blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data, user_meta)
|
75
|
+
temp_file.delete
|
76
|
+
respond_to do |format|
|
77
|
+
format.xml { haml :"blobs/show" }
|
78
|
+
format.html { haml :"blobs/show" }
|
79
|
+
format.json { convert_to_json(:blob, @blob) }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
collection :buckets do
|
86
|
+
|
87
|
+
standard_show_operation
|
88
|
+
standard_index_operation
|
89
|
+
|
90
|
+
operation :create, :with_capability => :create_bucket do
|
91
|
+
param :name, :string, :required
|
92
|
+
control do
|
93
|
+
@bucket = driver.create_bucket(credentials, params[:name], params)
|
94
|
+
status 201
|
95
|
+
response['Location'] = bucket_url(@bucket.id)
|
96
|
+
respond_to do |format|
|
97
|
+
format.xml { haml :"buckets/show" }
|
98
|
+
format.json { convert_to_json(:bucket, @bucket) }
|
99
|
+
format.html do
|
100
|
+
redirect bucket_url(@bucket.id) if @bucket and @bucket.id
|
101
|
+
redirect buckets_url
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
operation :destroy, :with_capability => :delete_bucket do
|
108
|
+
control do
|
109
|
+
driver.delete_bucket(credentials, params[:id], params)
|
110
|
+
status 204
|
111
|
+
respond_to do |format|
|
112
|
+
format.xml
|
113
|
+
format.json
|
114
|
+
format.html { redirect(buckets_url) }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
collection :blobs, :with_id => :blob_id, :no_member => true do
|
120
|
+
|
121
|
+
operation :show, :with_capability => :blob do
|
122
|
+
control do
|
123
|
+
@blob = driver.blob(credentials, { :id => params[:blob_id], 'bucket' => params[:id]} )
|
124
|
+
if @blob
|
125
|
+
respond_to do |format|
|
126
|
+
format.xml { haml :"blobs/show" }
|
127
|
+
format.html { haml :"blobs/show" }
|
128
|
+
format.json { convert_to_json(:blob, @blob) }
|
129
|
+
end
|
130
|
+
else
|
131
|
+
report_error(404)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
operation :create, :with_capability => :create_blob do
|
138
|
+
description "Create new blob"
|
139
|
+
param :blob_id, :string, :required
|
140
|
+
param :blob_data, :hash, :required
|
141
|
+
control do
|
142
|
+
bucket_id = params[:id]
|
143
|
+
blob_id = params['blob_id']
|
144
|
+
blob_data = params['blob_data']
|
145
|
+
user_meta = {}
|
146
|
+
#metadata from params (i.e., passed by http form post, e.g. browser)
|
147
|
+
max = params[:meta_params]
|
148
|
+
if(max)
|
149
|
+
(1..max.to_i).each do |i|
|
150
|
+
key = params[:"meta_name#{i}"]
|
151
|
+
key = "HTTP_X_Deltacloud_Blobmeta_#{key}"
|
152
|
+
value = params[:"meta_value#{i}"]
|
153
|
+
user_meta[key] = value
|
154
|
+
end
|
155
|
+
end
|
156
|
+
@blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data, user_meta)
|
157
|
+
respond_to do |format|
|
158
|
+
format.xml { haml :"blobs/show" }
|
159
|
+
format.html { haml :"blobs/show"}
|
160
|
+
format.json {convert_to_json(:blob, @blob)}
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
operation :destroy, :with_capability => :delete_blob do
|
166
|
+
control do
|
167
|
+
bucket_id = params[:id]
|
168
|
+
blob_id = params[:blob_id]
|
169
|
+
driver.delete_blob(credentials, bucket_id, blob_id)
|
170
|
+
status 204
|
171
|
+
respond_to do |format|
|
172
|
+
format.xml
|
173
|
+
format.json
|
174
|
+
format.html { redirect(bucket_url(bucket_id)) }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
action :stream, :http_method => :put, :with_capability => :create_blob do
|
180
|
+
description "Stream new blob data into the blob"
|
181
|
+
control do
|
182
|
+
if(env["BLOB_SUCCESS"]) #ie got a 200ok after putting blob
|
183
|
+
content_type = env["CONTENT_TYPE"]
|
184
|
+
content_type ||= ""
|
185
|
+
@blob = driver.blob(credentials, {:id => params[:blob],
|
186
|
+
'bucket' => params[:bucket]})
|
187
|
+
respond_to do |format|
|
188
|
+
format.xml { haml :"blobs/show" }
|
189
|
+
format.html { haml :"blobs/show" }
|
190
|
+
format.json { convert_to_json(:blob, @blob) }
|
191
|
+
end
|
192
|
+
elsif(env["BLOB_FAIL"])
|
193
|
+
report_error(500) #OK?
|
194
|
+
else # small blobs - < 112kb dont hit the streaming monkey patch - use 'normal' create_blob
|
195
|
+
# also, if running under webrick don't hit the streaming patch (Thin specific)
|
196
|
+
bucket_id = params[:bucket]
|
197
|
+
blob_id = params[:blob]
|
198
|
+
temp_file = Tempfile.new("temp_blob_file")
|
199
|
+
temp_file.write(env['rack.input'].read)
|
200
|
+
temp_file.flush
|
201
|
+
content_type = env['CONTENT_TYPE'] || ""
|
202
|
+
blob_data = {:tempfile => temp_file, :type => content_type}
|
203
|
+
user_meta = BlobHelper::extract_blob_metadata_hash(request.env)
|
204
|
+
@blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data, user_meta)
|
205
|
+
temp_file.delete
|
206
|
+
respond_to do |format|
|
207
|
+
format.xml { haml :"blobs/show" }
|
208
|
+
format.html { haml :"blobs/show" }
|
209
|
+
format.json { convert_to_json(:blob, @blob) }
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
action :metadata, :http_method => :head, :with_capability => :blob_metadata do
|
216
|
+
control do
|
217
|
+
@blob_id = params[:blob_id]
|
218
|
+
@blob_metadata = driver.blob_metadata(credentials, {:id => params[:blob_id], 'bucket' => params[:id]})
|
219
|
+
if @blob_metadata
|
220
|
+
@blob_metadata.each do |k,v|
|
221
|
+
headers["X-Deltacloud-Blobmeta-#{k}"] = v
|
222
|
+
end
|
223
|
+
status 204
|
224
|
+
respond_to do |format|
|
225
|
+
format.xml
|
226
|
+
format.json
|
227
|
+
end
|
228
|
+
else
|
229
|
+
report_error(404)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
action :update, :http_method => :post, :with_capability => :update_blob_metadata do
|
235
|
+
control do
|
236
|
+
meta_hash = BlobHelper::extract_blob_metadata_hash(request.env)
|
237
|
+
success = driver.update_blob_metadata(credentials, {'bucket'=>params[:id], :id =>params[:blob_id], 'meta_hash' => meta_hash})
|
238
|
+
if(success)
|
239
|
+
meta_hash.each do |k,v|
|
240
|
+
headers["X-Deltacloud-Blobmeta-#{k}"] = v
|
241
|
+
end
|
242
|
+
status 204
|
243
|
+
respond_to do |format|
|
244
|
+
format.xml
|
245
|
+
format.json
|
246
|
+
end
|
247
|
+
else
|
248
|
+
report_error(404) #FIXME is this the right error code?
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
action :content, :http_method => :get, :with_capability => :blob do
|
254
|
+
description "Download blob content"
|
255
|
+
control do
|
256
|
+
@blob = driver.blob(credentials, { :id => params[:blob_id], 'bucket' => params[:id]})
|
257
|
+
if @blob
|
258
|
+
params['content_length'] = @blob.content_length
|
259
|
+
params['content_type'] = @blob.content_type
|
260
|
+
params['content_disposition'] = "attachment; filename=#{@blob.id}"
|
261
|
+
BlobStream.call(self, credentials, params)
|
262
|
+
else
|
263
|
+
report_error(404)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
end
|