vcloud-core 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ ## 0.0.6 (2014-02-13)
2
+
3
+ Features:
4
+
5
+ - adds EdgeGateway.interfaces for returning array of EdgeGatewayInterface objects
6
+ associated with the EdgeGateway
7
+ - adds EdgeGatewayInterface class, representing a vCloud GatewayInterfaceType
8
+
9
+ ## 0.0.5 (2014-01-29)
10
+
11
+ Features:
12
+
13
+ - adds support for retrieving gateway interface by id
14
+
15
+ ## 0.0.4 (2014-01-23)
16
+
17
+ Features:
18
+
19
+ - adds ability to update Edge Gateway configuration
20
+
21
+ ## 0.0.1 (2014-01-17)
22
+
23
+ - First release of gem
@@ -8,6 +8,7 @@ require 'vcloud/core/metadata_helper'
8
8
  require 'vcloud/core/compute_metadata'
9
9
  require 'vcloud/core/vdc'
10
10
  require 'vcloud/core/edge_gateway'
11
+ require 'vcloud/core/edge_gateway_interface'
11
12
  require 'vcloud/core/vm'
12
13
  require 'vcloud/core/vapp'
13
14
  require 'vcloud/core/vapp_template'
@@ -55,6 +55,15 @@ module Vcloud
55
55
  vcloud_attributes[:name]
56
56
  end
57
57
 
58
+ def interfaces
59
+ gateway_config = vcloud_attributes[:Configuration]
60
+ return [] unless gateway_config[:GatewayInterfaces]
61
+ return [] unless gateway_interfaces = gateway_config[:GatewayInterfaces][:GatewayInterface]
62
+ gateway_interfaces.map do |vcloud_gateway_interface_hash|
63
+ EdgeGatewayInterface.new(vcloud_gateway_interface_hash)
64
+ end
65
+ end
66
+
58
67
  end
59
68
  end
60
69
  end
