fog 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/Gemfile.lock +1 -1
  2. data/README.rdoc +17 -12
  3. data/fog.gemspec +10 -5
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/models/storage/directory.rb +22 -0
  6. data/lib/fog/aws/models/storage/file.rb +15 -0
  7. data/lib/fog/aws/storage.rb +8 -0
  8. data/lib/fog/core/collection.rb +9 -8
  9. data/lib/fog/core/compute.rb +1 -1
  10. data/lib/fog/google/models/storage/directory.rb +23 -1
  11. data/lib/fog/google/models/storage/file.rb +16 -1
  12. data/lib/fog/google/parsers/storage/access_control_list.rb +16 -14
  13. data/lib/fog/local/models/storage/directory.rb +8 -0
  14. data/lib/fog/local/models/storage/file.rb +4 -0
  15. data/lib/fog/rackspace/cdn.rb +3 -3
  16. data/lib/fog/rackspace/models/storage/directory.rb +18 -0
  17. data/lib/fog/rackspace/models/storage/file.rb +7 -0
  18. data/lib/fog/rackspace/requests/cdn/{get_cdn_containers.rb → get_containers.rb} +3 -3
  19. data/lib/fog/rackspace/requests/cdn/{head_cdn_container.rb → head_container.rb} +3 -3
  20. data/lib/fog/rackspace/requests/cdn/{put_cdn_container.rb → put_container.rb} +3 -3
  21. data/lib/fog/rackspace/storage.rb +10 -0
  22. data/lib/fog/vcloud.rb +32 -153
  23. data/lib/fog/vcloud/collection.rb +18 -0
  24. data/lib/fog/vcloud/mock_data_classes.rb +701 -0
  25. data/lib/fog/vcloud/requests/get_network.rb +8 -8
  26. data/lib/fog/vcloud/requests/get_organization.rb +10 -10
  27. data/lib/fog/vcloud/requests/get_vdc.rb +18 -18
  28. data/lib/fog/vcloud/requests/get_versions.rb +3 -3
  29. data/lib/fog/vcloud/requests/login.rb +2 -2
  30. data/lib/fog/vcloud/terremark/ecloud.rb +65 -109
  31. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +1 -0
  32. data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -0
  33. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -0
  34. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
  35. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -0
  36. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +3 -2
  37. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -0
  38. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -0
  39. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -0
  40. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +20 -8
  41. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -0
  42. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -0
  43. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
  44. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +4 -8
  45. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +4 -7
  46. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +18 -20
  47. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +6 -7
  48. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +40 -9
  49. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +2 -10
  50. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +2 -6
  51. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +13 -1
  52. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +6 -6
  53. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +6 -7
  54. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -33
  55. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +23 -24
  56. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +10 -13
  57. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -19
  58. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +20 -22
  59. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +12 -15
  60. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +11 -12
  61. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -4
  62. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +9 -8
  63. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +33 -17
  64. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +54 -53
  65. data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +13 -19
  66. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +9 -2
  67. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +2 -4
  68. data/spec/vcloud/bin_spec.rb +3 -6
  69. data/spec/vcloud/models/vdc_spec.rb +8 -8
  70. data/spec/vcloud/requests/get_network_spec.rb +8 -8
  71. data/spec/vcloud/requests/get_organization_spec.rb +9 -9
  72. data/spec/vcloud/requests/get_vdc_spec.rb +7 -7
  73. data/spec/vcloud/requests/get_versions_spec.rb +1 -1
  74. data/spec/vcloud/requests/login_spec.rb +2 -2
  75. data/spec/vcloud/spec_helper.rb +45 -30
  76. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +10 -14
  77. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +5 -8
  78. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +2 -2
  79. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +15 -16
  80. data/spec/vcloud/terremark/ecloud/models/node_spec.rb +7 -7
  81. data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +1 -1
  82. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +4 -8
  83. data/spec/vcloud/terremark/ecloud/models/server_spec.rb +42 -0
  84. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +7 -7
  85. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +1 -1
  86. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +13 -18
  87. data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +9 -5
  88. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +5 -7
  89. data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +22 -28
  90. data/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +71 -0
  91. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +7 -9
  92. data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +3 -7
  93. data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +83 -0
  94. data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +6 -5
  95. data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +2 -2
  96. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +31 -42
  97. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +4 -7
  98. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +1 -1
  99. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +19 -11
  100. data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +8 -8
  101. data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +11 -11
  102. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +4 -5
  103. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +6 -6
  104. data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +36 -19
  105. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +21 -18
  106. data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +27 -17
  107. data/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +34 -0
  108. data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +3 -4
  109. data/spec/vcloud/vcloud_spec.rb +2 -2
  110. data/tests/helpers/storage/directory_tests.rb +8 -0
  111. data/tests/helpers/storage/file_tests.rb +4 -0
  112. 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
