fog 0.5.2 → 0.5.3
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.lock +3 -3
- data/fog.gemspec +2 -2
- data/lib/fog.rb +1 -1
- data/lib/fog/cdn/aws.rb +4 -1
- data/lib/fog/compute/parsers/terremark_ecloud/get_ip_address.rb +23 -0
- data/lib/fog/compute/parsers/terremark_ecloud/get_task.rb +42 -0
- data/lib/fog/compute/parsers/terremark_ecloud/get_task_list.rb +51 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_ip_address.rb +19 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_task.rb +19 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_task_list.rb +19 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_versions.rb +4 -2
- data/lib/fog/compute/requests/terremark_ecloud/login.rb +29 -0
- data/lib/fog/compute/terremark_ecloud.rb +18 -34
- data/lib/fog/core/attributes.rb +1 -1
- data/lib/fog/core/collection.rb +1 -0
- data/lib/fog/core/credentials.rb +1 -1
- data/lib/fog/core/model.rb +1 -0
- data/lib/fog/dns/aws.rb +4 -1
- data/lib/fog/storage/aws.rb +4 -3
- data/lib/fog/storage/google.rb +4 -1
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +23 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +47 -35
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +5 -0
- data/spec/vcloud/models/vdc_spec.rb +7 -8
- data/spec/vcloud/requests/get_network_spec.rb +10 -10
- data/spec/vcloud/requests/get_organization_spec.rb +7 -8
- data/spec/vcloud/requests/get_vdc_spec.rb +4 -5
- data/spec/vcloud/requests/get_versions_spec.rb +2 -2
- data/spec/vcloud/spec_helper.rb +36 -32
- data/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +3 -4
- data/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +4 -5
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +26 -3
- data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +4 -4
- data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/node_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +3 -4
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/server_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +5 -5
- data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +4 -4
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +7 -8
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +13 -13
- data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +3 -4
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +5 -6
- data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +9 -10
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +5 -6
- data/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +1 -1
- data/spec/vcloud/vcloud_spec.rb +3 -3
- data/tests/compute/requests/terremark_ecloud/organization_tests.rb +5 -0
- data/tests/compute/requests/terremark_ecloud/task_tests.rb +39 -0
- data/tests/helpers/formats_helper.rb +5 -3
- metadata +47 -38
data/lib/fog/storage/google.rb
CHANGED
|
@@ -202,7 +202,10 @@ module Fog
|
|
|
202
202
|
@host = options[:host] || 'commondatastorage.googleapis.com'
|
|
203
203
|
@port = options[:port] || 443
|
|
204
204
|
@scheme = options[:scheme] || 'https'
|
|
205
|
-
|
|
205
|
+
unless options.has_key?(:persistent)
|
|
206
|
+
options[:persistent] = true
|
|
207
|
+
end
|
|
208
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
|
206
209
|
end
|
|
207
210
|
|
|
208
211
|
def reload
|
|
@@ -35,6 +35,22 @@ module Fog
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
# disables monitoring for this service
|
|
39
|
+
def disable_monitor
|
|
40
|
+
if self.monitor and self.monitor[:type] == "Disabled"
|
|
41
|
+
raise RuntimeError.new("Monitoring already disabled")
|
|
42
|
+
else
|
|
43
|
+
self.monitor = {:type => "Disabled", :is_enabled => "true"}
|
|
44
|
+
self.save
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# enable default ping monitoring, use monitor= for more exotic forms (ECV & HTTP)
|
|
49
|
+
def enable_ping_monitor
|
|
50
|
+
self.monitor = nil
|
|
51
|
+
self.save
|
|
52
|
+
end
|
|
53
|
+
|
|
38
54
|
def monitor=(new_monitor = {})
|
|
39
55
|
if new_monitor.nil? || new_monitor.empty?
|
|
40
56
|
attributes[:monitor] = nil
|
|
@@ -43,7 +59,13 @@ module Fog
|
|
|
43
59
|
attributes[:monitor][:type] = new_monitor[:MonitorType] || new_monitor[:type]
|
|
44
60
|
attributes[:monitor][:url_send_string] = new_monitor[:UrlSendString] || new_monitor[:url_send_string]
|
|
45
61
|
attributes[:monitor][:http_headers] = new_monitor[:HttpHeader] || new_monitor[:http_headers]
|
|
46
|
-
|
|
62
|
+
if attributes[:monitor][:http_headers]
|
|
63
|
+
if attributes[:monitor][:http_headers].is_a?(String)
|
|
64
|
+
attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers].split("\n")
|
|
65
|
+
else
|
|
66
|
+
attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers]
|
|
67
|
+
end
|
|
68
|
+
end
|
|
47
69
|
attributes[:monitor][:receive_string] = new_monitor[:ReceiveString] || new_monitor[:receive_string]
|
|
48
70
|
attributes[:monitor][:interval] = new_monitor[:Interval] || new_monitor[:interval]
|
|
49
71
|
attributes[:monitor][:response_timeout] = new_monitor[:ResponseTimeOut] || new_monitor[:response_timeout]
|
|
@@ -5,18 +5,26 @@ module Fog
|
|
|
5
5
|
module Shared
|
|
6
6
|
def validate_internet_service_monitor(monitor)
|
|
7
7
|
#FIXME: Refactor this type of function into something generic
|
|
8
|
-
|
|
8
|
+
unless ['Disabled','HTTP','ECV'].include?(monitor[:type])
|
|
9
|
+
raise ArgumentError.new("Supported monitor types are: ECV & HTTP")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
required_opts = case monitor[:type]
|
|
13
|
+
when "Disabled"
|
|
14
|
+
[:type, :is_enabled]
|
|
15
|
+
else
|
|
16
|
+
[:type, :url_send_string, :http_headers, :receive_string, :is_enabled]
|
|
17
|
+
end
|
|
9
18
|
|
|
10
19
|
unless required_opts.all? { |opt| monitor.keys.include?(opt) && monitor[opt] }
|
|
11
20
|
raise ArgumentError.new("Required Monitor data missing: #{(required_opts - monitor.keys).map(&:inspect).join(", ")}")
|
|
12
21
|
end
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
raise ArgumentError.new("Monitor :http_headers must be a String or Array")
|
|
23
|
+
case monitor[:type]
|
|
24
|
+
when "HTTP", "ECV"
|
|
25
|
+
unless monitor[:http_headers].is_a?(Array) || monitor[:http_headers].is_a?(String)
|
|
26
|
+
raise ArgumentError.new("Monitor :http_headers must be a String or Array")
|
|
27
|
+
end
|
|
20
28
|
end
|
|
21
29
|
|
|
22
30
|
unless [true, false, "true", "false"].include?(monitor[:is_enabled])
|
|
@@ -33,6 +41,28 @@ module Fog
|
|
|
33
41
|
raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
|
|
34
42
|
end
|
|
35
43
|
end
|
|
44
|
+
|
|
45
|
+
def ensure_monitor_defaults!(monitor)
|
|
46
|
+
if monitor[:http_headers].is_a?(String)
|
|
47
|
+
monitor[:http_headers] = [ monitor[:http_headers] ]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
unless monitor[:retries]
|
|
51
|
+
monitor[:retries] = 3
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
unless monitor[:response_timeout]
|
|
55
|
+
monitor[:response_timeout] = 2
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
unless monitor[:down_time]
|
|
59
|
+
monitor[:down_time] = 30
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
unless monitor[:interval]
|
|
63
|
+
monitor[:interval] = 5
|
|
64
|
+
end
|
|
65
|
+
end
|
|
36
66
|
end
|
|
37
67
|
|
|
38
68
|
class Real
|
|
@@ -75,38 +105,20 @@ module Fog
|
|
|
75
105
|
def generate_monitor_section(builder, monitor)
|
|
76
106
|
builder.Monitor {
|
|
77
107
|
builder.MonitorType(monitor[:type])
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
case monitor[:type]
|
|
109
|
+
when "ECV","HTTP"
|
|
110
|
+
builder.UrlSendString(monitor[:url_send_string])
|
|
111
|
+
builder.HttpHeader(monitor[:http_headers].join("\n"))
|
|
112
|
+
builder.ReceiveString(monitor[:receive_string])
|
|
113
|
+
builder.Interval(monitor[:interval])
|
|
114
|
+
builder.ResponseTimeOut(monitor[:response_timeout])
|
|
115
|
+
builder.DownTime(monitor[:downtime])
|
|
116
|
+
builder.Retries(monitor[:retries])
|
|
117
|
+
end
|
|
85
118
|
builder.IsEnabled(monitor[:is_enabled])
|
|
86
119
|
}
|
|
87
120
|
end
|
|
88
121
|
|
|
89
|
-
def ensure_monitor_defaults!(monitor)
|
|
90
|
-
if monitor[:http_headers].is_a?(String)
|
|
91
|
-
monitor[:http_headers] = [ monitor[:http_headers] ]
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
unless monitor[:retries]
|
|
95
|
-
monitor[:retries] = 3
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
unless monitor[:response_timeout]
|
|
99
|
-
monitor[:response_timeout] = 2
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
unless monitor[:down_time]
|
|
103
|
-
monitor[:down_time] = 30
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
unless monitor[:interval]
|
|
107
|
-
monitor[:interval] = 5
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
122
|
end
|
|
111
123
|
|
|
112
124
|
class Mock
|
|
@@ -80,6 +80,11 @@ module Fog
|
|
|
80
80
|
|
|
81
81
|
validate_internet_service_data(service_data, true)
|
|
82
82
|
|
|
83
|
+
if monitor = service_data[:monitor]
|
|
84
|
+
validate_internet_service_monitor(monitor)
|
|
85
|
+
ensure_monitor_defaults!(monitor)
|
|
86
|
+
end
|
|
87
|
+
|
|
83
88
|
validate_public_ip_address_data(ip_address_data)
|
|
84
89
|
|
|
85
90
|
internet_service_uri = ensure_unparsed(internet_service_uri)
|
|
@@ -6,24 +6,24 @@ if Fog.mocking?
|
|
|
6
6
|
describe :class do
|
|
7
7
|
subject { Fog::Vcloud::Vdc }
|
|
8
8
|
|
|
9
|
-
it { should have_identity
|
|
9
|
+
it { should have_identity(:href) }
|
|
10
10
|
|
|
11
|
-
it { should have_only_these_attributes
|
|
12
|
-
:resource_entities, :enabled, :vm_quota, :nic_quota, :network_quota, :allocation_model] }
|
|
11
|
+
it { should have_only_these_attributes([:href, :name, :type, :description, :other_links, :compute_capacity, :storage_capacity, :available_networks,
|
|
12
|
+
:resource_entities, :enabled, :vm_quota, :nic_quota, :network_quota, :allocation_model]) }
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
context "with no uri" do
|
|
16
16
|
|
|
17
17
|
subject { Fog::Vcloud::Vdc.new() }
|
|
18
18
|
|
|
19
|
-
it { should
|
|
19
|
+
it { should(have_all_attributes_be_nil) }
|
|
20
20
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
context "as a collection member" do
|
|
24
24
|
subject { @vcloud.vdcs[0].reload }
|
|
25
25
|
|
|
26
|
-
it { should be_an_instance_of
|
|
26
|
+
it { should be_an_instance_of(Fog::Vcloud::Vdc) }
|
|
27
27
|
|
|
28
28
|
its(:href) { should == @mock_vdc.href }
|
|
29
29
|
its(:identity) { should == @mock_vdc.href }
|
|
@@ -32,12 +32,12 @@ if Fog.mocking?
|
|
|
32
32
|
its(:resource_entities) { should have(3).items }
|
|
33
33
|
its(:available_networks) { should have(2).items }
|
|
34
34
|
|
|
35
|
-
its(:compute_capacity) { should be_an_instance_of
|
|
35
|
+
its(:compute_capacity) { should be_an_instance_of(Hash) }
|
|
36
36
|
its(:compute_capacity) { should == {:Cpu =>
|
|
37
37
|
{:Units => "Mhz", :Allocated => @mock_vdc.cpu_allocated.to_s, :Limit => @mock_vdc.cpu_allocated.to_s},
|
|
38
38
|
:Memory =>
|
|
39
39
|
{:Units => "MB", :Allocated => @mock_vdc.memory_allocated.to_s, :Limit => @mock_vdc.memory_allocated.to_s}} }
|
|
40
|
-
its(:storage_capacity) { should be_an_instance_of
|
|
40
|
+
its(:storage_capacity) { should be_an_instance_of(Hash) }
|
|
41
41
|
its(:storage_capacity) { should == {:Limit => @mock_vdc.storage_allocated.to_s, :Units=>"MB", :Allocated => @mock_vdc.storage_allocated.to_s} }
|
|
42
42
|
|
|
43
43
|
its(:vm_quota) { should == "0" }
|
|
@@ -48,5 +48,4 @@ if Fog.mocking?
|
|
|
48
48
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
else
|
|
52
51
|
end
|
|
@@ -4,7 +4,7 @@ if Fog.mocking?
|
|
|
4
4
|
describe Fog::Vcloud, :type => :mock_vcloud_request do
|
|
5
5
|
subject { @vcloud }
|
|
6
6
|
|
|
7
|
-
it { should respond_to
|
|
7
|
+
it { should respond_to(:get_network) }
|
|
8
8
|
|
|
9
9
|
describe :get_network, :type => :vcloud_request do
|
|
10
10
|
context "with a valid network uri" do
|
|
@@ -12,7 +12,7 @@ if Fog.mocking?
|
|
|
12
12
|
subject { @network }
|
|
13
13
|
|
|
14
14
|
it_should_behave_like "all responses"
|
|
15
|
-
it { should have_headers_denoting_a_content_type_of
|
|
15
|
+
it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.network+xml") }
|
|
16
16
|
|
|
17
17
|
describe :body do
|
|
18
18
|
subject { @network.body }
|
|
@@ -20,19 +20,19 @@ if Fog.mocking?
|
|
|
20
20
|
it { should have(9).keys }
|
|
21
21
|
|
|
22
22
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
|
23
|
-
it { should have_key_with_value
|
|
24
|
-
it { should have_key_with_value
|
|
25
|
-
it { should have_key_with_value
|
|
26
|
-
it { should have_key_with_value
|
|
27
|
-
it { should have_key_with_value
|
|
28
|
-
it { should have_key_with_value
|
|
23
|
+
it { should have_key_with_value(:type, "application/vnd.vmware.vcloud.network+xml") }
|
|
24
|
+
it { should have_key_with_value(:Features, {:FenceMode => "isolated"}) }
|
|
25
|
+
it { should have_key_with_value(:Description, @mock_network.name) }
|
|
26
|
+
it { should have_key_with_value(:href, @mock_network.href) }
|
|
27
|
+
it { should have_key_with_value(:name, @mock_network.name) }
|
|
28
|
+
it { should have_key_with_value(:Configuration, {:Gateway => @mock_network.gateway,
|
|
29
29
|
:Netmask => @mock_network.netmask,
|
|
30
|
-
:Dns => @mock_network.dns } }
|
|
30
|
+
:Dns => @mock_network.dns }) }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
context "with a network uri that doesn't exist" do
|
|
34
34
|
subject { lambda { @vcloud.get_network(URI.parse('https://www.fakey.com/api/v0.8/network/999')) } }
|
|
35
|
-
it_should_behave_like
|
|
35
|
+
it_should_behave_like("a request for a resource that doesn't exist")
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -4,7 +4,7 @@ if Fog.mocking?
|
|
|
4
4
|
describe Fog::Vcloud, :type => :mock_vcloud_request do
|
|
5
5
|
subject { @vcloud }
|
|
6
6
|
|
|
7
|
-
it { should respond_to
|
|
7
|
+
it { should respond_to(:get_organization) }
|
|
8
8
|
|
|
9
9
|
describe "#get_organization" do
|
|
10
10
|
context "with a valid organization uri" do
|
|
@@ -12,7 +12,7 @@ if Fog.mocking?
|
|
|
12
12
|
subject { @organization }
|
|
13
13
|
|
|
14
14
|
it_should_behave_like "all responses"
|
|
15
|
-
it { should have_headers_denoting_a_content_type_of
|
|
15
|
+
it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.org+xml") }
|
|
16
16
|
|
|
17
17
|
describe "#body" do
|
|
18
18
|
subject { @organization.body }
|
|
@@ -23,9 +23,9 @@ if Fog.mocking?
|
|
|
23
23
|
it { should have(6).keys }
|
|
24
24
|
|
|
25
25
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
|
26
|
-
it { should have_key_with_value
|
|
27
|
-
it { should have_key_with_value
|
|
28
|
-
it { should have_key_with_array
|
|
26
|
+
it { should have_key_with_value(:href, @mock_organization.href)}
|
|
27
|
+
it { should have_key_with_value(:name, @mock_organization.name) }
|
|
28
|
+
it { should have_key_with_array(:Link, @mock_organization.vdcs.map { |vdc|
|
|
29
29
|
[{ :type => "application/vnd.vmware.vcloud.vdc+xml",
|
|
30
30
|
:href => vdc.href,
|
|
31
31
|
:name => vdc.name,
|
|
@@ -38,16 +38,15 @@ if Fog.mocking?
|
|
|
38
38
|
:href => vdc.task_list.href,
|
|
39
39
|
:name => vdc.task_list.name,
|
|
40
40
|
:rel => "down" }]
|
|
41
|
-
}.flatten }
|
|
41
|
+
}.flatten) }
|
|
42
42
|
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
context "with an organization uri that doesn't exist" do
|
|
46
46
|
subject { lambda { @vcloud.get_organization(URI.parse('https://www.fakey.com/api/v0.8/org/999')) } }
|
|
47
|
-
it_should_behave_like
|
|
47
|
+
it_should_behave_like("a request for a resource that doesn't exist")
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
else
|
|
52
51
|
end
|
|
53
52
|
|
|
@@ -8,7 +8,7 @@ if Fog.mocking?
|
|
|
8
8
|
describe Fog::Vcloud, :type => :mock_vcloud_request do
|
|
9
9
|
subject { @vcloud }
|
|
10
10
|
|
|
11
|
-
it { should respond_to
|
|
11
|
+
it { should respond_to(:get_vdc) }
|
|
12
12
|
|
|
13
13
|
describe :get_vdc, :type => :vcloud_request do
|
|
14
14
|
context "with a valid vdc uri" do
|
|
@@ -16,14 +16,14 @@ if Fog.mocking?
|
|
|
16
16
|
subject { @vdc }
|
|
17
17
|
|
|
18
18
|
it_should_behave_like "all responses"
|
|
19
|
-
it { should have_headers_denoting_a_content_type_of
|
|
19
|
+
it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.vdc+xml") }
|
|
20
20
|
|
|
21
21
|
describe :body do
|
|
22
22
|
subject { @vdc.body }
|
|
23
23
|
|
|
24
24
|
it { should have(16).items }
|
|
25
25
|
|
|
26
|
-
it_should_behave_like
|
|
26
|
+
it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys
|
|
27
27
|
|
|
28
28
|
its(:name) { should == @mock_vdc.name }
|
|
29
29
|
its(:href) { should == @mock_vdc.href }
|
|
@@ -53,11 +53,10 @@ if Fog.mocking?
|
|
|
53
53
|
end
|
|
54
54
|
context "with a vdc uri that doesn't exist" do
|
|
55
55
|
subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
|
|
56
|
-
it_should_behave_like
|
|
56
|
+
it_should_behave_like("a request for a resource that doesn't exist")
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
-
else
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
|
|
@@ -4,7 +4,7 @@ shared_examples_for "real or mock get_versions requests" do
|
|
|
4
4
|
|
|
5
5
|
subject { @vcloud }
|
|
6
6
|
|
|
7
|
-
it { should respond_to
|
|
7
|
+
it { should respond_to(:get_versions) }
|
|
8
8
|
|
|
9
9
|
describe "#get_versions" do
|
|
10
10
|
subject { @vcloud.get_versions( @vcloud.versions_uri ) }
|
|
@@ -29,7 +29,7 @@ shared_examples_for "real or mock get_versions requests" do
|
|
|
29
29
|
version_info.should include(:LoginUrl)
|
|
30
30
|
version_info[:LoginUrl].should be_a_url
|
|
31
31
|
version_info.should include(:Version)
|
|
32
|
-
version_info[:Version].should be_an_instance_of
|
|
32
|
+
version_info[:Version].should be_an_instance_of(String)
|
|
33
33
|
end
|
|
34
34
|
}
|
|
35
35
|
end
|
data/spec/vcloud/spec_helper.rb
CHANGED
|
@@ -30,34 +30,38 @@ def arrayify(item)
|
|
|
30
30
|
item.is_a?(Array) ? item : [ item ]
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
def ecloud_disabled_default_monitor
|
|
34
|
+
{:url_send_string=>nil, :receive_string=>nil, :response_timeout=>2, :retries=>3, :is_enabled=>"true", :down_time=>30, :type=>"Disabled", :http_headers=>nil, :interval=>5, :downtime=>nil}
|
|
35
|
+
end
|
|
36
|
+
|
|
33
37
|
shared_examples_for "all responses" do
|
|
34
|
-
it { should be_an_instance_of
|
|
35
|
-
it { should respond_to
|
|
36
|
-
it { should respond_to
|
|
38
|
+
it { should be_an_instance_of(Excon::Response) }
|
|
39
|
+
it { should respond_to(:body) }
|
|
40
|
+
it { should respond_to(:headers) }
|
|
37
41
|
it { should have_at_least(1).body }
|
|
38
42
|
it { should have_at_least(0).headers }
|
|
39
|
-
its(:body) { should be_an_instance_of
|
|
40
|
-
its(:headers) { should be_an_instance_of
|
|
43
|
+
its(:body) { should be_an_instance_of(Hash) }
|
|
44
|
+
its(:headers) { should be_an_instance_of(Hash) }
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
shared_examples_for "all delete responses" do
|
|
44
|
-
it { should be_an_instance_of
|
|
45
|
-
it { should respond_to
|
|
46
|
-
it { should respond_to
|
|
47
|
-
its(:headers) { should be_an_instance_of
|
|
48
|
+
it { should be_an_instance_of(Excon::Response) }
|
|
49
|
+
it { should respond_to(:body) }
|
|
50
|
+
it { should respond_to(:headers) }
|
|
51
|
+
its(:headers) { should be_an_instance_of(Hash) }
|
|
48
52
|
end
|
|
49
53
|
|
|
50
54
|
shared_examples_for "it has a Content-Type header" do
|
|
51
|
-
its(:headers) { should include
|
|
55
|
+
its(:headers) { should include("Content-Type") }
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
shared_examples_for "all rel=down vcloud links" do
|
|
55
|
-
it { should be_an_instance_of
|
|
59
|
+
it { should be_an_instance_of(Struct::VcloudLink) }
|
|
56
60
|
specify { subject.rel.should == "down" }
|
|
57
61
|
end
|
|
58
62
|
|
|
59
63
|
shared_examples_for "all vcloud links w/o a rel" do
|
|
60
|
-
it { should be_an_instance_of
|
|
64
|
+
it { should be_an_instance_of(Struct::VcloudLink) }
|
|
61
65
|
specify { subject.rel.should == nil }
|
|
62
66
|
end
|
|
63
67
|
|
|
@@ -91,21 +95,21 @@ end
|
|
|
91
95
|
|
|
92
96
|
shared_examples_for "all login requests" do
|
|
93
97
|
|
|
94
|
-
it { should respond_to
|
|
98
|
+
it { should respond_to(:login) }
|
|
95
99
|
|
|
96
100
|
describe "#login" do
|
|
97
101
|
before { @login = @vcloud.login }
|
|
98
102
|
subject { @login }
|
|
99
103
|
|
|
100
|
-
it_should_behave_like
|
|
104
|
+
it_should_behave_like("all responses")
|
|
101
105
|
|
|
102
|
-
its(:headers) { should include
|
|
106
|
+
its(:headers) { should include("Set-Cookie") }
|
|
103
107
|
|
|
104
108
|
describe "#body" do
|
|
105
109
|
subject { @login.body }
|
|
106
110
|
|
|
107
111
|
it { should have(4).items }
|
|
108
|
-
it_should_behave_like
|
|
112
|
+
it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys
|
|
109
113
|
it { should include(:Org) }
|
|
110
114
|
|
|
111
115
|
describe ":Org" do
|
|
@@ -114,11 +118,11 @@ shared_examples_for "all login requests" do
|
|
|
114
118
|
specify do
|
|
115
119
|
subject.each do |org|
|
|
116
120
|
org.should include(:type)
|
|
117
|
-
org[:type].should be_of_type
|
|
121
|
+
org[:type].should be_of_type("application/vnd.vmware.vcloud.org+xml")
|
|
118
122
|
org.should include(:name)
|
|
119
|
-
org[:name].should be_an_instance_of
|
|
123
|
+
org[:name].should be_an_instance_of(String)
|
|
120
124
|
org.should include(:href)
|
|
121
|
-
org[:href].should
|
|
125
|
+
org[:href].should(be_a_url)
|
|
122
126
|
end
|
|
123
127
|
end
|
|
124
128
|
end
|
|
@@ -139,17 +143,17 @@ shared_examples_for "it has the proper xmlns_xsd" do
|
|
|
139
143
|
end
|
|
140
144
|
|
|
141
145
|
shared_examples_for "it has the standard xmlns attributes" do
|
|
142
|
-
it_should_behave_like
|
|
143
|
-
it_should_behave_like
|
|
146
|
+
it_should_behave_like("it has the proper xmlns_xsi")
|
|
147
|
+
it_should_behave_like("it has the proper xmlns_xsd")
|
|
144
148
|
end
|
|
145
149
|
|
|
146
150
|
shared_examples_for "it has the standard vcloud v0.8 xmlns attributes" do
|
|
147
|
-
it_should_behave_like
|
|
148
|
-
it_should_behave_like
|
|
151
|
+
it_should_behave_like("it has a vcloud v0.8 xmlns")
|
|
152
|
+
it_should_behave_like("it has the standard xmlns attributes")
|
|
149
153
|
end
|
|
150
154
|
|
|
151
155
|
shared_examples_for "a request for a resource that doesn't exist" do
|
|
152
|
-
it { should raise_error
|
|
156
|
+
it { should raise_error(Excon::Errors::Unauthorized) }
|
|
153
157
|
end
|
|
154
158
|
|
|
155
159
|
shared_examples_for "a vdc catalog link" do
|
|
@@ -159,8 +163,8 @@ shared_examples_for "a vdc catalog link" do
|
|
|
159
163
|
end
|
|
160
164
|
|
|
161
165
|
shared_examples_for "a tmrk network link" do
|
|
162
|
-
it_should_behave_like
|
|
163
|
-
it_should_behave_like
|
|
166
|
+
it_should_behave_like("all vcloud links w/o a rel")
|
|
167
|
+
it_should_behave_like("all vcloud network types")
|
|
164
168
|
end
|
|
165
169
|
|
|
166
170
|
shared_examples_for "the mocked tmrk network links" do
|
|
@@ -186,22 +190,22 @@ shared_examples_for "the mocked tmrk resource entity links" do
|
|
|
186
190
|
|
|
187
191
|
describe "[0]" do
|
|
188
192
|
subject { @vdc.body.resource_entities[0] }
|
|
189
|
-
it_should_behave_like
|
|
190
|
-
it_should_behave_like
|
|
193
|
+
it_should_behave_like("a vapp type")
|
|
194
|
+
it_should_behave_like("all vcloud links w/o a rel")
|
|
191
195
|
its(:href) { should == URI.parse(@mock_vdc[:vms][0][:href]) }
|
|
192
196
|
its(:name) { should == @mock_vdc[:vms][0][:name] }
|
|
193
197
|
end
|
|
194
198
|
describe "[1]" do
|
|
195
199
|
subject { @vdc.body.resource_entities[1] }
|
|
196
|
-
it_should_behave_like
|
|
197
|
-
it_should_behave_like
|
|
200
|
+
it_should_behave_like("a vapp type")
|
|
201
|
+
it_should_behave_like("all vcloud links w/o a rel")
|
|
198
202
|
its(:href) { should == URI.parse(@mock_vdc[:vms][1][:href]) }
|
|
199
203
|
its(:name) { should == @mock_vdc[:vms][1][:name] }
|
|
200
204
|
end
|
|
201
205
|
describe "[2]" do
|
|
202
206
|
subject { @vdc.body.resource_entities[2] }
|
|
203
|
-
it_should_behave_like
|
|
204
|
-
it_should_behave_like
|
|
207
|
+
it_should_behave_like("a vapp type")
|
|
208
|
+
it_should_behave_like("all vcloud links w/o a rel")
|
|
205
209
|
its(:href) { should == URI.parse(@mock_vdc[:vms][2][:href]) }
|
|
206
210
|
its(:name) { should == @mock_vdc[:vms][2][:name] }
|
|
207
211
|
end
|