vagrant-registration 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4191a4626a0062ffe74a7e58f3a81ccedec71aed
4
- data.tar.gz: 4f804fb385b4b3078f3d1533616a790ab227dc3a
3
+ metadata.gz: 5986f6c0eaf90532c64bfb1c4ccf4763f8dcd130
4
+ data.tar.gz: 939849b4c8ddadb8edb6bfcb684faeb4c6e474cf
5
5
  SHA512:
6
- metadata.gz: 77ecff557286bb6180d7cb2d300b48e6907e6bb361e12d48d2235241c24d391a4c38378e9778a91107576238bbd1b7b310f990b9777332ddf5d91273e73f2754
7
- data.tar.gz: 4a199eb7a7d81e568e96c51a44313a4f4d3c1b563c233760f28ffdc0e34d7d3a39f052cfda3df6c24a3e8dd98609ef9acd0ddc99a94dd89a162b748567737974
6
+ metadata.gz: 05881a0cf219ee185fce48f1d41b92cabdfa9125b4faea4408f124512bc176c3e996723b169d8e458e448d8c02a7f93a06d83b3274cc2fe0625a14e767247a4c
7
+ data.tar.gz: 75696d5f372a0ef19e0da1a7eea93110693998de0293e502f2beae6b16517d4bd80029a836e891d133e2205ce3b8297d7f92269ce0b24398ad229a14a2fa2f3a
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2
4
+
5
+ - Introducing Cucumber based acceptance tests.
6
+ - Fix: Handling of vagrant-registration action hooks depending on provider used.
7
+
3
8
  ## 1.2.1
4
9
 
5
10
  - Fix regression: Use sudo when asking on registration managers being present
data/Gemfile CHANGED
@@ -3,9 +3,17 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
7
- gem 'gem-compare'
6
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
8
7
  gem 'rake'
8
+ gem 'cucumber', '~> 2.1'
9
+ gem 'aruba', '~> 0.13'
10
+ gem 'komenda', '~> 0.1.6'
11
+ gem 'launchy'
12
+ gem 'gem-compare'
13
+ gem 'mechanize'
14
+ gem 'vagrant-vbguest'
15
+ gem 'vagrant-libvirt' if RUBY_PLATFORM =~ /linux/i
16
+ gem 'fog-libvirt', '0.0.3' if RUBY_PLATFORM =~ /linux/i # https://github.com/pradels/vagrant-libvirt/issues/568
9
17
  end
10
18
 
11
19
  group :plugins do
data/README.md CHANGED
@@ -1,10 +1,30 @@
1
1
  # vagrant-registration
2
2
 
