deltacloud-core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +40 -28
- data/bin/deltacloud-db-upgrade +24 -0
- data/bin/deltacloudd +20 -9
- data/config.ru +12 -53
- data/db/migrations/1_add_realm_to_machine_template.rb +23 -0
- data/deltacloud-core.gemspec +11 -5
- data/lib/cimi/collections.rb +4 -31
- data/lib/cimi/collections/address_templates.rb +2 -5
- data/lib/cimi/collections/addresses.rb +2 -5
- data/lib/cimi/collections/base.rb +18 -6
- data/lib/cimi/collections/credentials.rb +2 -5
- data/lib/cimi/collections/machine_images.rb +2 -1
- data/lib/cimi/collections/machine_templates.rb +2 -5
- data/lib/cimi/collections/machines.rb +6 -9
- data/lib/cimi/collections/network_ports.rb +3 -3
- data/lib/cimi/collections/networks.rb +5 -8
- data/lib/cimi/collections/system_templates.rb +72 -0
- data/lib/cimi/collections/systems.rb +194 -0
- data/lib/cimi/collections/volume_configurations.rb +1 -1
- data/lib/cimi/collections/volume_images.rb +2 -1
- data/lib/cimi/collections/volume_templates.rb +3 -2
- data/lib/cimi/collections/volumes.rb +2 -2
- data/lib/cimi/dependencies.rb +0 -2
- data/lib/cimi/helpers/cimi_helper.rb +12 -57
- data/lib/cimi/helpers/database_helper.rb +0 -4
- data/lib/cimi/models.rb +25 -14
- data/lib/cimi/models/address.rb +4 -31
- data/lib/cimi/models/address_create.rb +51 -0
- data/lib/cimi/models/address_template.rb +8 -52
- data/lib/cimi/models/address_template_create.rb +44 -0
- data/lib/cimi/models/base.rb +44 -6
- data/lib/cimi/models/cloud_entry_point.rb +1 -1
- data/lib/cimi/models/credential.rb +1 -1
- data/lib/cimi/models/credential_create.rb +46 -0
- data/lib/cimi/models/credential_template.rb +24 -0
- data/lib/cimi/models/machine.rb +1 -71
- data/lib/cimi/models/machine_configuration.rb +3 -3
- data/lib/cimi/models/machine_create.rb +49 -0
- data/lib/cimi/models/machine_image.rb +2 -25
- data/lib/cimi/models/machine_image_create.rb +41 -0
- data/lib/cimi/models/machine_template.rb +14 -34
- data/lib/cimi/models/machine_template_create.rb +33 -0
- data/lib/cimi/models/network.rb +0 -38
- data/lib/cimi/models/network_create.rb +43 -0
- data/lib/cimi/models/network_port.rb +17 -17
- data/lib/cimi/models/network_template.rb +2 -3
- data/lib/cimi/models/resource.rb +22 -3
- data/lib/cimi/models/schema.rb +94 -8
- data/lib/cimi/models/system.rb +67 -0
- data/lib/cimi/models/system_template.rb +63 -0
- data/lib/cimi/models/volume.rb +2 -42
- data/lib/cimi/models/volume_configuration.rb +4 -4
- data/lib/cimi/models/volume_create.rb +58 -0
- data/lib/cimi/models/volume_image.rb +8 -17
- data/lib/cimi/models/volume_image_create.rb +47 -0
- data/lib/cimi/models/volume_template.rb +6 -19
- data/lib/cimi/models/volume_template_create.rb +33 -0
- data/lib/db.rb +14 -22
- data/lib/db/volume_template.rb +1 -1
- data/lib/deltacloud/api.rb +6 -5
- data/lib/deltacloud/collections.rb +4 -27
- data/lib/deltacloud/collections/base.rb +4 -0
- data/lib/deltacloud/collections/images.rb +1 -1
- data/lib/deltacloud/collections/instances.rb +2 -2
- data/lib/deltacloud/core_ext/array.rb +1 -0
- data/lib/deltacloud/core_ext/integer.rb +13 -9
- data/lib/deltacloud/core_ext/string.rb +45 -28
- data/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb +0 -9
- data/lib/deltacloud/drivers/base_driver.rb +45 -16
- data/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb +78 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +13 -9
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +44 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +164 -90
- data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +74 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +3 -3
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -1
- data/lib/deltacloud/drivers/mock/mock_driver.rb +161 -204
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +80 -0
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +6 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +61 -68
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +0 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +11 -6
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +11 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +0 -12
- data/lib/deltacloud/helpers/collection_helper.rb +106 -0
- data/lib/deltacloud/helpers/deltacloud_helper.rb +12 -8
- data/lib/deltacloud/models/address.rb +19 -17
- data/lib/deltacloud/models/base_model.rb +29 -26
- data/lib/deltacloud/models/blob.rb +22 -20
- data/lib/deltacloud/models/bucket.rb +21 -16
- data/lib/deltacloud/models/firewall.rb +18 -16
- data/lib/deltacloud/models/firewall_rule.rb +22 -20
- data/lib/deltacloud/models/image.rb +29 -28
- data/lib/deltacloud/models/instance.rb +92 -94
- data/lib/deltacloud/models/instance_address.rb +42 -40
- data/lib/deltacloud/models/instance_profile.rb +28 -26
- data/lib/deltacloud/models/key.rb +47 -45
- data/lib/deltacloud/models/load_balancer.rb +32 -31
- data/lib/deltacloud/models/metric.rb +76 -29
- data/lib/deltacloud/models/provider.rb +15 -13
- data/lib/deltacloud/models/realm.rb +15 -21
- data/lib/deltacloud/models/storage_snapshot.rb +23 -19
- data/lib/deltacloud/models/storage_volume.rb +35 -34
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +22 -0
- data/lib/initialize.rb +28 -0
- data/lib/initializers/database_initialize.rb +76 -0
- data/lib/initializers/frontend_initialize.rb +42 -0
- data/lib/initializers/mock_initialize.rb +33 -0
- data/lib/sinatra/rack_logger.rb +35 -24
- data/tests/cimi/collections/cloud_entry_point_test.rb +1 -7
- data/tests/cimi/collections/machine_images_test.rb +2 -2
- data/tests/cimi/collections/machine_templates_test.rb +75 -0
- data/tests/cimi/collections/machines_test.rb +2 -2
- data/tests/cimi/collections/system_templates_test.rb +41 -0
- data/tests/cimi/collections/systems_test.rb +50 -0
- data/tests/cimi/db/database_helper_test.rb +17 -25
- data/tests/cimi/db/db_helper.rb +1 -12
- data/tests/cimi/db/entity_test.rb +7 -8
- data/tests/cimi/model/machine_create_spec.rb +44 -0
- data/tests/cimi/model/machine_template_spec.rb +29 -0
- data/tests/cimi/model/resource_spec.rb +40 -0
- data/tests/cimi/model/schema_spec.rb +37 -0
- data/tests/cimi/spec_helper.rb +3 -0
- data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
- data/tests/deltacloud/collections/drivers_collection_test.rb +2 -2
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +2 -2
- data/tests/deltacloud/collections/images_collection_test.rb +2 -2
- data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
- data/tests/deltacloud/collections/instances_collection_test.rb +6 -3
- data/tests/deltacloud/collections/keys_collection_test.rb +2 -2
- data/tests/deltacloud/collections/realms_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_snapshots_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_volumes_collection_test.rb +2 -2
- data/tests/deltacloud/collections_test.rb +5 -5
- data/tests/deltacloud/common.rb +2 -13
- data/tests/deltacloud/launcher_test.rb +3 -3
- data/tests/deltacloud/rack_test.rb +2 -2
- data/tests/deltacloud/server_test.rb +1 -1
- data/tests/drivers/base/base_driver_test.rb +5 -5
- data/tests/drivers/base/common.rb +2 -12
- data/tests/drivers/ec2/buckets_test.rb +1 -1
- data/tests/drivers/ec2/images_test.rb +2 -2
- data/tests/drivers/ec2/instance_test.rb +6 -6
- data/tests/drivers/ec2/keys_test.rb +3 -3
- data/tests/drivers/ec2/realms_test.rb +2 -2
- data/tests/drivers/ec2/storage_snapshots_test.rb +1 -1
- data/tests/drivers/fgcp/common.rb +32 -0
- data/tests/drivers/fgcp/firewall_test.rb +70 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +61 -0
- data/tests/drivers/fgcp/images_test.rb +46 -0
- data/tests/drivers/fgcp/provider_test.rb +27 -0
- data/tests/drivers/fgcp/realms_test.rb +53 -0
- data/tests/drivers/fgcp/storage_volumes_test.rb +58 -0
- data/tests/drivers/gogrid/images_test.rb +2 -2
- data/tests/drivers/gogrid/instances_test.rb +2 -2
- data/tests/drivers/gogrid/realms_test.rb +2 -2
- data/tests/drivers/mock/images_test.rb +4 -4
- data/tests/drivers/mock/instances_test.rb +9 -9
- data/tests/drivers/mock/keys_test.rb +3 -3
- data/tests/drivers/mock/realms_test.rb +2 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +2 -2
- data/tests/drivers/mock/storage_volumes_test.rb +4 -4
- data/tests/drivers/models/instance_test.rb +2 -2
- data/tests/drivers/openstack/images_test.rb +2 -2
- data/tests/drivers/openstack/instances_test.rb +2 -3
- data/tests/drivers/openstack/keys_test.rb +1 -1
- data/tests/drivers/openstack/realms_test.rb +2 -11
- data/tests/drivers/rhevm/common.rb +33 -12
- data/tests/drivers/rhevm/images_test.rb +20 -12
- data/tests/drivers/rhevm/instance_test.rb +62 -46
- data/tests/drivers/rhevm/provider_test.rb +12 -6
- data/tests/drivers/rhevm/realms_test.rb +15 -9
- data/tests/ec2/query_parser_test.rb +1 -1
- data/tests/test_helper.rb +68 -12
- data/views/addresses/show.html.haml +1 -1
- data/views/buckets/show.html.haml +1 -1
- data/views/errors/{500.html.haml → common.html.haml} +0 -0
- data/views/errors/common.xml.haml +17 -0
- data/views/firewalls/index.xml.haml +2 -2
- data/views/firewalls/new.html.haml +2 -2
- data/views/images/show.html.haml +1 -1
- data/views/instances/run_command.html.haml +1 -1
- data/views/instances/show.html.haml +3 -3
- data/views/keys/index.html.haml +1 -0
- data/views/keys/show.html.haml +8 -4
- data/views/keys/show.xml.haml +3 -2
- data/views/load_balancers/new.html.haml +1 -1
- data/views/load_balancers/show.html.haml +2 -2
- data/views/metrics/show.html.haml +1 -1
- data/views/realms/index.html.haml +0 -2
- data/views/realms/show.html.haml +0 -4
- data/views/realms/show.xml.haml +0 -3
- data/views/storage_snapshots/index.html.haml +1 -1
- data/views/storage_snapshots/new.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +3 -3
- metadata +90 -41
- data/views/errors/400.html.haml +0 -41
- data/views/errors/400.xml.haml +0 -3
- data/views/errors/401.html.haml +0 -26
- data/views/errors/401.xml.haml +0 -3
- data/views/errors/403.html.haml +0 -42
- data/views/errors/403.xml.haml +0 -9
- data/views/errors/404.html.haml +0 -28
- data/views/errors/404.xml.haml +0 -3
- data/views/errors/405.html.haml +0 -29
- data/views/errors/405.xml.haml +0 -5
- data/views/errors/409.html.haml +0 -47
- data/views/errors/409.xml.haml +0 -11
- data/views/errors/500.xml.haml +0 -13
- data/views/errors/501.html.haml +0 -44
- data/views/errors/501.xml.haml +0 -1
- data/views/errors/502.html.haml +0 -44
- data/views/errors/502.xml.haml +0 -1
- data/views/errors/504.html.haml +0 -43
- data/views/errors/504.xml.haml +0 -1
@@ -46,11 +46,8 @@ module CIMI::Collections
|
|
46
46
|
operation :create, :with_capability => :create_key do
|
47
47
|
description "Show specific machine admin"
|
48
48
|
control do
|
49
|
-
|
50
|
-
|
51
|
-
else
|
52
|
-
new_admin = Credential.create_from_xml(request.body.read, self)
|
53
|
-
end
|
49
|
+
c = CIMI::Model::CredentialCreate.parse(request.body, request.content_type)
|
50
|
+
new_admin = c.create(self)
|
54
51
|
headers_for_create new_admin
|
55
52
|
respond_to do |format|
|
56
53
|
format.json { new_admin.to_json }
|
@@ -46,7 +46,8 @@ module CIMI::Collections
|
|
46
46
|
operation :create, :with_capability => :create_image do
|
47
47
|
description "Create a new machine image."
|
48
48
|
control do
|
49
|
-
|
49
|
+
mi = CIMI::Model::MachineImageCreate.parse(request.body, request.content_type)
|
50
|
+
machine_image = mi.create(self)
|
50
51
|
headers_for_create machine_image
|
51
52
|
respond_to do |format|
|
52
53
|
format.xml { machine_image.to_xml }
|
@@ -45,11 +45,8 @@ module CIMI::Collections
|
|
45
45
|
operation :create do
|
46
46
|
description "Create new machine template"
|
47
47
|
control do
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
new_machine_template = CIMI::Model::MachineTemplate.create_from_xml(request.body.read, self)
|
52
|
-
end
|
48
|
+
mt = CIMI::Model::MachineTemplateCreate.parse(request.body, request.content_type)
|
49
|
+
new_machine_template = mt.create(self)
|
53
50
|
headers_for_create new_machine_template
|
54
51
|
respond_to do |format|
|
55
52
|
format.json { new_machine_template.to_json }
|
@@ -46,11 +46,8 @@ module CIMI::Collections
|
|
46
46
|
operation :create, :with_capability => :create_instance do
|
47
47
|
description "Create a new Machine entity."
|
48
48
|
control do
|
49
|
-
|
50
|
-
|
51
|
-
else
|
52
|
-
new_machine = Machine.create_from_xml(request.body.read, self)
|
53
|
-
end
|
49
|
+
mc = MachineCreate.parse(request.body, request.content_type)
|
50
|
+
new_machine = mc.create(self)
|
54
51
|
headers_for_create new_machine
|
55
52
|
respond_to do |format|
|
56
53
|
format.json { new_machine.to_json }
|
@@ -72,7 +69,7 @@ module CIMI::Collections
|
|
72
69
|
param :id, :string, :required
|
73
70
|
control do
|
74
71
|
machine = Machine.find(params[:id], self)
|
75
|
-
if
|
72
|
+
if current_content_type == :json
|
76
73
|
action = Action.from_json(request.body.read)
|
77
74
|
else
|
78
75
|
action = Action.from_xml(request.body.read)
|
@@ -89,7 +86,7 @@ module CIMI::Collections
|
|
89
86
|
param :id, :string, :required
|
90
87
|
control do
|
91
88
|
machine = Machine.find(params[:id], self)
|
92
|
-
if
|
89
|
+
if current_content_type == :json
|
93
90
|
action = Action.from_json(request.body.read.gsub("restart", "reboot"))
|
94
91
|
else
|
95
92
|
action = Action.from_xml(request.body.read.gsub("restart", "reboot"))
|
@@ -106,7 +103,7 @@ module CIMI::Collections
|
|
106
103
|
param :id, :string, :required
|
107
104
|
control do
|
108
105
|
machine = Machine.find(params[:id], self)
|
109
|
-
if
|
106
|
+
if current_content_type == :json
|
110
107
|
action = Action.from_json(request.body.read)
|
111
108
|
else
|
112
109
|
action = Action.from_xml(request.body.read)
|
@@ -174,7 +171,7 @@ module CIMI::Collections
|
|
174
171
|
description "Attach CIMI Volume(s) to a machine."
|
175
172
|
param :id, :string, :required
|
176
173
|
control do
|
177
|
-
if
|
174
|
+
if current_content_type == :json
|
178
175
|
volume_to_attach, location = MachineVolume.find_to_attach_from_json(request.body.read, self)
|
179
176
|
else
|
180
177
|
volume_to_attach, location = MachineVolume.find_to_attach_from_xml(request.body.read, self)
|
@@ -47,7 +47,7 @@ module CIMI::Collections
|
|
47
47
|
operation :create, :with_capability => :create_network_port do
|
48
48
|
description "Create a new NetworkPort"
|
49
49
|
control do
|
50
|
-
if
|
50
|
+
if current_content_type == :json
|
51
51
|
network_port = CIMI::Model::NetworkPort.create(request.body.read, self, :json)
|
52
52
|
else
|
53
53
|
network_port = CIMI::Model::NetworkPort.create(request.body.read, self, :xml)
|
@@ -73,7 +73,7 @@ module CIMI::Collections
|
|
73
73
|
control do
|
74
74
|
network_port = NetworkPort.find(params[:id], self)
|
75
75
|
report_error(404) unless network_port
|
76
|
-
if
|
76
|
+
if current_content_type == :json
|
77
77
|
action = Action.from_json(request.body.read)
|
78
78
|
else
|
79
79
|
action = Action.from_xml(request.body.read)
|
@@ -91,7 +91,7 @@ module CIMI::Collections
|
|
91
91
|
control do
|
92
92
|
network_port = NetworkPort.find(params[:id], self)
|
93
93
|
report_error(404) unless network_port
|
94
|
-
if
|
94
|
+
if current_content_type == :json
|
95
95
|
action = Action.from_json(request.body.read)
|
96
96
|
else
|
97
97
|
action = Action.from_xml(request.body.read)
|
@@ -46,11 +46,8 @@ module CIMI::Collections
|
|
46
46
|
operation :create, :with_capability => :create_network do
|
47
47
|
description "Create a new Network"
|
48
48
|
control do
|
49
|
-
|
50
|
-
|
51
|
-
else
|
52
|
-
network = Network.create(request.body.read, self, :xml)
|
53
|
-
end
|
49
|
+
n = CIMI::Model::NetworkCreate.parse(request.body, request.content_type)
|
50
|
+
network = n.create(self)
|
54
51
|
respond_to do |format|
|
55
52
|
format.xml { network.to_xml}
|
56
53
|
format.json { network.to_json }
|
@@ -72,7 +69,7 @@ module CIMI::Collections
|
|
72
69
|
control do
|
73
70
|
network = Network.find(params[:id], self)
|
74
71
|
report_error(404) unless network
|
75
|
-
if
|
72
|
+
if current_content_type == :json
|
76
73
|
action = Action.from_json(request.body.read)
|
77
74
|
else
|
78
75
|
action = Action.from_xml(request.body.read)
|
@@ -90,7 +87,7 @@ module CIMI::Collections
|
|
90
87
|
control do
|
91
88
|
network = Network.find(params[:id], self)
|
92
89
|
report_error(404) unless network
|
93
|
-
if
|
90
|
+
if current_content_type == :json
|
94
91
|
action = Action.from_json(request.body.read)
|
95
92
|
else
|
96
93
|
action = Action.from_xml(request.body.read)
|
@@ -108,7 +105,7 @@ module CIMI::Collections
|
|
108
105
|
control do
|
109
106
|
network = Network.find(params[:id], self)
|
110
107
|
report_error(404) unless network
|
111
|
-
if
|
108
|
+
if current_content_type == :json
|
112
109
|
action = Action.from_json(request.body.read)
|
113
110
|
else
|
114
111
|
action = Action.from_xml(request.body.read)
|
@@ -0,0 +1,72 @@
|
|
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 CIMI::Collections
|
17
|
+
class SystemTemplates < Base
|
18
|
+
|
19
|
+
set :capability, lambda { |m| driver.respond_to? m }
|
20
|
+
|
21
|
+
collection :system_templates do
|
22
|
+
|
23
|
+
operation :index, :with_capability => :system_templates do
|
24
|
+
description "List all system templates"
|
25
|
+
control do
|
26
|
+
system_templates = CIMI::Model::SystemTemplate.list(self).select_by(params['$select'])
|
27
|
+
respond_to do |format|
|
28
|
+
format.xml { system_templates.to_xml }
|
29
|
+
format.json { system_templates.to_json }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
operation :show, :with_capability => :system_templates do
|
35
|
+
description "Show specific system template"
|
36
|
+
control do
|
37
|
+
system_template = CIMI::Model::SystemTemplate.find(params[:id], self)
|
38
|
+
respond_to do |format|
|
39
|
+
format.xml { system_template.to_xml }
|
40
|
+
format.json { system_template.to_json }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
operation :create, :with_capability => :create_system_template do
|
46
|
+
description "Create new system template"
|
47
|
+
control do
|
48
|
+
if grab_content_type(request.content_type, request.body) == :json
|
49
|
+
new_system_template = CIMI::Model::SystemTemplate.create_from_json(request.body.read, self)
|
50
|
+
else
|
51
|
+
new_system_template = CIMI::Model::SystemTemplate.create_from_xml(request.body.read, self)
|
52
|
+
end
|
53
|
+
headers_for_create new_system_template
|
54
|
+
respond_to do |format|
|
55
|
+
format.json { new_system_template.to_json }
|
56
|
+
format.xml { new_system_template.to_xml }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
operation :destroy, :with_capability => :destroy_system_template do
|
62
|
+
description "Delete a specified system template"
|
63
|
+
control do
|
64
|
+
CIMI::Model::SystemTemplate.delete!(params[:id], self)
|
65
|
+
no_content_with_status(200)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,194 @@
|
|
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 CIMI::Collections
|
17
|
+
class Systems < Base
|
18
|
+
|
19
|
+
set :capability, lambda { |m| driver.respond_to? m }
|
20
|
+
|
21
|
+
collection :systems do
|
22
|
+
description 'List all systems'
|
23
|
+
|
24
|
+
operation :index, :with_capability => :systems do
|
25
|
+
description "List all systems"
|
26
|
+
control do
|
27
|
+
systems = System.list(self).select_by(params['$select']).filter_by(params['$filter'])
|
28
|
+
respond_to do |format|
|
29
|
+
format.xml { systems.to_xml }
|
30
|
+
format.json { systems.to_json }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
operation :show, :with_capability => :systems do
|
36
|
+
description "Show specific system."
|
37
|
+
control do
|
38
|
+
system = System.find(params[:id], self)
|
39
|
+
respond_to do |format|
|
40
|
+
format.xml { system.to_xml }
|
41
|
+
format.json { system.to_json }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
operation :create, :with_capability => :create_system do
|
47
|
+
description "Create a new System entity."
|
48
|
+
control do
|
49
|
+
if grab_content_type(request.content_type, request.body) == :json
|
50
|
+
new_system = System.create_from_json(request.body.read, self)
|
51
|
+
else
|
52
|
+
new_system = System.create_from_xml(request.body.read, self)
|
53
|
+
end
|
54
|
+
headers_for_create new_system
|
55
|
+
respond_to do |format|
|
56
|
+
format.json { new_system.to_json }
|
57
|
+
format.xml { new_system.to_xml }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
operation :destroy, :with_capability => :destroy_system do
|
63
|
+
description "Delete a specified system."
|
64
|
+
control do
|
65
|
+
System.delete!(params[:id], self)
|
66
|
+
no_content_with_status(200)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
action :stop, :with_capability => :stop_system do
|
71
|
+
description "Stop specific system."
|
72
|
+
param :id, :string, :required
|
73
|
+
control do
|
74
|
+
system = System.find(params[:id], self)
|
75
|
+
action = Action.parse(request.body,
|
76
|
+
request.content_type)
|
77
|
+
system.perform(action, self) do |operation|
|
78
|
+
no_content_with_status(202) if operation.success?
|
79
|
+
# Handle errors using operation.failure?
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
action :restart, :with_capability => :reboot_system do
|
85
|
+
description "Restart specific system."
|
86
|
+
param :id, :string, :required
|
87
|
+
control do
|
88
|
+
system = System.find(params[:id], self)
|
89
|
+
if grab_content_type(request.content_type, request.body) == :json
|
90
|
+
action = Action.from_json(request.body.read.gsub("restart", "reboot"))
|
91
|
+
else
|
92
|
+
action = Action.from_xml(request.body.read.gsub("restart", "reboot"))
|
93
|
+
end
|
94
|
+
system.perform(action, self) do |operation|
|
95
|
+
no_content_with_status(202) if operation.success?
|
96
|
+
# Handle errors using operation.failure?
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
action :start, :with_capability => :start_system do
|
102
|
+
description "Start specific system."
|
103
|
+
param :id, :string, :required
|
104
|
+
control do
|
105
|
+
system = System.find(params[:id], self)
|
106
|
+
if grab_content_type(request.content_type, request.body) == :json
|
107
|
+
action = Action.from_json(request.body.read)
|
108
|
+
else
|
109
|
+
action = Action.from_xml(request.body.read)
|
110
|
+
end
|
111
|
+
system.perform(action, self) do |operation|
|
112
|
+
no_content_with_status(202) if operation.success?
|
113
|
+
# Handle errors using operation.failure?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
action :pause, :with_capability => :pause_system do
|
119
|
+
description "Pause specific system."
|
120
|
+
param :id, :string, :required
|
121
|
+
control do
|
122
|
+
system = System.find(params[:id], self)
|
123
|
+
if grab_content_type(request.content_type, request.body) == :json
|
124
|
+
action = Action.from_json(request.body.read)
|
125
|
+
else
|
126
|
+
action = Action.from_xml(request.body.read)
|
127
|
+
end
|
128
|
+
system.perform(action, self) do |operation|
|
129
|
+
no_content_with_status(202) if operation.success?
|
130
|
+
# Handle errors using operation.failure?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
action :suspend, :with_capability => :suspend_system do
|
136
|
+
description "Suspend specific system."
|
137
|
+
param :id, :string, :required
|
138
|
+
control do
|
139
|
+
system = System.find(params[:id], self)
|
140
|
+
if grab_content_type(request.content_type, request.body) == :json
|
141
|
+
action = Action.from_json(request.body.read)
|
142
|
+
else
|
143
|
+
action = Action.from_xml(request.body.read)
|
144
|
+
end
|
145
|
+
system.perform(action, self) do |operation|
|
146
|
+
no_content_with_status(202) if operation.success?
|
147
|
+
# Handle errors using operation.failure?
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
#use rabbit subcollections for volumes index/show:
|
153
|
+
collection :volumes, :with_id => :vol_id do
|
154
|
+
|
155
|
+
operation :index, :with_capability => :storage_volumes do
|
156
|
+
description "Retrieve the System's SystemVolumeCollection"
|
157
|
+
control do
|
158
|
+
volumes = CIMI::Model::SystemVolume.collection_for_system(params[:id], self)
|
159
|
+
respond_to do |format|
|
160
|
+
format.json {volumes.to_json}
|
161
|
+
format.xml {volumes.to_xml}
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
operation :show, :with_capability => :storage_volumes do
|
167
|
+
description "Retrieve a System's specific SystemVolume"
|
168
|
+
control do
|
169
|
+
volume = CIMI::Model::SystemVolume.find(params[:id], self, params[:vol_id])
|
170
|
+
respond_to do |format|
|
171
|
+
format.json {volume.to_json}
|
172
|
+
format.xml {volume.to_xml}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
operation :destroy, :with_capability => :detach_storage_volume do
|
178
|
+
description "Remove/detach a volume from the System's SystemVolumeCollection"
|
179
|
+
control do
|
180
|
+
system_volume = CIMI::Model::SystemVolume.find(params[:id], self, params[:vol_id])
|
181
|
+
location = system_volume.initial_location
|
182
|
+
system_volumes = System.detach_volume(params[:vol_id], location, self)
|
183
|
+
respond_to do |format|
|
184
|
+
format.json{ system_volumes.to_json}
|
185
|
+
format.xml{ system_volumes.to_xml}
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
@@ -45,7 +45,7 @@ module CIMI::Collections
|
|
45
45
|
operation :create, :with_capability => :create_storage_volume do
|
46
46
|
description "Create new VolumeConfiguration"
|
47
47
|
control do
|
48
|
-
if
|
48
|
+
if current_content_type == :json
|
49
49
|
new_config = CIMI::Model::VolumeConfiguration.create_from_json(request.body.read, self)
|
50
50
|
else
|
51
51
|
new_config = CIMI::Model::VolumeConfiguration.create_from_xml(request.body.read, self)
|
@@ -46,7 +46,8 @@ module CIMI::Collections
|
|
46
46
|
operation :create, :with_capability => :create_storage_snapshot do
|
47
47
|
description "Create a new volume image."
|
48
48
|
control do
|
49
|
-
|
49
|
+
img = CIMI::Model::VolumeImageCreate.parse(request.body, request.content_type)
|
50
|
+
volume_image = img.create(self)
|
50
51
|
headers_for_create volume_image
|
51
52
|
respond_to do |format|
|
52
53
|
format.xml { volume_image.to_xml }
|
@@ -45,8 +45,9 @@ module CIMI::Collections
|
|
45
45
|
operation :create, :with_capability => :create_storage_volume do
|
46
46
|
description "Create new VolumeTemplate"
|
47
47
|
control do
|
48
|
-
|
49
|
-
|
48
|
+
puts request.body
|
49
|
+
vol = CIMI::Model::VolumeTemplateCreate.parse(request.body, request.content_type)
|
50
|
+
new_template = vol.create(self)
|
50
51
|
headers_for_create new_template
|
51
52
|
respond_to do |format|
|
52
53
|
format.json { new_template.to_json }
|