fog 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +17 -12
- data/fog.gemspec +10 -5
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/models/storage/directory.rb +22 -0
- data/lib/fog/aws/models/storage/file.rb +15 -0
- data/lib/fog/aws/storage.rb +8 -0
- data/lib/fog/core/collection.rb +9 -8
- data/lib/fog/core/compute.rb +1 -1
- data/lib/fog/google/models/storage/directory.rb +23 -1
- data/lib/fog/google/models/storage/file.rb +16 -1
- data/lib/fog/google/parsers/storage/access_control_list.rb +16 -14
- data/lib/fog/local/models/storage/directory.rb +8 -0
- data/lib/fog/local/models/storage/file.rb +4 -0
- data/lib/fog/rackspace/cdn.rb +3 -3
- data/lib/fog/rackspace/models/storage/directory.rb +18 -0
- data/lib/fog/rackspace/models/storage/file.rb +7 -0
- data/lib/fog/rackspace/requests/cdn/{get_cdn_containers.rb → get_containers.rb} +3 -3
- data/lib/fog/rackspace/requests/cdn/{head_cdn_container.rb → head_container.rb} +3 -3
- data/lib/fog/rackspace/requests/cdn/{put_cdn_container.rb → put_container.rb} +3 -3
- data/lib/fog/rackspace/storage.rb +10 -0
- data/lib/fog/vcloud.rb +32 -153
- data/lib/fog/vcloud/collection.rb +18 -0
- data/lib/fog/vcloud/mock_data_classes.rb +701 -0
- data/lib/fog/vcloud/requests/get_network.rb +8 -8
- data/lib/fog/vcloud/requests/get_organization.rb +10 -10
- data/lib/fog/vcloud/requests/get_vdc.rb +18 -18
- data/lib/fog/vcloud/requests/get_versions.rb +3 -3
- data/lib/fog/vcloud/requests/login.rb +2 -2
- data/lib/fog/vcloud/terremark/ecloud.rb +65 -109
- data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +3 -2
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/server.rb +20 -8
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +4 -8
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +4 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +18 -20
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +6 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +40 -9
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +2 -10
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +2 -6
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +13 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +6 -6
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +6 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -33
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +23 -24
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +10 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -19
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +20 -22
- data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +12 -15
- data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +11 -12
- data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -4
- data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +9 -8
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +33 -17
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +54 -53
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +13 -19
- data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +9 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +2 -4
- data/spec/vcloud/bin_spec.rb +3 -6
- data/spec/vcloud/models/vdc_spec.rb +8 -8
- data/spec/vcloud/requests/get_network_spec.rb +8 -8
- data/spec/vcloud/requests/get_organization_spec.rb +9 -9
- data/spec/vcloud/requests/get_vdc_spec.rb +7 -7
- data/spec/vcloud/requests/get_versions_spec.rb +1 -1
- data/spec/vcloud/requests/login_spec.rb +2 -2
- data/spec/vcloud/spec_helper.rb +45 -30
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +10 -14
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +5 -8
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +15 -16
- data/spec/vcloud/terremark/ecloud/models/node_spec.rb +7 -7
- data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +4 -8
- data/spec/vcloud/terremark/ecloud/models/server_spec.rb +42 -0
- data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +7 -7
- data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +13 -18
- data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +9 -5
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +5 -7
- data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +22 -28
- data/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +71 -0
- data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +7 -9
- data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +3 -7
- data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +83 -0
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +6 -5
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +31 -42
- data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +4 -7
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +19 -11
- data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +8 -8
- data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +11 -11
- data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +4 -5
- data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +6 -6
- data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +36 -19
- data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +21 -18
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +27 -17
- data/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +34 -0
- data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +3 -4
- data/spec/vcloud/vcloud_spec.rb +2 -2
- data/tests/helpers/storage/directory_tests.rb +8 -0
- data/tests/helpers/storage/file_tests.rb +4 -0
- metadata +11 -6
@@ -9,8 +9,7 @@ if Fog.mocking?
|
|
9
9
|
describe "#get_public_ip" do
|
10
10
|
context "with a valid public_ip_uri" do
|
11
11
|
before do
|
12
|
-
@
|
13
|
-
@public_ip = @vcloud.get_public_ip( @mock_ip[:href] )
|
12
|
+
@public_ip = @vcloud.get_public_ip(@mock_public_ip.href)
|
14
13
|
end
|
15
14
|
|
16
15
|
subject { @public_ip }
|
@@ -21,9 +20,9 @@ if Fog.mocking?
|
|
21
20
|
describe "#body" do
|
22
21
|
subject { @public_ip.body }
|
23
22
|
|
24
|
-
its(:Name) { should == @
|
25
|
-
its(:Href) { should == @
|
26
|
-
its(:Id) { should == @
|
23
|
+
its(:Name) { should == @mock_public_ip.name }
|
24
|
+
its(:Href) { should == @mock_public_ip.href }
|
25
|
+
its(:Id) { should == @mock_public_ip.object_id.to_s }
|
27
26
|
|
28
27
|
end
|
29
28
|
end
|
@@ -8,7 +8,7 @@ if Fog.mocking?
|
|
8
8
|
|
9
9
|
describe "#get_public_ips" do
|
10
10
|
context "with a valid public_ips_uri" do
|
11
|
-
before { @public_ips = @vcloud.get_public_ips(
|
11
|
+
before { @public_ips = @vcloud.get_public_ips(@mock_public_ip_collection.href) }
|
12
12
|
subject { @public_ips }
|
13
13
|
|
14
14
|
it_should_behave_like "all responses"
|
@@ -22,16 +22,16 @@ if Fog.mocking?
|
|
22
22
|
describe "[:PublicIPAddress]" do
|
23
23
|
subject { @public_ips.body[:PublicIPAddress] }
|
24
24
|
|
25
|
-
it { should have(@
|
25
|
+
it { should have(@mock_public_ip_collection.items.length).addresses }
|
26
26
|
|
27
27
|
[0,1,2].each do |idx|
|
28
28
|
|
29
29
|
context "[#{idx}]" do
|
30
30
|
subject { @public_ips.body[:PublicIPAddress][idx] }
|
31
|
-
let(:public_ip) { @
|
32
|
-
its(:Href) { should == public_ip
|
33
|
-
its(:Id) { should == public_ip
|
34
|
-
its(:Name) { should == public_ip
|
31
|
+
let(:public_ip) { @mock_public_ip_collection.items[idx] }
|
32
|
+
its(:Href) { should == public_ip.href }
|
33
|
+
its(:Id) { should == public_ip.object_id.to_s }
|
34
|
+
its(:Name) { should == public_ip.name }
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -8,11 +8,9 @@ if Fog.mocking?
|
|
8
8
|
|
9
9
|
describe "#get_vapp" do
|
10
10
|
context "with a valid vapp_uri" do
|
11
|
-
before { @vapp = @vcloud.get_vapp(
|
11
|
+
before { @vapp = @vcloud.get_vapp(@mock_vm.href) }
|
12
12
|
subject { @vapp }
|
13
13
|
let(:vapp_id) { @vapp.body[:href].split("/").last }
|
14
|
-
let(:vm_data) { @vcloud.mock_data[:organizations].first[:vdcs].first[:vms].first }
|
15
|
-
let(:vdc) { @vcloud.vdcs.first }
|
16
14
|
|
17
15
|
it_should_behave_like "all responses"
|
18
16
|
it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.vApp+xml" }
|
@@ -20,21 +18,26 @@ if Fog.mocking?
|
|
20
18
|
describe "#body" do
|
21
19
|
subject { @vapp.body }
|
22
20
|
|
23
|
-
specify { subject.keys.sort_by(&:to_s).should == [:Link,
|
21
|
+
specify { subject.keys.sort_by(&:to_s).should == [:Link, :NetworkConnectionSection,
|
22
|
+
:OperatingSystemSection, :VirtualHardwareSection,
|
23
|
+
:href, :name,
|
24
|
+
:size, :status,
|
25
|
+
:type, :xmlns,
|
26
|
+
:xmlns_xsd, :xmlns_xsi] }
|
24
27
|
|
25
28
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
26
29
|
|
27
|
-
its(:href)
|
28
|
-
its(:name)
|
29
|
-
its(:status) { should ==
|
30
|
-
its(:size)
|
30
|
+
its(:href) { should == @mock_vm.href }
|
31
|
+
its(:name) { should == @mock_vm.name }
|
32
|
+
its(:status) { should == @mock_vm.status.to_s }
|
33
|
+
its(:size) { should == (@mock_vm.disks.inject(0) {|s, d| s += d[:size].to_i } * 1024).to_s }
|
31
34
|
|
32
35
|
describe "Link" do
|
33
36
|
subject { @vapp.body[:Link] }
|
34
37
|
|
35
38
|
its(:rel) { should == "up" }
|
36
39
|
its(:type) { should == "application/vnd.vmware.vcloud.vdc+xml" }
|
37
|
-
its(:href) { should ==
|
40
|
+
its(:href) { should == @mock_vdc.href }
|
38
41
|
end
|
39
42
|
|
40
43
|
describe "NetworkConnectionSection" do
|
@@ -45,7 +48,7 @@ if Fog.mocking?
|
|
45
48
|
describe "NetworkConnection" do
|
46
49
|
subject { @vapp.body[:NetworkConnectionSection][:NetworkConnection] }
|
47
50
|
|
48
|
-
its(:IpAddress) { should ==
|
51
|
+
its(:IpAddress) { should == @mock_vm.ip }
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -64,20 +67,20 @@ if Fog.mocking?
|
|
64
67
|
describe "Item" do
|
65
68
|
subject { @vapp.body[:VirtualHardwareSection][:Item] }
|
66
69
|
|
67
|
-
it { should have(
|
70
|
+
it { should have(5).items }
|
68
71
|
|
69
|
-
specify { subject.map {|i| i[:ResourceType] }.sort.should == %w(3 4 6 17).sort }
|
72
|
+
specify { subject.map {|i| i[:ResourceType] }.uniq.sort.should == %w(3 4 6 17).sort }
|
70
73
|
|
71
74
|
describe "CPU" do
|
72
75
|
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "3" } }
|
73
76
|
|
74
|
-
its(:VirtualQuantity) { should ==
|
77
|
+
its(:VirtualQuantity) { should == @mock_vm.cpus.to_s }
|
75
78
|
end
|
76
79
|
|
77
80
|
describe "memory" do
|
78
81
|
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "4" } }
|
79
82
|
|
80
|
-
its(:VirtualQuantity) { should ==
|
83
|
+
its(:VirtualQuantity) { should == @mock_vm.memory.to_s }
|
81
84
|
end
|
82
85
|
|
83
86
|
describe "SCSI controller" do
|
@@ -86,12 +89,26 @@ if Fog.mocking?
|
|
86
89
|
its(:Address) { should == "0" }
|
87
90
|
end
|
88
91
|
|
89
|
-
describe "Hard
|
90
|
-
subject { @vapp.body[:VirtualHardwareSection][:Item].
|
92
|
+
describe "Hard Disks" do
|
93
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" } }
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
+
it { should have(2).disks }
|
96
|
+
|
97
|
+
describe "#1" do
|
98
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" }[0] }
|
99
|
+
|
100
|
+
its(:AddressOnParent) { should == "0" }
|
101
|
+
its(:VirtualQuantity) { should == (1024 * @mock_vm.disks[0][:size].to_i).to_s }
|
102
|
+
its(:HostResource) { should == (1024 * @mock_vm.disks[0][:size].to_i).to_s }
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#2" do
|
106
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" }[1] }
|
107
|
+
|
108
|
+
its(:AddressOnParent) { should == "1" }
|
109
|
+
its(:VirtualQuantity) { should == (1024 * @mock_vm.disks[1][:size].to_i).to_s }
|
110
|
+
its(:HostResource) { should == (1024 * @mock_vm.disks[1][:size].to_i).to_s }
|
111
|
+
end
|
95
112
|
end
|
96
113
|
end
|
97
114
|
end
|
@@ -8,7 +8,7 @@ if Fog.mocking?
|
|
8
8
|
|
9
9
|
describe "#get_vdc" do
|
10
10
|
context "with a valid vdc uri" do
|
11
|
-
before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc
|
11
|
+
before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc.href)) }
|
12
12
|
subject { @vdc }
|
13
13
|
|
14
14
|
it_should_behave_like "all responses"
|
@@ -21,11 +21,14 @@ if Fog.mocking?
|
|
21
21
|
|
22
22
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
23
23
|
|
24
|
+
its(:href) { should == @mock_vdc.href }
|
25
|
+
its(:name) { should == @mock_vdc.name }
|
26
|
+
|
24
27
|
its(:Description) { should == "" }
|
25
|
-
its(:StorageCapacity) { should == {:Units => "bytes * 10^9", :Allocated => @mock_vdc
|
28
|
+
its(:StorageCapacity) { should == {:Units => "bytes * 10^9", :Allocated => @mock_vdc.storage_allocated.to_s, :Used => @mock_vdc.storage_used.to_s } }
|
26
29
|
its(:ComputeCapacity) { should == {:InstantiatedVmsQuota => { :Limit => "-1", :Used => "-1" },
|
27
|
-
:Memory => { :Units => "bytes * 2^20", :Allocated => @mock_vdc
|
28
|
-
:Cpu => { :Units => "hz * 10^6", :Allocated => @mock_vdc
|
30
|
+
:Memory => { :Units => "bytes * 2^20", :Allocated => @mock_vdc.memory_allocated.to_s },
|
31
|
+
:Cpu => { :Units => "hz * 10^6", :Allocated => @mock_vdc.cpu_allocated.to_s },
|
29
32
|
:DeployedVmsQuota => { :Limit => "-1", :Used => "-1" } } }
|
30
33
|
|
31
34
|
its(:Link) { should have(4).links }
|
@@ -35,49 +38,49 @@ if Fog.mocking?
|
|
35
38
|
it { should have(4).attributes }
|
36
39
|
its(:type) { should == "application/vnd.vmware.vcloud.catalog+xml" }
|
37
40
|
its(:rel) { should == "down" }
|
38
|
-
its(:href) { should ==
|
39
|
-
its(:name) { should == @mock_vdc
|
41
|
+
its(:href) { should == @mock_vdc.catalog.href }
|
42
|
+
its(:name) { should == @mock_vdc.catalog.name }
|
40
43
|
end
|
41
44
|
describe "link 1" do
|
42
45
|
subject { @vdc.body[:Link][1] }
|
43
46
|
it { should have(4).attributes }
|
44
47
|
its(:type) { should == "application/vnd.tmrk.ecloud.publicIpsList+xml" }
|
45
48
|
its(:rel) { should == "down" }
|
46
|
-
its(:href) { should ==
|
47
|
-
its(:name) { should ==
|
49
|
+
its(:href) { should == @mock_vdc.public_ip_collection.href }
|
50
|
+
its(:name) { should == @mock_vdc.public_ip_collection.name }
|
48
51
|
end
|
49
52
|
describe "link 2" do
|
50
53
|
subject { @vdc.body[:Link][2] }
|
51
54
|
it { should have(4).attributes }
|
52
55
|
its(:type) { should == "application/vnd.tmrk.ecloud.internetServicesList+xml" }
|
53
56
|
its(:rel) { should == "down" }
|
54
|
-
its(:href) { should ==
|
55
|
-
its(:name) { should ==
|
57
|
+
its(:href) { should == @mock_vdc.internet_service_collection.href }
|
58
|
+
its(:name) { should == @mock_vdc.internet_service_collection.name }
|
56
59
|
end
|
57
60
|
describe "link 3" do
|
58
61
|
subject { @vdc.body[:Link][3] }
|
59
62
|
it { should have(4).attributes }
|
60
63
|
its(:type) { should == "application/vnd.tmrk.ecloud.firewallAclsList+xml" }
|
61
64
|
its(:rel) { should == "down" }
|
62
|
-
its(:href) { should ==
|
63
|
-
its(:name) { should ==
|
65
|
+
its(:href) { should == @mock_vdc.firewall_acls.href }
|
66
|
+
its(:name) { should == @mock_vdc.firewall_acls.name }
|
64
67
|
end
|
65
68
|
|
66
69
|
let(:resource_entities) { subject[:ResourceEntities][:ResourceEntity] }
|
67
|
-
specify { resource_entities.should have(@mock_vdc
|
70
|
+
specify { resource_entities.should have(@mock_vdc.virtual_machines.length).vapps }
|
68
71
|
|
69
72
|
describe "[:ResourceEntities][:ResourceEntity]" do
|
70
73
|
context "[0]" do
|
71
74
|
subject { @vdc.body[:ResourceEntities][:ResourceEntity][0] }
|
72
|
-
it { should be_a_vapp_link_to @mock_vdc[
|
75
|
+
it { should be_a_vapp_link_to @mock_vdc.virtual_machines[0] }
|
73
76
|
end
|
74
77
|
context "[1]" do
|
75
78
|
subject { @vdc.body[:ResourceEntities][:ResourceEntity][1] }
|
76
|
-
it { should be_a_vapp_link_to @mock_vdc[
|
79
|
+
it { should be_a_vapp_link_to @mock_vdc.virtual_machines[1] }
|
77
80
|
end
|
78
81
|
context "[2]" do
|
79
82
|
subject { @vdc.body[:ResourceEntities][:ResourceEntity][2] }
|
80
|
-
it { should be_a_vapp_link_to @mock_vdc[
|
83
|
+
it { should be_a_vapp_link_to @mock_vdc.virtual_machines[2] }
|
81
84
|
end
|
82
85
|
end
|
83
86
|
|
@@ -89,11 +92,11 @@ if Fog.mocking?
|
|
89
92
|
describe "[:AvailableNetworks][:Network]" do
|
90
93
|
context "[0]" do
|
91
94
|
subject { @vdc.body[:AvailableNetworks][:Network][0] }
|
92
|
-
it { should be_a_network_link_to @mock_vdc
|
95
|
+
it { should be_a_network_link_to @mock_vdc.networks[0] }
|
93
96
|
end
|
94
97
|
context "[1]" do
|
95
98
|
subject { @vdc.body[:AvailableNetworks][:Network][1] }
|
96
|
-
it { should be_a_network_link_to @mock_vdc
|
99
|
+
it { should be_a_network_link_to @mock_vdc.networks[1] }
|
97
100
|
end
|
98
101
|
end
|
99
102
|
end
|
@@ -8,20 +8,24 @@ if Fog.mocking?
|
|
8
8
|
|
9
9
|
describe "#instantiate_vapp_template" do
|
10
10
|
let(:vdc) { @vcloud.vdcs.first }
|
11
|
+
let(:mock_vdc) { @mock_vdc }
|
12
|
+
|
11
13
|
let(:catalog_item) { vdc.catalog.first }
|
12
|
-
let(:
|
14
|
+
let(:mock_catalog_item) { @vcloud.mock_data.catalog_item_from_href(catalog_item.href) }
|
15
|
+
|
13
16
|
let(:new_vapp_data) do
|
14
17
|
{
|
15
18
|
:name => "foobar",
|
16
|
-
:network_uri => @mock_network
|
19
|
+
:network_uri => @mock_network.href,
|
17
20
|
:row => "test row",
|
18
21
|
:group => "test group",
|
19
22
|
:memory => 1024,
|
20
23
|
:cpus => 2,
|
21
|
-
:vdc_uri =>
|
24
|
+
:vdc_uri => @mock_vdc.href
|
22
25
|
}
|
23
26
|
end
|
24
|
-
|
27
|
+
|
28
|
+
let(:added_mock_data) { mock_vdc.virtual_machines.last }
|
25
29
|
|
26
30
|
context "with a valid data" do
|
27
31
|
let(:template_instantiation) { @vcloud.instantiate_vapp_template(catalog_item.href, new_vapp_data) }
|
@@ -31,25 +35,30 @@ if Fog.mocking?
|
|
31
35
|
it { should have_headers_denoting_a_content_type_of "application/xml" }
|
32
36
|
|
33
37
|
it "updates the mock data properly" do
|
34
|
-
expect {
|
38
|
+
expect { subject }.to change { mock_vdc.virtual_machines.size }.by(1)
|
35
39
|
end
|
36
40
|
|
37
41
|
describe "added mock data" do
|
38
|
-
|
42
|
+
before { template_instantiation }
|
43
|
+
subject { added_mock_data }
|
39
44
|
|
40
|
-
it { should
|
41
|
-
it { should include :href }
|
42
|
-
it { should include :disks }
|
43
|
-
it { should include :ip }
|
44
|
-
its(:status) { should == 2 }
|
45
|
+
it { should be_an_instance_of Fog::Vcloud::MockDataClasses::MockVirtualMachine }
|
45
46
|
|
46
|
-
its(:
|
47
|
-
|
48
|
-
|
47
|
+
its(:name) { should == new_vapp_data[:name] }
|
48
|
+
its(:memory) { should == new_vapp_data[:memory] }
|
49
|
+
its(:cpus) { should == new_vapp_data[:cpus] }
|
50
|
+
# WHAT
|
51
|
+
specify { subject._parent.should == mock_vdc }
|
52
|
+
specify { subject.status.should == 2 }
|
53
|
+
specify { subject.disks.should == mock_catalog_item.disks }
|
54
|
+
# its(:_parent) { should == mock_vdc }
|
55
|
+
#its(:status) { should == 2 }
|
56
|
+
#its(:disks) { should == mock_catalog_item.disks }
|
49
57
|
end
|
50
58
|
|
51
59
|
describe "server based on added mock data" do
|
52
|
-
|
60
|
+
before { template_instantiation }
|
61
|
+
subject { vdc.servers.reload.detect {|s| s.href == added_mock_data.href }.reload }
|
53
62
|
|
54
63
|
its(:name) { should == new_vapp_data[:name] }
|
55
64
|
end
|
@@ -61,7 +70,7 @@ if Fog.mocking?
|
|
61
70
|
|
62
71
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
63
72
|
|
64
|
-
its(:href) { should
|
73
|
+
its(:href) { should == added_mock_data.href }
|
65
74
|
its(:type) { should == "application/vnd.vmware.vcloud.vApp+xml" }
|
66
75
|
its(:name) { should == new_vapp_data[:name] }
|
67
76
|
its(:status) { should == "0" }
|
@@ -76,7 +85,8 @@ if Fog.mocking?
|
|
76
85
|
|
77
86
|
its(:rel) { should == "up" }
|
78
87
|
its(:type) { should == "application/vnd.vmware.vcloud.vdc+xml" }
|
79
|
-
|
88
|
+
# WHAT
|
89
|
+
its(:href) { blah = vdc.href; should == blah }
|
80
90
|
end
|
81
91
|
end
|
82
92
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do
|
5
|
+
subject { @vcloud }
|
6
|
+
|
7
|
+
it { should respond_to :power_off }
|
8
|
+
|
9
|
+
describe :power_off, :type => :vcloud_request do
|
10
|
+
context "with a valid vapp uri" do
|
11
|
+
before { @mock_vm.power_on!; @power_off = @vcloud.power_off(@mock_vm.href(:power_off)) }
|
12
|
+
subject { @power_off }
|
13
|
+
|
14
|
+
it_should_behave_like "all responses"
|
15
|
+
#it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" }
|
16
|
+
|
17
|
+
specify { @mock_vm.status.should == 2 }
|
18
|
+
|
19
|
+
describe :body do
|
20
|
+
subject { @power_off.body }
|
21
|
+
|
22
|
+
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with a vapp uri that doesn't exist" do
|
27
|
+
subject { lambda { @vcloud.power_off(URI.parse('https://www.fakey.com/api/v0.8/vapp/9999')) } }
|
28
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
end
|
34
|
+
|
@@ -8,14 +8,13 @@ if Fog.mocking?
|
|
8
8
|
|
9
9
|
describe :power_on, :type => :vcloud_request do
|
10
10
|
context "with a valid vapp uri" do
|
11
|
-
|
12
|
-
before { vm_data[:status] = 2; @power_on = @vcloud.power_on(@vcloud.vdcs.first.servers.first.href + "/power/action/powerOn") }
|
11
|
+
before { @mock_vm.power_off!; @power_on = @vcloud.power_on(@mock_vm.href(:power_on)) }
|
13
12
|
subject { @power_on }
|
14
13
|
|
15
14
|
it_should_behave_like "all responses"
|
16
15
|
#it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" }
|
17
16
|
|
18
|
-
specify {
|
17
|
+
specify { @mock_vm.status.should == 4 }
|
19
18
|
|
20
19
|
describe :body do
|
21
20
|
subject { @power_on.body }
|
@@ -25,7 +24,7 @@ if Fog.mocking?
|
|
25
24
|
end
|
26
25
|
|
27
26
|
context "with a vapp uri that doesn't exist" do
|
28
|
-
subject { lambda { @vcloud.
|
27
|
+
subject { lambda { @vcloud.power_on(URI.parse('https://www.fakey.com/api/v0.8/vapp/9999')) } }
|
29
28
|
it_should_behave_like "a request for a resource that doesn't exist"
|
30
29
|
end
|
31
30
|
end
|
data/spec/vcloud/vcloud_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require 'spec/vcloud/spec_helper.rb'
|
2
2
|
|
3
3
|
if Fog.mocking?
|
4
4
|
describe Fog::Vcloud, :type => :mock_vcloud_request do
|
@@ -12,7 +12,7 @@ if Fog.mocking?
|
|
12
12
|
|
13
13
|
it { should have_at_least(1).supported_versions }
|
14
14
|
|
15
|
-
its(:default_organization_uri) { should == @mock_organization
|
15
|
+
its(:default_organization_uri) { should == @mock_organization.href }
|
16
16
|
|
17
17
|
end
|
18
18
|
end
|
@@ -16,6 +16,14 @@ def directory_tests(connection, mocks_implemented = true)
|
|
16
16
|
@directory.destroy
|
17
17
|
end
|
18
18
|
|
19
|
+
tests("#public=(true)").succeeds do
|
20
|
+
@directory.public=(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
tests("#respond_to?(:public_url)").succeeds do
|
24
|
+
@directory.respond_to?(:public_url)
|
25
|
+
end
|
26
|
+
|
19
27
|
end
|
20
28
|
|
21
29
|
tests('failure') do
|