vcloud-core 0.0.3 → 0.0.4
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.
@@ -21,6 +21,11 @@ module Vcloud
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def update_configuration(config)
|
25
|
+
fsi = Vcloud::Fog::ServiceInterface.new
|
26
|
+
fsi.post_configure_edge_gateway_services(id, config)
|
27
|
+
end
|
28
|
+
|
24
29
|
def self.get_by_name(name)
|
25
30
|
ids = self.get_ids_by_name(name)
|
26
31
|
raise "edgeGateway #{name} not found" if ids.size == 0
|
data/lib/vcloud/core/version.rb
CHANGED
@@ -8,7 +8,8 @@ module Vcloud
|
|
8
8
|
def_delegators :@fog, :get_vapp, :organizations, :org_name, :delete_vapp, :vcloud_token, :end_point,
|
9
9
|
:get_execute_query, :get_vapp_metadata, :power_off_vapp, :shutdown_vapp, :session,
|
10
10
|
:post_instantiate_vapp_template, :put_memory, :put_cpu, :power_on_vapp, :put_vapp_metadata_value,
|
11
|
-
:put_vm, :get_edge_gateway, :get_network, :delete_network, :post_create_org_vdc_network
|
11
|
+
:put_vm, :get_edge_gateway, :get_network, :delete_network, :post_create_org_vdc_network,
|
12
|
+
:post_configure_edge_gateway_services
|
12
13
|
|
13
14
|
#########################
|
14
15
|
# FogFacade Inner class to represent a logic free facade over our interactions with Fog
|
@@ -123,6 +124,17 @@ module Vcloud
|
|
123
124
|
get_network(extract_id(attrs))
|
124
125
|
end
|
125
126
|
|
127
|
+
def post_configure_edge_gateway_services(edgegw_id, config)
|
128
|
+
Vcloud::Core.logger.info("Updating EdgeGateway #{edgegw_id}")
|
129
|
+
begin
|
130
|
+
task = @vcloud.post_configure_edge_gateway_services(edgegw_id, config).body
|
131
|
+
@vcloud.process_task(task)
|
132
|
+
rescue Exception => ex
|
133
|
+
Vcloud::Core.logger.error("Could not update EdgeGateway #{edgegw_id} : #{ex}")
|
134
|
+
raise
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
126
138
|
def power_off_vapp(vapp_id)
|
127
139
|
task = @vcloud.post_power_off_vapp(vapp_id).body
|
128
140
|
@vcloud.process_task(task)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Vcloud
|
4
|
+
module Core
|
5
|
+
describe EdgeGateway do
|
6
|
+
it "configure firewall service" do
|
7
|
+
configuration = {
|
8
|
+
:FirewallService =>
|
9
|
+
{
|
10
|
+
:IsEnabled => "true",
|
11
|
+
:DefaultAction => "allow",
|
12
|
+
:LogDefaultAction => "false",
|
13
|
+
:FirewallRule =>
|
14
|
+
[
|
15
|
+
{
|
16
|
+
:Id => "999",
|
17
|
+
:IsEnabled => "false",
|
18
|
+
:MatchOnTranslate => "false",
|
19
|
+
:Description => "generated from edge_gateway_tests",
|
20
|
+
:Policy => "drop",
|
21
|
+
:Protocols => {:Tcp => "true"},
|
22
|
+
:Port => "3412",
|
23
|
+
:DestinationPortRange => "3412",
|
24
|
+
:DestinationIp => "internal",
|
25
|
+
:SourcePort => "3412",
|
26
|
+
:SourcePortRange => "3412",
|
27
|
+
:SourceIp => "internal",
|
28
|
+
:EnableLogging => "false"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
}
|
33
|
+
edge_gateway = EdgeGateway.get_by_name(ENV['VCLOUD_EDGE_GATEWAY'])
|
34
|
+
edge_gateway.update_configuration(configuration)
|
35
|
+
|
36
|
+
actual_config = edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
37
|
+
actual_config[:FirewallService].should == configuration[:FirewallService]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,30 +1,62 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module Vcloud
|
4
|
+
module Fog
|
5
|
+
describe ServiceInterface do
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
FOG_SESSION_RESPONSE = {:xmlns => 'http://www.vmware.com/vcloud/v5.1', :xmlns_xsi => 'http://www.w3.org/2001/XMLSchema-instance', :user => 'me@dexample.com', :org => 'my_org', :type => 'application/vnd.vmware.vcloud.session+xml', :href => 'https://example.org/api/session/', :xsi_schemaLocation => 'http://www.vmware.com/vcloud/v5.1 http://example.org/api/v5.1/schema/master.xsd', :Link => [{:rel => 'down', :type => 'application/vnd.vmware.vcloud.orgList+xml', :href => 'https://example.com/api/org/'}, {:rel => 'down', :type => 'application/vnd.vmware.admin.vcloud+xml', :href => 'https://example.com/api/admin/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.org+xml', :name => 'vdc_name', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.query.queryList+xml', :href => 'https://example.com/api/query'}, {:rel => 'entityResolver', :type => 'application/vnd.vmware.vcloud.entity+xml', :href => 'https://example.com/api/entity/'}, {:rel => 'down:extensibility', :type => 'application/vnd.vmware.vcloud.apiextensibility+xml', :href => 'https://example.com/api/extensibility'}]}
|
8
|
+
FOG_ORGANIZATION_RESPONSE = {:xmlns => 'http://www.vmware.com/vcloud/v5.1', :xmlns_xsi => 'http://www.w3.org/2001/XMLSchema-instance', :name => 'org_name', :id => 'urn:vcloud:org:0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0', :type => 'application/vnd.vmware.vcloud.org+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0', :xsi_schemaLocation => 'http://www.vmware.com/vcloud/v1.5 http://example.com/api/v1.5/schema/master.xsd', :Link => [{:rel => 'down', :type => 'application/vnd.vmware.vcloud.vdc+xml', :name => 'vdc_name', :href => 'https://example.com/api/vdc/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.tasksList+xml', :href => 'https://example.com/api/tasksList/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'Appliances', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0X/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'Public Catalog', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'walker-ci', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'controlAccess', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/action/controlAccess'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'Images', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'add', :type => 'application/vnd.vmware.admin.catalog+xml', :href => 'https://example.com/api/admin/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalogs'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.orgNetwork+xml', :name => 'walker-ci-network', :href => 'https://example.com/api/network/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.orgNetwork+xml', :name => 'backend', :href => 'https://example.com/api/network/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.supportedSystemsInfo+xml', :href => 'https://example.com/api/supportedSystemsInfo/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.metadata+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/metadata'}], :Description => 'Added description', :FullName => 'GDS CI Tools', :Tasks => {:Task => []}}
|
7
9
|
|
8
|
-
|
10
|
+
it 'should raise a exception if named vdc not found in the data returned' do
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
fog_facade = double(:FogFacade)
|
13
|
+
expect(fog_facade).to receive(:session).any_number_of_times { FOG_SESSION_RESPONSE }
|
14
|
+
expect(fog_facade).to receive(:get_organization).any_number_of_times { FOG_ORGANIZATION_RESPONSE }
|
13
15
|
|
14
|
-
|
16
|
+
service_interface = ServiceInterface.new(fog_facade)
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
expect { service_interface.vdc('DoesNotExist') }.to raise_exception(RuntimeError, 'vdc DoesNotExist cannot be found')
|
19
|
+
end
|
18
20
|
|
19
|
-
|
21
|
+
it 'should raise a exception if named catalog cannot be found in the data returned' do
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
fog_facade = double(:FogFacade)
|
24
|
+
expect(fog_facade).to receive(:session).any_number_of_times { FOG_SESSION_RESPONSE }
|
25
|
+
expect(fog_facade).to receive(:get_organization).any_number_of_times { FOG_ORGANIZATION_RESPONSE }
|
24
26
|
|
25
|
-
|
27
|
+
service_interface = ServiceInterface.new(fog_facade)
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
expect { service_interface.catalog('DoesNotExist') }.to raise_exception(RuntimeError, 'catalog DoesNotExist cannot be found')
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'configure edge gateway' do
|
33
|
+
before(:each) do
|
34
|
+
@config = { :Blah => 'TestData' }
|
35
|
+
@vcloud = double(:vcloud)
|
36
|
+
::Fog::Compute::VcloudDirector.should_receive(:new).and_return(@vcloud)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should configure firewall for given edge gateway id" do
|
40
|
+
task = double(:task)
|
41
|
+
Vcloud::Core::logger.should_receive(:info).with("Updating EdgeGateway 1234")
|
42
|
+
@vcloud.should_receive(:post_configure_edge_gateway_services).with("1234", @config).
|
43
|
+
and_return(double(:response, :body => task ))
|
44
|
+
@vcloud.should_receive(:process_task).with(task)
|
29
45
|
|
46
|
+
ServiceInterface.new.post_configure_edge_gateway_services "1234", @config
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
it "should log and return exceptions without swallowing" do
|
51
|
+
Vcloud::Core::logger.should_receive(:info).with("Updating EdgeGateway 1234")
|
52
|
+
runtime_error = RuntimeError.new('Test Error')
|
53
|
+
Vcloud::Core::logger.should_receive(:error).with("Could not update EdgeGateway 1234 : #{runtime_error}")
|
54
|
+
@vcloud.should_receive(:post_configure_edge_gateway_services).with("1234", @config).
|
55
|
+
and_raise(runtime_error)
|
56
|
+
expect{ ServiceInterface.new.post_configure_edge_gateway_services("1234", @config) }.to raise_error("Test Error")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
30
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcloud-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/vcloud/fog/model_interface.rb
|
141
141
|
- lib/vcloud/fog/relation.rb
|
142
142
|
- lib/vcloud/fog/service_interface.rb
|
143
|
+
- spec/integration/edge_gateway/configure_edge_gateway_services_spec.rb
|
143
144
|
- spec/spec_helper.rb
|
144
145
|
- spec/support/stub_fog_interface.rb
|
145
146
|
- spec/vcloud/core/edge_gateway_spec.rb
|
@@ -176,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
177
|
version: '0'
|
177
178
|
segments:
|
178
179
|
- 0
|
179
|
-
hash: -
|
180
|
+
hash: -4507568303772117812
|
180
181
|
requirements: []
|
181
182
|
rubyforge_project:
|
182
183
|
rubygems_version: 1.8.23
|
@@ -184,6 +185,7 @@ signing_key:
|
|
184
185
|
specification_version: 3
|
185
186
|
summary: Core tools for interacting with VMware vCloud Director
|
186
187
|
test_files:
|
188
|
+
- spec/integration/edge_gateway/configure_edge_gateway_services_spec.rb
|
187
189
|
- spec/spec_helper.rb
|
188
190
|
- spec/support/stub_fog_interface.rb
|
189
191
|
- spec/vcloud/core/edge_gateway_spec.rb
|