fog 0.0.93 → 0.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -1
- data/Gemfile.lock +13 -7
- data/bin/fog +6 -0
- data/fog.gemspec +40 -3
- data/lib/fog.rb +2 -1
- data/lib/fog/aws.rb +12 -8
- data/lib/fog/aws/parsers/s3/get_bucket_logging.rb +40 -0
- data/lib/fog/aws/parsers/s3/get_bucket_object_versions.rb +88 -0
- data/lib/fog/aws/parsers/s3/get_bucket_versioning.rb +24 -0
- data/lib/fog/aws/requests/ec2/associate_address.rb +3 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +4 -3
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +4 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +6 -5
- data/lib/fog/aws/requests/s3/get_bucket_logging.rb +53 -0
- data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +83 -0
- data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +43 -0
- data/lib/fog/aws/requests/s3/get_object.rb +6 -1
- data/lib/fog/aws/requests/s3/get_object_acl.rb +8 -2
- data/lib/fog/aws/requests/s3/head_object.rb +4 -1
- data/lib/fog/aws/requests/s3/put_bucket_acl.rb +1 -1
- data/lib/fog/aws/requests/s3/put_bucket_logging.rb +87 -0
- data/lib/fog/aws/requests/s3/put_bucket_versioning.rb +40 -0
- data/lib/fog/aws/s3.rb +9 -1
- data/lib/fog/bin.rb +1 -1
- data/lib/fog/credentials.rb +6 -2
- data/lib/fog/vcloud.rb +288 -0
- data/lib/fog/vcloud/bin.rb +57 -0
- data/lib/fog/vcloud/parser.rb +34 -0
- data/lib/fog/vcloud/parsers/get_organization.rb +37 -0
- data/lib/fog/vcloud/parsers/get_vdc.rb +37 -0
- data/lib/fog/vcloud/parsers/get_versions.rb +46 -0
- data/lib/fog/vcloud/parsers/login.rb +40 -0
- data/lib/fog/vcloud/requests/get_organization.rb +55 -0
- data/lib/fog/vcloud/requests/get_vdc.rb +59 -0
- data/lib/fog/vcloud/requests/get_versions.rb +43 -0
- data/lib/fog/vcloud/requests/login.rb +46 -0
- data/lib/fog/vcloud/terremark/all.rb +9 -0
- data/lib/fog/vcloud/terremark/ecloud.rb +47 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +59 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +94 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +27 -0
- data/lib/fog/vcloud/terremark/vcloud.rb +43 -0
- data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +34 -0
- data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +65 -0
- data/spec/aws/requests/ec2/describe_instances_spec.rb +4 -4
- data/spec/spec_helper.rb +3 -1
- data/spec/vcloud/bin_spec.rb +31 -0
- data/spec/vcloud/requests/get_organization_spec.rb +46 -0
- data/spec/vcloud/requests/get_vdc_spec.rb +50 -0
- data/spec/vcloud/requests/get_versions_spec.rb +28 -0
- data/spec/vcloud/requests/login_spec.rb +8 -0
- data/spec/vcloud/spec_helper.rb +184 -0
- data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +135 -0
- data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -0
- data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +74 -0
- data/spec/vcloud/vcloud_spec.rb +17 -0
- data/tests/aws/requests/ec2/address_tests.rb +3 -0
- metadata +42 -5
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Vcloud
|
|
3
|
+
module Terremark
|
|
4
|
+
module Ecloud
|
|
5
|
+
|
|
6
|
+
module Real
|
|
7
|
+
|
|
8
|
+
# Get details of a vdc
|
|
9
|
+
def get_vdc(vdc_uri)
|
|
10
|
+
request(
|
|
11
|
+
:expects => 200,
|
|
12
|
+
:method => 'GET',
|
|
13
|
+
:parser => Fog::Parsers::Vcloud::Terremark::Ecloud::GetVdc.new,
|
|
14
|
+
:uri => vdc_uri
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module Mock
|
|
20
|
+
#
|
|
21
|
+
#Based off of:
|
|
22
|
+
#http://support.theenterprisecloud.com/kb/default.asp?id=545&Lang=1&SID=
|
|
23
|
+
|
|
24
|
+
def get_vdc(vdc_uri)
|
|
25
|
+
if vdc = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:href] == vdc_uri }
|
|
26
|
+
xml = Builder::XmlMarkup.new
|
|
27
|
+
mock_it Fog::Parsers::Vcloud::Terremark::Ecloud::GetVdc.new, 200,
|
|
28
|
+
xml.Vdc(xmlns.merge(:href => vdc[:href], :name => vdc[:name])) {
|
|
29
|
+
xml.Link(:rel => "down",
|
|
30
|
+
:href => vdc[:href] + "/catalog",
|
|
31
|
+
:type => "application/vnd.vmware.vcloud.catalog+xml",
|
|
32
|
+
:name => vdc[:name])
|
|
33
|
+
xml.Link(:rel => "down",
|
|
34
|
+
:href => vdc[:href].gsub('/vdc','/extensions/vdc') + "/publicIps",
|
|
35
|
+
:type => "application/vnd.tmrk.ecloud.publicIpsList+xml",
|
|
36
|
+
:name => "Public IPs")
|
|
37
|
+
xml.Link(:rel => "down",
|
|
38
|
+
:href => vdc[:href] + "/internetServices",
|
|
39
|
+
:type => "application/vnd.tmrk.ecloud.internetServicesList+xml",
|
|
40
|
+
:name => "Internet Services")
|
|
41
|
+
xml.Link(:rel => "down",
|
|
42
|
+
:href => vdc[:href].sub('/vdc','/extensions/vdc') + "/firewallAcls",
|
|
43
|
+
:type => "application/vnd.tmrk.ecloud.firewallAclsList+xml",
|
|
44
|
+
:name => "Firewall Access List")
|
|
45
|
+
xml.Description("")
|
|
46
|
+
xml.StorageCapacity {
|
|
47
|
+
xml.Units("bytes * 10^9")
|
|
48
|
+
xml.Allocated(vdc[:storage][:allocated])
|
|
49
|
+
xml.Used(vdc[:storage][:used])
|
|
50
|
+
}
|
|
51
|
+
xml.ComputeCapacity {
|
|
52
|
+
xml.Cpu {
|
|
53
|
+
xml.Units("hz * 10^6")
|
|
54
|
+
xml.Allocated(vdc[:cpu][:allocated])
|
|
55
|
+
}
|
|
56
|
+
xml.Memory {
|
|
57
|
+
xml.Units("bytes * 2^20")
|
|
58
|
+
xml.Allocated(vdc[:memory][:allocated])
|
|
59
|
+
}
|
|
60
|
+
xml.DeployedVmsQuota {
|
|
61
|
+
xml.Limit("-1")
|
|
62
|
+
xml.Used("-1")
|
|
63
|
+
}
|
|
64
|
+
xml.InstantiatedVmsQuota {
|
|
65
|
+
xml.Limit("-1")
|
|
66
|
+
xml.Used("-1")
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
xml.ResourceEntities {
|
|
70
|
+
vdc[:vms].each do |vm|
|
|
71
|
+
xml.ResourceEntity(:href => vm[:href],
|
|
72
|
+
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
|
73
|
+
:name => vm[:name])
|
|
74
|
+
end
|
|
75
|
+
}
|
|
76
|
+
xml.AvailableNetworks {
|
|
77
|
+
vdc[:networks].each do |network|
|
|
78
|
+
xml.Network(:href => network[:href],
|
|
79
|
+
:type => "application/vnd.vmware.vcloud.network+xml",
|
|
80
|
+
:name => network[:name])
|
|
81
|
+
end
|
|
82
|
+
}
|
|
83
|
+
}, { 'Content-Type' => 'application/vnd.vmware.vcloud.vdc+xml'}
|
|
84
|
+
else
|
|
85
|
+
mock_error 200, "401 Unauthorized"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Vcloud
|
|
3
|
+
module Terremark
|
|
4
|
+
module Ecloud
|
|
5
|
+
module Real
|
|
6
|
+
|
|
7
|
+
# See /lib/fog/vcloud/requests/get_organizations.rb
|
|
8
|
+
def login
|
|
9
|
+
unauthenticated_request({
|
|
10
|
+
:expects => 200,
|
|
11
|
+
:headers => {
|
|
12
|
+
'Authorization' => authorization_header,
|
|
13
|
+
'Content-Type' => "application/vnd.vmware.vcloud.orgList+xml"
|
|
14
|
+
},
|
|
15
|
+
:method => 'POST',
|
|
16
|
+
:parser => Fog::Parsers::Vcloud::Login.new,
|
|
17
|
+
:uri => @login_uri
|
|
18
|
+
})
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Vcloud
|
|
3
|
+
module Terremark
|
|
4
|
+
module Vcloud
|
|
5
|
+
|
|
6
|
+
module Versions
|
|
7
|
+
SUPPORTED = ["v0.8"]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.extended(klass)
|
|
11
|
+
#Do anything we need to do here that's specific to ecloud
|
|
12
|
+
unless @required
|
|
13
|
+
require 'fog/vcloud/terremark/all'
|
|
14
|
+
require 'fog/vcloud/terremark/vcloud/parsers/get_vdc'
|
|
15
|
+
require 'fog/vcloud/terremark/vcloud/requests/get_vdc'
|
|
16
|
+
Struct.new("TmrkVcloudVdc", :links, :resource_entities, :networks, :href, :type, :name, :xmlns)
|
|
17
|
+
@required = true
|
|
18
|
+
end
|
|
19
|
+
if Fog.mocking?
|
|
20
|
+
klass.extend Fog::Vcloud::Terremark::Vcloud::Mock
|
|
21
|
+
else
|
|
22
|
+
klass.extend Fog::Vcloud::Terremark::Vcloud::Real
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# If we don't support any versions the service does, then raise an error.
|
|
29
|
+
# If the @version that super selected isn't in our supported list, then select one that is.
|
|
30
|
+
def check_versions
|
|
31
|
+
super
|
|
32
|
+
unless (supported_version_ids & Versions::SUPPORTED).length > 0
|
|
33
|
+
raise UnsupportedVersion.new("\nService @ #{@versions_uri} supports: #{supported_version_ids.join(', ')}\n" +
|
|
34
|
+
"Fog::Vcloud::Terremark::Vcloud supports: #{Versions::SUPPORTED.join(', ')}")
|
|
35
|
+
end
|
|
36
|
+
unless supported_version_ids.include?(@version)
|
|
37
|
+
@version = (supported_version_ids & Versions::SUPPORTED).sort.first
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Parsers
|
|
3
|
+
module Vcloud
|
|
4
|
+
module Terremark
|
|
5
|
+
module Vcloud
|
|
6
|
+
|
|
7
|
+
class GetVdc < Fog::Parsers::Vcloud::Base
|
|
8
|
+
|
|
9
|
+
def reset
|
|
10
|
+
@target = nil
|
|
11
|
+
@response = Struct::TmrkVcloudVdc.new([],[],[])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def start_element(name, attributes)
|
|
15
|
+
@value = ''
|
|
16
|
+
case name
|
|
17
|
+
when 'Link'
|
|
18
|
+
@response.links << generate_link(attributes)
|
|
19
|
+
when 'Network'
|
|
20
|
+
@response.networks << generate_link(attributes)
|
|
21
|
+
when 'ResourceEntity'
|
|
22
|
+
@response.resource_entities << generate_link(attributes)
|
|
23
|
+
when 'Vdc'
|
|
24
|
+
handle_root(attributes)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Vcloud
|
|
3
|
+
module Terremark
|
|
4
|
+
module Vcloud
|
|
5
|
+
|
|
6
|
+
module Real
|
|
7
|
+
|
|
8
|
+
# Get details of a vdc
|
|
9
|
+
def get_vdc(vdc_uri)
|
|
10
|
+
request(
|
|
11
|
+
:expects => 200,
|
|
12
|
+
:method => 'GET',
|
|
13
|
+
:parser => Fog::Parsers::Vcloud::Terremark::Vcloud::GetVdc.new,
|
|
14
|
+
:uri => vdc_uri
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module Mock
|
|
20
|
+
#
|
|
21
|
+
#Based off of:
|
|
22
|
+
#https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/09-get-vdc.aspx
|
|
23
|
+
|
|
24
|
+
def get_vdc(vdc_uri)
|
|
25
|
+
if vdc = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:href] == vdc_uri }
|
|
26
|
+
xml = Builder::XmlMarkup.new
|
|
27
|
+
mock_it Fog::Parsers::Vcloud::Terremark::Vcloud::GetVdc.new, 200,
|
|
28
|
+
xml.Vdc(xmlns.merge(:href => vdc[:href], :name => vdc[:name])) {
|
|
29
|
+
xml.Link(:rel => "down",
|
|
30
|
+
:href => vdc[:href] + "/catalog",
|
|
31
|
+
:type => "application/vnd.vmware.vcloud.catalog+xml",
|
|
32
|
+
:name => vdc[:name])
|
|
33
|
+
xml.Link(:rel => "down",
|
|
34
|
+
:href => vdc[:href] + "/publicIps",
|
|
35
|
+
:type => "application/xml",
|
|
36
|
+
:name => "Public IPs")
|
|
37
|
+
xml.Link(:rel => "down",
|
|
38
|
+
:href => vdc[:href] + "/internetServices",
|
|
39
|
+
:type => "application/xml",
|
|
40
|
+
:name => "Internet Services")
|
|
41
|
+
xml.ResourceEntities {
|
|
42
|
+
vdc[:vms].each do |vm|
|
|
43
|
+
xml.ResourceEntity(:href => vm[:href],
|
|
44
|
+
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
|
45
|
+
:name => vm[:name])
|
|
46
|
+
end
|
|
47
|
+
}
|
|
48
|
+
xml.AvailableNetworks {
|
|
49
|
+
vdc[:networks].each do |network|
|
|
50
|
+
xml.Network(:href => network[:href],
|
|
51
|
+
:type => "application/vnd.vmware.vcloud.network+xml",
|
|
52
|
+
:name => network[:name])
|
|
53
|
+
end
|
|
54
|
+
}
|
|
55
|
+
}, { 'Content-Type' => 'application/vnd.vmware.vcloud.vdc+xml'}
|
|
56
|
+
else
|
|
57
|
+
mock_error 200, "401 Unauthorized"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -33,7 +33,7 @@ describe 'EC2.describe_instances' do
|
|
|
33
33
|
instance['instanceState']['code'].should be_a(Integer)
|
|
34
34
|
instance['instanceState']['name'].should be_a(String)
|
|
35
35
|
instance['instanceType'].should be_a(String)
|
|
36
|
-
|
|
36
|
+
instance['ipAddress'].should be_a(String)
|
|
37
37
|
instance['kernelId'].should be_a(String)
|
|
38
38
|
instance['keyName'].should be_a(String) if instance['keyName']
|
|
39
39
|
instance['launchTime'].should be_a(Time)
|
|
@@ -42,7 +42,7 @@ describe 'EC2.describe_instances' do
|
|
|
42
42
|
instance['placement'].should be_a(Hash)
|
|
43
43
|
instance['placement']['availabilityZone'].should be_a(String)
|
|
44
44
|
instance['privateDnsName'].should be_a(String)
|
|
45
|
-
|
|
45
|
+
instance['privateIpAddress'].should be_a(String)
|
|
46
46
|
instance['productCodes'].should be_an(Array)
|
|
47
47
|
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
|
|
48
48
|
instance['ramdiskId'].should be_a(String)
|
|
@@ -71,7 +71,7 @@ describe 'EC2.describe_instances' do
|
|
|
71
71
|
instance['instanceState']['code'].should be_a(Integer)
|
|
72
72
|
instance['instanceState']['name'].should be_a(String)
|
|
73
73
|
instance['instanceType'].should be_a(String)
|
|
74
|
-
|
|
74
|
+
instance['ipAddress'].should be_a(String)
|
|
75
75
|
instance['kernelId'].should be_a(String)
|
|
76
76
|
instance['keyName'].should be_a(String) if instance['keyName']
|
|
77
77
|
instance['launchTime'].should be_a(Time)
|
|
@@ -80,7 +80,7 @@ describe 'EC2.describe_instances' do
|
|
|
80
80
|
instance['placement'].should be_a(Hash)
|
|
81
81
|
instance['placement']['availabilityZone'].should be_a(String)
|
|
82
82
|
instance['privateDnsName'].should be_a(String)
|
|
83
|
-
|
|
83
|
+
instance['privateIpAddress'].should be_a(String)
|
|
84
84
|
instance['productCodes'].should be_an(Array)
|
|
85
85
|
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
|
|
86
86
|
instance['ramdiskId'].should be_a(String)
|
data/spec/spec_helper.rb
CHANGED
|
@@ -9,6 +9,8 @@ if ENV["FOG_MOCK"] == "true"
|
|
|
9
9
|
Fog.mock!
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
require "#{current_directory}/../lib/fog/vcloud/bin"
|
|
13
|
+
|
|
12
14
|
module AWS
|
|
13
15
|
class << self
|
|
14
16
|
def [](service)
|
|
@@ -100,4 +102,4 @@ end
|
|
|
100
102
|
|
|
101
103
|
def lorem_file
|
|
102
104
|
File.open(File.dirname(__FILE__) + '/lorem.txt', 'r')
|
|
103
|
-
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Vcloud do
|
|
4
|
+
it { should be_initialized }
|
|
5
|
+
|
|
6
|
+
it { should have(2).services }
|
|
7
|
+
|
|
8
|
+
describe "#registered_services" do
|
|
9
|
+
subject { Vcloud.registered_services }
|
|
10
|
+
|
|
11
|
+
it { should == ":ecloud, :vcloud" }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "when indexing it like an array" do
|
|
15
|
+
describe "with a service that exists" do
|
|
16
|
+
before do
|
|
17
|
+
Fog::Vcloud.should_receive(:new).and_return(true)
|
|
18
|
+
end
|
|
19
|
+
it "should return something when indexed with a configured service" do
|
|
20
|
+
Vcloud[:ecloud].should_not be_nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "with a service that does not exist" do
|
|
25
|
+
it "should raise an ArgumentError" do
|
|
26
|
+
lambda {Vcloud[:foozle]}.should raise_error(ArgumentError)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Fog::Vcloud, :type => :vcloud_request do
|
|
4
|
+
subject { @vcloud }
|
|
5
|
+
|
|
6
|
+
it { should respond_to :get_organization }
|
|
7
|
+
|
|
8
|
+
describe "#get_organization" do
|
|
9
|
+
context "with a valid organization uri" do
|
|
10
|
+
before { @organization = @vcloud.get_organization(@vcloud.default_organization_uri) }
|
|
11
|
+
subject { @organization }
|
|
12
|
+
|
|
13
|
+
it_should_behave_like "all requests"
|
|
14
|
+
|
|
15
|
+
its(:headers) { should include "Content-Type" }
|
|
16
|
+
its(:body) { should be_an_instance_of Struct::VcloudOrganization }
|
|
17
|
+
|
|
18
|
+
describe :headers do
|
|
19
|
+
let(:header){ @organization.headers["Content-Type"] }
|
|
20
|
+
specify{ header.should == "application/vnd.vmware.vcloud.org+xml" }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "#body" do
|
|
24
|
+
subject { @organization.body }
|
|
25
|
+
|
|
26
|
+
it_should_behave_like "it has a vcloud v0.8 xmlns"
|
|
27
|
+
|
|
28
|
+
its(:links) { should have(@mock_organization[:vdcs].length * 3).links }
|
|
29
|
+
its(:name) { should == @mock_organization[:info][:name] }
|
|
30
|
+
its(:href) { should == @mock_organization[:info][:href] }
|
|
31
|
+
|
|
32
|
+
let(:link) { subject.links[0] }
|
|
33
|
+
specify { link.should be_an_instance_of Struct::VcloudLink }
|
|
34
|
+
specify { link.rel.should == "down" }
|
|
35
|
+
specify { link.href.should == @mock_vdc[:href] }
|
|
36
|
+
specify { link.type.should == "application/vnd.vmware.vcloud.vdc+xml" }
|
|
37
|
+
specify { link.name.should == @mock_vdc[:name] }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
context "with an organization uri that doesn't exist" do
|
|
41
|
+
subject { lambda { @vcloud.get_organization(URI.parse('https://www.fakey.com/api/v0.8/org/999')) } }
|
|
42
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# WARNING: INCOMPLETE
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
describe Fog::Vcloud, :type => :vcloud_request do
|
|
8
|
+
subject { @vcloud }
|
|
9
|
+
|
|
10
|
+
it { should respond_to :get_vdc }
|
|
11
|
+
|
|
12
|
+
describe :get_vdc, :type => :vcloud_request do
|
|
13
|
+
context "with a valid vdc uri" do
|
|
14
|
+
before { @vdc = @vcloud.get_vdc(@mock_vdc[:href]) }
|
|
15
|
+
subject { @vdc }
|
|
16
|
+
|
|
17
|
+
it_should_behave_like "all requests"
|
|
18
|
+
|
|
19
|
+
its(:headers) { should include "Content-Type" }
|
|
20
|
+
its(:body) { should be_an_instance_of Struct::VcloudVdc }
|
|
21
|
+
|
|
22
|
+
describe :headers do
|
|
23
|
+
let(:header) { @vdc.headers["Content-Type"] }
|
|
24
|
+
specify { header.should == "application/vnd.vmware.vcloud.vdc+xml" }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe :body do
|
|
28
|
+
subject { @vdc.body }
|
|
29
|
+
|
|
30
|
+
it_should_behave_like "it has a vcloud v0.8 xmlns"
|
|
31
|
+
|
|
32
|
+
its(:links) { should have(7).links }
|
|
33
|
+
its(:name) { should == @mock_vdc[:name] }
|
|
34
|
+
its(:href) { should == @mock_vdc[:href] }
|
|
35
|
+
|
|
36
|
+
let(:link) { subject.links[0] }
|
|
37
|
+
specify { link.should be_an_instance_of Struct::VcloudLink }
|
|
38
|
+
specify { link.rel.should == "up" }
|
|
39
|
+
specify { link.href.should == @mock_organization[:info][:href] }
|
|
40
|
+
specify { link.type.should == "application/vnd.vmware.vcloud.org+xml" }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
context "with a vdc uri that doesn't exist" do
|
|
44
|
+
subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
|
|
45
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|