vcloud-net_launcher 0.1.0 → 0.2.0

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/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.3
5
+ branches:
6
+ except:
7
+ - master
8
+ notifications:
9
+ email: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.0 (2014-05-14)
2
+
3
+ Features:
4
+
5
+ - Depend on version 0.3.0 of vcloud-core which introduces breaking changes to OrgVdcNetwork
6
+
1
7
  ## 0.1.0 (2014-04-30)
2
8
 
3
9
  Features:
data/README.md CHANGED
@@ -104,14 +104,13 @@ If you want to be sure you are pinning to 5.1, or use 5.5, you can set the API v
104
104
 
105
105
  ## Testing
106
106
 
107
- Default target: `bundle exec rake` runs the cucumber features tests.
107
+ Run the default suite of tests (e.g. lint, unit, features):
108
108
 
109
- `bundle exec rake integration` runs the integration tests.
109
+ bundle exec rake
110
110
 
111
- `bundle exec rake features` runs the cucumber features tests.
111
+ Run the integration tests (slower and requires a real environment):
112
112
 
113
- There are currently no unit tests here, though the bulk of the logic is
114
- tested in vcloud-core.
113
+ bundle exec rake integration
115
114
 
116
115
  You need access to a suitable vCloud Director organization to run the
117
116
  integration tests. It is not necessarily safe to run them against an existing
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'cucumber/rake/task'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'gem_publisher'
4
4
 
5
- task :default => [:features]
5
+ task :default => [:rubocop, :spec, :features]
6
6
 
7
7
  RSpec::Core::RakeTask.new(:spec) do |task|
8
8
  # Set a bogus Fog credential, otherwise it's possible for the unit
@@ -21,7 +21,12 @@ RSpec::Core::RakeTask.new(:integration) do |t|
21
21
  t.pattern = FileList['spec/integration/**/*_spec.rb']
22
22
  end
23
23
 
24
- task :publish_gem do |t|
24
+ task :publish_gem do
25
25
  gem = GemPublisher.publish_if_updated("vcloud-net_launcher.gemspec", :rubygems)
26
26
  puts "Published #{gem}" if gem
27
27
  end
28
+
29
+ require 'rubocop/rake_task'
30
+ Rubocop::RakeTask.new(:rubocop) do |task|
31
+ task.options = ['--lint']
32
+ end
@@ -1,3 +1,3 @@
1
- Then(/^the banner should document that this app takes (\d+) argument$/) do |arg1|
1
+ Then(/^the banner should document that this app takes (\d+) argument$/) do
2
2
  pending # express the regexp above with the code you wish you had
3
3
  end
@@ -19,7 +19,7 @@ module Vcloud
19
19
  net_config[:fence_mode] ||= 'isolated'
20
20
  Vcloud::Core.logger.info("Provisioning orgVdcNetwork #{net_config[:name]}.")
21
21
  begin
22
- net = Vcloud::Core::OrgVdcNetwork.provision(net_config)
22
+ Vcloud::Core::OrgVdcNetwork.provision(net_config)
23
23
  rescue RuntimeError => e
24
24
  Vcloud::Core.logger.error("Could not provision orgVdcNetwork: #{e.message}")
25
25
  raise
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module NetLauncher
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -36,30 +36,35 @@ describe Vcloud::Core::OrgVdcNetwork do
36
36
  end
37
37
 
38
38
  it 'should have a name' do
39
- expect(@net.name) == @config[:name]
39
+ expect(@net.name).to eq(@config[:name])
40
40
  end
41
41
 
42
- it 'should have a :gateway attribute' do
43
- expect(@net.vcloud_attributes[:gateway]) == @config[:gateway]
42
+ it 'should have a :Gateway attribute' do
43
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Gateway]).
44
+ to eq(@config[:gateway])
44
45
  end
45
46
 
46
- it 'should have a :netmask attribute' do
47
- expect(@net.vcloud_attributes[:gateway]) == @config[:netmask]
47
+ it 'should have a :Netmask attribute' do
48
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Netmask]).
49
+ to eq(@config[:netmask])
48
50
  end
49
51
 
50
- it 'should have a :dns1 attribute' do
51
- expect(@net.vcloud_attributes[:dns1]) == @config[:dns1]
52
+ it 'should have a :Dns1 attribute' do
53
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Dns1]).
54
+ to eq(@config[:dns1])
52
55
  end
53
56
 
54
- it 'should have a :dns2 attribute' do
55
- expect(@net.vcloud_attributes[:dns2]) == @config[:dns2]
57
+ it 'should have a :Dns2 attribute' do
58
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Dns2]).
59
+ to eq(@config[:dns2])
56
60
  end
57
61
 
58
- it 'should have an :ip_ranges attribute' do
59
- expect(@net.vcloud_attributes[:ip_ranges]) == [
60
- {:start_address=>"10.88.11.200", :end_address=>"10.88.11.250"},
61
- {:start_address=>"10.88.11.100", :end_address=>"10.88.11.150"}
62
- ]
62
+ it 'should have an :IpRange list with each of our ranges' do
63
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:IpRanges][:IpRange]).
64
+ to match_array([
65
+ { :StartAddress => '10.88.11.100', :EndAddress => '10.88.11.150' },
66
+ { :StartAddress => '10.88.11.200', :EndAddress => '10.88.11.250' },
67
+ ])
63
68
  end
64
69
 
65
70
  after(:all) do
@@ -102,30 +107,35 @@ describe Vcloud::Core::OrgVdcNetwork do
102
107
  end
103
108
 
104
109
  it 'should have a name' do
105
- expect(@net.name) == @config[:name]
110
+ expect(@net.name).to eq(@config[:name])
106
111
  end
107
112
 
108
113
  it 'should have a :gateway attribute' do
109
- expect(@net.vcloud_attributes[:gateway]) == @config[:gateway]
114
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Gateway]).
115
+ to eq(@config[:gateway])
110
116
  end
111
117
 
112
118
  it 'should have a :netmask attribute' do
113
- expect(@net.vcloud_attributes[:gateway]) == @config[:netmask]
119
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Netmask]).
120
+ to eq(@config[:netmask])
114
121
  end
115
122
 
116
123
  it 'should have a :dns1 attribute' do
117
- expect(@net.vcloud_attributes[:dns1]) == @config[:dns1]
124
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Dns1]).
125
+ to eq(@config[:dns1])
118
126
  end
119
127
 
120
128
  it 'should have a :dns2 attribute' do
121
- expect(@net.vcloud_attributes[:dns2]) == @config[:dns2]
129
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:Dns2]).
130
+ to eq(@config[:dns2])
122
131
  end
123
132
 
124
- it 'should have an :ip_ranges attribute' do
125
- expect(@net.vcloud_attributes[:ip_ranges]) == [
126
- {:start_address=>"10.88.11.200", :end_address=>"10.88.11.250"},
127
- {:start_address=>"10.88.11.100", :end_address=>"10.88.11.150"}
128
- ]
133
+ it 'should have an :ip_ranges list with each of our ranges' do
134
+ expect(@net.vcloud_attributes[:Configuration][:IpScopes][:IpScope][:IpRanges][:IpRange]).
135
+ to match_array([
136
+ { :StartAddress => '10.88.11.100', :EndAddress => '10.88.11.150' },
137
+ { :StartAddress => '10.88.11.200', :EndAddress => '10.88.11.250' },
138
+ ])
129
139
  end
130
140
 
131
141
  after(:all) do
@@ -15,11 +15,11 @@ module Vcloud
15
15
  Vcloud::NetLauncher::NetLaunch.new.run(@minimum_data_yaml)
16
16
 
17
17
  @found_networks = find_network(test_data[:network_name])
18
- @found_networks.length.should == 1
18
+ @found_networks.length.should eq(1)
19
19
  provisioned_network = @found_networks[0]
20
- provisioned_network[:gateway].should == test_data[:gateway]
21
- provisioned_network[:netmask].should == test_data[:netmask]
22
- provisioned_network[:isLinked].should == 'false'
20
+ provisioned_network[:gateway].should eq(test_data[:gateway])
21
+ provisioned_network[:netmask].should eq(test_data[:netmask])
22
+ provisioned_network[:isLinked].should eq('false')
23
23
  end
24
24
 
25
25
  it 'should create an nat routed network' do
@@ -31,11 +31,11 @@ module Vcloud
31
31
 
32
32
  @found_networks = find_network(test_data[:network_name])
33
33
 
34
- @found_networks.length.should == 1
34
+ @found_networks.length.should eq(1)
35
35
  provisioned_network = @found_networks[0]
36
- provisioned_network[:gateway].should == test_data[:gateway]
37
- provisioned_network[:netmask].should == test_data[:netmask]
38
- provisioned_network[:isLinked].should == 'true'
36
+ provisioned_network[:gateway].should eq(test_data[:gateway])
37
+ provisioned_network[:netmask].should eq(test_data[:netmask])
38
+ provisioned_network[:isLinked].should eq('true')
39
39
  end
40
40
 
41
41
  after(:each) do
@@ -43,7 +43,7 @@ module Vcloud
43
43
  File.delete @minimum_data_yaml
44
44
  fog_interface = Vcloud::Fog::ServiceInterface.new
45
45
  provisioned_network_id = @found_networks[0][:href].split('/').last
46
- fog_interface.delete_network(provisioned_network_id).should == true
46
+ fog_interface.delete_network(provisioned_network_id).should be(true)
47
47
  end
48
48
  end
49
49
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
1
  require 'erb_helper'
2
2
  require 'bundler/setup'
3
3
  require 'vcloud/net_launcher'
4
- require 'support/stub_fog_interface.rb'
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vcloud::NetLauncher::NetLaunch do
4
+ context "ConfigLoader returns three different networks" do
5
+ let!(:network1) {
6
+ {
7
+ :name => 'Network 1',
8
+ :vdc_name => 'TestVDC',
9
+ :fence_mode => 'isolated',
10
+ :netmask => '255.255.255.0',
11
+ :gateway => '10.0.1.1',
12
+ :edge_gateway => 'TestVSE',
13
+ }
14
+ }
15
+ let!(:network2) {
16
+ {
17
+ :name => 'Network 2',
18
+ :vdc_name => 'TestVDC',
19
+ :fence_mode => 'natRouted',
20
+ :netmask => '255.255.0.0',
21
+ :gateway => '10.0.2.1',
22
+ :edge_gateway => 'TestVSE',
23
+ }
24
+ }
25
+ let!(:network3) {
26
+ {
27
+ :name => 'Network 3',
28
+ :vdc_name => 'TestVDC',
29
+ :fence_mode => 'natRouted',
30
+ :netmask => '355.255.0.0',
31
+ :gateway => '10.0.3.1',
32
+ :edge_gateway => 'TestVSE',
33
+ }
34
+ }
35
+
36
+ before(:each) do
37
+ config_loader = double(:config_loader)
38
+ expect(Vcloud::Core::ConfigLoader).to receive(:new).and_return(config_loader)
39
+ expect(config_loader).to receive(:load_config).and_return({
40
+ :org_vdc_networks => [network1, network2, network3],
41
+ })
42
+ end
43
+
44
+ it "should call provision once for each network" do
45
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).with(network1)
46
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).with(network2)
47
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).with(network3)
48
+
49
+ cli_options = {}
50
+ subject.run('input_config_yaml', cli_options)
51
+ end
52
+
53
+ it "should abort on errors from Vcloud::Core" do
54
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).with(network1)
55
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).with(network2).
56
+ and_raise(RuntimeError.new('Did not successfully create orgVdcNetwork'))
57
+ expect(Vcloud::Core::OrgVdcNetwork).not_to receive(:provision).with(network3)
58
+
59
+ cli_options = {}
60
+ expect {
61
+ Vcloud::NetLauncher::NetLaunch.new.run('input_config_yaml', cli_options)
62
+ }.to raise_error(RuntimeError, 'Did not successfully create orgVdcNetwork')
63
+ end
64
+
65
+ describe "fog mocking" do
66
+ it "should not mock fog by default" do
67
+ expect(Fog).to_not receive(:mock!)
68
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).exactly(3).times
69
+
70
+ cli_options = {}
71
+ subject.run('input_config_yaml', cli_options)
72
+ end
73
+
74
+ it "should mock fog when passed option" do
75
+ expect(Fog).to receive(:mock!)
76
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).exactly(3).times
77
+
78
+ cli_options = { :mock => true }
79
+ subject.run('input_config_yaml', cli_options)
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ context "ConfigLoader returns one network without :fence_mode set" do
86
+ let!(:network_without_fence_mode) {
87
+ {
88
+ :name => 'Network w/o fence_mode',
89
+ :vdc_name => 'TestVDC',
90
+ :netmask => '255.255.255.0',
91
+ :gateway => '10.0.1.1',
92
+ :edge_gateway => 'TestVSE',
93
+ }
94
+ }
95
+
96
+ before(:each) do
97
+ config_loader = double(:config_loader)
98
+ expect(Vcloud::Core::ConfigLoader).to receive(:new).and_return(config_loader)
99
+ expect(config_loader).to receive(:load_config).and_return({
100
+ :org_vdc_networks => [network_without_fence_mode],
101
+ })
102
+ end
103
+
104
+ it "should default :fence_mode to isolated" do
105
+ network_with_fence_mode = network_without_fence_mode.merge({
106
+ :fence_mode => 'isolated',
107
+ })
108
+
109
+ network_without_fence_mode.should_not have_key(:fence_mode)
110
+ expect(Vcloud::Core::OrgVdcNetwork).to receive(:provision).with(network_with_fence_mode)
111
+
112
+ cli_options = {}
113
+ subject.run('input_config_yaml', cli_options)
114
+ end
115
+ end
116
+ end
@@ -23,11 +23,12 @@ Gem::Specification.new do |s|
23
23
  s.required_ruby_version = '>= 1.9.2'
24
24
 
25
25
  s.add_runtime_dependency 'methadone'
26
- s.add_runtime_dependency 'vcloud-core', '~> 0.2.0'
26
+ s.add_runtime_dependency 'vcloud-core', '~> 0.3.0'
27
27
  s.add_development_dependency 'aruba', '~> 0.5.3'
28
28
  s.add_development_dependency 'cucumber', '~> 1.3.10'
29
29
  s.add_development_dependency 'gem_publisher', '1.2.0'
30
30
  s.add_development_dependency 'rake'
31
31
  s.add_development_dependency 'rspec', '~> 2.14.1'
32
+ s.add_development_dependency 'rubocop'
32
33
  end
33
34
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcloud-net_launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-05-06 00:00:00.000000000 Z
12
+ date: 2014-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: methadone
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.2.0
37
+ version: 0.3.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.2.0
45
+ version: 0.3.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: aruba
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
125
  version: 2.14.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  description: Tool to launch and configure vCloud networks. Uses vcloud-core.
127
143
  email:
128
144
  - anna.shipman@digital.cabinet-office.gov.uk
@@ -132,13 +148,13 @@ extensions: []
132
148
  extra_rdoc_files: []
133
149
  files:
134
150
  - .gitignore
151
+ - .travis.yml
135
152
  - CHANGELOG.md
136
153
  - Gemfile
137
154
  - LICENSE.txt
138
155
  - README.md
139
156
  - Rakefile
140
157
  - bin/vcloud-net-launch
141
- - examples/.fog-example.fog
142
158
  - examples/vcloud-net-launch/example-config.yaml
143
159
  - features/step_definitions/vcloud-launch_steps.rb
144
160
  - features/support/env.rb
@@ -154,7 +170,7 @@ files:
154
170
  - spec/integration/net_launcher/org_vdc_network_spec.rb
155
171
  - spec/integration/net_launcher/vcloud_net_launcher_spec.rb
156
172
  - spec/spec_helper.rb
157
- - spec/support/stub_fog_interface.rb
173
+ - spec/vcloud/net_launcher/net_launch_spec.rb
158
174
  - tools/fog_credentials.rb
159
175
  - vcloud-net_launcher.gemspec
160
176
  homepage: http://github.com/alphagov/vcloud-net_launcher
@@ -178,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
194
  version: '0'
179
195
  segments:
180
196
  - 0
181
- hash: 4125401217608110122
197
+ hash: -3237069924497883805
182
198
  requirements: []
183
199
  rubyforge_project:
184
200
  rubygems_version: 1.8.23
@@ -194,4 +210,4 @@ test_files:
194
210
  - spec/integration/net_launcher/org_vdc_network_spec.rb
195
211
  - spec/integration/net_launcher/vcloud_net_launcher_spec.rb
196
212
  - spec/spec_helper.rb
197
- - spec/support/stub_fog_interface.rb
213
+ - spec/vcloud/net_launcher/net_launch_spec.rb
@@ -1,15 +0,0 @@
1
- p1-production:
2
- vcloud_director_username: '<username_from_top_right_of_skyscape_flash_ui>@<org_id_from_url_in_skyscape_flash_ui>'
3
- vcloud_director_password: '<your_skyscape_password>'
4
- vcloud_director_host: 'vcd.portal.skyscapecloud.com'
5
-
6
- # You can extract this information by logging into skyscape portal
7
- performance-platform-production:
8
- vcloud_director_username: '<xxx.x.xxxxxx>@<x-x-xx-xxxxxx>'
9
- vcloud_director_password: '<your_skyscape_password>'
10
- vcloud_director_host: 'vcd.portal.skyscapecloud.com'
11
-
12
- carrenza-preview:
13
- vcloud_director_username: '<email>@<org_id>'
14
- vcloud_director_password: ''
15
- vcloud_director_host: 'myvdc.carrenza.net'
@@ -1,59 +0,0 @@
1
- require 'ostruct'
2
-
3
- class StubFogInterface
4
-
5
- def name
6
- 'Test vDC 1'
7
- end
8
-
9
- def vdc_object_by_name(vdc_name)
10
- vdc = OpenStruct.new
11
- vdc.name = 'test-vdc-1'
12
- vdc
13
- end
14
-
15
- def template
16
- { :href => '/vappTemplate-12345678-90ab-cdef-0123-4567890abcde' }
17
- end
18
-
19
- def find_networks(network_names, vdc_name)
20
- [{
21
- :name => 'org-vdc-1-net-1',
22
- :href => '/org-vdc-1-net-1-id',
23
- }]
24
- end
25
-
26
- def get_vapp(id)
27
- { :name => 'test-vapp-1' }
28
- end
29
-
30
- def get_edge_gateway(id)
31
- {
32
- :name => 'test-edgegw-1',
33
- :href => "/#{id}",
34
- }
35
- end
36
-
37
- def vdc(name)
38
- { }
39
- end
40
-
41
- def post_instantiate_vapp_template(vdc, template, name, params)
42
- {
43
- :href => '/test-vapp-1-id',
44
- :Children => {
45
- :Vm => ['bogus vm data']
46
- }
47
- }
48
- end
49
-
50
- def get_vapp_by_vdc_and_name
51
- { }
52
- end
53
-
54
- def template(catalog_name, name)
55
- { :href => '/vappTemplate-12345678-90ab-cdef-0123-4567890abcde' }
56
- end
57
-
58
-
59
- end