fog 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.rdoc +7 -1
- data/bin/fog +4 -3
- data/fog.gemspec +39 -24
- data/lib/fog.rb +4 -12
- data/lib/fog/aws.rb +14 -5
- data/lib/fog/aws/compute.rb +26 -9
- data/lib/fog/aws/elb.rb +3 -2
- data/lib/fog/aws/models/compute/address.rb +2 -1
- data/lib/fog/aws/models/compute/addresses.rb +11 -9
- data/lib/fog/aws/models/compute/flavor.rb +1 -1
- data/lib/fog/aws/models/compute/flavors.rb +13 -11
- data/lib/fog/aws/models/compute/image.rb +2 -1
- data/lib/fog/aws/models/compute/images.rb +7 -9
- data/lib/fog/aws/models/compute/key_pair.rb +1 -1
- data/lib/fog/aws/models/compute/key_pairs.rb +10 -8
- data/lib/fog/aws/models/compute/security_group.rb +1 -1
- data/lib/fog/aws/models/compute/security_groups.rb +11 -9
- data/lib/fog/aws/models/compute/server.rb +10 -3
- data/lib/fog/aws/models/compute/servers.rb +14 -8
- data/lib/fog/aws/models/compute/snapshot.rb +3 -2
- data/lib/fog/aws/models/compute/snapshots.rb +11 -16
- data/lib/fog/aws/models/compute/tag.rb +36 -0
- data/lib/fog/aws/models/compute/tags.rb +34 -0
- data/lib/fog/aws/models/compute/volume.rb +11 -10
- data/lib/fog/aws/models/compute/volumes.rb +11 -9
- data/lib/fog/aws/models/storage/directories.rb +1 -1
- data/lib/fog/aws/models/storage/directory.rb +1 -1
- data/lib/fog/aws/models/storage/file.rb +3 -2
- data/lib/fog/aws/models/storage/files.rb +1 -7
- data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +4 -2
- data/lib/fog/aws/parsers/compute/describe_images.rb +23 -13
- data/lib/fog/aws/parsers/compute/describe_instances.rb +34 -8
- data/lib/fog/aws/parsers/compute/describe_security_groups.rb +4 -3
- data/lib/fog/aws/parsers/compute/describe_snapshots.rb +33 -13
- data/lib/fog/aws/parsers/compute/describe_tags.rb +30 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +17 -3
- data/lib/fog/aws/parsers/compute/run_instances.rb +4 -4
- data/lib/fog/aws/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_logging.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_object_versions.rb +3 -3
- data/lib/fog/aws/requests/compute/create_snapshot.rb +1 -0
- data/lib/fog/aws/requests/compute/create_tags.rb +78 -0
- data/lib/fog/aws/requests/compute/delete_tags.rb +45 -0
- data/lib/fog/aws/requests/compute/describe_addresses.rb +27 -19
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +31 -25
- data/lib/fog/aws/requests/compute/describe_images.rb +11 -18
- data/lib/fog/aws/requests/compute/describe_instances.rb +125 -53
- data/lib/fog/aws/requests/compute/describe_key_pairs.rb +29 -21
- data/lib/fog/aws/requests/compute/describe_regions.rb +28 -23
- data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +8 -4
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +48 -19
- data/lib/fog/aws/requests/compute/describe_snapshots.rb +72 -35
- data/lib/fog/aws/requests/compute/describe_tags.rb +42 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +67 -36
- data/lib/fog/aws/requests/compute/run_instances.rb +10 -3
- data/lib/fog/aws/simpledb.rb +3 -1
- data/lib/fog/aws/storage.rb +17 -8
- data/lib/fog/bluebox/models/compute/flavor.rb +1 -1
- data/lib/fog/bluebox/models/compute/flavors.rb +1 -1
- data/lib/fog/bluebox/models/compute/image.rb +1 -1
- data/lib/fog/bluebox/models/compute/images.rb +1 -1
- data/lib/fog/bluebox/models/compute/server.rb +8 -6
- data/lib/fog/bluebox/models/compute/servers.rb +1 -1
- data/lib/fog/bluebox/requests/compute/get_blocks.rb +1 -1
- data/lib/fog/core.rb +11 -0
- data/lib/fog/{attributes.rb → core/attributes.rb} +0 -0
- data/lib/fog/{bin.rb → core/bin.rb} +1 -1
- data/lib/fog/{collection.rb → core/collection.rb} +4 -0
- data/lib/fog/{connection.rb → core/connection.rb} +0 -0
- data/lib/fog/{credentials.rb → core/credentials.rb} +2 -0
- data/lib/fog/{deprecation.rb → core/deprecation.rb} +0 -0
- data/lib/fog/{errors.rb → core/errors.rb} +0 -0
- data/lib/fog/{hmac.rb → core/hmac.rb} +0 -0
- data/lib/fog/{model.rb → core/model.rb} +0 -0
- data/lib/fog/{parser.rb → core/parser.rb} +0 -0
- data/lib/fog/{provider.rb → core/provider.rb} +0 -0
- data/lib/fog/{service.rb → core/service.rb} +1 -0
- data/lib/fog/{ssh.rb → core/ssh.rb} +7 -7
- data/lib/fog/go_grid.rb +1 -1
- data/lib/fog/go_grid/compute.rb +6 -1
- data/lib/fog/go_grid/models/compute/image.rb +60 -0
- data/lib/fog/go_grid/models/compute/images.rb +33 -0
- data/lib/fog/go_grid/models/compute/server.rb +56 -0
- data/lib/fog/go_grid/models/compute/servers.rb +35 -0
- data/lib/fog/go_grid/requests/compute/grid_image_get.rb +41 -0
- data/lib/fog/go_grid/requests/compute/grid_image_list.rb +6 -1
- data/lib/fog/go_grid/requests/compute/grid_server_power.rb +2 -2
- data/lib/fog/google/models/storage/directories.rb +1 -1
- data/lib/fog/google/models/storage/directory.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +3 -2
- data/lib/fog/google/models/storage/files.rb +1 -7
- data/lib/fog/google/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/linode/requests/compute/avail_linodeplans.rb +2 -2
- data/lib/fog/local/models/storage/directories.rb +1 -1
- data/lib/fog/local/models/storage/directory.rb +1 -1
- data/lib/fog/local/models/storage/file.rb +2 -2
- data/lib/fog/local/models/storage/files.rb +2 -5
- data/lib/fog/local/storage.rb +1 -1
- data/lib/fog/new_servers/compute.rb +1 -1
- data/lib/fog/rackspace/models/compute/flavor.rb +1 -3
- data/lib/fog/rackspace/models/compute/flavors.rb +1 -1
- data/lib/fog/rackspace/models/compute/image.rb +2 -1
- data/lib/fog/rackspace/models/compute/images.rb +1 -1
- data/lib/fog/rackspace/models/compute/server.rb +12 -11
- data/lib/fog/rackspace/models/compute/servers.rb +1 -1
- data/lib/fog/rackspace/models/storage/directories.rb +1 -1
- data/lib/fog/rackspace/models/storage/directory.rb +1 -1
- data/lib/fog/rackspace/models/storage/file.rb +4 -4
- data/lib/fog/rackspace/models/storage/files.rb +1 -1
- data/lib/fog/rackspace/requests/compute/create_image.rb +2 -2
- data/lib/fog/rackspace/requests/compute/delete_image.rb +1 -1
- data/lib/fog/rackspace/requests/compute/delete_server.rb +1 -1
- data/lib/fog/rackspace/requests/compute/get_server_details.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_images_detail.rb +2 -2
- data/lib/fog/rackspace/requests/compute/list_private_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_public_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/update_server.rb +1 -1
- data/lib/fog/rackspace/requests/storage/put_object.rb +4 -3
- data/lib/fog/slicehost/models/compute/flavor.rb +1 -1
- data/lib/fog/slicehost/models/compute/flavors.rb +1 -1
- data/lib/fog/slicehost/models/compute/image.rb +1 -1
- data/lib/fog/slicehost/models/compute/images.rb +1 -1
- data/lib/fog/slicehost/models/compute/server.rb +3 -1
- data/lib/fog/slicehost/models/compute/servers.rb +1 -1
- data/lib/fog/terremark/ecloud.rb +34 -33
- data/lib/fog/terremark/models/shared/address.rb +1 -1
- data/lib/fog/terremark/models/shared/network.rb +1 -1
- data/lib/fog/terremark/models/shared/server.rb +1 -1
- data/lib/fog/terremark/models/shared/servers.rb +1 -1
- data/lib/fog/terremark/models/shared/task.rb +1 -1
- data/lib/fog/terremark/models/shared/tasks.rb +1 -1
- data/lib/fog/terremark/models/shared/vdc.rb +1 -1
- data/lib/fog/terremark/parser.rb +1 -0
- data/lib/fog/terremark/vcloud.rb +4 -4
- data/lib/fog/vcloud.rb +15 -7
- data/lib/fog/vcloud/terremark/ecloud.rb +15 -3
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +55 -49
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +19 -15
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +8 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +17 -12
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +29 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +38 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +8 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +46 -4
- data/spec/aws/models/compute/server_spec.rb +2 -0
- data/spec/aws/requests/simpledb/select_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/vcloud/spec_helper.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +62 -0
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +39 -0
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +73 -0
- data/tests/aws/requests/compute/address_tests.rb +2 -6
- data/tests/aws/requests/compute/availability_zone_tests.rb +3 -10
- data/tests/aws/requests/compute/image_tests.rb +4 -9
- data/tests/aws/requests/compute/instance_tests.rb +7 -8
- data/tests/aws/requests/compute/key_pair_tests.rb +2 -6
- data/tests/aws/requests/compute/region_tests.rb +2 -9
- data/tests/aws/requests/compute/security_group_tests.rb +3 -7
- data/tests/aws/requests/compute/snapshot_tests.rb +4 -7
- data/tests/aws/requests/compute/tag_tests.rb +49 -0
- data/tests/aws/requests/compute/volume_tests.rb +2 -6
- data/tests/aws/requests/storage/bucket_tests.rb +48 -0
- data/tests/aws/requests/storage/object_tests.rb +63 -0
- data/tests/bluebox/requests/compute/block_tests.rb +24 -11
- data/tests/bluebox/requests/compute/product_tests.rb +3 -0
- data/tests/bluebox/requests/compute/template_tests.rb +3 -0
- data/tests/go_grid/helper.rb +0 -0
- data/tests/go_grid/requests/compute/image_tests.rb +0 -0
- data/tests/helper.rb +5 -1
- data/tests/linode/requests/compute/datacenter_tests.rb +1 -0
- data/tests/linode/requests/compute/distribution_tests.rb +2 -0
- data/tests/linode/requests/compute/linode_tests.rb +6 -0
- data/tests/linode/requests/compute/linodeplans_tests.rb +2 -0
- data/tests/lorem.txt +1 -0
- data/tests/rackspace/requests/compute/flavor_tests.rb +4 -0
- data/tests/rackspace/requests/compute/image_tests.rb +12 -4
- data/tests/rackspace/requests/compute/server_tests.rb +9 -0
- data/tests/slicehost/requests/compute/backup_tests.rb +1 -0
- data/tests/slicehost/requests/compute/flavor_tests.rb +3 -0
- data/tests/slicehost/requests/compute/image_tests.rb +3 -0
- data/tests/slicehost/requests/compute/slice_tests.rb +14 -2
- metadata +42 -27
- data/spec/aws/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/aws/requests/storage/delete_object_spec.rb +0 -36
- data/spec/aws/requests/storage/get_object_spec.rb +0 -58
- data/spec/aws/requests/storage/get_service_spec.rb +0 -32
- data/spec/aws/requests/storage/head_object_spec.rb +0 -26
- data/spec/aws/requests/storage/put_bucket_spec.rb +0 -19
- data/spec/aws/requests/storage/put_object_spec.rb +0 -43
@@ -2,21 +2,7 @@ module Fog
|
|
2
2
|
class Vcloud
|
3
3
|
module Terremark
|
4
4
|
class Ecloud
|
5
|
-
|
6
|
-
|
7
|
-
def add_node(nodes_uri, node_data)
|
8
|
-
validate_node_data(node_data)
|
9
|
-
|
10
|
-
request(
|
11
|
-
:body => generate_node_request(node_data),
|
12
|
-
:expects => 200,
|
13
|
-
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'},
|
14
|
-
:method => 'POST',
|
15
|
-
:uri => nodes_uri,
|
16
|
-
:parse => true
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
5
|
+
module Shared
|
20
6
|
private
|
21
7
|
|
22
8
|
def generate_node_request(node_data)
|
@@ -43,7 +29,25 @@ module Fog
|
|
43
29
|
end
|
44
30
|
end
|
45
31
|
|
32
|
+
class Real
|
33
|
+
include Shared
|
34
|
+
|
35
|
+
def add_node(nodes_uri, node_data)
|
36
|
+
validate_node_data(node_data)
|
37
|
+
|
38
|
+
request(
|
39
|
+
:body => generate_node_request(node_data),
|
40
|
+
:expects => 200,
|
41
|
+
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'},
|
42
|
+
:method => 'POST',
|
43
|
+
:uri => nodes_uri,
|
44
|
+
:parse => true
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
46
49
|
class Mock
|
50
|
+
include Shared
|
47
51
|
|
48
52
|
def add_node(nodes_uri, node_data)
|
49
53
|
validate_node_data(node_data)
|
@@ -2,7 +2,8 @@ module Fog
|
|
2
2
|
class Vcloud
|
3
3
|
module Terremark
|
4
4
|
class Ecloud
|
5
|
-
|
5
|
+
module Shared
|
6
|
+
private
|
6
7
|
|
7
8
|
def generate_internet_service_response(service_data,ip_address_data)
|
8
9
|
builder = Builder::XmlMarkup.new
|
@@ -34,6 +35,10 @@ module Fog
|
|
34
35
|
raise ArgumentError.new("Required Internet Service data missing: #{(valid_opts - ip_address_data.keys).map(&:inspect).join(", ")}")
|
35
36
|
end
|
36
37
|
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Real
|
41
|
+
include Shared
|
37
42
|
|
38
43
|
def configure_internet_service(internet_service_uri, service_data, ip_address_data)
|
39
44
|
validate_internet_service_data(service_data, true)
|
@@ -58,6 +63,8 @@ module Fog
|
|
58
63
|
end
|
59
64
|
|
60
65
|
class Mock
|
66
|
+
include Shared
|
67
|
+
|
61
68
|
#
|
62
69
|
# Based on
|
63
70
|
# http://support.theenterprisecloud.com/kb/default.asp?id=583&Lang=1&SID=
|
@@ -2,7 +2,23 @@ module Fog
|
|
2
2
|
class Vcloud
|
3
3
|
module Terremark
|
4
4
|
class Ecloud
|
5
|
+
module Shared
|
6
|
+
private
|
7
|
+
|
8
|
+
def generate_configure_node_request(node_data)
|
9
|
+
builder = Builder::XmlMarkup.new
|
10
|
+
builder.NodeService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
|
11
|
+
:xmlns => "urn:tmrk:eCloudExtensions-2.0") {
|
12
|
+
builder.Name(node_data[:name])
|
13
|
+
builder.Enabled(node_data[:enabled].to_s)
|
14
|
+
builder.Description(node_data[:description])
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
5
20
|
class Real
|
21
|
+
include Shared
|
6
22
|
|
7
23
|
def configure_node(node_uri, node_data)
|
8
24
|
validate_node_data(node_data, true)
|
@@ -17,21 +33,10 @@ module Fog
|
|
17
33
|
)
|
18
34
|
end
|
19
35
|
|
20
|
-
private
|
21
|
-
|
22
|
-
def generate_configure_node_request(node_data)
|
23
|
-
builder = Builder::XmlMarkup.new
|
24
|
-
builder.NodeService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
|
25
|
-
:xmlns => "urn:tmrk:eCloudExtensions-2.0") {
|
26
|
-
builder.Name(node_data[:name])
|
27
|
-
builder.Enabled(node_data[:enabled].to_s)
|
28
|
-
builder.Description(node_data[:description])
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
36
|
end
|
33
37
|
|
34
38
|
class Mock
|
39
|
+
include Shared
|
35
40
|
|
36
41
|
def configure_node(node_uri, node_data)
|
37
42
|
node_uri = ensure_unparsed(node_uri)
|
@@ -9,7 +9,35 @@ module Fog
|
|
9
9
|
|
10
10
|
class Mock
|
11
11
|
def get_catalog(catalog_uri)
|
12
|
-
|
12
|
+
catalog_uri = ensure_unparsed(catalog_uri)
|
13
|
+
xml = nil
|
14
|
+
|
15
|
+
if vdc = vdc_from_uri(catalog_uri)
|
16
|
+
builder = Builder::XmlMarkup.new
|
17
|
+
|
18
|
+
xml = builder.Catalog(xmlns.merge(
|
19
|
+
:type => "application/vnd.vmware.vcloud.catalog+xml",
|
20
|
+
:href => catalog_uri,
|
21
|
+
:name => vdc[:catalog][:name]
|
22
|
+
)) do |xml|
|
23
|
+
xml.CatalogItems do |xml|
|
24
|
+
vdc[:catalog][:items].each do |catalog_item|
|
25
|
+
xml.CatalogItem(
|
26
|
+
:type => "application/vnd.vmware.vcloud.catalogItem+xml",
|
27
|
+
:href => "#{self.class.base_url}/catalogItem/#{catalog_item[:id]}-#{vdc[:id]}",
|
28
|
+
:name => catalog_item[:name]
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if xml
|
36
|
+
mock_it 200,
|
37
|
+
xml, { 'Content-Type' => 'application/vnd.vmware.vcloud.catalog+xml' }
|
38
|
+
else
|
39
|
+
mock_error 200, "401 Unauthorized"
|
40
|
+
end
|
13
41
|
end
|
14
42
|
end
|
15
43
|
end
|
@@ -8,8 +8,44 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Mock
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
#
|
13
|
+
# Based on
|
14
|
+
# http://support.theenterprisecloud.com/kb/default.asp?id=542&Lang=1&SID=
|
15
|
+
#
|
16
|
+
|
17
|
+
def get_catalog_item(catalog_item_uri)
|
18
|
+
catalog_item_id, vdc_id = catalog_item_uri.split("/").last.split("-")
|
19
|
+
xml = nil
|
20
|
+
|
21
|
+
if vdc = vdc_from_id(vdc_id)
|
22
|
+
if catalog_item = vdc[:catalog][:items].detect {|ci| ci[:id] == catalog_item_id }
|
23
|
+
builder = Builder::XmlMarkup.new
|
24
|
+
|
25
|
+
xml = builder.CatalogItem(xmlns.merge(:href => catalog_item_uri, :name => catalog_item[:name])) do
|
26
|
+
builder.Link(
|
27
|
+
:rel => "down",
|
28
|
+
:href => Fog::Vcloud::Terremark::Ecloud::Mock.catalog_item_customization_href(:id => catalog_item_id),
|
29
|
+
:type => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml",
|
30
|
+
:name => "Customization Options"
|
31
|
+
)
|
32
|
+
|
33
|
+
builder.Entity(
|
34
|
+
:href => Fog::Vcloud::Terremark::Ecloud::Mock.vapp_template_href(:id => catalog_item_id),
|
35
|
+
:type => "application/vnd.vmware.vcloud.vAppTemplate+xml",
|
36
|
+
:name => catalog_item[:name]
|
37
|
+
)
|
38
|
+
|
39
|
+
builder.Property(0, :key => "LicensingCost")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if xml
|
45
|
+
mock_it 200, xml, {'Content-Type' => 'application/vnd.vmware.vcloud.catalogItem+xml'}
|
46
|
+
else
|
47
|
+
mock_error 200, "401 Unauthorized"
|
48
|
+
end
|
13
49
|
end
|
14
50
|
end
|
15
51
|
end
|
@@ -8,8 +8,14 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Mock
|
11
|
-
def get_customization_options(
|
12
|
-
|
11
|
+
def get_customization_options(options_uri)
|
12
|
+
builder = Builder::XmlMarkup.new
|
13
|
+
xml = builder.CustomizationParameters(xmlns) do
|
14
|
+
builder.CustomizeNetwork "true"
|
15
|
+
builder.CustomizePassword "false"
|
16
|
+
end
|
17
|
+
|
18
|
+
mock_it 200, xml, "Content-Type" => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml"
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -2,8 +2,8 @@ module Fog
|
|
2
2
|
class Vcloud
|
3
3
|
module Terremark
|
4
4
|
class Ecloud
|
5
|
-
|
6
|
-
|
5
|
+
module Shared
|
6
|
+
private
|
7
7
|
|
8
8
|
def validate_instantiate_vapp_template_options(catalog_item_uri, options)
|
9
9
|
valid_opts = [:name, :vdc_uri, :network_uri, :cpus, :memory, :row, :group]
|
@@ -74,6 +74,10 @@ module Fog
|
|
74
74
|
}
|
75
75
|
}
|
76
76
|
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Real
|
80
|
+
include Shared
|
77
81
|
|
78
82
|
def instantiate_vapp_template(catalog_item_uri, options = {})
|
79
83
|
validate_instantiate_vapp_template_options(catalog_item_uri, options)
|
@@ -90,8 +94,46 @@ module Fog
|
|
90
94
|
end
|
91
95
|
|
92
96
|
class Mock
|
93
|
-
|
94
|
-
|
97
|
+
include Shared
|
98
|
+
|
99
|
+
#
|
100
|
+
# Based on
|
101
|
+
# http://support.theenterprisecloud.com/kb/default.asp?id=554&Lang=1&SID=
|
102
|
+
#
|
103
|
+
|
104
|
+
def instantiate_vapp_template(catalog_item_uri, options = {})
|
105
|
+
validate_instantiate_vapp_template_options(catalog_item_uri, options)
|
106
|
+
|
107
|
+
xml = nil
|
108
|
+
if vdc = vdc_from_uri(options[:vdc_uri])
|
109
|
+
id = rand(1000)
|
110
|
+
vapp_uri = Fog::Vcloud::Terremark::Ecloud::Mock.vapp_href(:id => id)
|
111
|
+
options.update(:id => id.to_s, :href => vapp_uri)
|
112
|
+
vdc[:vms] << options
|
113
|
+
|
114
|
+
xml = generate_instantiate_vapp_template_response(vdc[:href], options[:name], vapp_uri)
|
115
|
+
end
|
116
|
+
|
117
|
+
if xml
|
118
|
+
mock_it 200, xml, {'Content-Type' => 'application/xml'}
|
119
|
+
else
|
120
|
+
mock_error 200, "401 Unauthorized"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def generate_instantiate_vapp_template_response(vdc_uri, vapp_name, vapp_uri)
|
127
|
+
builder = Builder::XmlMarkup.new
|
128
|
+
builder.VApp(xmlns.merge(
|
129
|
+
:href => vapp_uri,
|
130
|
+
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
131
|
+
:name => vapp_name,
|
132
|
+
:status => 0,
|
133
|
+
:size => 4
|
134
|
+
)) {
|
135
|
+
builder.Link(:rel => "up", :href => vdc_uri, :type => "application/vnd.vmware.vcloud.vdc+xml")
|
136
|
+
}
|
95
137
|
end
|
96
138
|
end
|
97
139
|
end
|
@@ -23,6 +23,7 @@ describe 'Fog::AWS::Compute::Server' do
|
|
23
23
|
it "should remap attributes from parser" do
|
24
24
|
server = @servers.new({
|
25
25
|
'amiLaunchIndex' => 'ami_launch_index',
|
26
|
+
'clientToken' => 'client_token',
|
26
27
|
'dnsName' => 'dns_name',
|
27
28
|
'imageId' => 'image_id',
|
28
29
|
'instanceId' => 'instance_id',
|
@@ -35,6 +36,7 @@ describe 'Fog::AWS::Compute::Server' do
|
|
35
36
|
'ramdiskId' => 'ramdisk_id'
|
36
37
|
})
|
37
38
|
server.ami_launch_index.should == 'ami_launch_index'
|
39
|
+
server.client_token.should == 'client_token'
|
38
40
|
server.dns_name.should == 'dns_name'
|
39
41
|
server.image_id.should == 'image_id'
|
40
42
|
server.id.should == 'instance_id'
|
@@ -13,6 +13,7 @@ describe 'SimpleDB.select' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should return multi-value attributes when present' do
|
16
|
+
pending if Fog.mocking?
|
16
17
|
@item = "someitem_fog_domain_#{Time.now.to_i}"
|
17
18
|
AWS[:sdb].put_attributes(@domain_name, @item, { "attr" => "foo" })
|
18
19
|
AWS[:sdb].put_attributes(@domain_name, @item, { "attr" => "foo2" })
|
data/spec/spec_helper.rb
CHANGED
data/spec/vcloud/spec_helper.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
5
|
+
subject { @vcloud }
|
6
|
+
|
7
|
+
it { should respond_to :get_catalog_item }
|
8
|
+
|
9
|
+
describe "#get_catalog_item" do
|
10
|
+
context "with a valid catalog_item_uri" do
|
11
|
+
before { @catalog_item = @vcloud.get_catalog_item(@vcloud.vdcs.first.catalog.first.href) }
|
12
|
+
subject { @catalog_item }
|
13
|
+
let(:catalog_item_id) { @catalog_item.body[:href].split("/").last.split("-").first }
|
14
|
+
|
15
|
+
it_should_behave_like "all responses"
|
16
|
+
it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.catalogItem+xml" }
|
17
|
+
|
18
|
+
describe "#body" do
|
19
|
+
subject { @catalog_item.body }
|
20
|
+
|
21
|
+
it { should have(8).items }
|
22
|
+
|
23
|
+
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
24
|
+
|
25
|
+
its(:name) { should == "Item 0" }
|
26
|
+
|
27
|
+
it { should include :Entity }
|
28
|
+
it { should include :Link }
|
29
|
+
it { should include :Property }
|
30
|
+
|
31
|
+
describe "Entity" do
|
32
|
+
subject { @catalog_item.body[:Entity] }
|
33
|
+
|
34
|
+
it { should have(3).items }
|
35
|
+
|
36
|
+
its(:name) { should == "Item 0" }
|
37
|
+
its(:type) { should == "application/vnd.vmware.vcloud.vAppTemplate+xml" }
|
38
|
+
its(:href) { should == Fog::Vcloud::Terremark::Ecloud::Mock.vapp_template_href(:id => catalog_item_id) }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "Link" do
|
42
|
+
subject { @catalog_item.body[:Link] }
|
43
|
+
|
44
|
+
it { should have(4).items }
|
45
|
+
|
46
|
+
its(:rel) { should == "down" }
|
47
|
+
its(:href) { should == Fog::Vcloud::Terremark::Ecloud::Mock.catalog_item_customization_href(:id => catalog_item_id) }
|
48
|
+
its(:name) { should == "Customization Options" }
|
49
|
+
its(:type) { should == "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with a catalog uri that doesn't exist" do
|
55
|
+
subject { lambda { @vcloud.get_catalog(URI.parse('https://www.fakey.com/api/v0.8/vdc/999/catalog')) } }
|
56
|
+
|
57
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
else
|
62
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
5
|
+
subject { @vcloud }
|
6
|
+
|
7
|
+
it { should respond_to :get_catalog }
|
8
|
+
|
9
|
+
describe "#get_catalog" do
|
10
|
+
context "with a valid vdc catalog_uri" do
|
11
|
+
before { @catalog = @vcloud.get_catalog(@mock_vdc[:href] + "/catalog") }
|
12
|
+
subject { @catalog }
|
13
|
+
|
14
|
+
it_should_behave_like "all responses"
|
15
|
+
it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.catalog+xml" }
|
16
|
+
|
17
|
+
describe "#body" do
|
18
|
+
subject { @catalog.body }
|
19
|
+
|
20
|
+
it { should have(7).items }
|
21
|
+
|
22
|
+
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
23
|
+
|
24
|
+
its(:name) { should == "The catalog" }
|
25
|
+
|
26
|
+
it { should include :CatalogItems }
|
27
|
+
|
28
|
+
describe "CatalogItems" do
|
29
|
+
subject { @catalog.body[:CatalogItems] }
|
30
|
+
|
31
|
+
it { should have(1).items }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with a catalog uri that doesn't exist" do
|
37
|
+
subject { lambda { @vcloud.get_catalog(URI.parse('https://www.fakey.com/api/v0.8/vdc/999/catalog')) } }
|
38
|
+
|
39
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
else
|
44
|
+
end
|