@@ -0,0 +1,30 @@
1
+ module Vcloud
2
+ module Core
3
+ class EdgeGatewayInterface
4
+
5
+ attr_accessor :name, :network_href, :network_name
6
+
7
+ def initialize(gateway_interface_hash)
8
+ raise "Argument error: nil not allowed" if gateway_interface_hash.nil?
9
+ @vcloud_gateway_interface = gateway_interface_hash
10
+ unless @name = gateway_interface_hash[:Name]
11
+ raise "Argument error: must have a :Name"
12
+ end
13
+ unless network_section = gateway_interface_hash[:Network]
14
+ raise "Argument error: must have a :Network section"
15
+ end
16
+ unless @network_href = network_section[:href]
17
+ raise "Argument error: must have a :Network[:href]"
18
+ end
19
+ unless @network_name = network_section[:name]
20
+ raise "Argument error: must have a :Network[:name]"
21
+ end
22
+ end
23
+
24
+ def network_id
25
+ network_href.split('/').last
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Core
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ module Vcloud
4
+ module Core
5
+ describe EdgeGatewayInterface do
6
+
7
+ before(:each) do
8
+ @valid_ext_id = "12345678-70ac-487e-9c1e-124716764274"
9
+ @gateway_interface_hash = {
10
+ :Name=>"EXTERNAL_NETWORK",
11
+ :Network=>{
12
+ :type=>"application/vnd.vmware.admin.network+xml",
13
+ :name=>"EXTERNAL_NETWORK",
14
+ :href=>"https://example.com/api/admin/network/#{@valid_ext_id}"
15
+ },
16
+ :InterfaceType=>"uplink",
17
+ :SubnetParticipation=>{
18
+ :Gateway=>"192.2.0.1",
19
+ :Netmask=>"255.255.255.0",
20
+ :IpAddress=>"192.2.0.66"
21
+ },
22
+ :UseForDefaultRoute=>"true"
23
+ }
24
+ @interface = EdgeGatewayInterface.new(@gateway_interface_hash)
25
+ end
26
+
27
+ context "Instance public interface" do
28
+ subject { EdgeGatewayInterface.new(@gateway_interface_hash) }
29
+ it { should respond_to(:name) }
30
+ it { should respond_to(:network_id) }
31
+ it { should respond_to(:network_name) }
32
+ it { should respond_to(:network_href) }
33
+ end
34
+
35
+ context "#initialize" do
36
+
37
+ it "should be constructable from just a Fog vCloud GatewayInterfaceType hash" do
38
+ obj = EdgeGatewayInterface.new(@gateway_interface_hash)
39
+ expect(obj.class).to be(Vcloud::Core::EdgeGatewayInterface)
40
+ end
41
+
42
+ it "should raise an error if passed a nil value" do
43
+ expect { EdgeGatewayInterface.new(nil) }.to raise_error("Argument error: nil not allowed")
44
+ end
45
+
46
+ it "should raise an error if a :Name is not passed" do
47
+ expect { EdgeGatewayInterface.new({}) }.to raise_error("Argument error: must have a :Name")
48
+ end
49
+
50
+ it "should raise an error if a :Network is not passed" do
51
+ expect { EdgeGatewayInterface.new({Name: 'test-interface'}) }.to raise_error("Argument error: must have a :Network section")
52
+ end
53
+
54
+ it "should raise an error if a :Network :href is not passed" do
55
+ bad_input = {
56
+ Name: 'test-interface',
57
+ Network: { name: "test-network" }
58
+ }
59
+ expect { EdgeGatewayInterface.new(bad_input) }.to raise_error("Argument error: must have a :Network[:href]")
60
+ end
61
+
62
+ it "should raise an error if a :Network :name is not passed" do
63
+ bad_input = {
64
+ Name: 'test-interface',
65
+ Network: { href: "http://example.com/1234" }
66
+ }
67
+ expect { EdgeGatewayInterface.new(bad_input) }.to raise_error("Argument error: must have a :Network[:name]")
68
+ end
69
+
70
+ end
71
+
72
+ context "#name" do
73
+ it "should return the name of the interface" do
74
+ expect(@interface.name).to eq('EXTERNAL_NETWORK')
75
+ end
76
+ end
77
+
78
+ context "#network_id" do
79
+ it "should return the id of the network the interface is connected to" do
80
+ expect(@interface.network_id).to eq(@valid_ext_id)
81
+ end
82
+ end
83
+
84
+ context "#network_name" do
85
+ it "should return the name of the network the interface is connected to" do
86
+ expect(@interface.network_name).to eq('EXTERNAL_NETWORK')
87
+ end
88
+ end
89
+
90
+ context "#network_href" do
91
+ it "should return the href of the network the interface is connected to" do
92
+ expect(@interface.network_href).to eq("https://example.com/api/admin/network/#{@valid_ext_id}")
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -73,7 +73,7 @@ module Vcloud
73
73
 
74
74
  end
75
75
 
76
- context "#vcloud_gateway_interface_by_id" do
76
+ context "Interface related tests" do
77
77
 
78
78
  before(:each) do
79
79
  @valid_ext_id = "12345678-70ac-487e-9c1e-124716764274"
@@ -117,29 +117,42 @@ module Vcloud
117
117
  @edgegw = EdgeGateway.new(@edgegw_id)
118
118
  end
119
119
 
120
- it "should return nil if the network id is not found" do
121
- expect(@edgegw.vcloud_gateway_interface_by_id(
122
- '12345678-1234-1234-1234-123456789012')).
123
- to be_nil
120
+ context "#vcloud_gateway_interface_by_id" do
121
+
122
+ it "should return nil if the network id is not found" do
123
+ expect(@edgegw.vcloud_gateway_interface_by_id(
124
+ '12345678-1234-1234-1234-123456789012')).
125
+ to be_nil
126
+ end
127
+
128
+ it "should return a vcloud network hash if the network id is found" do
129
+ expect(@edgegw.vcloud_gateway_interface_by_id(@valid_int_id)).
130
+ to eq(
131
+ {:Name=>"INTERNAL_NETWORK",
132
+ :Network=>
133
+ {:type=>"application/vnd.vmware.admin.network+xml",
134
+ :name=>"INTERNAL_NETWORK",
135
+ :href=>
136
+ "https://example.com/api/admin/network/#{@valid_int_id}"},
137
+ :InterfaceType=>"internal",
138
+ :SubnetParticipation=>
139
+ {:Gateway=>"192.168.1.1",
140
+ :Netmask=>"255.255.255.0",
141
+ :IpAddress=>"192.168.1.55"},
142
+ :UseForDefaultRoute=>"false"
143
+ },
144
+ )
145
+ end
124
146
  end
