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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/vagrant-registration/version.rb +1 -1
  4. data/vagrant-registration.gemspec +6 -1
  5. metadata +2 -94
  6. data/.gitignore +0 -34
  7. data/Vagrantfile +0 -44
  8. data/dummy.box +0 -0
  9. data/vagrant-registration-0.0.16/.gitignore +0 -34
  10. data/vagrant-registration-0.0.16/CHANGELOG.md +0 -3
  11. data/vagrant-registration-0.0.16/Gemfile +0 -9
  12. data/vagrant-registration-0.0.16/LICENSE.md +0 -339
  13. data/vagrant-registration-0.0.16/README.md +0 -149
  14. data/vagrant-registration-0.0.16/Rakefile +0 -25
  15. data/vagrant-registration-0.0.16/Vagrantfile +0 -44
  16. data/vagrant-registration-0.0.16/dummy.box +0 -0
  17. data/vagrant-registration-0.0.16/lib/vagrant-registration/action/register.rb +0 -113
  18. data/vagrant-registration-0.0.16/lib/vagrant-registration/action/unregister.rb +0 -56
  19. data/vagrant-registration-0.0.16/lib/vagrant-registration/action.rb +0 -22
  20. data/vagrant-registration-0.0.16/lib/vagrant-registration/config.rb +0 -39
  21. data/vagrant-registration-0.0.16/lib/vagrant-registration/plugin.rb +0 -74
  22. data/vagrant-registration-0.0.16/lib/vagrant-registration/version.rb +0 -5
  23. data/vagrant-registration-0.0.16/lib/vagrant-registration.rb +0 -21
  24. data/vagrant-registration-0.0.16/plugins/guests/redhat/cap/registration.rb +0 -72
  25. data/vagrant-registration-0.0.16/plugins/guests/redhat/cap/subscription_manager.rb +0 -63
  26. data/vagrant-registration-0.0.16/plugins/guests/redhat/plugin.rb +0 -62
  27. data/vagrant-registration-0.0.16/tests/helpers.sh +0 -128
  28. data/vagrant-registration-0.0.16/tests/run.sh +0 -59
  29. data/vagrant-registration-0.0.16/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +0 -19
  30. data/vagrant-registration-0.0.16/tests/vagrantfiles/Vagrantfile.rhel_wrong_credentials +0 -14
  31. data/vagrant-registration-0.0.16/vagrant-registration.gemspec +0 -49
  32. data/vagrant-registration-0.0.17/.gitignore +0 -34
  33. data/vagrant-registration-0.0.17/CHANGELOG.md +0 -3
  34. data/vagrant-registration-0.0.17/Gemfile +0 -9
  35. data/vagrant-registration-0.0.17/LICENSE.md +0 -339
  36. data/vagrant-registration-0.0.17/README.md +0 -149
  37. data/vagrant-registration-0.0.17/Rakefile +0 -25
  38. data/vagrant-registration-0.0.17/Vagrantfile +0 -44
  39. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/ChangeHostName.html +0 -1016
  40. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/ConfigureNetworks.html +0 -355
  41. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/Flavor.html +0 -209
  42. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/NFSClient.html +0 -189
  43. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap/NetworkScriptsDir.html +0 -205
  44. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Cap.html +0 -117
  45. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Guest.html +0 -211
  46. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora/Plugin.html +0 -120
  47. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestFedora.html +0 -119
  48. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/RedHatCertification.html +0 -189
  49. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/Register.html +0 -191
  50. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/SubscriptionManager.html +0 -189
  51. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap/Unregister.html +0 -189
  52. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Cap.html +0 -117
  53. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat/Plugin.html +0 -120
  54. data/vagrant-registration-0.0.17/doc/VagrantPlugins/GuestRedHat.html +0 -119
  55. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Action/Register.html +0 -345
  56. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Action/Unregister.html +0 -315
  57. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Action.html +0 -246
  58. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Config.html +0 -433
  59. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors/RegisterError.html +0 -123
  60. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors/UnregisterError.html +0 -123
  61. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors/VagrantRHELError.html +0 -123
  62. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Errors.html +0 -115
  63. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration/Plugin.html +0 -356
  64. data/vagrant-registration-0.0.17/doc/VagrantPlugins/Registration.html +0 -226
  65. data/vagrant-registration-0.0.17/doc/VagrantPlugins.html +0 -117
  66. data/vagrant-registration-0.0.17/doc/_index.html +0 -375
  67. data/vagrant-registration-0.0.17/doc/class_list.html +0 -58
  68. data/vagrant-registration-0.0.17/doc/css/common.css +0 -1
  69. data/vagrant-registration-0.0.17/doc/css/full_list.css +0 -57
  70. data/vagrant-registration-0.0.17/doc/css/style.css +0 -339
  71. data/vagrant-registration-0.0.17/doc/file.README.html +0 -135
  72. data/vagrant-registration-0.0.17/doc/file_list.html +0 -60
  73. data/vagrant-registration-0.0.17/doc/frames.html +0 -26
  74. data/vagrant-registration-0.0.17/doc/index.html +0 -135
  75. data/vagrant-registration-0.0.17/doc/js/app.js +0 -219
  76. data/vagrant-registration-0.0.17/doc/js/full_list.js +0 -181
  77. data/vagrant-registration-0.0.17/doc/js/jquery.js +0 -4
  78. data/vagrant-registration-0.0.17/doc/method_list.html +0 -279
  79. data/vagrant-registration-0.0.17/doc/top-level-namespace.html +0 -112
  80. data/vagrant-registration-0.0.17/dummy.box +0 -0
  81. data/vagrant-registration-0.0.17/lib/vagrant-registration/action/register.rb +0 -113
  82. data/vagrant-registration-0.0.17/lib/vagrant-registration/action/unregister.rb +0 -56
  83. data/vagrant-registration-0.0.17/lib/vagrant-registration/action.rb +0 -22
  84. data/vagrant-registration-0.0.17/lib/vagrant-registration/config.rb +0 -39
  85. data/vagrant-registration-0.0.17/lib/vagrant-registration/plugin.rb +0 -74
  86. data/vagrant-registration-0.0.17/lib/vagrant-registration/version.rb +0 -5
  87. data/vagrant-registration-0.0.17/lib/vagrant-registration.rb +0 -21
  88. data/vagrant-registration-0.0.17/plugins/guests/redhat/cap/registration.rb +0 -72
  89. data/vagrant-registration-0.0.17/plugins/guests/redhat/cap/subscription_manager.rb +0 -63
  90. data/vagrant-registration-0.0.17/plugins/guests/redhat/plugin.rb +0 -62
  91. data/vagrant-registration-0.0.17/tests/helpers.sh +0 -128
  92. data/vagrant-registration-0.0.17/tests/run.sh +0 -59
  93. data/vagrant-registration-0.0.17/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +0 -19
  94. data/vagrant-registration-0.0.17/tests/vagrantfiles/Vagrantfile.rhel_wrong_credentials +0 -14
  95. data/vagrant-registration-0.0.17/vagrant-registration.gemspec +0 -49
  96. data/vagrant-registration-0.0.17/vagrant-registration.spec +0 -90
  97. data/vagrant-registration.spec +0 -90
