fog 0.3.8 → 0.3.9
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 +0 -6
- data/fog.gemspec +4 -2
- data/lib/fog.rb +1 -1
- data/lib/fog/aws.rb +2 -2
- data/lib/fog/rackspace/models/storage/directories.rb +7 -2
- data/lib/fog/rackspace/models/storage/directory.rb +2 -2
- data/lib/fog/rackspace/models/storage/file.rb +5 -5
- data/lib/fog/vcloud.rb +33 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +19 -23
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +68 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +11 -3
- data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +11 -2
- data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +109 -0
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +14 -1
- data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +35 -0
- metadata +5 -3
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -2,12 +2,6 @@ http://geemus.com/fog.png
|
|
2
2
|
|
3
3
|
fog is the Ruby cloud computing library.
|
4
4
|
|
5
|
-
################################################################################
|
6
|
-
|
7
|
-
Thursday, October 14, 2010 10:00 am PST, hear it straight from {geemus}[http://github.com/geemus] in the {fog webinar}[http://pages.engineyard.com/FogWebinar.html]
|
8
|
-
|
9
|
-
################################################################################
|
10
|
-
|
11
5
|
The quick and dirty, top to bottom:
|
12
6
|
* Collections provide a simplified interface, making clouds easier to work with and switch between.
|
13
7
|
* Requests allow power users to get the most out of the features of each individual cloud.
|
data/fog.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.3.
|
11
|
-
s.date = '2010-10-
|
10
|
+
s.version = '0.3.9'
|
11
|
+
s.date = '2010-10-18'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -650,9 +650,11 @@ Gem::Specification.new do |s|
|
|
650
650
|
spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb
|
651
651
|
spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb
|
652
652
|
spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb
|
653
|
+
spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb
|
653
654
|
spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
|
654
655
|
spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb
|
655
656
|
spec/vcloud/terremark/ecloud/requests/login_spec.rb
|
657
|
+
spec/vcloud/terremark/ecloud/requests/power_on_spec.rb
|
656
658
|
spec/vcloud/vcloud_spec.rb
|
657
659
|
tests/aws/helper.rb
|
658
660
|
tests/aws/models/storage/directory_tests.rb
|
data/lib/fog.rb
CHANGED
data/lib/fog/aws.rb
CHANGED
@@ -170,7 +170,7 @@ module Fog
|
|
170
170
|
end
|
171
171
|
|
172
172
|
private
|
173
|
-
|
173
|
+
|
174
174
|
def self.random_selection(characters, length)
|
175
175
|
selection = ''
|
176
176
|
length.times do
|
@@ -194,7 +194,7 @@ module Fog
|
|
194
194
|
|
195
195
|
def self.hex(length)
|
196
196
|
max = ('f' * length).to_i(16)
|
197
|
-
rand(max).to_s(16)
|
197
|
+
rand(max).to_s(16).rjust(length, '0')
|
198
198
|
end
|
199
199
|
|
200
200
|
def self.base64(length)
|
@@ -15,11 +15,16 @@ module Fog
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def get(key, options = {})
|
18
|
-
data = connection.get_container(key, options)
|
18
|
+
data = connection.get_container(key, options)
|
19
19
|
directory = new(:key => key)
|
20
|
+
for key, value in data.headers
|
21
|
+
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
|
22
|
+
directory.merge_attributes(key => value)
|
23
|
+
end
|
24
|
+
end
|
20
25
|
directory.files.merge_attributes(options)
|
21
26
|
directory.files.instance_variable_set(:@loaded, true)
|
22
|
-
data.each do |file|
|
27
|
+
data.body.each do |file|
|
23
28
|
directory.files << directory.files.new(file)
|
24
29
|
end
|
25
30
|
directory
|
@@ -6,13 +6,13 @@ module Fog
|
|
6
6
|
|
7
7
|
class File < Fog::Model
|
8
8
|
|
9
|
-
identity :key, :aliases => '
|
9
|
+
identity :key, :aliases => 'name'
|
10
10
|
|
11
11
|
attr_writer :body
|
12
|
-
attribute :content_length, :aliases => 'Content-Length'
|
13
|
-
attribute :content_type, :aliases => 'Content-Type'
|
14
|
-
attribute :etag, :aliases => 'Etag'
|
15
|
-
attribute :last_modified, :aliases => 'Last-Modified'
|
12
|
+
attribute :content_length, :aliases => ['bytes', 'Content-Length']
|
13
|
+
attribute :content_type, :aliases => ['content_type', 'Content-Type']
|
14
|
+
attribute :etag, :aliases => ['hash', 'Etag']
|
15
|
+
attribute :last_modified, :aliases => ['last_modified', 'Last-Modified']
|
16
16
|
|
17
17
|
def body
|
18
18
|
@body ||= if last_modified
|
data/lib/fog/vcloud.rb
CHANGED
@@ -296,7 +296,7 @@ module Fog
|
|
296
296
|
:catalog => {
|
297
297
|
:name => "The catalog",
|
298
298
|
:items => [
|
299
|
-
{ :id => "0", :name => "Item 0" },
|
299
|
+
{ :id => "0", :name => "Item 0", :disks => [{ :size => 25 }] },
|
300
300
|
{ :id => "1", :name => "Item 1" },
|
301
301
|
{ :id => "2", :name => "Item 2" },
|
302
302
|
]
|
@@ -328,13 +328,19 @@ module Fog
|
|
328
328
|
},
|
329
329
|
],
|
330
330
|
:vms => [
|
331
|
-
{ :href => "#{base_url}/
|
332
|
-
:name => "Broom 1"
|
331
|
+
{ :href => "#{base_url}/vapp/41",
|
332
|
+
:name => "Broom 1",
|
333
|
+
:ip => "1.2.3.3",
|
334
|
+
:memory => 1024,
|
335
|
+
:cpus => 1,
|
336
|
+
:disks => [{ :size => 25 }],
|
337
|
+
:status => 2
|
333
338
|
},
|
334
|
-
{ :href => "#{base_url}/
|
335
|
-
:name => "Broom 2"
|
339
|
+
{ :href => "#{base_url}/vapp/42",
|
340
|
+
:name => "Broom 2",
|
341
|
+
:ip => "1.2.3.4"
|
336
342
|
},
|
337
|
-
{ :href => "#{base_url}/
|
343
|
+
{ :href => "#{base_url}/vapp/43",
|
338
344
|
:name => "Email!"
|
339
345
|
}
|
340
346
|
]
|
@@ -360,7 +366,7 @@ module Fog
|
|
360
366
|
}
|
361
367
|
],
|
362
368
|
:vms => [
|
363
|
-
{ :href => "#{base_url}/
|
369
|
+
{ :href => "#{base_url}/vapp/44",
|
364
370
|
:name => "Master Blaster"
|
365
371
|
}
|
366
372
|
]
|
@@ -387,6 +393,26 @@ module Fog
|
|
387
393
|
end
|
388
394
|
end
|
389
395
|
|
396
|
+
def vapp_and_vdc_from_vapp_uri(uri)
|
397
|
+
if vdc = mock_data[:organizations].map {|o| o[:vdcs] }.flatten.detect {|vd| vd[:vms].detect {|vm| uri =~ %r{^#{Regexp.escape(vm[:href])}($|/)} } }
|
398
|
+
vapp = vdc[:vms].detect {|v| uri =~ %r{^#{Regexp.escape(v[:href])}($|/)} }
|
399
|
+
if vapp
|
400
|
+
[vapp, vdc]
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
def catalog_item_and_vdc_from_catalog_item_uri(uri)
|
406
|
+
catalog_item_id, vdc_id = uri.split("/").last.split("-")
|
407
|
+
vdc = vdc_from_id(vdc_id)
|
408
|
+
if vdc
|
409
|
+
catalog_item = vdc[:catalog][:items].detect {|ci| ci[:id] == catalog_item_id }
|
410
|
+
if catalog_item
|
411
|
+
[catalog_item, vdc]
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
390
416
|
def initialize(options = {})
|
391
417
|
@versions_uri = URI.parse('https://vcloud.fakey.com/api/versions')
|
392
418
|
end
|
@@ -15,29 +15,25 @@ module Fog
|
|
15
15
|
#
|
16
16
|
|
17
17
|
def get_catalog_item(catalog_item_uri)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
builder
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
)
|
38
|
-
|
39
|
-
builder.Property(0, :key => "LicensingCost")
|
40
|
-
end
|
18
|
+
if catalog_item_and_vdc = catalog_item_and_vdc_from_catalog_item_uri(catalog_item_uri)
|
19
|
+
catalog_item, vdc = catalog_item_and_vdc
|
20
|
+
builder = Builder::XmlMarkup.new
|
21
|
+
|
22
|
+
xml = builder.CatalogItem(xmlns.merge(:href => catalog_item_uri, :name => catalog_item[:name])) do
|
23
|
+
builder.Link(
|
24
|
+
:rel => "down",
|
25
|
+
:href => Fog::Vcloud::Terremark::Ecloud::Mock.catalog_item_customization_href(:id => catalog_item[:id]),
|
26
|
+
:type => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml",
|
27
|
+
:name => "Customization Options"
|
28
|
+
)
|
29
|
+
|
30
|
+
builder.Entity(
|
31
|
+
:href => Fog::Vcloud::Terremark::Ecloud::Mock.vapp_template_href(:id => catalog_item[:id]),
|
32
|
+
:type => "application/vnd.vmware.vcloud.vAppTemplate+xml",
|
33
|
+
:name => catalog_item[:name]
|
34
|
+
)
|
35
|
+
|
36
|
+
builder.Property(0, :key => "LicensingCost")
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
@@ -9,7 +9,74 @@ module Fog
|
|
9
9
|
|
10
10
|
class Mock
|
11
11
|
def get_vapp(vapp_uri)
|
12
|
-
|
12
|
+
xml = nil
|
13
|
+
|
14
|
+
if vapp_and_vdc = vapp_and_vdc_from_vapp_uri(vapp_uri)
|
15
|
+
xml = generate_get_vapp_response(*vapp_and_vdc)
|
16
|
+
end
|
17
|
+
|
18
|
+
if xml
|
19
|
+
mock_it 200, xml, "Content-Type" => "application/vnd.vmware.vcloud.vApp+xml"
|
20
|
+
else
|
21
|
+
mock_error 200, "401 Unauthorized"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def generate_get_vapp_response(vapp, vdc)
|
28
|
+
builder = Builder::XmlMarkup.new
|
29
|
+
builder.VApp(xmlns.merge(
|
30
|
+
:href => vapp[:href],
|
31
|
+
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
32
|
+
:name => vapp[:name],
|
33
|
+
:status => vapp[:status] || 4
|
34
|
+
)) do
|
35
|
+
builder.Link(:rel => "up", :href => vdc[:href], :type => "application/vnd.vmware.vcloud.vdc+xml")
|
36
|
+
|
37
|
+
builder.NetworkConnectionSection(:xmlns => "http://schemas.dmtf.org/ovf/envelope/1") do
|
38
|
+
builder.NetworkConnection(:Network => "Internal", :xmlns => "http://www.vmware.com/vcloud/v0.8") do
|
39
|
+
builder.IpAddress vapp[:ip]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
builder.OperatingSystemSection(
|
44
|
+
"d2p1:id" => 4,
|
45
|
+
:xmlns => "http://schemas.dmtf.org/ovf/envelope/1",
|
46
|
+
"xmlns:d2p1" => "http://schemas.dmtf.org/ovf/envelope/1") do
|
47
|
+
builder.Info "The kind of installed guest operating system"
|
48
|
+
builder.Description "Red Hat Enterprise Linux 5 (64-bit)"
|
49
|
+
end
|
50
|
+
|
51
|
+
builder.VirtualHardwareSection(:xmlns => "http://schemas.dmtf.org/ovf/envelope/1") do
|
52
|
+
builder.Info
|
53
|
+
builder.System
|
54
|
+
builder.Item do
|
55
|
+
# CPUs
|
56
|
+
builder.VirtualQuantity vapp[:cpus] || 1
|
57
|
+
builder.ResourceType 3
|
58
|
+
end
|
59
|
+
builder.Item do
|
60
|
+
# memory
|
61
|
+
builder.VirtualQuantity vapp[:memory] || 1024
|
62
|
+
builder.ResourceType 4
|
63
|
+
end
|
64
|
+
builder.Item do
|
65
|
+
# SCSI controller
|
66
|
+
builder.Address 0
|
67
|
+
builder.ResourceType 6
|
68
|
+
builder.InstanceId 3
|
69
|
+
end
|
70
|
+
builder.Item do
|
71
|
+
# Hard Disk 1
|
72
|
+
builder.Parent 3
|
73
|
+
builder.VirtualQuantity vapp[:disks].first[:size] * 1024 # MB
|
74
|
+
builder.HostResource vapp[:disks].first[:size] * 1024 # MB
|
75
|
+
builder.ResourceType 17
|
76
|
+
builder.AddressOnParent 0
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
13
80
|
end
|
14
81
|
end
|
15
82
|
end
|
@@ -103,12 +103,13 @@ module Fog
|
|
103
103
|
|
104
104
|
def instantiate_vapp_template(catalog_item_uri, options = {})
|
105
105
|
validate_instantiate_vapp_template_options(catalog_item_uri, options)
|
106
|
+
catalog_item, _ = catalog_item_and_vdc_from_catalog_item_uri(catalog_item_uri)
|
106
107
|
|
107
108
|
xml = nil
|
108
109
|
if vdc = vdc_from_uri(options[:vdc_uri])
|
109
|
-
|
110
|
-
vapp_uri = Fog::Vcloud::Terremark::Ecloud::Mock.vapp_href(:id =>
|
111
|
-
options.update(:id =>
|
110
|
+
vapp_id = rand(1000)
|
111
|
+
vapp_uri = Fog::Vcloud::Terremark::Ecloud::Mock.vapp_href(:id => vapp_id)
|
112
|
+
options.update(:id => vapp_id.to_s, :href => vapp_uri, :disks => catalog_item[:disks], :ip => random_ip_in_network(options[:network_uri]), :status => 2)
|
112
113
|
vdc[:vms] << options
|
113
114
|
|
114
115
|
xml = generate_instantiate_vapp_template_response(vdc[:href], options[:name], vapp_uri)
|
@@ -123,6 +124,13 @@ module Fog
|
|
123
124
|
|
124
125
|
private
|
125
126
|
|
127
|
+
def random_ip_in_network(network_uri)
|
128
|
+
network = mock_data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:href] == network_uri }
|
129
|
+
subnet_ipaddr = IPAddr.new(network[:subnet])
|
130
|
+
ips = subnet_ipaddr.to_range.to_a[3..-2]
|
131
|
+
ips[rand(ips.size)].to_s
|
132
|
+
end
|
133
|
+
|
126
134
|
def generate_instantiate_vapp_template_response(vdc_uri, vapp_name, vapp_uri)
|
127
135
|
builder = Builder::XmlMarkup.new
|
128
136
|
builder.VApp(xmlns.merge(
|
@@ -8,8 +8,17 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Mock
|
11
|
-
def power_on(
|
12
|
-
|
11
|
+
def power_on(vapp_uri)
|
12
|
+
vapp, vdc = vapp_and_vdc_from_vapp_uri(vapp_uri)
|
13
|
+
|
14
|
+
if vapp
|
15
|
+
vapp[:status] = 4
|
16
|
+
|
17
|
+
builder = Builder::XmlMarkup.new
|
18
|
+
mock_it 200, builder.Task(xmlns)
|
19
|
+
else
|
20
|
+
mock_error 200, "401 Unauthorized"
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
@@ -0,0 +1,109 @@
|
|
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_vapp }
|
8
|
+
|
9
|
+
describe "#get_vapp" do
|
10
|
+
context "with a valid vapp_uri" do
|
11
|
+
before { @vapp = @vcloud.get_vapp(vm_data[:href]) }
|
12
|
+
subject { @vapp }
|
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
|
+
|
17
|
+
it_should_behave_like "all responses"
|
18
|
+
it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.vApp+xml" }
|
19
|
+
|
20
|
+
describe "#body" do
|
21
|
+
subject { @vapp.body }
|
22
|
+
|
23
|
+
specify { subject.keys.sort_by(&:to_s).should == [:Link, :NetworkConnectionSection, :OperatingSystemSection, :VirtualHardwareSection, :href, :name, :status, :type, :xmlns, :xmlns_xsd, :xmlns_xsi] }
|
24
|
+
|
25
|
+
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
26
|
+
|
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 }
|
31
|
+
|
32
|
+
describe "Link" do
|
33
|
+
subject { @vapp.body[:Link] }
|
34
|
+
|
35
|
+
its(:rel) { should == "up" }
|
36
|
+
its(:type) { should == "application/vnd.vmware.vcloud.vdc+xml" }
|
37
|
+
its(:href) { should == vdc.href }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "NetworkConnectionSection" do
|
41
|
+
subject { @vapp.body[:NetworkConnectionSection] }
|
42
|
+
|
43
|
+
it { should include :NetworkConnection }
|
44
|
+
|
45
|
+
describe "NetworkConnection" do
|
46
|
+
subject { @vapp.body[:NetworkConnectionSection][:NetworkConnection] }
|
47
|
+
|
48
|
+
its(:IpAddress) { should == vm_data[:ip] }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "OperatingSystemSection" do
|
53
|
+
subject { @vapp.body[:OperatingSystemSection] }
|
54
|
+
|
55
|
+
its(:Info) { should == "The kind of installed guest operating system" }
|
56
|
+
its(:Description) { should == "Red Hat Enterprise Linux 5 (64-bit)" }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "VirtualHardwareSection" do
|
60
|
+
subject { @vapp.body[:VirtualHardwareSection] }
|
61
|
+
|
62
|
+
specify { subject.keys.sort_by(&:to_s).should == [:Info, :Item, :System, :xmlns] }
|
63
|
+
|
64
|
+
describe "Item" do
|
65
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item] }
|
66
|
+
|
67
|
+
it { should have(4).items }
|
68
|
+
|
69
|
+
specify { subject.map {|i| i[:ResourceType] }.sort.should == %w(3 4 6 17).sort }
|
70
|
+
|
71
|
+
describe "CPU" do
|
72
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "3" } }
|
73
|
+
|
74
|
+
its(:VirtualQuantity) { should == vm_data[:cpus].to_s }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "memory" do
|
78
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "4" } }
|
79
|
+
|
80
|
+
its(:VirtualQuantity) { should == vm_data[:memory].to_s }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "SCSI controller" do
|
84
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "6" } }
|
85
|
+
|
86
|
+
its(:Address) { should == "0" }
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "Hard Disk 1" do
|
90
|
+
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "17" } }
|
91
|
+
|
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
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "with a vapp uri that doesn't exist" do
|
102
|
+
subject { lambda { @vcloud.get_vapp(URI.parse('https://www.fakey.com/api/v0.8/vApp/99999')) } }
|
103
|
+
|
104
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
else
|
109
|
+
end
|
@@ -9,6 +9,7 @@ if Fog.mocking?
|
|
9
9
|
describe "#instantiate_vapp_template" do
|
10
10
|
let(:vdc) { @vcloud.vdcs.first }
|
11
11
|
let(:catalog_item) { vdc.catalog.first }
|
12
|
+
let(:catalog_item_data) { @vcloud.catalog_item_and_vdc_from_catalog_item_uri(catalog_item.href).first }
|
12
13
|
let(:new_vapp_data) do
|
13
14
|
{
|
14
15
|
:name => "foobar",
|
@@ -20,6 +21,7 @@ if Fog.mocking?
|
|
20
21
|
:vdc_uri => vdc.href
|
21
22
|
}
|
22
23
|
end
|
24
|
+
let(:added_mock_data) { @vcloud.vdc_from_uri(vdc.href)[:vms].last }
|
23
25
|
|
24
26
|
context "with a valid data" do
|
25
27
|
let(:template_instantiation) { @vcloud.instantiate_vapp_template(catalog_item.href, new_vapp_data) }
|
@@ -33,14 +35,25 @@ if Fog.mocking?
|
|
33
35
|
end
|
34
36
|
|
35
37
|
describe "added mock data" do
|
36
|
-
subject { template_instantiation;
|
38
|
+
subject { template_instantiation; added_mock_data }
|
37
39
|
|
38
40
|
it { should include :id }
|
39
41
|
it { should include :href }
|
42
|
+
it { should include :disks }
|
43
|
+
it { should include :ip }
|
44
|
+
its(:status) { should == 2 }
|
45
|
+
|
46
|
+
its(:disks) { should == catalog_item_data[:disks] }
|
40
47
|
|
41
48
|
specify { subject.values_at(*new_vapp_data.keys).should == new_vapp_data.values }
|
42
49
|
end
|
43
50
|
|
51
|
+
describe "server based on added mock data" do
|
52
|
+
subject { template_instantiation; vdc.servers.reload.detect {|s| s.href == added_mock_data[:href] }.reload }
|
53
|
+
|
54
|
+
its(:name) { should == new_vapp_data[:name] }
|
55
|
+
end
|
56
|
+
|
44
57
|
describe "#body" do
|
45
58
|
subject { template_instantiation.body }
|
46
59
|
|
@@ -0,0 +1,35 @@
|
|
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_on }
|
8
|
+
|
9
|
+
describe :power_on, :type => :vcloud_request do
|
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") }
|
13
|
+
subject { @power_on }
|
14
|
+
|
15
|
+
it_should_behave_like "all responses"
|
16
|
+
#it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" }
|
17
|
+
|
18
|
+
specify { vm_data[:status].should == 4 }
|
19
|
+
|
20
|
+
describe :body do
|
21
|
+
subject { @power_on.body }
|
22
|
+
|
23
|
+
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
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')) } }
|
29
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
else
|
34
|
+
end
|
35
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 9
|
9
|
+
version: 0.3.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-18 00:00:00 -07:00
|
18
18
|
default_executable: fog
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -757,9 +757,11 @@ files:
|
|
757
757
|
- spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb
|
758
758
|
- spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb
|
759
759
|
- spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb
|
760
|
+
- spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb
|
760
761
|
- spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
|
761
762
|
- spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb
|
762
763
|
- spec/vcloud/terremark/ecloud/requests/login_spec.rb
|
764
|
+
- spec/vcloud/terremark/ecloud/requests/power_on_spec.rb
|
763
765
|
- spec/vcloud/vcloud_spec.rb
|
764
766
|
- tests/aws/helper.rb
|
765
767
|
- tests/aws/models/storage/directory_tests.rb
|