deltacloud-core 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/LICENSE +23 -0
  2. data/NOTICE +3 -0
  3. data/Rakefile +32 -20
  4. data/bin/deltacloudd +1 -1
  5. data/config.ru +25 -32
  6. data/deltacloud-core.gemspec +1 -1
  7. data/lib/cimi/collections.rb +4 -1
  8. data/lib/cimi/collections/address_templates.rb +2 -2
  9. data/lib/cimi/collections/addresses.rb +1 -1
  10. data/lib/cimi/collections/base.rb +64 -0
  11. data/lib/cimi/collections/{machine_admins.rb → credentials.rb} +12 -12
  12. data/lib/cimi/collections/{vsp_templates.rb → forwarding_group_templates.rb} +12 -16
  13. data/lib/cimi/collections/{vsp_configurations.rb → forwarding_groups.rb} +12 -13
  14. data/lib/cimi/collections/machine_configurations.rb +2 -2
  15. data/lib/cimi/collections/machine_images.rb +1 -1
  16. data/lib/cimi/collections/machines.rb +8 -2
  17. data/lib/cimi/collections/network_configurations.rb +2 -2
  18. data/lib/cimi/collections/{routing_groups.rb → network_port_configurations.rb} +12 -12
  19. data/lib/cimi/collections/{routing_group_templates.rb → network_port_templates.rb} +15 -12
  20. data/lib/cimi/collections/{vsps.rb → network_ports.rb} +33 -32
  21. data/lib/cimi/collections/network_templates.rb +2 -2
  22. data/lib/cimi/collections/networks.rb +17 -2
  23. data/lib/cimi/collections/{entity_metadata.rb → resource_metadata.rb} +10 -10
  24. data/lib/cimi/collections/volume_configurations.rb +1 -1
  25. data/lib/cimi/collections/volume_images.rb +1 -1
  26. data/lib/cimi/collections/volumes.rb +1 -2
  27. data/lib/cimi/dependencies.rb +1 -1
  28. data/lib/cimi/helpers.rb +3 -84
  29. data/lib/cimi/helpers/cimi_helper.rb +15 -14
  30. data/lib/cimi/models.rb +20 -36
  31. data/lib/cimi/models/address.rb +32 -4
  32. data/lib/cimi/models/address_template.rb +2 -2
  33. data/lib/cimi/models/base.rb +24 -5
  34. data/lib/cimi/models/cloud_entry_point.rb +4 -9
  35. data/lib/cimi/models/collection.rb +101 -0
  36. data/lib/cimi/models/{machine_admin.rb → credential.rb} +6 -4
  37. data/lib/cimi/models/disk_collection.rb +1 -2
  38. data/lib/cimi/models/{routing_group_template.rb → forwarding_group.rb} +5 -3
  39. data/lib/cimi/models/{routing_group.rb → forwarding_group_template.rb} +5 -3
  40. data/lib/cimi/models/machine.rb +9 -7
  41. data/lib/cimi/models/machine_configuration.rb +2 -0
  42. data/lib/cimi/models/machine_image.rb +2 -0
  43. data/lib/cimi/models/machine_template.rb +3 -1
  44. data/lib/cimi/models/machine_volume_collection.rb +1 -1
  45. data/lib/cimi/models/network.rb +2 -0
  46. data/lib/cimi/models/network_configuration.rb +4 -8
  47. data/lib/cimi/models/{vsp.rb → network_port.rb} +7 -11
  48. data/lib/cimi/models/{network_configuration_collection.rb → network_port_collection.rb} +25 -8
  49. data/lib/cimi/models/{vsp_configuration.rb → network_port_configuration.rb} +6 -10
  50. data/lib/cimi/models/{network_collection.rb → network_port_configuration_collection.rb} +9 -9
  51. data/lib/cimi/models/{vsp_template.rb → network_port_template.rb} +6 -4
  52. data/lib/cimi/models/{network_template_collection.rb → network_port_template_collection.rb} +10 -8
  53. data/lib/cimi/models/network_template.rb +3 -1
  54. data/lib/cimi/models/{entity_metadata.rb → resource_metadata.rb} +16 -15
  55. data/lib/cimi/models/schema.rb +23 -12
  56. data/lib/cimi/models/volume.rb +2 -0
  57. data/lib/cimi/models/volume_configuration.rb +2 -0
  58. data/lib/cimi/models/volume_image.rb +2 -0
  59. data/lib/cimi/models/volume_template.rb +2 -0
  60. data/lib/cimi/server.rb +10 -6
  61. data/lib/deltacloud/collections.rb +7 -2
  62. data/lib/deltacloud/collections/addresses.rb +3 -1
  63. data/lib/deltacloud/collections/base.rb +64 -0
  64. data/lib/deltacloud/collections/buckets.rb +14 -4
  65. data/lib/deltacloud/collections/drivers.rb +1 -1
  66. data/lib/deltacloud/collections/firewalls.rb +1 -1
  67. data/lib/deltacloud/collections/instances.rb +5 -1
  68. data/lib/deltacloud/collections/keys.rb +1 -1
  69. data/lib/deltacloud/collections/load_balancers.rb +2 -0
  70. data/lib/deltacloud/collections/storage_volumes.rb +3 -5
  71. data/lib/deltacloud/core_ext.rb +1 -0
  72. data/lib/deltacloud/core_ext/hash.rb +8 -0
  73. data/lib/deltacloud/core_ext/ordered_hash.rb +222 -0
  74. data/lib/deltacloud/core_ext/string.rb +9 -0
  75. data/lib/deltacloud/drivers/aruba/aruba_driver.rb +0 -9
  76. data/lib/deltacloud/drivers/base_driver.rb +22 -4
  77. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +0 -4
  78. data/lib/deltacloud/drivers/exceptions.rb +30 -13
  79. data/lib/deltacloud/drivers/features.rb +7 -0
  80. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1 -9
  81. data/lib/deltacloud/drivers/google/google_driver.rb +13 -0
  82. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.1.yml +3 -0
  83. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.2.yml +3 -0
  84. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.3.yml +3 -0
  85. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.4.yml +3 -0
  86. data/lib/deltacloud/drivers/mock/mock_driver.rb +65 -1
  87. data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +55 -32
  88. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +18 -6
  89. data/lib/deltacloud/helpers.rb +0 -75
  90. data/lib/deltacloud/helpers/deltacloud_helper.rb +66 -28
  91. data/lib/deltacloud/helpers/driver_helper.rb +7 -0
  92. data/lib/deltacloud/helpers/rabbit_helper.rb +51 -0
  93. data/lib/deltacloud/server.rb +12 -14
  94. data/lib/deltacloud/version.rb +1 -1
  95. data/lib/deltacloud_rack.rb +26 -2
  96. data/lib/ec2/query_parser.rb +18 -3
  97. data/lib/sinatra/rack_accept.rb +7 -2
  98. data/lib/sinatra/rack_matrix_params.rb +14 -14
  99. data/public/javascripts/cmwgapp.js +2 -2
  100. data/tests/cimi/collections/cloud_entry_point_test.rb +3 -3
  101. data/tests/cimi/collections/machine_images_test.rb +2 -2
  102. data/tests/cimi/collections/machines_test.rb +1 -1
  103. data/tests/cimi/collections/url_helper_test.rb +31 -0
  104. data/tests/cimi/spec/cimi/model/{machine_admin_spec.rb → credential_spec.rb} +4 -4
  105. data/tests/deltacloud/base_collection_test.rb +0 -5
  106. data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
  107. data/tests/deltacloud/collections/drivers_collection_test.rb +1 -1
  108. data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +1 -1
  109. data/tests/deltacloud/collections/images_collection_test.rb +1 -1
  110. data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
  111. data/tests/deltacloud/collections/instances_collection_test.rb +1 -1
  112. data/tests/deltacloud/collections/keys_collection_test.rb +1 -4
  113. data/tests/deltacloud/deltacloud_helper_test.rb +0 -9
  114. data/tests/deltacloud/server_test.rb +1 -1
  115. data/tests/drivers/base/base_driver_test.rb +30 -0
  116. data/tests/drivers/base/common.rb +14 -0
  117. data/tests/drivers/base/exceptions_test.rb +64 -0
  118. data/tests/drivers/ec2/buckets_test.rb +45 -0
  119. data/tests/drivers/ec2/keys_test.rb +1 -1
  120. data/tests/drivers/google/buckets_test.rb +2 -2
  121. data/tests/drivers/google/common.rb +3 -3
  122. data/tests/test_helper.rb +28 -0
  123. data/views/api/show.html.haml +2 -2
  124. data/views/api/show.xml.haml +1 -1
  125. data/views/buckets/index.html.haml +1 -1
  126. data/views/cimi/cloudEntryPoint/index.xml.haml +1 -1
  127. data/views/cimi/collection/index.html.haml +3 -3
  128. data/views/cimi/collection/response.xml.haml +1 -1
  129. data/views/cimi/error.html.haml +1 -1
  130. data/views/cimi/errors/500.xml.haml +1 -1
  131. data/views/cimi/layout.html.haml +1 -1
  132. data/views/cimi/machine_configurations/show.html.haml +2 -2
  133. data/views/cimi/machine_configurations/show.xml.haml +1 -1
  134. data/views/cimi/machine_images/show.html.haml +2 -2
  135. data/views/cimi/machine_images/show.xml.haml +1 -1
  136. data/views/cimi/machines/show.html.haml +2 -2
  137. data/views/cimi/machines/show.xml.haml +1 -1
  138. data/views/cimi/volumes/show.html.haml +2 -2
  139. data/views/cimi/volumes/show.xml.haml +1 -1
  140. data/views/docs/collection.html.haml +1 -1
  141. data/views/docs/collection.xml.haml +2 -2
  142. data/views/docs/index.html.haml +1 -1
  143. data/views/docs/index.xml.haml +1 -1
  144. data/views/docs/operation.xml.haml +1 -1
  145. data/views/error.html.haml +1 -1
  146. data/views/errors/500.html.haml +7 -4
  147. data/views/firewalls/index.html.haml +1 -1
  148. data/views/firewalls/show.html.haml +1 -1
  149. data/views/images/show.html.haml +2 -2
  150. data/views/index.html.haml +9 -0
  151. data/views/instance_states/show.html.haml +1 -1
  152. data/views/instances/run_command.html.haml +1 -1
  153. data/views/instances/show.html.haml +2 -2
  154. data/views/keys/index.html.haml +1 -1
  155. data/views/layout.html.haml +1 -1
  156. data/views/load_balancers/index.html.haml +1 -1
  157. data/views/load_balancers/show.html.haml +3 -3
  158. data/views/storage_snapshots/show.html.haml +1 -1
  159. data/views/storage_volumes/attach.html.haml +1 -1
  160. data/views/storage_volumes/index.html.haml +1 -1
  161. data/views/storage_volumes/show.html.haml +4 -4
  162. metadata +40 -43
  163. data/lib/cimi/models/address_collection.rb +0 -34
  164. data/lib/cimi/models/address_template_collection.rb +0 -34
  165. data/lib/cimi/models/entity_metadata_collection.rb +0 -31
  166. data/lib/cimi/models/machine_admin_collection.rb +0 -34
  167. data/lib/cimi/models/machine_collection.rb +0 -37
  168. data/lib/cimi/models/machine_configuration_collection.rb +0 -36
  169. data/lib/cimi/models/machine_image_collection.rb +0 -36
  170. data/lib/cimi/models/machine_template_collection.rb +0 -36
  171. data/lib/cimi/models/routing_group_collection.rb +0 -34
  172. data/lib/cimi/models/routing_group_template_collection.rb +0 -35
  173. data/lib/cimi/models/volume_collection.rb +0 -36
  174. data/lib/cimi/models/volume_configuration_collection.rb +0 -36
  175. data/lib/cimi/models/volume_image_collection.rb +0 -36
  176. data/lib/cimi/models/volume_template_collection.rb +0 -36
  177. data/lib/cimi/models/vsp_collection.rb +0 -34
  178. data/lib/cimi/models/vsp_configuration_collection.rb +0 -34
  179. data/lib/cimi/models/vsp_template_collection.rb +0 -34
  180. data/lib/deltacloud/helpers/url_helper.rb +0 -115
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::MachineConfigurationCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :machine_configuration
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::MachineConfiguration)
23
-
24
- def self.default(context)
25
- machine_configurations = CIMI::Model::MachineConfiguration.all(context)
26
- self.new(
27
- :id => context.machine_configurations_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} MachineConfigurationCollection",
31
- :count => machine_configurations.count,
32
- :machine_configurations => machine_configurations
33
- )
34
- end
35
-
36
- end
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::MachineImageCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :machine_image
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::MachineImage)
23
-
24
- def self.default(context)
25
- machine_images = CIMI::Model::MachineImage.all(context)
26
- self.new(
27
- :id => context.machine_images_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} MachineImageCollection",
31
- :count => machine_images.count,
32
- :machine_images => machine_images
33
- )
34
- end
35
-
36
- end
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::MachineTemplateCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :machine_template
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::MachineTemplate)
23
-
24
- def self.default(context)
25
- machine_templates = CIMI::Model::MachineTemplate.all(context)
26
- self.new(
27
- :id => context.machine_template_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} MachineTemplateCollection",
31
- :count => machine_templates.size,
32
- :machine_templates => machine_templates
33
- )
34
- end
35
-
36
- end
@@ -1,34 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::RoutingGroupCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :routing_group
19
-
20
- array :routing_groups do
21
- scalar :href
22
- end
23
-
24
- def self.default(context)
25
- self.new(
26
- :id => context.routing_groups_url,
27
- :name => 'default',
28
- :created => Time.now,
29
- :description => "#{context.driver.name.capitalize} RoutingGroupCollection",
30
- :routing_groups => CIMI::Model::RoutingGroup.all_uri(context)
31
- )
32
- end
33
-
34
- end
@@ -1,35 +0,0 @@
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
-
17
- class CIMI::Model::RoutingGroupTemplateCollection < CIMI::Model::Base
18
-
19
- act_as_root_entity :routing_group_template
20
-
21
- array :routing_group_templates do
22
- scalar :href
23
- end
24
-
25
- def self.default(context)
26
- self.new(
27
- :id => context.routing_group_templates_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} RoutingGroupTemplateCollection",
31
- :routing_group_templates => CIMI::Model::RoutingGroupTemplate.all_uri(context)
32
- )
33
- end
34
-
35
- end
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VolumeCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :volume
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::Volume)
23
-
24
- def self.default(context)
25
- volumes = CIMI::Model::Volume.all(context)
26
- self.new(
27
- :id => context.volumes_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} VolumeCollection",
31
- :count => volumes.count,
32
- :volumes => volumes
33
- )
34
- end
35
-
36
- end
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VolumeConfigurationCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :volume_configuration
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::VolumeConfiguration)
23
-
24
- def self.default(context)
25
- volume_configurations = CIMI::Model::VolumeConfiguration.all(context)
26
- self.new(
27
- :id => context.volume_configurations_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} VolumeConfigurationCollection",
31
- :count => volume_configurations.size,
32
- :volume_configurations => volume_configurations
33
- )
34
- end
35
-
36
- end
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VolumeImageCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :volume_image
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::VolumeImage)
23
-
24
- def self.default(context)
25
- volume_images = CIMI::Model::VolumeImage.all(context)
26
- self.new(
27
- :id => context.volume_images_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} VolumeImageCollection",
31
- :count => volume_images.count,
32
- :volume_images => volume_images
33
- )
34
- end
35
-
36
- end
@@ -1,36 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VolumeTemplateCollection < CIMI::Model::Base
17
-
18
- act_as_root_entity :volume_template
19
-
20
- text :count
21
-
22
- self.schema.add_collection_member_array(CIMI::Model::VolumeTemplate)
23
-
24
- def self.default(context)
25
- volume_templates = CIMI::Model::VolumeTemplate.all(context)
26
- self.new(
27
- :id => context.volume_template_url,
28
- :name => 'default',
29
- :created => Time.now,
30
- :description => "#{context.driver.name.capitalize} VolumeTemplateCollection",
31
- :count => volume_templates.size,
32
- :volume_templates => volume_templates
33
- )
34
- end
35
-
36
- end
@@ -1,34 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VSPCollection < CIMI::Model::Base
17
-
18
- CIMI::Model.register_as_root_entity! "VSPs"
19
-
20
- array :vsps do
21
- scalar :href
22
- end
23
-
24
- def self.default(context)
25
- self.new(
26
- :id => context.vsps_url,
27
- :name => 'default',
28
- :created => Time.now,
29
- :description => "#{context.driver.name.capitalize} VSPCollection",
30
- :vsps => CIMI::Model::VSP.all_uri(context)
31
- )
32
- end
33
-
34
- end
@@ -1,34 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VSPConfigurationCollection < CIMI::Model::Base
17
-
18
- CIMI::Model.register_as_root_entity! "VSPConfigurations"
19
-
20
- array :vsp_configurations do
21
- scalar :href
22
- end
23
-
24
- def self.default(context)
25
- self.new(
26
- :id => context.vsp_configurations_url,
27
- :name => 'default',
28
- :created => Time.now,
29
- :description => "#{context.driver.name.capitalize} VSPConfigurationCollection",
30
- :vsp_configurations => CIMI::Model::VSPConfiguration.all_uri(context)
31
- )
32
- end
33
-
34
- end
@@ -1,34 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright ownership. The
4
- # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the
6
- # License. You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations
14
- # under the License.
15
-
16
- class CIMI::Model::VSPTemplateCollection < CIMI::Model::Base
17
-
18
- CIMI::Model.register_as_root_entity! "VSPTemplates"
19
-
20
- array :vsp_templates do
21
- scalar :href
22
- end
23
-
24
- def self.default(context)
25
- self.new(
26
- :id => context.vsp_templates_url,
27
- :name => 'default',
28
- :created => Time.now,
29
- :description => "#{context.driver.name.capitalize} VSPTemplateCollection",
30
- :vsp_templates => CIMI::Model::VSPTemplate.all_uri(context)
31
- )
32
- end
33
-
34
- end
@@ -1,115 +0,0 @@
1
- #
2
- # Based on https://github.com/emk/sinatra-url-for/
3
- # Commit 1df339284203f8f6ed8d
4
- #
5
- # Original license:
6
- # Copyright (C) 2009 Eric Kidd
7
- #
8
- # Permission is hereby granted, free of charge, to any person obtaining a
9
- # copy of this software and associated documentation files (the
10
- # "Software"), to deal in the Software without restriction, including
11
- # without limitation the rights to use, copy, modify, merge, publish,
12
- # distribute, sublicense, and/or sell copies of the Software, and to permit
13
- # persons to whom the Software is furnished to do so, subject to the
14
- # following conditions:
15
- #
16
- # The above copyright notice and this permission notice shall be included
17
- # in all copies or substantial portions of the Software.
18
- #
19
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22
- # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23
- # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24
- # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
26
-
27
- module Sinatra
28
- module UrlForHelper
29
-
30
- require 'uri'
31
-
32
- def method_missing(name, *args)
33
- if name.to_s =~ /^([\w\_]+)_url$/
34
- if args.size > 0
35
- t = $1
36
- if t.match(/^(stop|reboot|start|attach|detach)_/)
37
- action = $1
38
- api_url_for(t.pluralize.split('_').last + '/' + args.first.to_s + '/' + action, :full)
39
- elsif t.match(/^(destroy|update)_/)
40
- api_url_for(t.pluralize.split('_').last + '/' + args.first.to_s, :full)
41
- else
42
- api_url_for(t.pluralize, :full) + '/' + "#{args.first}"
43
- end
44
- else
45
- api_url_for($1, :full)
46
- end
47
- else
48
- super
49
- end
50
- end
51
-
52
- def api_url_for(url_fragment, mode=:path_only)
53
- matrix_params = ''
54
- if request.params['api']
55
- matrix_params += ";provider=%s" % request.params['api']['provider'] if request.params['api']['provider']
56
- matrix_params += ";driver=%s" % request.params['api']['driver'] if request.params['api']['driver']
57
- end
58
- url_fragment = "/#{url_fragment}" unless url_fragment =~ /^\// # There is no need to prefix URI with '/'
59
- if mode == :path_only
60
- url_for "#{settings.root_url}#{matrix_params}#{url_fragment}", mode
61
- else
62
- url_for "#{matrix_params}#{url_fragment}", :full
63
- end
64
- end
65
-
66
- # Construct a link to +url_fragment+, which should be given relative to
67
- # the base of this Sinatra app. The mode should be either
68
- # <code>:path_only</code>, which will generate an absolute path within
69
- # the current domain (the default), or <code>:full</code>, which will
70
- # include the site name and port number. (The latter is typically
71
- # necessary for links in RSS feeds.) Example usage:
72
- #
73
- # url_for "/" # Returns "/myapp/"
74
- # url_for "/foo" # Returns "/myapp/foo"
75
- # url_for "/foo", :full # Returns "http://example.com/myapp/foo"
76
- #--
77
- # See README.rdoc for a list of some of the people who helped me clean
78
- # up earlier versions of this code.
79
- def url_for url_fragment, mode=:path_only
80
- case mode
81
- when :path_only
82
- base = request.script_name.empty? ? Deltacloud.default_frontend.root_url : request.script_name
83
- when :full
84
- scheme = request.scheme
85
- port = request.port
86
- request_host = request.host
87
- if request.env['HTTP_X_FORWARDED_FOR']
88
- scheme = request.env['HTTP_X_FORWARDED_SCHEME'] || scheme
89
- port = request.env['HTTP_X_FORWARDED_PORT']
90
- request_host = request.env['HTTP_X_FORWARDED_HOST']
91
- end
92
- if (port.nil? || port == "" ||
93
- (scheme == 'http' && port.to_s == '80') ||
94
- (scheme == 'https' && port.to_s == '443'))
95
- port = ""
96
- else
97
- port = ":#{port}"
98
- end
99
- base = "#{scheme}://#{request_host}#{port}#{request.script_name.empty? ? settings.config.root_url : request.script_name}"
100
- else
101
- raise TypeError, "Unknown url_for mode #{mode}"
102
- end
103
- uri_parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
104
- url_escape = uri_parser.escape(url_fragment)
105
- # Don't add the base fragment if url_for gets called more than once
106
- # per url or the url_fragment passed in is an absolute url
107
- if url_escape.match(/^#{base}/) or url_escape.match(/^http/)
108
- url_escape
109
- else
110
- "#{base}#{url_escape}"
111
- end
112
- end
113
- end
114
-
115
- end