vcloud-launcher 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,15 +2,10 @@
2
2
  *.rbc
3
3
  *.swp
4
4
  *.un~
5
- vcloud_env.sh
6
- replace_variables.sh
7
5
  /.bundle/
8
6
  /.ruby-version
9
7
  /Gemfile.lock
10
8
  /bundle/
11
9
  /pkg/
12
- vendor/
13
- coverage/
14
- results.html
15
10
  fog_integration_test.config
16
11
  .idea
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.4 (2014-05-01)
2
+
3
+ - Use pessimistic version dependency for vcloud-core
4
+
1
5
  ## 0.0.3 (2014-04-22)
2
6
 
3
7
  Features:
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  vCloud Launcher
2
2
  ===============
3
- A tool that takes a YAML or JSON configuration file describing a vDC, and provisions
4
- the vApps and VMs contained within.
3
+ A tool that takes a YAML or JSON configuration file describing a vDC, and
4
+ provisions the vApps and VMs contained within.
5
5
 
6
6
  ### Supports
7
7
 
@@ -14,10 +14,15 @@ the vApps and VMs contained within.
14
14
 
15
15
  ### Limitations
16
16
 
17
- - Source vApp Template must contain a single VM. This is VMware's recommended 'simple' method of vApp creation. Complex multi-VM vApps are not supported.
17
+ - Source vApp Template must contain a single VM. This is VMware's recommended
18
+ 'simple' method of vApp creation. Complex multi-VM vApps are not supported.
18
19
  - Org vDC Networks must be precreated.
19
- - IP addresses are assigned manually (recommended) or via DHCP. VM IP pools are not supported.
20
- - vCloud has some interesting ideas about the size of potential 'guest customisation scripts' (aka preambles). You may need to use an external minify tool to reduce the size, or speak to your provider to up the limit. 2048 bytes seems to be a practical default maximum.
20
+ - IP addresses are assigned manually (recommended) or via DHCP. VM IP pools are
21
+ not supported.
22
+ - vCloud has some interesting ideas about the size of potential 'guest
23
+ customisation scripts' (aka preambles). You may need to use an external minify
24
+ tool to reduce the size, or speak to your provider to up the limit. 2048 bytes
25
+ seems to be a practical default maximum.
21
26
 
22
27
  ## Installation
23
28
 
@@ -40,72 +45,70 @@ Or install it yourself as:
40
45
 
41
46
  ## Credentials
42
47
 