3
+ <!-- MarkdownTOC -->
4
+
5
+ - [Installation](#installation)
6
+ - [Usage](#usage)
7
+ - [Plugin Configuration](#plugin-configuration)
8
+ - [Credentials Configuration](#credentials-configuration)
9
+ - [subscription-manager Configuration](#subscription-manager-configuration)
10
+ - [subscription-manager Default Options](#subscription-manager-default-options)
11
+ - [subscription-manager Options Reference](#subscription-manager-options-reference)
12
+ - [rhn-register Configuration](#rhn-register-configuration)
13
+ - [rhn-register Default Options](#rhn-register-default-options)
14
+ - [rhn-register Options Reference](#rhn-register-options-reference)
15
+ - [Development](#development)
16
+ - [Tests](#tests)
17
+ - [Shell script based tests](#shell-script-based-tests)
18
+ - [Acceptance tests](#acceptance-tests)
19
+ - [Acknowledgements](#acknowledgements)
20
+
21
+ <!-- /MarkdownTOC -->
22
+
3
23
  vagrant-registration plugin for Vagrant allows developers to easily register their guests for updates on systems with a subscription model (like Red Hat Enterprise Linux).
4
24
 
5
25
  This plugin would run *register* action on `vagrant up` before any provisioning and *unregister* on `vagrant halt` or `vagrant destroy`. The actions then call the registration capabilities that have to be provided for given OS.
6
26
 
7
-
27
+ <a name="installation"></a>
8
28
  ## Installation
9
29
 
10
30
  Install vagrant-registration as any other Vagrant plugin:
@@ -19,6 +39,7 @@ If you are on Fedora, you can install the packaged version of the plugin by runn
19
39
  # dnf install vagrant-registration
20
40
  ```
21
41
 
42
+ <a name="usage"></a>
22
43
  ## Usage
23
44
 
24
45
  The plugin is designed in an registration-manager-agnostic way which means that plugin itself does not depend on any OS nor way of registration. vagrant-registration only calls registration capabilities for given guest, passes the configuration options to them and handles interactive registration.
@@ -33,6 +54,7 @@ Vagrant.configure('2') do |config|
33
54
  end
34
55
  ```
35
56
 
57
+ <a name="plugin-configuration"></a>
36
58
  ### Plugin Configuration
37
59
 
38
60
  - **skip** skips the registration. If you wish to skip the registration process altogether, you can do so by setting a `skip` option to `true`:
@@ -53,6 +75,7 @@ end
53
75
  config.registration.manager = 'subscription_manager'
54
76
  ```
55
77
 
78
+ <a name="credentials-configuration"></a>
56
79
  ### Credentials Configuration
57
80
 
58
81
  Setting up the credentials can be done as follows:
@@ -96,6 +119,7 @@ If you do not provide credentials, you will be prompted for them in the "up proc
96
119
  Please note the the interactive mode asks you for the preferred registration pair only
97
120
  of the configured manager.
98
121
 
122
+ <a name="subscription-manager-configuration"></a>
99
123
  ### subscription-manager Configuration
100
124
 
101
125
  vagrant-registration will use the `subscription_manager` manager by default or can be explicitly configured by setting the `manager` option to `subscription_manager`:
@@ -118,6 +142,7 @@ You can set any option easily by setting `config.registration.OPTION_NAME = 'OPT
118
142
  in your Vagrantfile (please see the subscription-manager's documentation for option
119
143
  description).
120
144
 
145
+ <a name="subscription-manager-default-options"></a>
121
146
  #### subscription-manager Default Options
122
147
 
123
148
  - **--force**: Subscription Manager will fail if you attempt to register an already registered machine (see the man page for explanation), therefore vagrant-registration appends the `--force` flag automatically when subscribing. If you would like to disable this feature, set `force` option to `false`:
@@ -135,6 +160,7 @@ description).
135
160
 
136
161
  Note that the `auto_attach` option is set to false when using org/activationkey for registration or if pools are specified.
137
162
 
163
+ <a name="subscription-manager-options-reference"></a>
138
164
  #### subscription-manager Options Reference
139
165
 
140
166
  ```ruby
@@ -197,6 +223,7 @@ Note that the `auto_attach` option is set to false when using org/activationkey
197
223
  config.registration.pools
198
224
  ```
199
225
 
226
+ <a name="rhn-register-configuration"></a>
200
227
  ### rhn-register Configuration
201
228
 
202
229
  vagrant-registration will use the `rhn_register` manager only if explicitly configured by setting the `manager` option to `rhn_register`:
@@ -217,6 +244,7 @@ vagrant-registration supports most of the options of rhnreg_ks's command. You ca
217
244
 
218
245
  `rhn_register` manager reuses the naming of `subscription-manager`'s command options where possible.
219
246
 
247
+ <a name="rhn-register-default-options"></a>
220
248
  #### rhn-register Default Options
221
249
 
222
250
  - **--force**: `rhnreg_ks` command will fail if you attempt to register an already registered machine (see the man page for explanation), therefore vagrant-registration appends the `--force` flag automatically when subscribing. If you would like to disable this feature, set `force` option to `false`:
@@ -225,6 +253,7 @@ vagrant-registration supports most of the options of rhnreg_ks's command. You ca
225
253
  config.registration.force = false
226
254
  ```
227
255
 
256
+ <a name="rhn-register-options-reference"></a>
228
257
  #### rhn-register Options Reference
229
258
 
230
259
  ```ruby
@@ -291,7 +320,23 @@ vagrant-registration supports most of the options of rhnreg_ks's command. You ca
291
320
  config.registration.skip
292
321
  ```
293
322
 
294
- ## Tests
323
+ <a name="development"></a>
324
+ ## Development
325
+
326
+ To install a development environment, clone the repo and prepare dependencies by
327
+
328
+ ```
329
+ gem install bundler -v 1.7.5
330
+ bundler install
331
+ ```
332
+
333
+ The use of [RVM|https://rvm.io] is recommended. Verified to work with ruby 2.0.0p643.
334
+
335
+ <a name="tests"></a>
336
+ ### Tests
337
+
338
+ <a name="shell-script-based-tests"></a>
339
+ #### Shell script based tests
295
340
 
296
341
  Tests currently test the plugin with `subscription-manager` and `rhn_register` on RHEL 7.1 guest and Fedora host. You need an imported RHEL 7.1 Vagrant box named `rhel-7.1`.
297
342
 
@@ -316,6 +361,37 @@ environment variable on `1` before executing the test script:
316
361
  export DEBUG=1
317
362
  ```
318
363
 
364
+ <a name="acceptance-tests"></a>
365
+ #### Acceptance tests
366
+
367
+ The source also contains a set of [Cucumber](https://cucumber.io/) acceptance tests. They can be run via:
368
+
369
+ $ bundle exec rake features
370
+
371
+ The tests assume that the CDK box files are available under
372
+ _build/boxes/cdk-\<provider\>.box_. You can either copy the box files manually or
373
+ use the _get_cdk_ Rake task to download them.
374
+
375
+ Per default only the scenarios for CDK in combination with VirtualBox
376
+ are run. You can also run against Libvirt using the environment variable
377
+ _PROVIDER_:
378
+
379
+ # Run tests against Libvirt
380
+ $ bundle exec rake features PROVIDER=libvirt
381
+
382
+ # Run against VirtualBox and Libvirt
383
+ $ bundle exec rake features PROVIDER=virtualbox,libvirt
384
+
385
+ You can also run a single feature specifying the explicit feature file to use:
386
+
387
+ $ bundle exec rake features FEATURE=features/<feature-filename>.feature
388
+
389
+ After test execution the Cucumber test reports can be found under _build/features_report.html_.
390
+ They can also be opened via
391
+
392
+ $ bundle exec rake features:open_report
393
+
394
+ <a name="acknowledgements"></a>
319
395
  ## Acknowledgements
320
396
 
321
397
  The project would like to make sure we thank [purpleidea](https://github.com/purpleidea/), [humaton](https://github.com/humaton/), [strzibny](https://github.com/strzibny), [scollier](https://github.com/scollier/), [puzzle](https://github.com/puzzle), [voxik](https://github.com/voxik), [lukaszachy](https://github.com/lukaszachy), [goern](https://github.com/goern), [iconoeugen](https://github.com/iconoeugen) and [pvalena](https://github.com/pvalena) (in no particular order) for their contributions of ideas, code and testing for this project.
data/Rakefile CHANGED
@@ -1,5 +1,14 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rake/clean'
3
+ require 'cucumber/rake/task'
2
4
  require 'yard'
5
+ require 'rubygems/comparator'
6
+ require 'launchy'
7
+ require 'mechanize'
8
+ require 'fileutils'
9
+
10
+ CLOBBER.include('pkg')
11
+ CLEAN.include('build')
3
12
 
4
13
  # Documentation
5
14
  YARD::Rake::YardocTask.new do |t|
@@ -8,12 +17,22 @@ YARD::Rake::YardocTask.new do |t|
8
17
  t.stats_options = ['--list-undoc']
9
18
  end
10
19
 
11
- task :clean do
12
- `rm -rf pkg`
20
+ task :init do
21
+ FileUtils.mkdir_p 'build'
22
+ end
23
+
24
+ # Cucumber acceptance test tasks
25
+ Cucumber::Rake::Task.new(:features)
26
+ task :features => :init
27
+
28
+ namespace :features do
29
+ desc 'Opens the HTML Cucumber test report'
30
+ task :open_report do
31
+ Launchy.open('./build/features_report.html')
32
+ end
13
33
  end
14
34
 
15
35
  # Compare latest release with current git head
16
- require 'rubygems/comparator'
17
36
  task compare: [:clean, :build] do
18
37
  git_version = VagrantPlugins::Registration::VERSION
19
38
  options = {}
@@ -23,3 +42,39 @@ task compare: [:clean, :build] do
23
42
  comparator.compare_versions('vagrant-registration', ['_', git_version])
24
43
  comparator.print_results
25
44
  end
45
+
46
+ desc 'Download CDK Vagrant box using the specified provider (default \'virtualbox\')'
47
+ task :get_cdk, [:provider] do |t, args|
48
+ provider = args[:provider].nil? ? 'virtualbox' : args[:provider]
49
+ agent = Mechanize.new
50
+ agent.follow_meta_refresh = true
51
+ agent.get(CDK_DOWNLOAD_URL) do |page|
52
+
53
+ # Submit first form which is the redirect to login page form
54
+ login_page = page.forms.first.submit
55
+
56
+ # Submit the login form
57
+ after_login = login_page.form_with(:name => 'login_form') do |f|
58
+ username_field = f.field_with(:id => 'username')
59
+ username_field.value = 'service-manager@mailinator.com'
60
+ password_field = f.field_with(:id => 'password')
61
+ password_field.value = 'service-manager'
62
+ end.click_button
63
+
64
+ # There is one more redirect after successful login
65
+ download_page = after_login.forms.first.submit
66
+
67
+ download_page.links.each do |link|
68
+ if link.href =~ /#{Regexp.quote(CDK_BOX_BASE_NAME)}-#{Regexp.quote(provider)}.box/
69
+ download_dir = File.join(File.dirname(__FILE__), 'build', 'boxes')
70
+ unless File.directory?(download_dir)
71
+ FileUtils.mkdir_p(download_dir)
72
+ end
73
+ agent.pluggable_parser.default = Mechanize::Download
74
+ puts "Downloading #{link.href}"
75
+ agent.get(link.href).save(File.join(download_dir, "cdk-#{provider}.box"))
76
+ end
77
+ end
78
+ end
79
+ end
80
+ task :get_cdk => :init
@@ -11,11 +11,6 @@ module VagrantPlugins
11
11
  end
12
12
 
13
13
  def call(env)
14
- # Vbguest plugin (if present) is called next. Therefore registration
15
- # needs to be done first. This does not work with the default
16
- # 'action_register' hook.
17
- @app.call(env) unless Plugin.vbguest_plugin?
18
-
19
14
  # Configuration from Vagrantfile
20
15
  config = env[:machine].config.registration
21
16
  machine = env[:machine]
@@ -42,7 +37,8 @@ module VagrantPlugins
42
37
 
43
38
  @logger.debug('Registration is skipped due to the configuration') if config.skip
44
39
 
45
- @app.call(env) if Plugin.vbguest_plugin?
40
+ # Call next middleware in chain
41
+ @app.call(env)
46
42
  end
47
43
 
48
44
  private
@@ -15,20 +15,34 @@ module VagrantPlugins
15
15
  class Plugin < Vagrant.plugin('2')
16
16
  class << self
17
17
 
18
- # Vbguest plugin updates GuestAdditions for VirtualBox before
19
- # '::Vagrant::Action::Builtin::SyncedFolders' and therefore needs
20
- # to be registered. Prepending Vbguest hook ensures that, but this
21
- # is done only with Vbguest plugin and VirtualBox provider. In other
22
- # cases the behavior is unchanged.
18
+ # vagrant-vbguest plugin updates GuestAdditions for VirtualBox
19
+ # and therefore needs to be run after the box got registered.
20
+ # See https://github.com/projectatomic/adb-vagrant-registration/issues/69
21
+ #
22
+ # vagrant-vbguest hooks before VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions
23
+ # (see https://github.com/mitchellh/vagrant/blob/master/plugins/providers/virtualbox/action.rb#L81)
24
+ # For registration to occur in time, it has to happen before that. Using WaitForCommunicator
25
+ # to be sure - https://github.com/dotless-de/vagrant-vbguest/blob/master/lib/vagrant-vbguest.rb#L53
26
+ #
27
+ # For vagrant-libvirt WaitTillUp is used
23
28
  def register(hook)
24
29
  setup_logging
25
30
 
26
- if vbguest_plugin?
27
- hook.before(::VagrantVbguest::Middleware,
28
- VagrantPlugins::Registration::Action.action_register)
29
- else
30
- hook.after(::Vagrant::Action::Builtin::SyncedFolders,
31
- VagrantPlugins::Registration::Action.action_register)
31
+ registered = false
32
+ if virtual_box?
33
+ hook.after(VagrantPlugins::ProviderVirtualBox::Action::WaitForCommunicator,
34
+ VagrantPlugins::Registration::Action.action_register)
35
+ registered = true
36
+ end
37
+ if libvirt?
38
+ hook.after(VagrantPlugins::ProviderLibvirt::Action::WaitTillUp,
39
+ VagrantPlugins::Registration::Action.action_register)
40
+ registered = true
41
+ end
42
+ # Best guess for the other providers
43
+ unless registered
44
+ hook.after(Vagrant::Action::Builtin::WaitForCommunicator,
45
+ VagrantPlugins::Registration::Action.action_register)
32
46
  end
33
47
  end
34
48
 
@@ -87,12 +101,14 @@ module VagrantPlugins
87
101
  end
88
102
  end
89
103
 
90
- # Determines if both VirtualBox provider and Vbguest plugin are present.
91
- def self.vbguest_plugin?
92
- @@vbguest_plugin ||= (
93
- defined?(VagrantPlugins::ProviderVirtualBox::Provider) &&
94
- defined?(VagrantVbguest::Middleware)
95
- )
104
+ # Determines if VirtualBox is provider
105
+ def self.virtual_box?
106
+ defined?(VagrantPlugins::ProviderVirtualBox::Provider)
107
+ end
108
+
109
+ # Determines if LibVirt is provider
110
+ def self.libvirt?
111
+ defined?(VagrantPlugins::ProviderLibvirt::Provider)
96
112
  end
97
113
  end
98
114
  end
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  # Registration plugin to auto-register guests on `vagrant up`
3
3
  module Registration
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.2'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-registration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Langdon White
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-29 00:00:00.000000000 Z
13
+ date: 2016-06-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yard