- @mock_ip = @mock_vdc[:public_ips].first
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 == @mock_ip[:name] }
25
- its(:Href) { should == @mock_ip[:href] }
26
- its(:Id) { should == @mock_ip[:id] }
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(URI.parse(@mock_vdc[:href] + "/publicIps")) }
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(@mock_vdc[:public_ips].length).addresses }
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) { @mock_vdc[:public_ips][idx] }
32
- its(:Href) { should == public_ip[:href] }
33
- its(:Id) { should == public_ip[:id] }
34
- its(:Name) { should == public_ip[:name] }
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(vm_data[:href]) }
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, :NetworkConnectionSection, :OperatingSystemSection, :VirtualHardwareSection, :href, :name, :status, :type, :xmlns, :xmlns_xsd, :xmlns_xsi] }
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) { should == vm_data[:href] }
28
- its(:name) { should == vm_data[:name] }
29
- its(:status) { should == vm_data[:status].to_s }
30
- its(:size) { (vm_data[:disks].inject(0) {|s, d| s += d[:size] } * 1024).to_s }
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 == vdc.href }
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 == vm_data[:ip] }
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(4).items }
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 == vm_data[:cpus].to_s }
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 == vm_data[:memory].to_s }
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 Disk 1" do
90
- subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "17" } }
92
+ describe "Hard Disks" do
93
+ subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" } }
91
94
 
92
- its(:AddressOnParent) { should == "0" }
93
- its(:VirtualQuantity) { should == (vm_data[:disks].first[:size] * 1024).to_s }
94
- its(:HostResource) { should == (vm_data[:disks].first[:size] * 1024).to_s }
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[:href])) }
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[:storage][:allocated], :Used => @mock_vdc[:storage][:used] } }
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[:memory][:allocated] },
28
- :Cpu => { :Units => "hz * 10^6", :Allocated => @mock_vdc[:cpu][:allocated] },
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 == "#{@mock_vdc[:href]}/catalog" }
39
- its(:name) { should == @mock_vdc[:name] }
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 == "#{@mock_vdc[:extension_href]}/publicIps"}
47
- its(:name) { should == "Public IPs" }
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 == "#{@mock_vdc[:extension_href]}/internetServices"}
55
- its(:name) { should == "Internet Services" }
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 == "#{@mock_vdc[:extension_href]}/firewallAcls"}
63
- its(:name) { should == "Firewall Access List" }
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[:vms].length).vapps }
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[:vms][0] }
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[:vms][1] }
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[:vms][2] }
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[:networks][0] }
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[:networks][1] }
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(:catalog_item_data) { @vcloud.catalog_item_and_vdc_from_catalog_item_uri(catalog_item.href).first }
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[:href],
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 => vdc.href
24
+ :vdc_uri => @mock_vdc.href
22
25
  }
23
26
  end
24
- let(:added_mock_data) { @vcloud.vdc_from_uri(vdc.href)[:vms].last }
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 { template_instantiation }.to change { @vcloud.vdc_from_uri(vdc.href)[:vms].count }.by(1)
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
- subject { template_instantiation; added_mock_data }
42
+ before { template_instantiation }
43
+ subject { added_mock_data }
39
44
 
40
- it { should include :id }
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(:disks) { should == catalog_item_data[:disks] }
47
-
48
- specify { subject.values_at(*new_vapp_data.keys).should == new_vapp_data.values }
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
- subject { template_instantiation; vdc.servers.reload.detect {|s| s.href == added_mock_data[:href] }.reload }
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 =~ %r{/vapp/\d+$} }
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
- its(:href) { should == vdc.href }
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
- let(:vm_data) { @vcloud.mock_data[:organizations].first[:vdcs].first[:vms].first }
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 { vm_data[:status].should == 4 }
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.get_network(URI.parse('https://www.fakey.com/api/v0.8/vapp/9999')) } }
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
@@ -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[:info][:href] }
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
@@ -20,6 +20,10 @@ def file_tests(connection, mocks_implemented = true)
20
20
  @file.destroy
21
21
  end
22
22
 
23
+ tests("#respond_to?(:public_url)").succeeds do
24
+ @directory.respond_to?(:public_url)
25
+ end
26
+
23
27
  end
24
28
 
25
29
  tests('failure') do