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.
- data/Rakefile +99 -141
- data/bin/deltacloudd +4 -1
- data/config.ru +13 -6
- data/config/drivers/aruba.yaml +8 -0
- data/config/drivers/fgcp.yaml +3 -2
- data/deltacloud-core.gemspec +13 -9
- data/lib/cimi/collections/cloud_entry_point.rb +1 -1
- data/lib/cimi/models.rb +1 -7
- data/lib/cimi/models/base.rb +1 -4
- data/lib/cimi/models/cloud_entry_point.rb +14 -0
- data/lib/cimi/models/machine.rb +4 -4
- data/lib/cimi/models/machine_admin.rb +1 -0
- data/lib/cimi/models/machine_configuration.rb +4 -4
- data/lib/cimi/models/schema.rb +17 -14
- data/lib/cimi/models/volume_image.rb +1 -1
- data/lib/cimi/server.rb +1 -1
- data/lib/deltacloud/api.rb +55 -3
- data/lib/deltacloud/collections/addresses.rb +1 -1
- data/lib/deltacloud/collections/buckets.rb +12 -10
- data/lib/deltacloud/collections/firewalls.rb +2 -1
- data/lib/deltacloud/collections/hardware_profiles.rb +1 -1
- data/lib/deltacloud/collections/images.rb +2 -2
- data/lib/deltacloud/collections/instance_states.rb +6 -3
- data/lib/deltacloud/collections/instances.rb +2 -1
- data/lib/deltacloud/collections/keys.rb +6 -2
- data/lib/deltacloud/collections/load_balancers.rb +8 -7
- data/lib/deltacloud/collections/metrics.rb +2 -1
- data/lib/deltacloud/collections/realms.rb +1 -1
- data/lib/deltacloud/collections/storage_snapshots.rb +2 -1
- data/lib/deltacloud/collections/storage_volumes.rb +2 -2
- data/lib/deltacloud/core_ext.rb +1 -7
- data/lib/deltacloud/core_ext/hash.rb +7 -5
- data/lib/deltacloud/core_ext/string.rb +1 -0
- data/lib/deltacloud/drivers/aruba/aruba_driver.rb +469 -0
- data/lib/deltacloud/drivers/base_driver.rb +12 -17
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +50 -22
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
- data/lib/deltacloud/drivers/exceptions.rb +12 -2
- data/lib/deltacloud/drivers/features.rb +8 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +21 -6
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +169 -57
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
- data/lib/deltacloud/drivers/mock/mock_client.rb +2 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +101 -13
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +12 -6
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +10 -18
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +46 -1
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +17 -17
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +4 -4
- data/lib/deltacloud/helpers.rb +4 -4
- data/lib/deltacloud/helpers/blob_stream_helper.rb +4 -6
- data/lib/deltacloud/helpers/deltacloud_helper.rb +17 -1
- data/lib/deltacloud/helpers/driver_helper.rb +7 -3
- data/lib/deltacloud/helpers/url_helper.rb +4 -4
- data/lib/deltacloud/models/address.rb +1 -1
- data/lib/deltacloud/models/base_model.rb +0 -14
- data/lib/deltacloud/models/bucket.rb +0 -10
- data/lib/deltacloud/models/hardware_profile.rb +5 -26
- data/lib/deltacloud/models/image.rb +0 -12
- data/lib/deltacloud/models/instance.rb +6 -22
- data/lib/deltacloud/models/key.rb +2 -2
- data/lib/deltacloud/models/metric.rb +1 -1
- data/lib/deltacloud/models/storage_snapshot.rb +4 -0
- data/lib/deltacloud/server.rb +8 -2
- data/lib/deltacloud_rack.rb +40 -10
- data/lib/ec2/query_parser.rb +9 -4
- data/lib/ec2/server.rb +1 -1
- data/lib/ec2/views/create_key_pair.haml +3 -0
- data/lib/ec2/views/delete_key_pair.haml +1 -0
- data/lib/ec2/views/describe_availability_zones.haml +6 -0
- data/lib/ec2/views/describe_images.haml +10 -0
- data/lib/ec2/views/describe_instance_set.haml +24 -0
- data/lib/ec2/views/describe_instances.haml +9 -0
- data/lib/ec2/views/describe_key_pairs.haml +5 -0
- data/lib/ec2/views/error.haml +4 -0
- data/lib/ec2/views/instance_action.haml +9 -0
- data/lib/ec2/views/reboot_instances.haml +1 -0
- data/lib/ec2/views/run_instances.haml +7 -0
- data/lib/ec2/views/start_instances.haml +1 -0
- data/lib/ec2/views/stop_instances.haml +1 -0
- data/lib/ec2/views/terminate_instances.haml +9 -0
- data/lib/sinatra.rb +0 -1
- data/lib/sinatra/rack_accept.rb +1 -1
- data/lib/sinatra/rack_driver_select.rb +2 -2
- data/lib/sinatra/rack_etag.rb +5 -1
- data/lib/sinatra/rack_logger.rb +127 -0
- data/lib/sinatra/rack_matrix_params.rb +1 -1
- data/tests/cimi/collections/cloud_entry_point_test.rb +46 -0
- data/tests/cimi/collections/common.rb +17 -0
- data/tests/cimi/collections/machine_images_test.rb +44 -0
- data/tests/cimi/collections/machines_test.rb +41 -0
- data/tests/cimi/spec/cimi/model/machine_admin_spec.rb +35 -0
- data/tests/cimi/spec/cimi/model/machine_configuration_spec.rb +31 -0
- data/tests/cimi/spec/cimi/model/machine_image_spec.rb +33 -0
- data/tests/cimi/spec/cimi/model/machine_spec.rb +32 -0
- data/tests/cimi/spec/cimi/model/machine_template_spec.rb +32 -0
- data/tests/cimi/spec/cimi/model/schema_spec.rb +245 -0
- data/tests/cimi/spec/cimi/model/volume_configuration_spec.rb +34 -0
- data/tests/cimi/spec/cimi/model/volume_image_spec.rb +33 -0
- data/tests/cimi/spec/cimi/model/volume_spec.rb +32 -0
- data/tests/cimi/spec/cimi/model/volume_template_spec.rb +32 -0
- data/tests/cimi/spec/spec_helper.rb +136 -0
- data/tests/deltacloud/base_collection_test.rb +30 -0
- data/tests/deltacloud/collections/buckets_collection_test.rb +65 -0
- data/tests/deltacloud/collections/drivers_collection_test.rb +37 -0
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +53 -0
- data/tests/deltacloud/collections/images_collection_test.rb +59 -0
- data/tests/deltacloud/collections/instance_states_collection_test.rb +34 -0
- data/tests/deltacloud/collections/instances_collection_test.rb +63 -0
- data/tests/deltacloud/collections/keys_collection_test.rb +63 -0
- data/tests/deltacloud/collections_test.rb +35 -0
- data/tests/deltacloud/common.rb +14 -0
- data/tests/deltacloud/deltacloud_helper_test.rb +55 -0
- data/tests/deltacloud/drivers_test.rb +73 -0
- data/tests/deltacloud/rack_test.rb +51 -0
- data/tests/deltacloud/server_test.rb +149 -0
- data/tests/{api → deprecated/api}/common.rb +0 -0
- data/tests/{api → deprecated/api}/driver_test.rb +0 -0
- data/tests/deprecated/api/library_test.rb +6 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/common_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/machines_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/volumes_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/support/env.rb +0 -0
- data/tests/{common.rb → deprecated/common.rb} +0 -0
- data/tests/{core_ext → deprecated/core_ext}/string.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/ec2/api_test.rb +0 -0
- data/tests/deprecated/drivers/ec2/common.rb +23 -0
- data/tests/{drivers → deprecated/drivers}/ec2/drivers_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/ec2/hardware_profiles_test.rb +0 -0
- data/tests/deprecated/drivers/ec2/images_test.rb +230 -0
- data/tests/{drivers → deprecated/drivers}/ec2/instances_test.rb +0 -0
- data/tests/deprecated/drivers/ec2/keys_test.rb +181 -0
- data/tests/deprecated/drivers/ec2/realms_test.rb +146 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/hardware_profiles_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/realms_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/setup.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/google/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/google/buckets_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/google/common.rb +2 -2
- data/tests/{drivers → deprecated/drivers}/mock/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/buckets_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/common.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/drivers_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/hardware_profiles_test.rb +0 -0
- data/tests/deprecated/drivers/mock/images_test.rb +197 -0
- data/tests/deprecated/drivers/mock/instances_test.rb +343 -0
- data/tests/deprecated/drivers/mock/keys_test.rb +161 -0
- data/tests/deprecated/drivers/mock/realms_test.rb +132 -0
- data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +114 -0
- data/tests/deprecated/drivers/mock/storage_volumes_test.rb +122 -0
- data/tests/{drivers → deprecated/drivers}/openstack/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/common.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/hardware_profiles_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/images_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/instances_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/realms_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/buckets_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/common.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/hardware_profiles_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/images_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/instances_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/realms_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rhevm/api_test.rb +0 -0
- data/tests/deprecated/drivers/rhevm/common.rb +21 -0
- data/tests/{drivers → deprecated/drivers}/rhevm/hardware_profiles_test.rb +0 -0
- data/tests/deprecated/drivers/rhevm/images_test.rb +48 -0
- data/tests/{drivers → deprecated/drivers}/rhevm/instances_test.rb +0 -0
- data/tests/deprecated/drivers/rhevm/realms_test.rb +40 -0
- data/tests/{minitest_common.rb → deprecated/minitest_common.rb} +0 -0
- data/tests/{minitest_common_api_test.rb → deprecated/minitest_common_api_test.rb} +0 -0
- data/tests/{rabbit_test.rb → deprecated/rabbit_test.rb} +0 -0
- data/tests/drivers/base/base_driver_test.rb +124 -0
- data/tests/{api → drivers/base}/library_test.rb +2 -8
- data/tests/drivers/ec2/common.rb +23 -15
- data/tests/drivers/ec2/images_test.rb +30 -211
- data/tests/drivers/ec2/instance_test.rb +104 -0
- data/tests/drivers/ec2/keys_test.rb +32 -161
- data/tests/drivers/ec2/realms_test.rb +26 -128
- data/tests/drivers/ec2/storage_snapshots_test.rb +54 -0
- data/tests/drivers/mock/images_test.rb +37 -179
- data/tests/drivers/mock/instances_test.rb +103 -340
- data/tests/drivers/mock/keys_test.rb +30 -145
- data/tests/drivers/mock/realms_test.rb +23 -118
- data/tests/drivers/mock/storage_snapshots_test.rb +23 -100
- data/tests/drivers/mock/storage_volumes_test.rb +41 -104
- data/tests/drivers/models/address_test.rb +18 -0
- data/tests/drivers/models/base_test.rb +33 -0
- data/tests/drivers/models/blob_test.rb +18 -0
- data/tests/drivers/models/hardware_profile_test.rb +52 -0
- data/tests/drivers/models/instance_address_test.rb +24 -0
- data/tests/drivers/models/instance_profile_test.rb +21 -0
- data/tests/drivers/models/instance_test.rb +29 -0
- data/tests/drivers/models/keys_test.rb +25 -0
- data/tests/drivers/models/metrics_test.rb +20 -0
- data/tests/drivers/rhevm/common.rb +15 -15
- data/tests/drivers/rhevm/images_test.rb +61 -36
- data/tests/drivers/rhevm/instance_test.rb +104 -0
- data/tests/drivers/rhevm/provider_test.rb +48 -0
- data/tests/drivers/rhevm/realms_test.rb +40 -37
- data/tests/ec2/common.rb +24 -0
- data/tests/ec2/query_parser_test.rb +98 -0
- data/tests/ec2/server_test.rb +45 -0
- data/tests/helpers/core_ext/array_test.rb +24 -0
- data/tests/helpers/core_ext/hash_test.rb +42 -0
- data/tests/helpers/core_ext/integer_test.rb +19 -0
- data/tests/helpers/core_ext/string_test.rb +74 -0
- data/tests/test_helper.rb +66 -0
- data/views/api/show.html.haml +1 -2
- data/views/api/show.xml.haml +1 -2
- data/views/blobs/show.xml.haml +1 -2
- data/views/keys/new.html.haml +9 -2
- data/views/load_balancers/new.html.haml +35 -34
- data/views/metrics/index.html.haml +1 -1
- data/views/metrics/show.html.haml +2 -2
- data/views/metrics/show.xml.haml +6 -2
- data/views/storage_volumes/attach.html.haml +1 -1
- data/views/storage_volumes/show.html.haml +1 -1
- metadata +853 -544
- 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
|
data/views/api/show.html.haml
CHANGED
@@ -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
|
-
-
|
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
|
|
data/views/api/show.xml.haml
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
%api{ :version => settings.version, :driver => driver_symbol, :provider => Thread.current[:provider] || ENV['API_PROVIDER'] }
|
2
|
-
-
|
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 }
|
data/views/blobs/show.xml.haml
CHANGED
@@ -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'}
|
data/views/keys/new.html.haml
CHANGED
@@ -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
|
-
%
|
7
|
-
|
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
|
-
|
1
|
+
=header "Create new load balancer"
|
2
2
|
|
3
|
-
%
|
4
|
-
%
|
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
|
-
|
12
|
-
%
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
%
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
%
|
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
|
|
data/views/metrics/show.xml.haml
CHANGED
@@ -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
|
-
-
|
9
|
+
- if prop.values
|
10
|
+
- prop.values.each do |p|
|
11
|
+
%sample
|
12
|
+
- p.each do |k, v|
|
13
|
+
%property{ :name => k, :value => v }
|