43
- vCloud Launcher uses [Fog](http://fog.io/). To use it you'll need to give it credentials that allow it to talk to a VMware environment. Fog offers two ways to do this.
48
+ vCloud Launcher is based around [fog](http://fog.io/). To use it you'll need to give it
49
+ credentials that allow it to talk to a vCloud Director environment.
44
50
 
45
- ### 1. Create a `.fog` file containing your credentials
51
+ 1. Create a '.fog' file in your home directory.
46
52
 
47
- To use this method, you need a `.fog` file in your home directory.
53
+ For example:
48
54
 
49
- For example:
55
+ test_credentials:
56
+ vcloud_director_host: 'host.api.example.com'
57
+ vcloud_director_username: 'username@org_name'
58
+ vcloud_director_password: ''
50
59
 
51
- test:
52
- vcloud_director_username: 'username@org_name'
53
- vcloud_director_password: 'password'
54
- vcloud_director_host: 'host.api.example.com'
60
+ 2. Obtain a session token. First, curl the API:
55
61
 
56
- Unfortunately current usage of fog requires the password in this file. Multiple sets of credentials can be specified in the fog file, using the following format:
62
+ curl -D- -d '' \
63
+ -H 'Accept: application/*+xml;version=5.1' -u '<username>@<org_name>' \
64
+ https://<host.api.example.com>/api/sessions
57
65
 
58
- test:
59
- vcloud_director_username: 'username@org_name'
60
- vcloud_director_password: 'password'
61
- vcloud_director_host: 'host.api.example.com'
66
+ This will prompt for your password.
62
67
 
63
- test2:
64
- vcloud_director_username: 'username@org_name'
65
- vcloud_director_password: 'password'
66
- vcloud_director_host: 'host.api.vendor.net'
68
+ From the headers returned, the value of the `x-vcloud-authorization` header is your
69
+ session token, and this will be valid for 30 minutes idle - any activity will extend
70
+ its life by another 30 minutes.
67
71
 
68
- You can then pass the `FOG_CREDENTIAL` environment variable at the start of your command. The value of the `FOG_CREDENTIAL` environment variable is the name of the credential set in your fog file which you wish to use. For instance:
72
+ 3. Specify your credentials and session token at the beginning of the command. For example:
69
73
 
70
- FOG_CREDENTIAL=test2 bundle exec vcloud-launch node.yaml
74
+ FOG_CREDENTIAL=test_credentials \
75
+ FOG_VCLOUD_TOKEN=AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF= \
76
+ vcloud-launch node.yaml
71
77
 
72
- To understand more about `.fog` files, visit the 'Credentials' section here => http://fog.io/about/getting_started.html.
78
+ You may find it easier to export one or both of the values as environment variables.
73
79
 
74
- ### 2. Log on externally and supply your session token
80
+ **NB** It is also possible to sidestep the need for the session token by saving your
81
+ password in the fog file. This is **not recommended**.
75
82
 
76
- You can choose to log on externally by interacting independently with the API and supplying your session token to the
77
- tool by setting the `FOG_VCLOUD_TOKEN` ENV variable. This option reduces the risk footprint by allowing the user to
78
- store their credentials in safe storage. The default token lifetime is '30 minutes idle' - any activity extends the life by another 30 mins.
83
+ ## Contributing
79
84
 
80
- A basic example of this would be the following:
85
+ 1. Fork it
86
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
87
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
88
+ 4. Push to the branch (`git push origin my-new-feature`)
89
+ 5. Create new Pull Request
81
90
 
82
- curl
83
- -D-
84
- -d ''
85
- -H 'Accept: application/*+xml;version=5.1' -u '<user>@<org>'
86
- https://host.com/api/sessions
91
+ ## Other settings
87
92
 
88
- This will prompt for your password.
93
+ vCloud Launcher uses vCloud Core. If you want to use the latest version of
94
+ vCloud Core, or a local version, you can export some variables. See the Gemfile
95
+ for details.
89
96
 
90
- From the headers returned, select the header below
97
+ ## The vCloud API
91
98
 
92
- x-vcloud-authorization: AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF=
99
+ vCloud Tools currently use version 5.1 of the [vCloud API](http://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.doc_51%2FGUID-F4BF9D5D-EF66-4D36-A6EB-2086703F6E37.html). Version 5.5 may work but is not currently supported. You should be able to access the 5.1 API in a 5.5 environment, and this *is* currently supported.
93
100
 
94
- Use token as ENV var FOG_VCLOUD_TOKEN
101
+ The default version is defined in [Fog](https://github.com/fog/fog/blob/244a049918604eadbcebd3a8eaaf433424fe4617/lib/fog/vcloud_director/compute.rb#L32).
95
102
 
96
- FOG_VCLOUD_TOKEN=AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF= bundle exec ...
103
+ If you want to be sure you are pinning to 5.1, or use 5.5, you can set the API version to use in your fog file, e.g.
97
104
 
98
- ## Contributing
105
+ `vcloud_director_api_version: 5.1`
99
106
 
100
- 1. Fork it
101
- 2. Create your feature branch (`git checkout -b my-new-feature`)
102
- 3. Commit your changes (`git commit -am 'Add some feature'`)
103
- 4. Push to the branch (`git push origin my-new-feature`)
104
- 5. Create new Pull Request
107
+ ## Debugging
105
108
 
106
- ## Other settings
109
+ `export EXCON_DEBUG=true` - this will print out the API requests and responses.
107
110
 
108
- vCloud Launcher uses vCloud Core. If you want to use the latest version of vCloud Core, or a local version, you can export some variables. See the Gemfile for details.
111
+ `export DEBUG=true` - this will show you the stack trace when there is an exception instead of just the message.
109
112
 
110
113
  ## Testing
111
114
 
@@ -113,9 +116,12 @@ Default target: `bundle exec rake`
113
116
  Runs the unit and feature tests (pretty quick right now)
114
117
 
115
118
  * Unit tests only: `bundle exec rake spec`
119
+ * Feature tests only: `bundle exec rake features`
116
120
  * Integration tests ('quick' tests): `bundle exec rake integration:quick`
117
121
  * Integration tests (all tests - takes 20mins+): `bundle exec rake integration:all`
118
122
 
123
+ NB. `bundle exec rake integration` is an alias for `bundle exec rake integration:all`.
124
+
119
125
  You need access to a suitable vCloud Director organization to run the
120
126
  integration tests. It is not necessarily safe to run them against an existing
121
127
  environment, unless care is taken with the entities being tested.
@@ -140,7 +146,11 @@ Then run this before you run the integration tests.
140
146
 
141
147
  #### Storage profile tests
142
148
 
143
- There is an integration test to check storage profile behaviour, but it requires a lot of set-up so it is not called by the rake task. If you wish to run it you need access to an environment that has two VDCs, each one containing a storage profile with the same name. This named storage profile needs to be different from teh default storage profile.
149
+ There is an integration test to check storage profile behaviour, but it requires
150
+ a lot of set-up so it is not called by the rake task. If you wish to run it you
151
+ need access to an environment that has two VDCs, each one containing a storage
152
+ profile with the same name. This named storage profile needs to be different
153
+ from the default storage profile.
144
154
 
145
155
  You will need to set the following environment variables:
146
156
 
data/Rakefile CHANGED
@@ -1,25 +1,9 @@
1
- require 'rake/clean'
2
- require 'rake/testtask'
3
1
  require 'cucumber/rake/task'
4
2
  require 'rspec/core/rake_task'
3
+ require 'gem_publisher'
5
4
 
6
- require 'vcloud/launcher/version'
7
-
8
- include Rake::DSL
9
-
10
- Bundler::GemHelper.install_tasks
11
-
12
- Rake::TestTask.new do |t|
13
- t.pattern = 'test/tc_*.rb'
14
- end
15
-
16
- CUKE_RESULTS = 'results.html'
17
- CLEAN << CUKE_RESULTS
18
-
19
- Cucumber::Rake::Task.new(:features) do |t|
20
- t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
21
- t.fork = false
22
- end
5
+ task :default => [:spec,:features]
6
+ task :integration => ['integration:all']
23
7
 
24
8
  RSpec::Core::RakeTask.new(:spec) do |task|
25
9
  # Set a bogus Fog credential, otherwise it's possible for the unit
@@ -29,6 +13,11 @@ RSpec::Core::RakeTask.new(:spec) do |task|
29
13
  task.pattern = FileList['spec/vcloud/**/*_spec.rb']
30
14
  end
31
15
 
16
+ Cucumber::Rake::Task.new(:features) do |t|
17
+ t.cucumber_opts = "--format pretty --no-source"
18
+ t.fork = false
19
+ end
20
+
32
21
  RSpec::Core::RakeTask.new('integration:quick') do |t|
33
22
  t.rspec_opts = %w(--tag ~take_too_long)
34
23
  t.pattern = FileList['spec/integration/**/*_spec.rb']
@@ -38,9 +27,6 @@ RSpec::Core::RakeTask.new('integration:all') do |t|
38
27
  t.pattern = FileList['spec/integration/**/*_spec.rb']
39
28
  end
40
29
 
41
- task :default => [:spec,:features]
42
-
43
- require "gem_publisher"
44
30
  task :publish_gem do |t|
45
31
  gem = GemPublisher.publish_if_updated("vcloud-launcher.gemspec", :rubygems)
46
32
  puts "Published #{gem}" if gem
data/jenkins.sh CHANGED
@@ -1,11 +1,8 @@
1
1
  #!/bin/bash -x
2
2
  set -e
3
3
  bundle install --path "${HOME}/bundles/${JOB_NAME}"
4
- bundle exec rake
4
+ bundle exec rake
5
5
 
6
- ./scripts/generate_fog_conf_file.sh
7
- export FOG_RC=fog_integration_test.config
8
- bundle exec rake integration:all
9
- rm fog_integration_test.config
6
+ RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration:all
10
7
 
11
8
  bundle exec rake publish_gem
@@ -1,7 +1,4 @@
1
1
  #!/bin/bash -x
2
2
  set -e
3
3
  bundle install --path "${HOME}/bundles/${JOB_NAME}"
4
- ./scripts/generate_fog_conf_file.sh
5
- export FOG_RC=fog_integration_test.config
6
- bundle exec rake integration:all
7
- rm fog_integration_test.config
4
+ RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration:all
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Launcher
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -5,20 +5,44 @@ vapps:
5
5
  catalog: <%= catalog %>
6
6
  catalog_item: <%= vapp_template %>
7
7
  vm:
8
+ hardware_config: &hardware_config
9
+ memory: 4096
10
+ cpu: 2
11
+ bootstrap: &bootstrap
12
+ script_path: <%= bootstrap_script %>
13
+ vars:
14
+ message: hello world
8
15
  storage_profile: <%= storage_profile %>
9
16
  - name: <%= vapp_name_2 %>
10
17
  vdc_name: <%= vdc_name_2 %>
11
18
  catalog: <%= catalog %>
12
19
  catalog_item: <%= vapp_template %>
13
20
  vm:
21
+ hardware_config:
22
+ <<: *hardware_config
23
+ bootstrap:
24
+ <<: *bootstrap
14
25
  storage_profile: <%= storage_profile %>
15
26
  - name: <%= vapp_name_3 %>
16
27
  vdc_name: <%= vdc_name_1 %>
17
28
  catalog: <%= catalog %>
18
29
  catalog_item: <%= vapp_template %>
30
+ vm:
31
+ hardware_config:
32
+ <<: *hardware_config
33
+ metadata:
34
+ storage_profile_test_vm: true
35
+ bootstrap:
36
+ <<: *bootstrap
19
37
  - name: <%= vapp_name_4 %>
20
38
  vdc_name: <%= vdc_name_1 %>
21
39
  catalog: <%= catalog %>
22
40
  catalog_item: <%= vapp_template %>
23
41
  vm:
42
+ hardware_config:
43
+ <<: *hardware_config
44
+ metadata:
45
+ storage_profile_test_vm: true
46
+ bootstrap:
47
+ <<: *bootstrap
24
48
  storage_profile: <%= nonsense_storage_profile %>
@@ -50,11 +50,24 @@ describe Vcloud::Launcher::Launch do
50
50
  @vm_3[:StorageProfile][:href].should == @test_data[:default_storage_profile_href]
51
51
  end
52
52
 
53
+ it "when a storage profile is not specified, customize continues with other customizations" do
54
+ @vm_3_id = @vm_3[:href].split('/').last
55
+ @vm_3_metadata = Vcloud::Core::Vm.get_metadata @vm_3_id
56
+ @vm_3_metadata[:storage_profile_test_vm].should == true
57
+ end
58
+
53
59
  it "when a storage profile specified does not exist, vm uses the default" do
54
60
  @vm_4[:StorageProfile][:name].should == @test_data[:default_storage_profile_name]
55
61
  @vm_4[:StorageProfile][:href].should == @test_data[:default_storage_profile_href]
56
62
  end
57
63
 
64
+ # This is a bug - if it has failed customization it should let the user know
65
+ it "when storage profile specified doesn't exist, it errors and continues" do
66
+ @vm_4_id = @vm_4[:href].split('/').last
67
+ @vm_4_metadata = Vcloud::Core::Vm.get_metadata @vm_4_id
68
+ @vm_4_metadata[:storage_profile_test_vm].should be_nil
69
+ end
70
+
58
71
  after(:all) do
59
72
  unless ENV['VCLOUD_TOOLS_RSPEC_NO_DELETE_VAPP']
60
73
  File.delete @config_yaml
@@ -0,0 +1,17 @@
1
+ # Initialiser for getting vCloud credentials into Fog from Jenkins build
2
+ # parameters, without needing to write them to disk. To be used with:
3
+ #
4
+ # RUBYOPT="-r ./tools/fog_credentials" bundle exec integration
5
+ #
6
+ # Replace with FOG_VCLOUD_TOKEN support when we have a tool:
7
+ #
8
+ # https://www.pivotaltracker.com/story/show/68989754
9
+ #
10
+ require 'bundler/setup'
11
+ require 'fog'
12
+
13
+ Fog.credentials = {
14
+ :vcloud_director_host => ENV['API_HOST'],
15
+ :vcloud_director_username => ENV['API_USERNAME'],
16
+ :vcloud_director_password => ENV['API_PASSWORD'],
17
+ }
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.required_ruby_version = '>= 1.9.2'
22
22
 
23
23
  s.add_runtime_dependency 'methadone'
24
- s.add_runtime_dependency 'vcloud-core', '>= 0.0.12'
24
+ s.add_runtime_dependency 'vcloud-core', '~> 0.0.12'
25
25
  s.add_development_dependency 'aruba', '~> 0.5.3'
26
26
  s.add_development_dependency 'cucumber', '~> 1.3.10'
27
27
  s.add_development_dependency 'gem_publisher', '1.2.0'
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.0.3
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-04-22 00:00:00.000000000 Z
12
+ date: 2014-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: methadone
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
37
  version: 0.0.12
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 0.0.12
46
46
  - !ruby/object:Gem::Dependency
@@ -155,7 +155,6 @@ files:
155
155
  - lib/vcloud/launcher/version.rb
156
156
  - lib/vcloud/launcher/vm_orchestrator.rb
157
157
  - scripts/basic.erb
158
- - scripts/generate_fog_conf_file.sh
159
158
  - spec/erb_helper.rb
160
159
  - spec/integration/launcher/data/basic_preamble_test.erb
161
160
  - spec/integration/launcher/data/happy_path.yaml.erb
@@ -168,6 +167,7 @@ files:
168
167
  - spec/vcloud/launcher/launch_spec.rb
169
168
  - spec/vcloud/launcher/vapp_orchestrator_spec.rb
170
169
  - spec/vcloud/launcher/vm_orchestrator_spec.rb
170
+ - tools/fog_credentials.rb
171
171
  - vcloud-launcher.gemspec
172
172
  homepage: https://github.com/alphagov/vcloud-launcher
173
173
  licenses:
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  segments:
192
192
  - 0
193
- hash: 8814923118188880
193
+ hash: -3318848198983750692
194
194
  requirements: []
195
195
  rubyforge_project:
196
196
  rubygems_version: 1.8.23
@@ -1,6 +0,0 @@
1
- cat <<EOF >fog_integration_test.config
2
- default:
3
- vcloud_director_username: '$API_USERNAME'
4
- vcloud_director_password: '$API_PASSWORD'
5
- vcloud_director_host: '$API_HOST'
6
- EOF