@@ -1,112 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <title>
7
- Top Level Namespace
8
-
9
- &mdash; Documentation by YARD 0.8.7.6
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- hasFrames = window.top.frames.main ? true : false;
19
- relpath = '';
20
- framesUrl = "frames.html#!top-level-namespace.html";
21
- </script>
22
-
23
-
24
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
-
26
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
-
28
-
29
- </head>
30
- <body>
31
- <div id="header">
32
- <div id="menu">
33
-
34
- <a href="_index.html">Index</a> &raquo;
35
-
36
-
37
- <span class="title">Top Level Namespace</span>
38
-
39
-
40
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
- </div>
42
-
43
- <div id="search">
44
-
45
- <a class="full_list_link" id="class_list_link"
46
- href="class_list.html">
47
- Class List
48
- </a>
49
-
50
- <a class="full_list_link" id="method_list_link"
51
- href="method_list.html">
52
- Method List
53
- </a>
54
-
55
- <a class="full_list_link" id="file_list_link"
56
- href="file_list.html">
57
- File List
58
- </a>
59
-
60
- </div>
61
- <div class="clear"></div>
62
- </div>
63
-
64
- <iframe id="search_frame"></iframe>
65
-
66
- <div id="content"><h1>Top Level Namespace
67
-
68
-
69
-
70
- </h1>
71
-
72
- <dl class="box">
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
- </dl>
82
- <div class="clear"></div>
83
-
84
- <h2>Defined Under Namespace</h2>
85
- <p class="children">
86
-
87
-
88
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="VagrantPlugins.html" title="VagrantPlugins (module)">VagrantPlugins</a></span>
89
-
90
-
91
-
92
-
93
- </p>
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
- </div>
104
-
105
- <div id="footer">
106
- Generated on Fri Apr 17 13:41:45 2015 by
107
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.7.6 (ruby-2.1.5).
109
- </div>
110
-
111
- </body>
112
- </html>
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,5 +0,0 @@
1
- module VagrantPlugins
2
- module Registration
3
- VERSION = "0.0.17"
4
- end
5
- 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
@@ -1,63 +0,0 @@
1
- module VagrantPlugins
2
- module GuestRedHat
3
- module Cap
4
- class SubscriptionManager
5
- # Test that we have subscription-manager installed
6
- def self.subscription_manager(machine)
7
- machine.communicate.test("/usr/sbin/subscription-manager", sudo: true)
8
- end
9
-
10
- # Register the machine using 'register' option, config is (Open)Struct
11
- def self.subscription_manager_register(machine, config)
12
- command = "subscription-manager register #{configuration_to_options(config)}"
13
- machine.communicate.execute("cmd=$(#{command}); if [ \"$?\" != \"0\" ]; then echo $cmd | grep 'This system is already registered' || (echo $cmd 1>&2 && exit 1) ; fi", sudo: true)
14
- end
15
-
16
- # Unregister the machine using 'unregister' option
17
- def self.subscription_manager_unregister(machine)
18
- machine.communicate.execute("subscription-manager unregister || :", sudo: true)
19
- end
20
-
21
- # Return required configuration options for subscription-manager
22
- def self.subscription_manager_credentials(machine)
23
- [[:username, :password], [:org, :activationkey]]
24
- end
25
-
26
- # Return secret options for subscription-manager
27
- def self.subscription_manager_secrets(machine)
28
- [:password]
29
- end
30
-
31
- private
32
-
33
- # Build additional subscription-manager options based on plugin configuration
34
- def self.configuration_to_options(config)
35
- config.force = true unless config.force
36
-
37
- # --auto-attach cannot be used in case of org/activationkey registration
38
- if config.org && config.activationkey
39
- config.auto_attach = false
40
- else
41
- config.auto_attach = true unless config.auto_attach
42
- end
43
-
44
- options = []
45
- options << "--username='#{config.username}'" if config.username
46
- options << "--password='#{config.password}'" if config.password
47
- options << "--serverurl='#{config.serverurl}'" if config.serverurl
48
- options << "--baseurl='#{config.baseurl}'" if config.baseurl
49
- options << "--org='#{config.org}'" if config.org
50
- options << "--environment='#{config.environment}'" if config.environment
51
- options << "--name='#{config.name}'" if config.name
52
- options << "--auto-attach" if config.auto_attach
53
- options << "--activationkey='#{config.activationkey}'" if config.activationkey
54
- options << "--servicelevel='#{config.servicelevel}'" if config.servicelevel
55
- options << "--release='#{config.release}'" if config.release
56
- options << "--force" if config.force
57
- options << "--type='#{config.type}'" if config.type
58
- options.join(' ')
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,62 +0,0 @@
1
- require "vagrant"
2
-
3
- module VagrantPlugins
4
- module GuestRedHat
5
- class Plugin < Vagrant.plugin("2")
6
- guest_capability("redhat", "registration_register") do
7
- require_relative "cap/registration"
8
- Cap::Registration
9
- end
10
-
11
- guest_capability("redhat", "registration_unregister") do
12
- require_relative "cap/registration"
13
- Cap::Registration
14
- end
15
-
16
- guest_capability("redhat", "registration_manager_installed") do
17
- require_relative "cap/registration"
18
- Cap::Registration
19
- end
20
-
21
- guest_capability("redhat", "registration_credentials") do
22
- require_relative "cap/registration"
23
- Cap::Registration
24
- end
25
-
26
- guest_capability("redhat", "registration_secrets") do
27
- require_relative "cap/registration"
28
- Cap::Registration
29
- end
30
-
31
- guest_capability("redhat", "registration_manager") do
32
- require_relative "cap/registration"
33
- Cap::Registration
34
- end
35
-
36
- guest_capability("redhat", "subscription_manager") do
37
- require_relative "cap/subscription_manager"
38
- Cap::SubscriptionManager
39
- end
40
-
41
- guest_capability("redhat", "subscription_manager_register") do
42
- require_relative "cap/subscription_manager"
43
- Cap::SubscriptionManager
44
- end
45
-
46
- guest_capability("redhat", "subscription_manager_unregister") do
47
- require_relative "cap/subscription_manager"
48
- Cap::SubscriptionManager
49
- end
50
-
51
- guest_capability("redhat", "subscription_manager_credentials") do
52
- require_relative "cap/subscription_manager"
53
- Cap::SubscriptionManager
54
- end
55
-
56
- guest_capability("redhat", "subscription_manager_secrets") do
57
- require_relative "cap/subscription_manager"
58
- Cap::SubscriptionManager
59
- end
60
- end
61
- end
62
- end