deltacloud-core 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. data/Rakefile +99 -141
  2. data/bin/deltacloudd +4 -1
  3. data/config.ru +13 -6
  4. data/config/drivers/aruba.yaml +8 -0
  5. data/config/drivers/fgcp.yaml +3 -2
  6. data/deltacloud-core.gemspec +13 -9
  7. data/lib/cimi/collections/cloud_entry_point.rb +1 -1
  8. data/lib/cimi/models.rb +1 -7
  9. data/lib/cimi/models/base.rb +1 -4
  10. data/lib/cimi/models/cloud_entry_point.rb +14 -0
  11. data/lib/cimi/models/machine.rb +4 -4
  12. data/lib/cimi/models/machine_admin.rb +1 -0
  13. data/lib/cimi/models/machine_configuration.rb +4 -4
  14. data/lib/cimi/models/schema.rb +17 -14
  15. data/lib/cimi/models/volume_image.rb +1 -1
  16. data/lib/cimi/server.rb +1 -1
  17. data/lib/deltacloud/api.rb +55 -3
  18. data/lib/deltacloud/collections/addresses.rb +1 -1
  19. data/lib/deltacloud/collections/buckets.rb +12 -10
  20. data/lib/deltacloud/collections/firewalls.rb +2 -1
  21. data/lib/deltacloud/collections/hardware_profiles.rb +1 -1
  22. data/lib/deltacloud/collections/images.rb +2 -2
  23. data/lib/deltacloud/collections/instance_states.rb +6 -3
  24. data/lib/deltacloud/collections/instances.rb +2 -1
  25. data/lib/deltacloud/collections/keys.rb +6 -2
  26. data/lib/deltacloud/collections/load_balancers.rb +8 -7
  27. data/lib/deltacloud/collections/metrics.rb +2 -1
  28. data/lib/deltacloud/collections/realms.rb +1 -1
  29. data/lib/deltacloud/collections/storage_snapshots.rb +2 -1
  30. data/lib/deltacloud/collections/storage_volumes.rb +2 -2
  31. data/lib/deltacloud/core_ext.rb +1 -7
  32. data/lib/deltacloud/core_ext/hash.rb +7 -5
  33. data/lib/deltacloud/core_ext/string.rb +1 -0
  34. data/lib/deltacloud/drivers/aruba/aruba_driver.rb +469 -0
  35. data/lib/deltacloud/drivers/base_driver.rb +12 -17
  36. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +50 -22
  37. data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
  38. data/lib/deltacloud/drivers/exceptions.rb +12 -2
  39. data/lib/deltacloud/drivers/features.rb +8 -0
  40. data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +21 -6
  41. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +169 -57
  42. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
  43. data/lib/deltacloud/drivers/mock/mock_client.rb +2 -0
  44. data/lib/deltacloud/drivers/mock/mock_driver.rb +101 -13
  45. data/lib/deltacloud/drivers/opennebula/occi_client.rb +12 -6
  46. data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +10 -18
  47. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +46 -1
  48. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +17 -17
  49. data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +4 -4
  50. data/lib/deltacloud/helpers.rb +4 -4
  51. data/lib/deltacloud/helpers/blob_stream_helper.rb +4 -6
  52. data/lib/deltacloud/helpers/deltacloud_helper.rb +17 -1
  53. data/lib/deltacloud/helpers/driver_helper.rb +7 -3
  54. data/lib/deltacloud/helpers/url_helper.rb +4 -4
  55. data/lib/deltacloud/models/address.rb +1 -1
  56. data/lib/deltacloud/models/base_model.rb +0 -14
  57. data/lib/deltacloud/models/bucket.rb +0 -10
  58. data/lib/deltacloud/models/hardware_profile.rb +5 -26
  59. data/lib/deltacloud/models/image.rb +0 -12
  60. data/lib/deltacloud/models/instance.rb +6 -22
  61. data/lib/deltacloud/models/key.rb +2 -2
  62. data/lib/deltacloud/models/metric.rb +1 -1
  63. data/lib/deltacloud/models/storage_snapshot.rb +4 -0
  64. data/lib/deltacloud/server.rb +8 -2
  65. data/lib/deltacloud_rack.rb +40 -10
  66. data/lib/ec2/query_parser.rb +9 -4
  67. data/lib/ec2/server.rb +1 -1
  68. data/lib/ec2/views/create_key_pair.haml +3 -0
  69. data/lib/ec2/views/delete_key_pair.haml +1 -0
  70. data/lib/ec2/views/describe_availability_zones.haml +6 -0
  71. data/lib/ec2/views/describe_images.haml +10 -0
  72. data/lib/ec2/views/describe_instance_set.haml +24 -0
  73. data/lib/ec2/views/describe_instances.haml +9 -0
  74. data/lib/ec2/views/describe_key_pairs.haml +5 -0
  75. data/lib/ec2/views/error.haml +4 -0
  76. data/lib/ec2/views/instance_action.haml +9 -0
  77. data/lib/ec2/views/reboot_instances.haml +1 -0
  78. data/lib/ec2/views/run_instances.haml +7 -0
  79. data/lib/ec2/views/start_instances.haml +1 -0
  80. data/lib/ec2/views/stop_instances.haml +1 -0
  81. data/lib/ec2/views/terminate_instances.haml +9 -0
  82. data/lib/sinatra.rb +0 -1
  83. data/lib/sinatra/rack_accept.rb +1 -1
  84. data/lib/sinatra/rack_driver_select.rb +2 -2
  85. data/lib/sinatra/rack_etag.rb +5 -1
  86. data/lib/sinatra/rack_logger.rb +127 -0
  87. data/lib/sinatra/rack_matrix_params.rb +1 -1
  88. data/tests/cimi/collections/cloud_entry_point_test.rb +46 -0
  89. data/tests/cimi/collections/common.rb +17 -0
  90. data/tests/cimi/collections/machine_images_test.rb +44 -0
  91. data/tests/cimi/collections/machines_test.rb +41 -0
  92. data/tests/cimi/spec/cimi/model/machine_admin_spec.rb +35 -0
  93. data/tests/cimi/spec/cimi/model/machine_configuration_spec.rb +31 -0
  94. data/tests/cimi/spec/cimi/model/machine_image_spec.rb +33 -0
  95. data/tests/cimi/spec/cimi/model/machine_spec.rb +32 -0
  96. data/tests/cimi/spec/cimi/model/machine_template_spec.rb +32 -0
  97. data/tests/cimi/spec/cimi/model/schema_spec.rb +245 -0
  98. data/tests/cimi/spec/cimi/model/volume_configuration_spec.rb +34 -0
  99. data/tests/cimi/spec/cimi/model/volume_image_spec.rb +33 -0
  100. data/tests/cimi/spec/cimi/model/volume_spec.rb +32 -0
  101. data/tests/cimi/spec/cimi/model/volume_template_spec.rb +32 -0
  102. data/tests/cimi/spec/spec_helper.rb +136 -0
  103. data/tests/deltacloud/base_collection_test.rb +30 -0
  104. data/tests/deltacloud/collections/buckets_collection_test.rb +65 -0
  105. data/tests/deltacloud/collections/drivers_collection_test.rb +37 -0
  106. data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +53 -0
  107. data/tests/deltacloud/collections/images_collection_test.rb +59 -0
  108. data/tests/deltacloud/collections/instance_states_collection_test.rb +34 -0
  109. data/tests/deltacloud/collections/instances_collection_test.rb +63 -0
  110. data/tests/deltacloud/collections/keys_collection_test.rb +63 -0
  111. data/tests/deltacloud/collections_test.rb +35 -0
  112. data/tests/deltacloud/common.rb +14 -0
  113. data/tests/deltacloud/deltacloud_helper_test.rb +55 -0
  114. data/tests/deltacloud/drivers_test.rb +73 -0
  115. data/tests/deltacloud/rack_test.rb +51 -0
  116. data/tests/deltacloud/server_test.rb +149 -0
  117. data/tests/{api → deprecated/api}/common.rb +0 -0
  118. data/tests/{api → deprecated/api}/driver_test.rb +0 -0
  119. data/tests/deprecated/api/library_test.rb +6 -0
  120. data/tests/{cimi → deprecated/cimi}/features/step_definitions/common_steps.rb +0 -0
  121. data/tests/{cimi → deprecated/cimi}/features/step_definitions/machine_images_steps.rb +0 -0
  122. data/tests/{cimi → deprecated/cimi}/features/step_definitions/machines_steps.rb +0 -0
  123. data/tests/{cimi → deprecated/cimi}/features/step_definitions/volumes_steps.rb +0 -0
  124. data/tests/{cimi → deprecated/cimi}/features/support/env.rb +0 -0
  125. data/tests/{common.rb → deprecated/common.rb} +0 -0
  126. data/tests/{core_ext → deprecated/core_ext}/string.rb +0 -0
  127. data/tests/{drivers → deprecated/drivers}/ec2/api_test.rb +0 -0
  128. data/tests/deprecated/drivers/ec2/common.rb +23 -0
  129. data/tests/{drivers → deprecated/drivers}/ec2/drivers_test.rb +0 -0
  130. data/tests/{drivers → deprecated/drivers}/ec2/hardware_profiles_test.rb +0 -0
  131. data/tests/deprecated/drivers/ec2/images_test.rb +230 -0
  132. data/tests/{drivers → deprecated/drivers}/ec2/instances_test.rb +0 -0
  133. data/tests/deprecated/drivers/ec2/keys_test.rb +181 -0
  134. data/tests/deprecated/drivers/ec2/realms_test.rb +146 -0
  135. data/tests/{drivers → deprecated/drivers}/fgcp/api_test.rb +0 -0
  136. data/tests/{drivers → deprecated/drivers}/fgcp/hardware_profiles_test.rb +0 -0
  137. data/tests/{drivers → deprecated/drivers}/fgcp/realms_test.rb +0 -0
  138. data/tests/{drivers → deprecated/drivers}/fgcp/setup.rb +0 -0
  139. data/tests/{drivers → deprecated/drivers}/google/api_test.rb +0 -0
  140. data/tests/{drivers → deprecated/drivers}/google/buckets_test.rb +0 -0
  141. data/tests/{drivers → deprecated/drivers}/google/common.rb +2 -2
  142. data/tests/{drivers → deprecated/drivers}/mock/api_test.rb +0 -0
  143. data/tests/{drivers → deprecated/drivers}/mock/buckets_test.rb +0 -0
  144. data/tests/{drivers → deprecated/drivers}/mock/common.rb +0 -0
  145. data/tests/{drivers → deprecated/drivers}/mock/drivers_test.rb +0 -0
  146. data/tests/{drivers → deprecated/drivers}/mock/hardware_profiles_test.rb +0 -0
  147. data/tests/deprecated/drivers/mock/images_test.rb +197 -0
  148. data/tests/deprecated/drivers/mock/instances_test.rb +343 -0
  149. data/tests/deprecated/drivers/mock/keys_test.rb +161 -0
  150. data/tests/deprecated/drivers/mock/realms_test.rb +132 -0
  151. data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +114 -0
  152. data/tests/deprecated/drivers/mock/storage_volumes_test.rb +122 -0
  153. data/tests/{drivers → deprecated/drivers}/openstack/api_test.rb +0 -0
  154. data/tests/{drivers → deprecated/drivers}/openstack/common.rb +0 -0
  155. data/tests/{drivers → deprecated/drivers}/openstack/hardware_profiles_test.rb +0 -0
  156. data/tests/{drivers → deprecated/drivers}/openstack/images_test.rb +0 -0
  157. data/tests/{drivers → deprecated/drivers}/openstack/instances_test.rb +0 -0
  158. data/tests/{drivers → deprecated/drivers}/openstack/realms_test.rb +0 -0
  159. data/tests/{drivers → deprecated/drivers}/rackspace/api_test.rb +0 -0
  160. data/tests/{drivers → deprecated/drivers}/rackspace/buckets_test.rb +0 -0
  161. data/tests/{drivers → deprecated/drivers}/rackspace/common.rb +0 -0
  162. data/tests/{drivers → deprecated/drivers}/rackspace/hardware_profiles_test.rb +0 -0
  163. data/tests/{drivers → deprecated/drivers}/rackspace/images_test.rb +0 -0
  164. data/tests/{drivers → deprecated/drivers}/rackspace/instances_test.rb +0 -0
  165. data/tests/{drivers → deprecated/drivers}/rackspace/realms_test.rb +0 -0
  166. data/tests/{drivers → deprecated/drivers}/rhevm/api_test.rb +0 -0
  167. data/tests/deprecated/drivers/rhevm/common.rb +21 -0
  168. data/tests/{drivers → deprecated/drivers}/rhevm/hardware_profiles_test.rb +0 -0
  169. data/tests/deprecated/drivers/rhevm/images_test.rb +48 -0
  170. data/tests/{drivers → deprecated/drivers}/rhevm/instances_test.rb +0 -0
  171. data/tests/deprecated/drivers/rhevm/realms_test.rb +40 -0
  172. data/tests/{minitest_common.rb → deprecated/minitest_common.rb} +0 -0
  173. data/tests/{minitest_common_api_test.rb → deprecated/minitest_common_api_test.rb} +0 -0
  174. data/tests/{rabbit_test.rb → deprecated/rabbit_test.rb} +0 -0
  175. data/tests/drivers/base/base_driver_test.rb +124 -0
  176. data/tests/{api → drivers/base}/library_test.rb +2 -8
  177. data/tests/drivers/ec2/common.rb +23 -15
  178. data/tests/drivers/ec2/images_test.rb +30 -211
  179. data/tests/drivers/ec2/instance_test.rb +104 -0
  180. data/tests/drivers/ec2/keys_test.rb +32 -161
  181. data/tests/drivers/ec2/realms_test.rb +26 -128
  182. data/tests/drivers/ec2/storage_snapshots_test.rb +54 -0
  183. data/tests/drivers/mock/images_test.rb +37 -179
  184. data/tests/drivers/mock/instances_test.rb +103 -340
  185. data/tests/drivers/mock/keys_test.rb +30 -145
  186. data/tests/drivers/mock/realms_test.rb +23 -118
  187. data/tests/drivers/mock/storage_snapshots_test.rb +23 -100
  188. data/tests/drivers/mock/storage_volumes_test.rb +41 -104
  189. data/tests/drivers/models/address_test.rb +18 -0
  190. data/tests/drivers/models/base_test.rb +33 -0
  191. data/tests/drivers/models/blob_test.rb +18 -0
  192. data/tests/drivers/models/hardware_profile_test.rb +52 -0
  193. data/tests/drivers/models/instance_address_test.rb +24 -0
  194. data/tests/drivers/models/instance_profile_test.rb +21 -0
  195. data/tests/drivers/models/instance_test.rb +29 -0
  196. data/tests/drivers/models/keys_test.rb +25 -0
  197. data/tests/drivers/models/metrics_test.rb +20 -0
  198. data/tests/drivers/rhevm/common.rb +15 -15
  199. data/tests/drivers/rhevm/images_test.rb +61 -36
  200. data/tests/drivers/rhevm/instance_test.rb +104 -0
  201. data/tests/drivers/rhevm/provider_test.rb +48 -0
  202. data/tests/drivers/rhevm/realms_test.rb +40 -37
  203. data/tests/ec2/common.rb +24 -0
  204. data/tests/ec2/query_parser_test.rb +98 -0
  205. data/tests/ec2/server_test.rb +45 -0
  206. data/tests/helpers/core_ext/array_test.rb +24 -0
  207. data/tests/helpers/core_ext/hash_test.rb +42 -0
  208. data/tests/helpers/core_ext/integer_test.rb +19 -0
  209. data/tests/helpers/core_ext/string_test.rb +74 -0
  210. data/tests/test_helper.rb +66 -0
  211. data/views/api/show.html.haml +1 -2
  212. data/views/api/show.xml.haml +1 -2
  213. data/views/blobs/show.xml.haml +1 -2
  214. data/views/keys/new.html.haml +9 -2
  215. data/views/load_balancers/new.html.haml +35 -34
  216. data/views/metrics/index.html.haml +1 -1
  217. data/views/metrics/show.html.haml +2 -2
  218. data/views/metrics/show.xml.haml +6 -2
  219. data/views/storage_volumes/attach.html.haml +1 -1
  220. data/views/storage_volumes/show.html.haml +1 -1
  221. metadata +853 -544
  222. data/lib/sinatra/accept_media_types.rb +0 -154
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'require_relative' if RUBY_VERSION < '1.9'
3
+
4
+ require_relative './common.rb'
5
+
6
+ describe Deltacloud::EC2::API do
7
+
8
+ before do
9
+ def app; Deltacloud::EC2::API; end
10
+ end
11
+
12
+ it 'has the config set property' do
13
+ Deltacloud::config[:ec2].must_be_kind_of Deltacloud::Server
14
+ root_url.must_equal Deltacloud[:ec2].root_url
15
+ end
16
+
17
+ it 'must do a redirection when no Action parameter' do
18
+ get root_url
19
+ status.must_equal 301
20
+ headers['Location'].must_equal 'http://example.org/'
21
+ end
22
+
23
+ it 'must set the Connection header to close' do
24
+ get root_url
25
+ headers['Connection'].must_equal 'close'
26
+ end
27
+
28
+ it 'must advertise current API version in response headers' do
29
+ get root_url
30
+ headers['Server'].must_equal 'Apache-Deltacloud-EC2/2012-04-01'
31
+ end
32
+
33
+ it 'must return EC2 exception when unknown action' do
34
+ get root_url + '?Action=UnknownActionTest'
35
+ xml.root.name.must_equal 'Response'
36
+ (xml/'Response/Errors/Code').first.text.strip.must_equal 'InvalidAction'
37
+ end
38
+
39
+ it 'must return EC2 exception when authentication failed' do
40
+ authorize 'unknownuser', 'password'
41
+ get root_url + '?Action=DescribeAvailabilityZones'
42
+ status.must_equal 401
43
+ end
44
+
45
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'require_relative' if RUBY_VERSION < '1.9'
3
+ require_relative '../../test_helper.rb'
4
+
5
+ require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'core_ext.rb')
6
+
7
+ class TestArray < MiniTest::Unit::TestCase
8
+
9
+
10
+ def test_expand_opts!
11
+ assert_equal true, [].respond_to?(:"expand_opts!")
12
+ a = [1,2,3]
13
+ a.expand_opts!(:test => 1)
14
+ assert_equal Hash, a.last.class
15
+ end
16
+
17
+ def test_extract_opts!
18
+ assert_equal true, [].respond_to?(:"extract_opts!")
19
+ a = [1,2,3, { :test => 1}]
20
+ a.extract_opts!
21
+ assert_equal [1,2,3], a
22
+ end
23
+
24
+ end
@@ -0,0 +1,42 @@
1
+ require 'rubygems'
2
+ require 'require_relative' if RUBY_VERSION < '1.9'
3
+
4
+ require_relative '../../test_helper.rb'
5
+ require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'core_ext.rb')
6
+
7
+ class TestHash < MiniTest::Unit::TestCase
8
+
9
+
10
+ def test_gsub_keys
11
+ assert_equal true, {}.respond_to?(:"gsub_keys")
12
+ h = {
13
+ :'test-key-1' => '1',
14
+ :'test-key-2' => '2',
15
+ 'test-key-3' => '3',
16
+ :random => '10'
17
+ }
18
+
19
+ h.gsub_keys(/test/, 'new')
20
+
21
+ assert_equal '1', h['new-key-1']
22
+ assert_equal '2', h['new-key-2']
23
+ assert_equal '3', h['new-key-3']
24
+ assert_equal '10', h[:random]
25
+ end
26
+
27
+ def test_symbolize_keys
28
+ assert_equal true, {}.respond_to?(:"symbolize_keys")
29
+ h = {
30
+ 'test1' => 1,
31
+ :test3 => 3
32
+ }
33
+
34
+ h.symbolize_keys
35
+
36
+ assert_equal 1, h[:test1]
37
+ assert_equal nil, h['test1']
38
+ assert_equal 3, h[:test3]
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'require_relative' if RUBY_VERSION < '1.9'
3
+
4
+ require_relative '../../test_helper.rb'
5
+ require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'core_ext.rb')
6
+
7
+ class TestInteger < MiniTest::Unit::TestCase
8
+
9
+
10
+ def test_ordinalize
11
+ assert_equal true, 1.respond_to?(:"ordinalize")
12
+ assert_equal '1st', 1.ordinalize
13
+ assert_equal '2nd', 2.ordinalize
14
+ assert_equal '3rd', 3.ordinalize
15
+ assert_equal '6th', 6.ordinalize
16
+ assert_equal '1211th', 1211.ordinalize
17
+ end
18
+
19
+ end
@@ -0,0 +1,74 @@
1
+ require 'rubygems'
2
+ require 'require_relative' if RUBY_VERSION < '1.9'
3
+
4
+ require_relative '../../test_helper.rb'
5
+ require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'core_ext.rb')
6
+
7
+ class TestString < MiniTest::Unit::TestCase
8
+
9
+
10
+ def test_blank?
11
+ assert_equal true, ''.respond_to?(:"blank?")
12
+ assert_equal true, ''.blank?
13
+ assert_equal true, ' '.blank?
14
+ assert_equal false, 'test'.blank?
15
+ end
16
+
17
+ def test_titlecase
18
+ assert_equal true, ''.respond_to?(:"titlecase")
19
+ assert_equal "This Is A String", 'this is a string'.titlecase
20
+ assert_equal 'This', 'this'.titlecase
21
+ end
22
+
23
+ def test_pluralize
24
+ assert_equal true, ''.respond_to?(:"pluralize")
25
+ assert_equal 'instances', 'instance'.pluralize
26
+ assert_equal 'properties', 'property'.pluralize
27
+ assert_equal 'addresses', 'address'.pluralize
28
+ end
29
+
30
+ def test_singularize
31
+ assert_equal true, ''.respond_to?(:"singularize")
32
+ assert_equal 'instance', 'instances'.singularize
33
+ assert_equal 'property', 'properties'.singularize
34
+ assert_equal 'address', 'addresses'.singularize
35
+ end
36
+
37
+ def test_underscore
38
+ assert_equal true, ''.respond_to?(:"underscore")
39
+ assert_equal 'test_model', 'TestModel'.underscore
40
+ assert_equal 'test/model', 'Test::Model'.underscore
41
+ end
42
+
43
+ def test_camelize
44
+ assert_equal true, ''.respond_to?(:"camelize")
45
+ assert_equal 'TestModel', 'test_model'.camelize
46
+ assert_equal 'testModel', 'test_model'.camelize(:lowercase_first_letter)
47
+ end
48
+
49
+ def test_uncapitalize
50
+ assert_equal true, ''.respond_to?(:"uncapitalize")
51
+ assert_equal 'testModel', 'TestModel'.uncapitalize
52
+ assert_equal 'test', 'Test'.uncapitalize
53
+ end
54
+
55
+ def test_upcase_first
56
+ assert_equal true, ''.respond_to?(:"upcase_first")
57
+ assert_equal 'Test', 'test'.upcase_first
58
+ assert_equal 'Test', 'Test'.upcase_first
59
+ assert_equal 'TestModel', 'testModel'.upcase_first
60
+ end
61
+
62
+ def test_truncate
63
+ assert_equal true, ''.respond_to?(:"truncate")
64
+ assert_equal 'ThisIs...cated', 'ThisIsALogStringThatNeedsToBeTruncated'.truncate
65
+ assert_equal 'Thi...ed', 'ThisIsALogStringThatNeedsToBeTruncated'.truncate(5)
66
+ assert_equal 'T...', 'ThisIsALogStringThatNeedsToBeTruncated'.truncate(1)
67
+ assert_equal 'This', 'This'.truncate(10)
68
+ end
69
+
70
+ def test_it_has_each
71
+ assert_equal true, ''.respond_to?(:each)
72
+ end
73
+
74
+ end
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+ require 'logger'
3
+ require 'minitest/autorun'
4
+ require 'rack/test'
5
+ require 'nokogiri'
6
+ require 'pp'
7
+ require 'require_relative' if RUBY_VERSION < '1.9'
8
+
9
+ ENV['RACK_ENV'] = 'test'
10
+
11
+ if ENV['COVERAGE']
12
+ begin
13
+ require 'simplecov'
14
+ rescue LoadError
15
+ warn "To generate code coverage you need to install 'simplecov' (gem install simplecov OR bundle)"
16
+ end
17
+ end
18
+
19
+ require 'time'
20
+
21
+ # This code was originally copied from:
22
+ # https://github.com/jtrupiano/timecop/issues/8#issuecomment-1396047
23
+ #
24
+ # Since 'timecop' gem has broken 'timezone' support, this small monkey-patching
25
+ # on Time object seems to fix this issue.
26
+
27
+ class Time
28
+ module TimeMock
29
+ attr_accessor :mock_time
30
+
31
+ def mock_now
32
+ @mock_time || Time.original_now
33
+ end
34
+
35
+ def be(a_time)
36
+ @mock_time = Time.parse(a_time)
37
+ end
38
+
39
+ end
40
+
41
+ class << self
42
+ include TimeMock
43
+ alias_method :original_now, :now
44
+ alias_method :now, :mock_now
45
+ end
46
+ end
47
+
48
+ # Test helpers
49
+
50
+ def record_retries(name='')
51
+ {
52
+ :before => Proc.new { |r, &block|
53
+ VCR.use_cassette("#{__name__}-#{name.empty? ? '' : "#{name}-"}#{r}", &block)
54
+ }
55
+ }
56
+ end
57
+
58
+ include Rack::Test::Methods
59
+
60
+ def status; last_response.status; end
61
+ def headers; last_response.headers; end
62
+ def response_body; last_response.body; end
63
+ def xml; Nokogiri::XML(response_body); end
64
+ def json; JSON::parse(response_body); end
65
+ def formats; [ 'application/xml', 'application/json', 'text/html' ]; end
66
+ def root_url(url=''); Deltacloud.default_frontend.root_url + url; end
@@ -3,8 +3,7 @@
3
3
 
4
4
  %div{ :'data-role' => :content, :'data-theme' => 'c'}
5
5
  %ul{ :'data-role' => :listview, :'data-inset' => 'true'}
6
- - Deltacloud.collections.each do |c|
7
- - next unless c.operation(:index).has_capability?
6
+ - supported_collections do |c|
8
7
  %li
9
8
  %a{ :href => api_url_for(c.collection_name), :'data-icon' => "arrow-r"}=c.collection_name.to_s.gsub('_', ' ').titlecase
10
9
 
@@ -1,6 +1,5 @@
1
1
  %api{ :version => settings.version, :driver => driver_symbol, :provider => Thread.current[:provider] || ENV['API_PROVIDER'] }
2
- - Deltacloud.collections.each do |c|
3
- - next unless c.operation(:index).has_capability?
2
+ - supported_collections do |c|
4
3
  %link{ :rel => c.collection_name, :href => self.send(:"#{c.collection_name}_url")}
5
4
  - c.features.select { |f| driver.class.has_feature?(c.collection_name, f.name) }.each do |f|
6
5
  %feature{ :name => f.name }
@@ -9,6 +9,5 @@
9
9
  %user_metadata
10
10
  - if @blob.user_metadata.respond_to? :each
11
11
  - @blob.user_metadata.each do |k, v|
12
- %entry{:key => k}
13
- #{cdata v}
12
+ %entry{:key => k}=render_cdata(v)
14
13
  %content{:href => bucket_url(@blob.bucket) + '/' + @blob.id + '/content', :rel => 'blob_content'}
@@ -3,6 +3,13 @@
3
3
  %div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
4
4
  %form{ :action => keys_url, :method => :post}
5
5
  %div{ 'data-role' => :fieldcontain }
6
- %label{ :for => :name} Key name:
7
- %input{ :type => :text, :id => :name, :name => :name, :value => '' }
6
+ %p
7
+ %label{ :for => :name} Key name:
8
+ %p
9
+ %input{ :type => :text, :id => :name, :name => :name, :value => '' }
10
+ %p
11
+ %label{ :for => :public_key} Public Key (Optional - import):
12
+ %small Enter your public key here to import it rather than creating a new one (not supported by all providers)
13
+ %p
14
+ %textarea{ :name => :public_key, :cols=>65, :rows=>5 }
8
15
  %button{ :type => :submit} Create key
@@ -1,38 +1,39 @@
1
- %h1 New Load Balancer
1
+ =header "Create new load balancer"
2
2
 
3
- %form{ :action => load_balancers_url, :method => :post }
4
- %p
5
- %label
6
- Name:
7
- %input{ :name => 'name', :size => 30 }/
8
- -if @instances
3
+ %div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
4
+ %form{ :action => load_balancers_url, :method => :post }
9
5
  %p
10
6
  %label
11
- Running instance:
12
- %select{ :name => 'instance_id'}
13
- - @instances.select{|i| i.state=="RUNNING"}.each do |instance|
14
- %option{ :value => instance.id } #{instance.id}
15
- %p
16
- %label
17
- Realm:
18
- %select{ :name => 'realm_id'}
19
- - @realms.each do |realm|
20
- %option{ :value => realm.id } #{realm.id} - #{realm.name}
21
- %hr
22
- %p
23
- %label
24
- Protocol:
25
- %select{ :name => 'listener_protocol'}
26
- %option{ :value => 'HTTP'} HTTP
27
- %option{ :value => 'TCP'} TCP
28
- %p
29
- %label
30
- Load balancer port:
31
- %input{ :name => "listener_balancer_port", :size => 30}
32
- %p
33
- %label
34
- Instances port:
35
- %input{ :name => "listener_instance_port", :size => 30}
36
- %p
37
- %input{ :type => :submit, :name => "commit", :value => "create" }/
7
+ Name:
8
+ %input{ :name => 'name', :size => 30 }/
9
+ -if @instances
10
+ %p
11
+ %label
12
+ Running instance:
13
+ %select{ :name => 'instance_id'}
14
+ - @instances.select{|i| i.state=="RUNNING"}.each do |instance|
15
+ %option{ :value => instance.id } #{instance.id}
16
+ %p
17
+ %label
18
+ Realm:
19
+ %select{ :name => 'realm_id'}
20
+ - @realms.each do |realm|
21
+ %option{ :value => realm.id } #{realm.id} - #{realm.name}
22
+ %hr
23
+ %p
24
+ %label
25
+ Protocol:
26
+ %select{ :name => 'listener_protocol'}
27
+ %option{ :value => 'HTTP'} HTTP
28
+ %option{ :value => 'TCP'} TCP
29
+ %p
30
+ %label
31
+ Load balancer port:
32
+ %input{ :name => "listener_balancer_port", :size => 30}
33
+ %p
34
+ %label
35
+ Instances port:
36
+ %input{ :name => "listener_instance_port", :size => 30}
37
+ %p
38
+ %input{ :type => :submit, :name => "commit", :value => "create" }/
38
39
 
@@ -8,6 +8,6 @@
8
8
  %li
9
9
  %a{ :href => metric_url(metric.id), :'data-ajax' => 'false'}
10
10
  %img{ :class => 'ui-link-thumb', :src => '/images/metric.png'}
11
- %h3= metric.id
11
+ %h3= metric.entity || metric.id
12
12
  %p
13
13
  = metric.properties.map { |p| p.name }.join(', ')
@@ -10,10 +10,10 @@
10
10
  %caption Statistics for last 60 minutes
11
11
  %tr
12
12
  %th Time
13
- %th Minumum
13
+ %th Minimum
14
14
  %th Maximum
15
15
  %th Average
16
- %th Units
16
+ %th Unit
17
17
  - p.values.each do |v|
18
18
  %tr
19
19
  %td=v[:timestamp]
@@ -2,8 +2,12 @@
2
2
  !!! XML
3
3
  %metric{:href => metric_url(@metric.id), :id => @metric.id}
4
4
  -haml_tag(:entity, :<) do
5
- -haml_concat @metric.send(:id)
5
+ -haml_concat @metric.send(:entity) || @metric.send(:id)
6
6
  %properties
7
7
  -@metric.properties.each do |prop|
8
8
  -haml_tag(prop.name, :<) do
9
- - haml_concat prop.values
9
+ - if prop.values
10
+ - prop.values.each do |p|
11
+ %sample
12
+ - p.each do |k, v|
13
+ %property{ :name => k, :value => v }
@@ -1,6 +1,6 @@
1
1
  %h1 Attach storage volume
2
2
 
3
- %form{ :action => attach_storage_volume_url(params[:id]), :method => :post }
3
+ %form{ :action => api_url_for("storage_volumes/#{params[:id]}/attach"), :method => :post }
4
4
  %p
5
5
  %label
6
6
  Instance ID: