vcloud-launcher 0.3.1 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.4.0 (2014-09-11)
2
+
3
+ - Upgrade dependency on vCloud Core to 0.11.0 which prevents plaintext
4
+ passwords in FOG_RC. Please use tokens via vcloud-login as per
5
+ the documentation: http://gds-operations.github.io/vcloud-tools/usage/
6
+
1
7
  ## 0.3.1 (2014-08-11)
2
8
 
3
9
  Maintenance:
@@ -19,7 +19,8 @@ module Vcloud
19
19
 
20
20
  def run
21
21
  begin
22
- Vcloud::Launcher::Launch.new.run(@config_file, @options)
22
+ launch = Vcloud::Launcher::Launch.new(@config_file, @options)
23
+ launch.run
23
24
  rescue => error_msg
24
25
  $stderr.puts(error_msg)
25
26
  exit 1
@@ -5,23 +5,23 @@ module Vcloud
5
5
  class MissingPreambleError < RuntimeError ; end
6
6
  class MissingConfigurationError < RuntimeError ; end
7
7
 
8
- attr_reader :config
8
+ attr_reader :config, :cli_options
9
9
 
10
- def initialize
11
- @config_loader = Vcloud::Core::ConfigLoader.new
12
- end
10
+ def initialize(config_file, cli_options = {})
11
+ config_loader = ::Vcloud::Core::ConfigLoader.new
12
+ @cli_options = cli_options
13
13
 
14
- def run(config_file = nil, cli_options = {})
15
- set_logging_level(cli_options)
16
- @config = @config_loader.load_config(config_file, Vcloud::Launcher::Schema::LAUNCHER_VAPPS)
14
+ set_logging_level
15
+ @config = config_loader.load_config(config_file, Vcloud::Launcher::Schema::LAUNCHER_VAPPS)
17
16
 
18
17
  validate_config
18
+ end
19
19
 
20
- config[:vapps].each do |vapp_config|
20
+ def run
21
+ @config[:vapps].each do |vapp_config|
21
22
  Vcloud::Core.logger.info("Provisioning vApp #{vapp_config[:name]}.")
22
23
  begin
23
24
  vapp = ::Vcloud::Launcher::VappOrchestrator.provision(vapp_config)
24
- #methadone sends option starting with 'no' as false.
25
25
  vapp.power_on unless cli_options["dont-power-on"]
26
26
  Vcloud::Core.logger.info("Provisioned vApp #{vapp_config[:name]} successfully.")
27
27
  rescue RuntimeError => e
@@ -32,7 +32,9 @@ module Vcloud
32
32
  end
33
33
  end
34
34
 
35
- def set_logging_level(cli_options)
35
+ private
36
+
37
+ def set_logging_level
36
38
  if cli_options[:verbose]
37
39
  Vcloud::Core.logger.level = Logger::DEBUG
38
40
  elsif cli_options[:quiet]
@@ -42,8 +44,6 @@ module Vcloud
42
44
  end
43
45
  end
44
46
 
45
- private
46
-
47
47
  def validate_config
48
48
  @config[:vapps].each do |vapp_config|
49
49
  validate_vapp_config(vapp_config)
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Launcher
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ describe Vcloud::Launcher::Launch do
12
12
  @minimum_data_yaml = ErbHelper.convert_erb_template_to_yaml(test_data_1, minimum_data_erb)
13
13
  @api_interface = Vcloud::Core::ApiInterface.new
14
14
 
15
- Vcloud::Launcher::Launch.new.run(@minimum_data_yaml, {"dont-power-on" => true})
15
+ Vcloud::Launcher::Launch.new(@minimum_data_yaml, {"dont-power-on" => true}).run
16
16
 
17
17
  vapp_query_result = @api_interface.get_vapp_by_name_and_vdc_name(test_data_1[:vapp_name], test_data_1[:vdc_name])
18
18
  @provisioned_vapp_id = vapp_query_result[:href].split('/').last
@@ -36,7 +36,7 @@ describe Vcloud::Launcher::Launch do
36
36
  @test_data = define_test_data
37
37
  @config_yaml = ErbHelper.convert_erb_template_to_yaml(@test_data, File.join(File.dirname(__FILE__), 'data/happy_path.yaml.erb'))
38
38
  @api_interface = Vcloud::Core::ApiInterface.new
39
- Vcloud::Launcher::Launch.new.run(@config_yaml, { "dont-power-on" => true })
39
+ Vcloud::Launcher::Launch.new(@config_yaml, { "dont-power-on" => true }).run
40
40
 
41
41
  @vapp_query_result = @api_interface.get_vapp_by_name_and_vdc_name(@test_data[:vapp_name], @test_data[:vdc_name])
42
42
  @vapp_id = @vapp_query_result[:href].split('/').last
@@ -7,7 +7,7 @@ describe Vcloud::Launcher::Launch do
7
7
  @test_data = define_test_data
8
8
  @config_yaml = ErbHelper.convert_erb_template_to_yaml(@test_data, File.join(File.dirname(__FILE__), 'data/storage_profile.yaml.erb'))
9
9
  @api_interface = Vcloud::Core::ApiInterface.new
10
- Vcloud::Launcher::Launch.new.run(@config_yaml, {'dont-power-on' => true})
10
+ Vcloud::Launcher::Launch.new(@config_yaml, {'dont-power-on' => true}).run
11
11
 
12
12
  @vapp_query_result_1 = @api_interface.get_vapp_by_name_and_vdc_name(@test_data[:vapp_name_1], @test_data[:vdc_1_name])
13
13
  @vapp_id_1 = @vapp_query_result_1[:href].split('/').last
@@ -38,9 +38,8 @@ describe Vcloud::Launcher::Cli do
38
38
  shared_examples "a good CLI command" do
39
39
  it "passes the right CLI options and exits normally" do
40
40
  expect(Vcloud::Launcher::Launch).to receive(:new).
41
- and_return(mock_launch)
42
- expect(mock_launch).to receive(:run).
43
- with(config_file, cli_options)
41
+ with(config_file, cli_options).and_return(mock_launch)
42
+
44
43
  expect(subject.exitstatus).to eq(0)
45
44
  end
46
45
  end
@@ -156,6 +155,24 @@ describe Vcloud::Launcher::Cli do
156
155
  end
157
156
  end
158
157
 
158
+ describe '.run' do
159
+ let(:mock_launch) { double(:launch, :run => true) }
160
+
161
+ subject { Vcloud::Launcher::Cli.new([ config_file ]) }
162
+
163
+ it 'calls Vcloud::Launcher::Launch.run' do
164
+ allow( Vcloud::Launcher::Launch).to receive(:new).and_return(mock_launch)
165
+
166
+ expect(mock_launch).to receive(:run)
167
+
168
+ begin
169
+ subject.run
170
+ rescue SystemExit => e
171
+ e.exitstatus
172
+ end
173
+ end
174
+ end
175
+
159
176
  describe "incorrect usage" do
160
177
  shared_examples "print usage and exit abnormally" do |error|
161
178
  it "does not call Launch" do
@@ -1,72 +1,141 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vcloud::Launcher::Launch do
4
- context "#run" do
5
- before(:each) do
6
- config_loader = double(:config_loader)
7
- expect(Vcloud::Core::ConfigLoader).to receive(:new).and_return(config_loader)
8
- @successful_app_1 = {
9
- :name => "successful app 1",
10
- :vdc_name => "Test Vdc",
11
- :catalog_name => "default",
12
- :vapp_template_name => "ubuntu-precise"
13
- }
14
- @fake_failing_app = {
15
- :name => "fake failing app",
16
- :vdc_name => "wrong vdc",
17
- :catalog_name => "default",
18
- :vapp_template_name => "ubuntu-precise"
19
- }
20
- @successful_app_2 = {
21
- :name => "successful app 2",
22
- :vdc_name => "Test Vdc",
23
- :catalog_name => "default",
24
- :vapp_template_name => "ubuntu-precise"
25
- }
26
- expect(config_loader).to receive(:load_config).
27
- and_return({:vapps => [@successful_app_1, @fake_failing_app, @successful_app_2]})
4
+ let(:good_vapp_one) do
5
+ {
6
+ name: "successful app 1",
7
+ vdc_name: "Test Vdc",
8
+ catalog_name: "default",
9
+ vapp_template_name: "ubuntu-precise"
10
+ }
11
+ end
12
+ let(:good_vapp_two) do
13
+ {
14
+ name: "successful app 2",
15
+ vdc_name: "Test Vdc",
16
+ catalog_name: "default",
17
+ vapp_template_name: "ubuntu-precise"
18
+ }
19
+ end
20
+ let(:bad_vapp_one) do
21
+ {
22
+ name: "fake failing app",
23
+ vdc_name: "wrong vdc",
24
+ catalog_name: "default",
25
+ vapp_template_name: "ubuntu-precise"
26
+ }
27
+ end
28
+
29
+ let(:config) do
30
+ { vapps: [ good_vapp_one, bad_vapp_one, good_vapp_two ] }
31
+ end
32
+
33
+ let(:config_file) { 'foo.yml' }
34
+ let(:config_loader) { double(:config_loader) }
35
+
36
+ before do
37
+ allow(Vcloud::Core::ConfigLoader).to receive(:new).and_return(config_loader)
38
+ allow(config_loader).to receive(:load_config).and_return(config)
39
+ end
40
+
41
+ describe '#new' do
42
+ subject { Vcloud::Launcher::Launch }
43
+
44
+ context 'with minimally correct configuration' do
45
+ it 'does not raise an error' do
46
+ expect{ subject.new(config_file) }.not_to raise_error
47
+ end
48
+
49
+ it 'loads configuration' do
50
+ config_loader.should_receive(:load_config).and_return(config)
51
+ subject.new(config_file)
52
+ end
53
+
54
+ it 'validates the configuration' do
55
+ subject.any_instance.should_receive(:validate_config)
56
+ subject.new(config_file)
57
+ end
58
+ end
59
+
60
+ context 'without a configuration file' do
61
+ it 'raises an error' do
62
+ expect { subject.new }.to raise_error(ArgumentError)
63
+ end
28
64
  end
65
+ end
29
66
 
30
- it "should stop on failure by default" do
31
- expect(Vcloud::Launcher::VappOrchestrator).to receive(:provision).with(@successful_app_1).and_return(double(:vapp, :power_on => true))
32
- expect(Vcloud::Launcher::VappOrchestrator).to receive(:provision).with(@fake_failing_app).and_raise(RuntimeError.new('failed to find vdc'))
33
- expect(Vcloud::Launcher::VappOrchestrator).not_to receive(:provision).with(@successful_app_2)
67
+ context "#run" do
68
+ subject { Vcloud::Launcher::Launch.new(config_file, cli_options) }
34
69
 
35
- cli_options = {}
36
- subject.run('input_config_yaml', cli_options)
70
+ before do
71
+ allow(Vcloud::Launcher::VappOrchestrator).to receive(:provision).
72
+ with(good_vapp_one).and_return(double(:vapp, power_on: true))
37
73
  end
38
74
 
39
- it "should continue on error if cli option continue-on-error is set" do
40
- expect(Vcloud::Launcher::VappOrchestrator).to receive(:provision).with(@successful_app_1).and_return(double(:vapp, :power_on => true))
41
- expect(Vcloud::Launcher::VappOrchestrator).to receive(:provision).with(@fake_failing_app).and_raise(RuntimeError.new('failed to find vdc'))
42
- expect(Vcloud::Launcher::VappOrchestrator).to receive(:provision).with(@successful_app_2).and_return(double(:vapp, :power_on => true))
75
+ context "default behaviour on failure" do
76
+ let(:cli_options) { {} }
77
+
78
+ it "should stop" do
79
+ allow(Vcloud::Launcher::VappOrchestrator).to receive(:provision).
80
+ with(bad_vapp_one).and_raise(RuntimeError.new('failed to find vdc'))
81
+
82
+ expect(Vcloud::Launcher::VappOrchestrator).not_to receive(:provision).with(good_vapp_two)
43
83
 
44
- cli_options = {"continue-on-error" => true}
45
- subject.run('input_config_yaml', cli_options)
84
+ subject.run
85
+ end
46
86
  end
47
87
 
88
+ context "with continue-on-error set" do
89
+ let(:cli_options) { {"continue-on-error" => true} }
90
+
91
+ it "should continue" do
92
+ allow(Vcloud::Launcher::VappOrchestrator).to receive(:provision).
93
+ with(bad_vapp_one).and_raise(RuntimeError.new('failed to find vdc'))
94
+
95
+ expect(Vcloud::Launcher::VappOrchestrator).to receive(:provision).with(good_vapp_two).and_return(double(:vapp, :power_on => true))
96
+
97
+ subject.run
98
+ end
99
+ end
48
100
  end
49
101
 
50
102
  context "#set_logging_level" do
103
+ subject { Vcloud::Launcher::Launch.new(config_file, cli_options) }
104
+
105
+ describe "default log level" do
106
+ let(:cli_options) { {} }
51
107
 
52
- it "sets the logging level to DEBUG when :verbose is specified" do
53
- expect(Vcloud::Core.logger).to receive(:level=).with(Logger::DEBUG)
54
- subject.set_logging_level(:verbose => true)
108
+ it "sets the logging level to INFO" do
109
+ expect(Vcloud::Core.logger).to receive(:level=).with(Logger::INFO)
110
+ subject
111
+ end
55
112
  end
56
113
 
57
- it "sets the logging level to ERROR when :quiet is specified" do
58
- expect(Vcloud::Core.logger).to receive(:level=).with(Logger::ERROR)
59
- subject.set_logging_level(:quiet => true)
114
+ describe "when :verbose is specified" do
115
+ let(:cli_options) { { verbose: true } }
116
+
117
+ it "sets the logging level to DEBUG" do
118
+ expect(Vcloud::Core.logger).to receive(:level=).with(Logger::DEBUG)
119
+ subject
120
+ end
60
121
  end
61
122
 
62
- it "sets the logging level to DEBUG when :quiet and :verbose are specified" do
63
- expect(Vcloud::Core.logger).to receive(:level=).with(Logger::DEBUG)
64
- subject.set_logging_level(:quiet => true, :verbose => true)
123
+ describe "when :quiet is specified" do
124
+ let(:cli_options) { { quiet: true } }
125
+
126
+ it "sets the logging level to ERROR" do
127
+ expect(Vcloud::Core.logger).to receive(:level=).with(Logger::ERROR)
128
+ subject
129
+ end
65
130
  end
66
131
 
67
- it "sets the logging level to INFO by default" do
68
- expect(Vcloud::Core.logger).to receive(:level=).with(Logger::INFO)
69
- subject.set_logging_level({})
132
+ describe "when :quiet and :verbose are specified" do
133
+ let(:cli_options) { { quiet: true, verbose: true } }
134
+
135
+ it "sets the logging level to DEBUG when :quiet and :verbose are specified" do
136
+ expect(Vcloud::Core.logger).to receive(:level=).with(Logger::DEBUG)
137
+ subject
138
+ end
70
139
  end
71
140
  end
72
141
 
@@ -80,7 +149,7 @@ describe Vcloud::Launcher::Launch do
80
149
  to receive(:provision).and_return(double(:vapp, :power_on => true))
81
150
  end
82
151
 
83
- subject { Vcloud::Launcher::Launch.new }
152
+ subject { Vcloud::Launcher::Launch.new(config_file) }
84
153
 
85
154
  context "when bootstrap configuration is supplied" do
86
155
  context "script_path is missing" do
@@ -100,7 +169,7 @@ describe Vcloud::Launcher::Launch do
100
169
  end
101
170
 
102
171
  it "raises MissingConfigurationError" do
103
- expect{ subject.run(config_file) }.
172
+ expect{ subject }.
104
173
  to raise_error(Vcloud::Launcher::Launch::MissingConfigurationError)
105
174
  end
106
175
  end
@@ -123,7 +192,7 @@ describe Vcloud::Launcher::Launch do
123
192
  end
124
193
 
125
194
  it "raises MissingPreambleError" do
126
- expect{ subject.run(config_file) }.
195
+ expect{ subject }.
127
196
  to raise_error(Vcloud::Launcher::Launch::MissingPreambleError)
128
197
  end
129
198
  end
@@ -154,7 +223,7 @@ describe Vcloud::Launcher::Launch do
154
223
  # A rather overly specific test to find the message of
155
224
  # interest amongst other log messages.
156
225
  expect(Vcloud::Core.logger).to receive(:info).with(/without variables to template/)
157
- subject.run(config_file)
226
+ subject
158
227
  end
159
228
  end
160
229
  end
@@ -173,7 +242,7 @@ describe Vcloud::Launcher::Launch do
173
242
  end
174
243
 
175
244
  it "should not raise an error" do
176
- expect{ subject.run(config_file) }.not_to raise_error
245
+ expect{ subject }.not_to raise_error
177
246
  end
178
247
  end
179
248
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.required_ruby_version = '>= 1.9.3'
22
22
 
23
- s.add_runtime_dependency 'vcloud-core', '~> 0.10.0'
23
+ s.add_runtime_dependency 'vcloud-core', '~> 0.11.0'
24
24
  s.add_development_dependency 'gem_publisher', '1.2.0'
25
25
  s.add_development_dependency 'pry'
26
26
  s.add_development_dependency 'rake'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcloud-launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,43 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-11 00:00:00.000000000 Z
12
+ date: 2014-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vcloud-core
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &5183540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.10.0
21
+ version: 0.11.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.10.0
24
+ version_requirements: *5183540
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: gem_publisher
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &5182780 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
- - - '='
30
+ - - =
36
31
  - !ruby/object:Gem::Version
37
32
  version: 1.2.0
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - '='
44
- - !ruby/object:Gem::Version
45
- version: 1.2.0
35
+ version_requirements: *5182780
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: pry
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &5182260 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: '0'
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
46
+ version_requirements: *5182260
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: rake
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &5181560 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ! '>='
@@ -69,15 +54,10 @@ dependencies:
69
54
  version: '0'
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
57
+ version_requirements: *5181560
78
58
  - !ruby/object:Gem::Dependency
79
59
  name: rspec
80
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &5180780 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
63
  - - ~>
@@ -85,15 +65,10 @@ dependencies:
85
65
  version: 2.14.1
86
66
  type: :development
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: 2.14.1
68
+ version_requirements: *5180780
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: rubocop
96
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &5179260 !ruby/object:Gem::Requirement
97
72
  none: false
98
73
  requirements:
99
74
  - - ~>
@@ -101,15 +76,10 @@ dependencies:
101
76
  version: 0.23.0
102
77
  type: :development
103
78
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 0.23.0
79
+ version_requirements: *5179260
110
80
  - !ruby/object:Gem::Dependency
111
81
  name: simplecov
112
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &5177520 !ruby/object:Gem::Requirement
113
83
  none: false
114
84
  requirements:
115
85
  - - ~>
@@ -117,15 +87,10 @@ dependencies:
117
87
  version: 0.7.1
118
88
  type: :development
119
89
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: 0.7.1
90
+ version_requirements: *5177520
126
91
  - !ruby/object:Gem::Dependency
127
92
  name: vcloud-tools-tester
128
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &5192280 !ruby/object:Gem::Requirement
129
94
  none: false
130
95
  requirements:
131
96
  - - ~>
@@ -133,12 +98,7 @@ dependencies:
133
98
  version: 0.2.0
134
99
  type: :development
135
100
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: 0.2.0
101
+ version_requirements: *5192280
142
102
  description:
143
103
  email:
144
104
  - anna.shipman@digital.cabinet-office.gov.uk
@@ -211,10 +171,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
171
  version: '0'
212
172
  segments:
213
173
  - 0
214
- hash: -4291001892380431135
174
+ hash: -1721812803548595572
215
175
  requirements: []
216
176
  rubyforge_project:
217
- rubygems_version: 1.8.23
177
+ rubygems_version: 1.8.11
218
178
  signing_key:
219
179
  specification_version: 3
220
180
  summary: Tool to launch and configure vCloud vApps