vagrant-registration 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/vagrant-registration/version.rb +1 -1
- data/vagrant-registration.gemspec +6 -1
- metadata +2 -94
- data/.gitignore +0 -34
- data/Vagrantfile +0 -44
- data/dummy.box +0 -0
- data/vagrant-registration-0.0.16/.gitignore +0 -34
- data/vagrant-registration-0.0.16/CHANGELOG.md +0 -3
- data/vagrant-registration-0.0.16/Gemfile +0 -9
- data/vagrant-registration-0.0.16/LICENSE.md +0 -339
- data/vagrant-registration-0.0.16/README.md +0 -149
- data/vagrant-registration-0.0.16/Rakefile +0 -25
- data/vagrant-registration-0.0.16/Vagrantfile +0 -44
- data/vagrant-registration-0.0.16/dummy.box +0 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration/action/register.rb +0 -113
- data/vagrant-registration-0.0.16/lib/vagrant-registration/action/unregister.rb +0 -56
- data/vagrant-registration-0.0.16/lib/vagrant-registration/action.rb +0 -22
- data/vagrant-registration-0.0.16/lib/vagrant-registration/config.rb +0 -39
- data/vagrant-registration-0.0.16/lib/vagrant-registration/plugin.rb +0 -74
- data/vagrant-registration-0.0.16/lib/vagrant-registration/version.rb +0 -5
- data/vagrant-registration-0.0.16/lib/vagrant-registration.rb +0 -21
- data/vagrant-registration-0.0.16/plugins/guests/redhat/cap/registration.rb +0 -72
- data/vagrant-registration-0.0.16/plugins/guests/redhat/cap/subscription_manager.rb +0 -63
- data/vagrant-registration-0.0.16/plugins/guests/redhat/plugin.rb +0 -62
- data/vagrant-registration-0.0.16/tests/helpers.sh +0 -128
- data/vagrant-registration-0.0.16/tests/run.sh +0 -59
- data/vagrant-registration-0.0.16/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +0 -19
- data/vagrant-registration-0.0.16/tests/vagrantfiles/Vagrantfile.rhel_wrong_credentials +0 -14
- data/vagrant-registration-0.0.16/vagrant-registration.gemspec +0 -49
- data/vagrant-registration-0.0.17/.gitignore +0 -34
- data/vagrant-registration-0.0.17/CHANGELOG.md +0 -3
- data/vagrant-registration-0.0.17/Gemfile +0 -9
- data/vagrant-registration-0.0.17/LICENSE.md +0 -339
- data/vagrant-registration-0.0.17/README.md +0 -149
- data/vagrant-registration-0.0.17/Rakefile +0 -25
- data/vagrant-registration-0.0.17/Vagrantfile +0 -44
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/ChangeHostName.html +0 -1016
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/ConfigureNetworks.html +0 -355
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/Flavor.html +0 -209
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/NFSClient.html +0 -189
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/NetworkScriptsDir.html +0 -205
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap.html +0 -117
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Guest.html +0 -211
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Plugin.html +0 -120
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora.html +0 -119
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/RedHatCertification.html +0 -189
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/Register.html +0 -191
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/SubscriptionManager.html +0 -189
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/Unregister.html +0 -189
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap.html +0 -117
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Plugin.html +0 -120
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat.html +0 -119
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Action/Register.html +0 -345
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Action/Unregister.html +0 -315
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Action.html +0 -246
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Config.html +0 -433
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors/RegisterError.html +0 -123
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors/UnregisterError.html +0 -123
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors/VagrantRHELError.html +0 -123
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors.html +0 -115
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Plugin.html +0 -356
- data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration.html +0 -226
- data/vagrant-registration-0.0.17/doc/VagrantPlugins.html +0 -117
- data/vagrant-registration-0.0.17/doc/_index.html +0 -375
- data/vagrant-registration-0.0.17/doc/class_list.html +0 -58
- data/vagrant-registration-0.0.17/doc/css/common.css +0 -1
- data/vagrant-registration-0.0.17/doc/css/full_list.css +0 -57
- data/vagrant-registration-0.0.17/doc/css/style.css +0 -339
- data/vagrant-registration-0.0.17/doc/file.README.html +0 -135
- data/vagrant-registration-0.0.17/doc/file_list.html +0 -60
- data/vagrant-registration-0.0.17/doc/frames.html +0 -26
- data/vagrant-registration-0.0.17/doc/index.html +0 -135
- data/vagrant-registration-0.0.17/doc/js/app.js +0 -219
- data/vagrant-registration-0.0.17/doc/js/full_list.js +0 -181
- data/vagrant-registration-0.0.17/doc/js/jquery.js +0 -4
- data/vagrant-registration-0.0.17/doc/method_list.html +0 -279
- data/vagrant-registration-0.0.17/doc/top-level-namespace.html +0 -112
- data/vagrant-registration-0.0.17/dummy.box +0 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/action/register.rb +0 -113
- data/vagrant-registration-0.0.17/lib/vagrant-registration/action/unregister.rb +0 -56
- data/vagrant-registration-0.0.17/lib/vagrant-registration/action.rb +0 -22
- data/vagrant-registration-0.0.17/lib/vagrant-registration/config.rb +0 -39
- data/vagrant-registration-0.0.17/lib/vagrant-registration/plugin.rb +0 -74
- data/vagrant-registration-0.0.17/lib/vagrant-registration/version.rb +0 -5
- data/vagrant-registration-0.0.17/lib/vagrant-registration.rb +0 -21
- data/vagrant-registration-0.0.17/plugins/guests/redhat/cap/registration.rb +0 -72
- data/vagrant-registration-0.0.17/plugins/guests/redhat/cap/subscription_manager.rb +0 -63
- data/vagrant-registration-0.0.17/plugins/guests/redhat/plugin.rb +0 -62
- data/vagrant-registration-0.0.17/tests/helpers.sh +0 -128
- data/vagrant-registration-0.0.17/tests/run.sh +0 -59
- data/vagrant-registration-0.0.17/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +0 -19
- data/vagrant-registration-0.0.17/tests/vagrantfiles/Vagrantfile.rhel_wrong_credentials +0 -14
- data/vagrant-registration-0.0.17/vagrant-registration.gemspec +0 -49
- data/vagrant-registration-0.0.17/vagrant-registration.spec +0 -90
- data/vagrant-registration.spec +0 -90
@@ -1,149 +0,0 @@
|
|
1
|
-
# vagrant-registration
|
2
|
-
|
3
|
-
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
|
-
|
5
|
-
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
|
-
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
Install vagrant-registration as any other Vagrant plugin:
|
11
|
-
|
12
|
-
```shell
|
13
|
-
$ vagrant plugin install vagrant-registration
|
14
|
-
```
|
15
|
-
|
16
|
-
If you are on Fedora, you can install the packaged version of the plugin by running:
|
17
|
-
|
18
|
-
```shell
|
19
|
-
# dnf install vagrant-registration
|
20
|
-
```
|
21
|
-
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
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.
|
25
|
-
|
26
|
-
That being said, this plugin currently ships only with registration capability files for RHEL's Subscription Manager. Feel free to submit others.
|
27
|
-
|
28
|
-
*Note:* This plugin is still alpha. Please help us to find and fix any bugs.
|
29
|
-
|
30
|
-
### Plugin Configuration
|
31
|
-
|
32
|
-
- **skip**: If you wish to skip the registration process altogether, you can do so by setting a `skip` option to `true`:
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
config.registration.skip = true
|
36
|
-
```
|
37
|
-
|
38
|
-
### subscription-manager Configuration
|
39
|
-
|
40
|
-
vagrant-registration supports all the options of subscription-manager's register command.
|
41
|
-
You can set any option easily by setting `config.registration.OPTION_NAME = 'OPTION_VALUE'`
|
42
|
-
in your Vagrantfile (please see the subscription-manager's documentation for option
|
43
|
-
description).
|
44
|
-
|
45
|
-
Setting up the credentials can be done as follows:
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
if Vagrant.has_plugin?('vagrant-registration')
|
49
|
-
config.registration.username = 'foo'
|
50
|
-
config.registration.password = 'bar'
|
51
|
-
end
|
52
|
-
|
53
|
-
# Alternatively
|
54
|
-
if Vagrant.has_plugin?('vagrant-registration')
|
55
|
-
config.registration.org = 'foo'
|
56
|
-
config.registration.activationkey = 'bar'
|
57
|
-
end
|
58
|
-
```
|
59
|
-
|
60
|
-
This should go, preferably, into the Vagrantfile in your Vagrant home directory
|
61
|
-
(defaults to ~/.vagrant.d), to make it available for every project. It can be
|
62
|
-
later overridden in an individual project's Vagrantfile if needed.
|
63
|
-
|
64
|
-
If you prefer not to store your username and/or password on your filesystem,
|
65
|
-
you can optionally configure vagrant-registration plugin to use environment
|
66
|
-
variables, such as:
|
67
|
-
|
68
|
-
```ruby
|
69
|
-
config.registration.username = ENV['SUB_USERNAME']
|
70
|
-
config.registration.password = ENV['SUB_PASSWORD']
|
71
|
-
```
|
72
|
-
|
73
|
-
If you do not provide credentials, you will be prompted for them in the "up process."
|
74
|
-
|
75
|
-
Please note the the interactive mode asks you for the preferred registration pair only.
|
76
|
-
In case of a subscription-manager, you would be ask on your username/password combination.
|
77
|
-
|
78
|
-
#### subscription-manager Default Options
|
79
|
-
|
80
|
-
- **--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`:
|
81
|
-
|
82
|
-
```ruby
|
83
|
-
config.registration.force = false
|
84
|
-
```
|
85
|
-
- **--auto-attach**: Vagrant would fail to install packages on registered RHEL system if the subscription is not attached, therefore vagrant-registration appends the
|
86
|
-
`--auto-attach` flag automatically when subscribing. To disable this option, set `auto_attach` option to `false`:
|
87
|
-
|
88
|
-
|
89
|
-
```ruby
|
90
|
-
config.registration.auto_attach = false
|
91
|
-
```
|
92
|
-
|
93
|
-
Note that the `auto_attach` option is set to false when using org/activationkey for registration.
|
94
|
-
|
95
|
-
#### subscription-manager Options Reference
|
96
|
-
|
97
|
-
```ruby
|
98
|
-
# The username to subscribe with (required)
|
99
|
-
config.registration.username
|
100
|
-
|
101
|
-
# The password of the subscriber (required)
|
102
|
-
config.registration.password
|
103
|
-
|
104
|
-
# Give the hostname of the subscription service to use (required for Subscription
|
105
|
-
# Asset Manager, defaults to Customer Portal Subscription Management)
|
106
|
-
config.registration.serverurl
|
107
|
-
|
108
|
-
# Give the hostname of the content delivery server to use to receive updates
|
109
|
-
# (required for Satellite 6)
|
110
|
-
config.registration.baseurl
|
111
|
-
|
112
|
-
# Give the organization to which to join the system (required, except for
|
113
|
-
# hosted environments)
|
114
|
-
config.registration.org
|
115
|
-
|
116
|
-
# Register the system to an environment within an organization (optional)
|
117
|
-
config.registration.environment
|
118
|
-
|
119
|
-
# Name of the subscribed system (optional, defaults to hostname if unset)
|
120
|
-
config.registration.name
|
121
|
-
|
122
|
-
# Auto attach suitable subscriptions (optional, auto attach if true,
|
123
|
-
# defaults to true)
|
124
|
-
config.registration.auto_attach
|
125
|
-
|
126
|
-
# Attach existing subscriptions as part of the registration process (optional)
|
127
|
-
config.registration.activationkey
|
128
|
-
|
129
|
-
# Set the service level to use for subscriptions on that machine
|
130
|
-
# (optional, used only used with the --auto-attach)
|
131
|
-
config.registration.servicelevel
|
132
|
-
|
133
|
-
# Set the operating system minor release to use for subscriptions for
|
134
|
-
# the system (optional, used only used with the --auto-attach)
|
135
|
-
config.registration.release
|
136
|
-
|
137
|
-
# Force the registration (optional, force if true, defaults to true)
|
138
|
-
config.registration.force
|
139
|
-
|
140
|
-
# Set what type of consumer is being registered (optional, defaults to system)
|
141
|
-
config.registration.type
|
142
|
-
|
143
|
-
# Skip the registration (optional, skip if true, defaults to false)
|
144
|
-
config.registration.skip
|
145
|
-
```
|
146
|
-
|
147
|
-
## Acknowledgements
|
148
|
-
|
149
|
-
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) and [goern](https://github.com/goern) (in no particular order) for their contributions of ideas, code and testing for this project.
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'yard'
|
3
|
-
|
4
|
-
# Documentation
|
5
|
-
YARD::Rake::YardocTask.new do |t|
|
6
|
-
t.files = ['lib/**/*.rb', 'plugins/**/*.rb']
|
7
|
-
t.options = []
|
8
|
-
t.stats_options = ['--list-undoc']
|
9
|
-
end
|
10
|
-
|
11
|
-
task :clean do
|
12
|
-
`rm -rf pkg`
|
13
|
-
end
|
14
|
-
|
15
|
-
# Compare latest release with current git head
|
16
|
-
require 'rubygems/comparator'
|
17
|
-
task compare: [:clean, :build] do
|
18
|
-
git_version = VagrantPlugins::Registration::VERSION
|
19
|
-
options = {}
|
20
|
-
options[:output] = 'pkg'
|
21
|
-
options[:keep_all] = true
|
22
|
-
comparator = Gem::Comparator.new(options)
|
23
|
-
comparator.compare_versions('vagrant-registration', ['_', git_version])
|
24
|
-
comparator.print_results
|
25
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# BEING USED FOR TESTING, REMOVE BEFORE RELEASE
|
2
|
-
#
|
3
|
-
# -*- mode: ruby -*-
|
4
|
-
# vi: set ft=ruby :
|
5
|
-
|
6
|
-
Vagrant.configure('2') do |config|
|
7
|
-
# Example configuration of new VM..
|
8
|
-
config.vm.define :default do |vagrant_host|
|
9
|
-
# Box name
|
10
|
-
vagrant_host.vm.box = 'rhel-7.0'
|
11
|
-
|
12
|
-
# Domain Specific Options
|
13
|
-
vagrant_host.vm.provider :libvirt do |domain|
|
14
|
-
domain.memory = 2048
|
15
|
-
domain.cpus = 1
|
16
|
-
end
|
17
|
-
|
18
|
-
config.vm.synced_folder './', '/vagrant', type: 'rsync'
|
19
|
-
|
20
|
-
# vagrant_host.vm.network :private_network,
|
21
|
-
# :libvirt__network_name => 'either_nat'
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
# config.vm.provision "ansible" do |ansible|
|
26
|
-
# ansible.playbook = "playbook.yml"
|
27
|
-
# ansible.extra_vars = "vagrant-config.yml"
|
28
|
-
# end
|
29
|
-
|
30
|
-
# config.vm.provision "ansible" do |ansible|
|
31
|
-
# ansible.playbook = "playbook.yml"
|
32
|
-
# ansible.extra_vars = "vagrant-config.yml"
|
33
|
-
# ansible.sudo = "true"
|
34
|
-
# end
|
35
|
-
|
36
|
-
# Options for libvirt vagrant provider.
|
37
|
-
config.vm.provider :libvirt do |libvirt|
|
38
|
-
libvirt.driver = 'kvm'
|
39
|
-
libvirt.connect_via_ssh = false
|
40
|
-
libvirt.username = 'root'
|
41
|
-
libvirt.storage_pool_name = 'mnt_vms'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
Binary file
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require "log4r"
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Registration
|
5
|
-
module Action
|
6
|
-
# This registers the guest if the guest plugin supports it
|
7
|
-
class Register
|
8
|
-
def initialize(app, env)
|
9
|
-
@app = app
|
10
|
-
@logger = Log4r::Logger.new("vagrant_registration::action::register")
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(env)
|
14
|
-
@app.call(env)
|
15
|
-
|
16
|
-
# Configuration from Vagrantfile
|
17
|
-
config = env[:machine].config.registration
|
18
|
-
machine = env[:machine]
|
19
|
-
guest = env[:machine].guest
|
20
|
-
|
21
|
-
if capabilities_provided?(guest) && manager_installed?(guest) && !config.skip
|
22
|
-
env[:ui].info("Registering box with vagrant-registration...")
|
23
|
-
|
24
|
-
unless credentials_provided? machine
|
25
|
-
@logger.debug("Credentials for registration not provided")
|
26
|
-
|
27
|
-
# Offer to register ATM or skip
|
28
|
-
register_now = env[:ui].ask("Would you like to register the system now (default: yes)? [y|n] ")
|
29
|
-
|
30
|
-
if register_now == 'n'
|
31
|
-
config.skip = true
|
32
|
-
else
|
33
|
-
config = register_on_screen(machine, env[:ui])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
guest.capability(:registration_register) unless config.skip
|
37
|
-
end
|
38
|
-
|
39
|
-
@logger.debug("Registration is skipped due to the configuration") if config.skip
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
# Check if registration capabilities are available
|
45
|
-
def capabilities_provided?(guest)
|
46
|
-
if guest.capability?(:registration_register) && guest.capability?(:registration_manager_installed)
|
47
|
-
true
|
48
|
-
else
|
49
|
-
@logger.debug("Registration is skipped due to the missing guest capability")
|
50
|
-
false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Check if selected registration manager is installed
|
55
|
-
def manager_installed?(guest)
|
56
|
-
if guest.capability(:registration_manager_installed)
|
57
|
-
true
|
58
|
-
else
|
59
|
-
@logger.debug("Registration manager not found on guest")
|
60
|
-
false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# Fetch required credentials for selected manager
|
65
|
-
def credentials_required(machine)
|
66
|
-
if machine.guest.capability?(:registration_credentials)
|
67
|
-
machine.guest.capability(:registration_credentials)
|
68
|
-
else
|
69
|
-
[]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Secret options for selected manager
|
74
|
-
def secrets(machine)
|
75
|
-
if machine.guest.capability?(:registration_secrets)
|
76
|
-
machine.guest.capability(:registration_secrets)
|
77
|
-
else
|
78
|
-
[]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Check if required credentials has been provided in Vagrantfile
|
83
|
-
#
|
84
|
-
# Checks if at least one of the registration options is able to
|
85
|
-
# register.
|
86
|
-
def credentials_provided?(machine)
|
87
|
-
provided = true
|
88
|
-
credentials_required(machine).each do |registration_option|
|
89
|
-
provided = true
|
90
|
-
registration_option.each do |value|
|
91
|
-
provided = false unless machine.config.registration.send value
|
92
|
-
end
|
93
|
-
break if provided
|
94
|
-
end
|
95
|
-
provided ? true : false
|
96
|
-
end
|
97
|
-
|
98
|
-
# Ask user on required credentials and return them,
|
99
|
-
# skip options that are provided by Vagrantfile
|
100
|
-
def register_on_screen(machine, ui)
|
101
|
-
credentials_required(machine)[0].each do |option|
|
102
|
-
unless machine.config.registration.send(option)
|
103
|
-
echo = !(secrets(machine).include? option)
|
104
|
-
response = ui.ask("#{option}: ", echo: echo)
|
105
|
-
machine.config.registration.send("#{option.to_s}=".to_sym, response)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
machine.config.registration
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require "log4r"
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Registration
|
5
|
-
module Action
|
6
|
-
# This unregisters the guest if the guest has registration capability
|
7
|
-
class Unregister
|
8
|
-
def initialize(app, env)
|
9
|
-
@app = app
|
10
|
-
@logger = Log4r::Logger.new("vagrant_registration::action::unregister")
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(env)
|
14
|
-
config = env[:machine].config.registration
|
15
|
-
guest = env[:machine].guest
|
16
|
-
|
17
|
-
if capabilities_provided?(guest) && manager_installed?(guest) && !config.skip
|
18
|
-
env[:ui].info("Unregistering box with vagrant-registration...")
|
19
|
-
guest.capability(:registration_unregister)
|
20
|
-
end
|
21
|
-
|
22
|
-
@logger.debug("Unregistration is skipped due to the configuration") if config.skip
|
23
|
-
@app.call(env)
|
24
|
-
|
25
|
-
# Guest might not be available after halting, so log the exception and continue
|
26
|
-
rescue => e
|
27
|
-
@logger.info(e)
|
28
|
-
@logger.debug("Guest is not available, ignore unregistration")
|
29
|
-
@app.call(env)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Check if registration capabilities are available
|
35
|
-
def capabilities_provided?(guest)
|
36
|
-
if guest.capability?(:registration_unregister) && guest.capability?(:registration_manager_installed)
|
37
|
-
true
|
38
|
-
else
|
39
|
-
@logger.debug("Unregistration is skipped due to the missing guest capability")
|
40
|
-
false
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Check if selected registration manager is installed
|
45
|
-
def manager_installed?(guest)
|
46
|
-
if guest.capability(:registration_manager_installed)
|
47
|
-
true
|
48
|
-
else
|
49
|
-
@logger.debug("Registration manager not found on guest")
|
50
|
-
false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module Registration
|
3
|
-
module Action
|
4
|
-
|
5
|
-
def self.action_register
|
6
|
-
Vagrant::Action::Builder.new.tap do |b|
|
7
|
-
b.use Register
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.action_unregister
|
12
|
-
Vagrant::Action::Builder.new.tap do |b|
|
13
|
-
b.use Unregister
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
18
|
-
autoload :Register, action_root.join("register")
|
19
|
-
autoload :Unregister, action_root.join("unregister")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "vagrant"
|
2
|
-
require "ostruct"
|
3
|
-
|
4
|
-
module VagrantPlugins
|
5
|
-
module Registration
|
6
|
-
class Config < Vagrant.plugin("2", :config)
|
7
|
-
def initialize(region_specific=false)
|
8
|
-
@conf = UNSET_VALUE
|
9
|
-
@logger = Log4r::Logger.new("vagrant_registration::config")
|
10
|
-
end
|
11
|
-
|
12
|
-
def finalize!
|
13
|
-
get_config
|
14
|
-
@conf.skip = false unless @conf.skip
|
15
|
-
@logger.info "Final registration configuration: #{@conf.inspect}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def method_missing(method_sym, *arguments, &block)
|
19
|
-
get_config
|
20
|
-
command = "@conf.#{method_sym} #{adjust_arguments(arguments)}"
|
21
|
-
@logger.info "Evaluating registration configuration: #{command}"
|
22
|
-
eval command
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
# Don't set @conf to OpenStruct in initialize
|
28
|
-
# to preserve config hierarchy
|
29
|
-
def get_config
|
30
|
-
@conf = OpenStruct.new if @conf == UNSET_VALUE
|
31
|
-
end
|
32
|
-
|
33
|
-
def adjust_arguments(args)
|
34
|
-
return '' if args.size < 1
|
35
|
-
args.map{|a| a.is_a?(String) ? "'#{a}'" : a}.join(',')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'vagrant'
|
3
|
-
rescue LoadError
|
4
|
-
raise 'The vagrant-registration plugin must be run within Vagrant.'
|
5
|
-
end
|
6
|
-
|
7
|
-
# This is a sanity check to make sure no one is attempting to install
|
8
|
-
# this into an early Vagrant version.
|
9
|
-
if Vagrant::VERSION < "1.2.0"
|
10
|
-
raise "The Vagrant RHEL plugin is only compatible with Vagrant 1.2+"
|
11
|
-
end
|
12
|
-
|
13
|
-
module VagrantPlugins
|
14
|
-
module Registration
|
15
|
-
class Plugin < Vagrant.plugin("2")
|
16
|
-
class << self
|
17
|
-
def register(hook)
|
18
|
-
setup_logging
|
19
|
-
hook.after(::Vagrant::Action::Builtin::SyncedFolders,
|
20
|
-
VagrantPlugins::Registration::Action.action_register)
|
21
|
-
end
|
22
|
-
|
23
|
-
def unregister(hook)
|
24
|
-
setup_logging
|
25
|
-
hook.prepend(VagrantPlugins::Registration::Action.action_unregister)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
name "Registration"
|
30
|
-
description <<-DESC
|
31
|
-
This plugin adds register and unregister functionality to Vagrant Guests that
|
32
|
-
support the capability
|
33
|
-
DESC
|
34
|
-
|
35
|
-
action_hook(:registration_register, :machine_action_up, &method(:register))
|
36
|
-
action_hook(:registration_register, :machine_action_provision, &method(:register))
|
37
|
-
action_hook(:registration_unregister, :machine_action_halt, &method(:unregister))
|
38
|
-
action_hook(:registration_unregister, :machine_action_destroy, &method(:unregister))
|
39
|
-
|
40
|
-
config(:registration) do
|
41
|
-
setup_logging
|
42
|
-
require_relative 'config'
|
43
|
-
Config
|
44
|
-
end
|
45
|
-
|
46
|
-
# This sets up our log level to be whatever VAGRANT_LOG is
|
47
|
-
# for loggers prepended with 'vagrant_registration'
|
48
|
-
def self.setup_logging
|
49
|
-
require 'log4r'
|
50
|
-
level = nil
|
51
|
-
begin
|
52
|
-
level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
|
53
|
-
rescue NameError
|
54
|
-
# This means that the logging constant wasn't found,
|
55
|
-
# which is fine. We just keep `level` as `nil`. But
|
56
|
-
# we tell the user.
|
57
|
-
level = nil
|
58
|
-
end
|
59
|
-
# Some constants, such as "true" resolve to booleans, so the
|
60
|
-
# above error checking doesn't catch it. This will check to make
|
61
|
-
# sure that the log level is an integer, as Log4r requires.
|
62
|
-
level = nil if !level.is_a?(Integer)
|
63
|
-
# Set the logging level on all "vagrant" namespaced
|
64
|
-
# logs as long as we have a valid level.
|
65
|
-
if level
|
66
|
-
logger = Log4r::Logger.new('vagrant_registration')
|
67
|
-
logger.outputters = Log4r::Outputter.stderr
|
68
|
-
logger.level = level
|
69
|
-
logger = nil
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
require "vagrant-registration/plugin"
|
4
|
-
|
5
|
-
module VagrantPlugins
|
6
|
-
module Registration
|
7
|
-
lib_path = Pathname.new(File.expand_path("../vagrant-registration", __FILE__))
|
8
|
-
autoload :Action, lib_path.join("action")
|
9
|
-
#autoload :Errors, lib_path.join("errors")
|
10
|
-
|
11
|
-
# This returns the path to the source of this plugin.
|
12
|
-
#
|
13
|
-
# @return [Pathname]
|
14
|
-
def self.source_root
|
15
|
-
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
|
-
end
|
17
|
-
|
18
|
-
# Temporally load the extra capability files for Red Hat
|
19
|
-
load(File.join(self.source_root, 'plugins/guests/redhat/plugin.rb'))
|
20
|
-
end
|
21
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module GuestRedHat
|
3
|
-
module Cap
|
4
|
-
# This provides registration capabilities for vagrant-registration
|
5
|
-
#
|
6
|
-
# As we might support more registration options (managers), this
|
7
|
-
# just calls the capabilities of the selected registration manager
|
8
|
-
# (from config.registration.manager).
|
9
|
-
class Registration
|
10
|
-
# Register the given machine
|
11
|
-
def self.registration_register(machine)
|
12
|
-
cap = "#{self.registration_manager(machine).to_s}_register".to_sym
|
13
|
-
if machine.guest.capability?(cap)
|
14
|
-
machine.guest.capability(cap, machine.config.registration)
|
15
|
-
else
|
16
|
-
false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Unregister the given machine
|
21
|
-
def self.registration_unregister(machine)
|
22
|
-
cap = "#{self.registration_manager(machine).to_s}_unregister".to_sym
|
23
|
-
if machine.guest.capability?(cap)
|
24
|
-
machine.guest.capability(cap)
|
25
|
-
else
|
26
|
-
false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Check that the machine has the selected registration manager installed
|
31
|
-
def self.registration_manager_installed(machine)
|
32
|
-
cap = "#{self.registration_manager(machine).to_s}".to_sym
|
33
|
-
if machine.guest.capability?(cap)
|
34
|
-
machine.guest.capability(cap)
|
35
|
-
else
|
36
|
-
false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# Required configuration options of the registration manager
|
41
|
-
#
|
42
|
-
# This is array of arrays of all possible registration combinations.
|
43
|
-
# First one is the default used in interactive mode.
|
44
|
-
#
|
45
|
-
# e.g. [[:username, :password]]
|
46
|
-
def self.registration_credentials(machine)
|
47
|
-
cap = "#{self.registration_manager(machine).to_s}_credentials".to_sym
|
48
|
-
if machine.guest.capability?(cap)
|
49
|
-
machine.guest.capability(cap)
|
50
|
-
else
|
51
|
-
[]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Return secret options for the registration manager
|
56
|
-
def self.registration_secrets(machine)
|
57
|
-
cap = "#{self.registration_manager(machine).to_s}_secrets".to_sym
|
58
|
-
if machine.guest.capability?(cap)
|
59
|
-
machine.guest.capability(cap)
|
60
|
-
else
|
61
|
-
[]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Return selected registration manager or default
|
66
|
-
def self.registration_manager(machine)
|
67
|
-
(machine.config.registration.manager || 'subscription_manager').to_sym
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|