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,51 @@
|
|
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 Drivers < Base
|
18
|
+
|
19
|
+
collection :drivers do
|
20
|
+
|
21
|
+
operation :index do
|
22
|
+
control do
|
23
|
+
@drivers = Deltacloud::Drivers.driver_config
|
24
|
+
respond_to do |format|
|
25
|
+
format.xml { haml :"drivers/index" }
|
26
|
+
format.json { @drivers.to_json }
|
27
|
+
format.html { haml :"drivers/index" }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
operation :show do
|
33
|
+
control do
|
34
|
+
@name = params[:id].to_sym
|
35
|
+
if driver_symbol == @name
|
36
|
+
@providers = driver.providers(credentials) if driver.respond_to? :providers
|
37
|
+
end
|
38
|
+
@driver = Deltacloud::Drivers.driver_config[@name]
|
39
|
+
halt 404 unless @driver
|
40
|
+
respond_to do |format|
|
41
|
+
format.xml { haml :"drivers/show" }
|
42
|
+
format.json { @driver.to_json }
|
43
|
+
format.html { haml :"drivers/show" }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,116 @@
|
|
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 Firewalls < Base
|
18
|
+
|
19
|
+
check_capability :for => lambda { |m| driver.respond_to? m }
|
20
|
+
check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
|
21
|
+
|
22
|
+
get route_for('/firewalls/:id/new_rule') do
|
23
|
+
@firewall_name = params[:id]
|
24
|
+
respond_to do |format|
|
25
|
+
format.html {haml :"firewalls/new_rule" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
new_route_for :firewalls
|
30
|
+
|
31
|
+
collection :firewalls do
|
32
|
+
description "Allow user to define firewall rules for an instance (ec2 security groups) eg expose ssh access [port 22, tcp]."
|
33
|
+
|
34
|
+
collection :rules, :with_id => :rule_id, :no_member => true do
|
35
|
+
|
36
|
+
operation :destroy, :with_capability => :delete_firewall_rule do
|
37
|
+
control do
|
38
|
+
opts = {}
|
39
|
+
opts[:firewall] = params[:id]
|
40
|
+
opts[:rule_id] = params[:rule_id]
|
41
|
+
driver.delete_firewall_rule(credentials, opts)
|
42
|
+
status 204
|
43
|
+
respond_to do |format|
|
44
|
+
format.xml
|
45
|
+
format.json
|
46
|
+
format.html {redirect firewall_url(params[:id])}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
standard_show_operation
|
54
|
+
standard_index_operation
|
55
|
+
|
56
|
+
operation :create, :with_capability => :create_firewall do
|
57
|
+
param :name, :string, :required
|
58
|
+
param :description, :string, :required
|
59
|
+
control do
|
60
|
+
@firewall = driver.create_firewall(credentials, params )
|
61
|
+
status 201 # Created
|
62
|
+
response['Location'] = firewall_url(@firewall.id)
|
63
|
+
respond_to do |format|
|
64
|
+
format.xml { haml :"firewalls/show" }
|
65
|
+
format.html { haml :"firewalls/show" }
|
66
|
+
format.json { convert_to_json(:firewall, @firewall) }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
operation :destroy, :with_capability => :delete_firewall do
|
72
|
+
control do
|
73
|
+
driver.delete_firewall(credentials, params)
|
74
|
+
status 204
|
75
|
+
respond_to do |format|
|
76
|
+
format.xml
|
77
|
+
format.json
|
78
|
+
format.html { redirect(firewalls_url) }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
action :rules, :with_capability => :create_firewall_rule do
|
84
|
+
param :protocol, :required, :string, ['tcp','udp','icmp'], "Transport layer protocol for the rule"
|
85
|
+
param :port_from, :required, :string, [], "Start of port range for the rule"
|
86
|
+
param :port_to, :required, :string, [], "End of port range for the rule"
|
87
|
+
control do
|
88
|
+
#source IPs from params
|
89
|
+
addresses = params.inject([]){|result,current| result << current.last unless current.grep(/^ip[-_]address/i).empty?; result}
|
90
|
+
#source groups from params
|
91
|
+
groups = {}
|
92
|
+
max_groups = params.select{|k,v| k=~/^group/}.size/2
|
93
|
+
for i in (1..max_groups) do
|
94
|
+
groups.merge!({params["group#{i}"]=>params["group#{i}owner"]})
|
95
|
+
end
|
96
|
+
params['addresses'] = addresses
|
97
|
+
params['groups'] = groups
|
98
|
+
if addresses.empty? && groups.empty?
|
99
|
+
raise Deltacloud::ExceptionHandler::ValidationFailure.new(
|
100
|
+
StandardError.new("No sources. Specify at least one source ip_address or group")
|
101
|
+
)
|
102
|
+
end
|
103
|
+
driver.create_firewall_rule(credentials, params)
|
104
|
+
@firewall = driver.firewall(credentials, {:id => params[:id]})
|
105
|
+
status 201
|
106
|
+
respond_to do |format|
|
107
|
+
format.xml { haml :"firewalls/show" }
|
108
|
+
format.html { haml :"firewalls/show" }
|
109
|
+
format.json { convert_to_json(:firewall, @firewall) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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 HardwareProfiles < Base
|
18
|
+
|
19
|
+
check_capability :for => lambda { |m| !driver.class.send(m).empty? }
|
20
|
+
|
21
|
+
collection :hardware_profiles do
|
22
|
+
|
23
|
+
standard_index_operation :capability => :hardware_profiles
|
24
|
+
standard_show_operation :capability => :hardware_profiles
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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 Images < 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 :images do
|
25
|
+
@instance = Instance.new( :id => params[:instance_id] )
|
26
|
+
status 404 unless @instance
|
27
|
+
end
|
28
|
+
|
29
|
+
collection :images do
|
30
|
+
description "Within a cloud provider a realm represents a boundary containing resources"
|
31
|
+
|
32
|
+
operation :index, :with_capability => :images do
|
33
|
+
param :architecture, :string, :optional
|
34
|
+
control { filter_all(:images) }
|
35
|
+
end
|
36
|
+
|
37
|
+
operation :show, :with_capability => :image do
|
38
|
+
control { show(:image) }
|
39
|
+
end
|
40
|
+
|
41
|
+
operation :create, :with_capability => :create_image do
|
42
|
+
param :instance_id, :string, :required
|
43
|
+
control do
|
44
|
+
@image = driver.create_image(credentials, {
|
45
|
+
:id => params[:instance_id],
|
46
|
+
:name => params[:name],
|
47
|
+
:description => params[:description]
|
48
|
+
})
|
49
|
+
status 201 # Created
|
50
|
+
response['Location'] = image_url(@image.id)
|
51
|
+
respond_to do |format|
|
52
|
+
format.xml { haml :"images/show" }
|
53
|
+
format.json { xml_to_json('images/show') }
|
54
|
+
format.html { haml :"images/show" }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
operation :destroy, :with_capability => :destroy_image do
|
60
|
+
control do
|
61
|
+
driver.destroy_image(credentials, params[:id])
|
62
|
+
respond_to do |format|
|
63
|
+
format.xml { status 204 }
|
64
|
+
format.json { status 204 }
|
65
|
+
format.html { redirect(images_url) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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 InstanceStates < Base
|
18
|
+
|
19
|
+
check_capability :for => lambda { |m| !driver.send(m).nil? }
|
20
|
+
|
21
|
+
collection :instance_states do
|
22
|
+
operation :index, :with_capability => :instance_state_machine do
|
23
|
+
control do
|
24
|
+
@machine = driver.instance_state_machine
|
25
|
+
respond_to do |format|
|
26
|
+
format.xml { haml :'instance_states/show', :layout => false }
|
27
|
+
format.json do
|
28
|
+
out = []
|
29
|
+
@machine.states.each do |state|
|
30
|
+
transitions = state.transitions.collect do |t|
|
31
|
+
t.automatically? ? {:to => t.destination, :auto => 'true'} : {:to => t.destination, :action => t.action}
|
32
|
+
end
|
33
|
+
out << { :name => state, :transitions => transitions }
|
34
|
+
end
|
35
|
+
out.to_json
|
36
|
+
end
|
37
|
+
format.html { haml :'instance_states/show'}
|
38
|
+
format.gv { erb :"instance_states/show" }
|
39
|
+
format.png do
|
40
|
+
# Trick respond_to into looking up the right template for the
|
41
|
+
# graphviz file
|
42
|
+
gv = erb(:"instance_states/show")
|
43
|
+
png = ''
|
44
|
+
cmd = 'dot -Kdot -Gpad="0.2,0.2" -Gsize="5.0,8.0" -Gdpi="180" -Tpng'
|
45
|
+
Open3.popen3( cmd ) do |stdin, stdout, stderr|
|
46
|
+
stdin.write( gv )
|
47
|
+
stdin.close()
|
48
|
+
png = stdout.read
|
49
|
+
end
|
50
|
+
content_type 'image/png'
|
51
|
+
png
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,113 @@
|
|
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 Instances < 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(:instances) do
|
25
|
+
@instance = Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } )
|
26
|
+
@image = Image.new( :id => params[:image_id] )
|
27
|
+
@hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture )
|
28
|
+
@realms = [Realm.new(:id => params[:realm_id])] if params[:realm_id]
|
29
|
+
@realms ||= driver.realms(credentials)
|
30
|
+
@firewalls = driver.firewalls(credentials) if driver.class.has_feature? :instances, :firewalls
|
31
|
+
@keys = driver.keys(credentials) if driver.class.has_feature? :instances, :authentication_key
|
32
|
+
end
|
33
|
+
|
34
|
+
get route_for('/instances/:id/run') do
|
35
|
+
respond_to do |format|
|
36
|
+
@instance = driver.instances(credentials, :id => params[:id]).first
|
37
|
+
format.html {haml :"instances/run_command" }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
collection :instances do
|
42
|
+
|
43
|
+
standard_show_operation
|
44
|
+
standard_index_operation
|
45
|
+
|
46
|
+
operation :create, :with_capability => :create_instance do
|
47
|
+
param :image_id, :string, :required
|
48
|
+
param :realm_id, :string, :optional
|
49
|
+
param :hwp_id, :string, :optional
|
50
|
+
control do
|
51
|
+
@instance = driver.create_instance(credentials, params[:image_id], params)
|
52
|
+
if @instance.kind_of? Array
|
53
|
+
@elements = @instance
|
54
|
+
action_handler = "index"
|
55
|
+
else
|
56
|
+
response['Location'] = instance_url(@instance.id)
|
57
|
+
action_handler = "show"
|
58
|
+
end
|
59
|
+
status 201 # Created
|
60
|
+
respond_to do |format|
|
61
|
+
format.xml { haml :"instances/#{action_handler}" }
|
62
|
+
format.json { xml_to_json("instances/#{action_handler}") }
|
63
|
+
format.html do
|
64
|
+
if @elements
|
65
|
+
haml :"instances/index"
|
66
|
+
elsif @instance and @instance.id
|
67
|
+
response['Location'] = instance_url(@instance.id)
|
68
|
+
haml :"instances/show"
|
69
|
+
else
|
70
|
+
redirect instances_url
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
action :reboot, :with_capability => :reboot_instance do
|
78
|
+
description "Reboot a running instance."
|
79
|
+
control { instance_action(:reboot) }
|
80
|
+
end
|
81
|
+
|
82
|
+
action :start, :with_capability => :start_instance do
|
83
|
+
description "Start an instance."
|
84
|
+
control { instance_action(:start) }
|
85
|
+
end
|
86
|
+
|
87
|
+
action :stop, :with_capability => :stop_instance do
|
88
|
+
description "Stop a running instance."
|
89
|
+
control { instance_action(:stop) }
|
90
|
+
end
|
91
|
+
|
92
|
+
operation :destroy, :with_capability => :destroy_instance do
|
93
|
+
control { instance_action(:destroy) }
|
94
|
+
end
|
95
|
+
|
96
|
+
action :run, :with_capability => :run_on_instance do
|
97
|
+
param :cmd, :string, :required, [], "Shell command to run on instance"
|
98
|
+
param :private_key, :string, :optional, [], "Private key in PEM format for authentication"
|
99
|
+
param :password, :string, :optional, [], "Password used for authentication"
|
100
|
+
param :ip, :string, :optional, [], "IP address of target instance"
|
101
|
+
param :port, :string, :optional, ['22'], "Target port"
|
102
|
+
control do
|
103
|
+
@output = driver.run_on_instance(credentials, params)
|
104
|
+
respond_to do |format|
|
105
|
+
format.xml { haml :"instances/run" }
|
106
|
+
format.html { haml :"instances/run" }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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 Keys < Base
|
18
|
+
check_capability :for => lambda { |m| driver.respond_to? m }
|
19
|
+
check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
|
20
|
+
|
21
|
+
get route_for('/keys/new') do
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { haml :"keys/new" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
collection :keys do
|
28
|
+
|
29
|
+
standard_show_operation
|
30
|
+
standard_index_operation
|
31
|
+
|
32
|
+
operation :create, :with_capability => :create_key do
|
33
|
+
param :name, :string, :required
|
34
|
+
control do
|
35
|
+
@key = driver.create_key(credentials, { :key_name => params[:name] })
|
36
|
+
status 201
|
37
|
+
response['Location'] = key_url(@key.id)
|
38
|
+
respond_to do |format|
|
39
|
+
format.xml { haml :"keys/show", :ugly => true }
|
40
|
+
format.html { haml :"keys/show" }
|
41
|
+
format.json { convert_to_json(:key, @key)}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
operation :destroy, :with_capability => :destroy_key do
|
47
|
+
control do
|
48
|
+
driver.destroy_key(credentials, { :id => params[:id]})
|
49
|
+
status 204
|
50
|
+
respond_to do |format|
|
51
|
+
format.xml
|
52
|
+
format.json
|
53
|
+
format.html { redirect(keys_url) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|