125
147
 
126
- it "should return a vcloud network hash if the network id is found" do
127
- expect(@edgegw.vcloud_gateway_interface_by_id(@valid_int_id)).
128
- to eq(
129
- {:Name=>"INTERNAL_NETWORK",
130
- :Network=>
131
- {:type=>"application/vnd.vmware.admin.network+xml",
132
- :name=>"INTERNAL_NETWORK",
133
- :href=>
134
- "https://example.com/api/admin/network/#{@valid_int_id}"},
135
- :InterfaceType=>"internal",
136
- :SubnetParticipation=>
137
- {:Gateway=>"192.168.1.1",
138
- :Netmask=>"255.255.255.0",
139
- :IpAddress=>"192.168.1.55"},
140
- :UseForDefaultRoute=>"false"
141
- },
142
- )
148
+ context "#interfaces" do
149
+
150
+ it "should return an array of EdgeGatewayInterface objects" do
151
+ interfaces_list = @edgegw.interfaces
152
+ expect(interfaces_list.class).to be(Array)
153
+ expect(interfaces_list.first.class).to be(Vcloud::Core::EdgeGatewayInterface)
154
+ end
155
+
143
156
  end
144
157
 
145
158
  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.5
4
+ version: 0.0.6
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-29 00:00:00.000000000 Z
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -117,6 +117,7 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - .gitignore
120
+ - CHANGELOG.md
120
121
  - Gemfile
121
122
  - LICENSE.txt
122
123
  - README.md
@@ -126,6 +127,7 @@ files:
126
127
  - lib/vcloud/core.rb
127
128
  - lib/vcloud/core/compute_metadata.rb
128
129
  - lib/vcloud/core/edge_gateway.rb
130
+ - lib/vcloud/core/edge_gateway_interface.rb
129
131
  - lib/vcloud/core/entity.rb
130
132
  - lib/vcloud/core/metadata_helper.rb
131
133
  - lib/vcloud/core/org_vdc_network.rb
@@ -144,6 +146,7 @@ files:
144
146
  - spec/integration/edge_gateway/edge_gateway_spec.rb
145
147
  - spec/spec_helper.rb
146
148
  - spec/support/stub_fog_interface.rb
149
+ - spec/vcloud/core/edge_gateway_interface_spec.rb
147
150
  - spec/vcloud/core/edge_gateway_spec.rb
148
151
  - spec/vcloud/core/metadata_helper_spec.rb
149
152
  - spec/vcloud/core/org_vdc_network_spec.rb
@@ -178,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
181
  version: '0'
179
182
  segments:
180
183
  - 0
181
- hash: -849601463027409956
184
+ hash: 4034652362745429730
182
185
  requirements: []
183
186
  rubyforge_project:
184
187
  rubygems_version: 1.8.23
@@ -190,6 +193,7 @@ test_files:
190
193
  - spec/integration/edge_gateway/edge_gateway_spec.rb
191
194
  - spec/spec_helper.rb
192
195
  - spec/support/stub_fog_interface.rb
196
+ - spec/vcloud/core/edge_gateway_interface_spec.rb
193
197
  - spec/vcloud/core/edge_gateway_spec.rb
194
198
  - spec/vcloud/core/metadata_helper_spec.rb
195
199
  - spec/vcloud/core/org_vdc_network_spec.rb