vagrant-registration 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a8f4534dbe539fa82bd23f06489bcdca99e03a92
4
+ data.tar.gz: 1dcb8d87da44d20fcac238e6b7fe81b1fc03dabd
5
+ SHA512:
6
+ metadata.gz: 5e19c82994c0c43052e8f4b14c2a7ae1d9ed3d82040a2529577093b2c206660503d5e7b5b8426a0b94c39fb6094ae1301e31cd380012be309d0b4f13bc01472e
7
+ data.tar.gz: cb80c45c5d3ed8aa63ebf8fdca976f1d84cede342ef260dd926d58a5cb767d3ac4c6d3cbe34e4286a63ecadd9c5e9f11b8b26ced3927847ed656fe8e8f8f16d3
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /spec/reports/
7
+ /pkg/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 0.1.0 (Oct 22, 2014)
2
+
3
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ end
6
+
7
+ group :plugins do
8
+ gem "vagrant-registration", path: "."
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vagrant-registration (0.0.1)
5
+
6
+ PATH
7
+ remote: ../vagrant
8
+ specs:
9
+ vagrant (1.7.0.dev)
10
+ bundler (>= 1.5.2, < 1.8.0)
11
+ childprocess (~> 0.5.0)
12
+ erubis (~> 2.7.0)
13
+ hashicorp-checkpoint (~> 0.1.1)
14
+ i18n (~> 0.6.0)
15
+ listen (~> 2.7.11)
16
+ log4r (~> 1.1.9, < 1.1.11)
17
+ net-scp (~> 1.1.0)
18
+ net-ssh (>= 2.6.6, < 2.10.0)
19
+ nokogiri (= 1.6.3.1)
20
+ rb-kqueue (~> 0.2.0)
21
+ wdm (~> 0.1.0)
22
+ winrm (~> 1.1.3)
23
+
24
+ GEM
25
+ remote: https://rubygems.org/
26
+ specs:
27
+ akami (1.2.2)
28
+ gyoku (>= 0.4.0)
29
+ nokogiri
30
+ builder (3.2.2)
31
+ celluloid (0.16.0)
32
+ timers (~> 4.0.0)
33
+ childprocess (0.5.5)
34
+ ffi (~> 1.0, >= 1.0.11)
35
+ erubis (2.7.0)
36
+ ffi (1.9.6)
37
+ gssapi (1.0.3)
38
+ ffi (>= 1.0.1)
39
+ gyoku (1.2.2)
40
+ builder (>= 2.1.2)
41
+ hashicorp-checkpoint (0.1.4)
42
+ hitimes (1.2.2)
43
+ httpclient (2.5.2)
44
+ httpi (0.9.7)
45
+ rack
46
+ i18n (0.6.11)
47
+ listen (2.7.11)
48
+ celluloid (>= 0.15.2)
49
+ rb-fsevent (>= 0.9.3)
50
+ rb-inotify (>= 0.9)
51
+ little-plugger (1.1.3)
52
+ log4r (1.1.10)
53
+ logging (1.8.2)
54
+ little-plugger (>= 1.1.3)
55
+ multi_json (>= 1.8.4)
56
+ multi_json (1.10.1)
57
+ net-scp (1.1.2)
58
+ net-ssh (>= 2.6.5)
59
+ net-ssh (2.9.1)
60
+ nokogiri (1.6.3.1)
61
+ nori (1.1.5)
62
+ rack (1.5.2)
63
+ rb-fsevent (0.9.4)
64
+ rb-inotify (0.9.5)
65
+ ffi (>= 0.5.0)
66
+ rb-kqueue (0.2.3)
67
+ ffi (>= 0.5.0)
68
+ rubyntlm (0.1.1)
69
+ savon (0.9.5)
70
+ akami (~> 1.0)
71
+ builder (>= 2.1.2)
72
+ gyoku (>= 0.4.0)
73
+ httpi (~> 0.9)
74
+ nokogiri (>= 1.4.0)
75
+ nori (~> 1.0)
76
+ wasabi (~> 1.0)
77
+ timers (4.0.1)
78
+ hitimes
79
+ uuidtools (2.1.5)
80
+ wasabi (1.0.0)
81
+ nokogiri (>= 1.4.0)
82
+ wdm (0.1.0)
83
+ winrm (1.1.3)
84
+ gssapi (~> 1.0.0)
85
+ httpclient (~> 2.2, >= 2.2.0.2)
86
+ logging (~> 1.6, >= 1.6.1)
87
+ nokogiri (~> 1.5)
88
+ rubyntlm (~> 0.1.1)
89
+ savon (= 0.9.5)
90
+ uuidtools (~> 2.1.2)
91
+
92
+ PLATFORMS
93
+ ruby
94
+
95
+ DEPENDENCIES
96
+ vagrant!
97
+ vagrant-registration!
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # vagrant-registration
2
+
3
+ The vagrant-registration plugin supports new capabilities "register" and "unregister." The "register" event occurs during the "up" process, immediately after startup but before any provisioning (including built-in like rysnc). The "unregister" event occurs during the "halt" process (which also is called during the "destroy" process) immediately before the instances goes down.
4
+
5
+ Essentially, this supports developers wanting to use linuxes that have a subscription model for updates, like RHEL.
6
+
7
+ To use, make sure you have the cabilities registered, then set environment variables for your user and password.The two environment variables are 'SUB_USERNAME' and 'SUB_PASSWORD'. Decided to use environment variables to not force the user to type in the user and pass all the time.
8
+
9
+ ## Using
10
+
11
+ The plugin is still very early alpha, so YMMV. If you try it out, and have problems, please feel free to file an issue.
12
+
13
+ * Grab https://github.com/whitel/vagrant-registration/blob/c98e5d773b1621bc41454417c01fcc36a5f85270/pkg/vagrant-registration-0.0.1.gem (which should be the v0.1.1 gem file).
14
+ * vagrant plugin install vagrant-registration-0.0.1.gem
15
+ * Set SUB_USERNAME & SUB_PASSWORD env vars
16
+ * that should be it
17
+
18
+ ## Support
19
+ Currently, "capabilities" are only provided for Red Hat's Subscription Manager. To add others, one just needs to add a new guest plugin, then a cap directory with register.rb and unregister.rb. See the redhat guest for an example.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/Vagrantfile ADDED
@@ -0,0 +1,44 @@
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
+
data/dummy.box ADDED
Binary file
@@ -0,0 +1,27 @@
1
+ module VagrantPlugins
2
+ module Registration
3
+ module Action
4
+ # This registers the guest if the guest plugin supports it
5
+ class Register
6
+
7
+ def initialize(app, env)
8
+ @app = app
9
+ @env = env
10
+ @logger = Log4r::Logger.new("vagrant_register::action::register")
11
+ end
12
+
13
+ def call(env)
14
+ @app.call(env)
15
+ guest = @env[:machine].guest
16
+ @logger.info("Testing for registration_register capability on ")
17
+
18
+ if guest.capability?(:register)
19
+ @logger.info("registration_register capability exists on ")
20
+ result = guest.capability(:register)
21
+ @logger.info("called registration_register capability on ")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ module VagrantPlugins
2
+ module Registration
3
+ module Action
4
+ # This unregisters the guest if the guest plugin supports it
5
+ class Unregister
6
+
7
+ def initialize(app, env)
8
+ @app = app
9
+ @env = env
10
+ @logger = Log4r::Logger.new("vagrant_register::action::unregister")
11
+ end
12
+
13
+ def call(env)
14
+ guest = @env[:machine].guest
15
+ # @logger.info("Testing for registration_unregister capability on ")
16
+ if guest.capability?(:unregister)
17
+ @logger.info("registration_unregister capability exists on ")
18
+ result = guest.capability(:unregister)
19
+ @logger.info("called registration_unregister capability on ")
20
+ end
21
+
22
+ @app.call(env)
23
+
24
+ rescue Vagrant::Errors::MachineGuestNotReady => e
25
+ @logger.info("Machine is offline (caught error: #{e.inspect} ), no need to unreg: #{e.inspect}")
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,29 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Registration
5
+ class Config < Vagrant.plugin("2", :config)
6
+ # The username to subscribe with
7
+ #
8
+ # @return [String]
9
+ attr_accessor :subscriber_username
10
+
11
+ # The password of the subscriber
12
+ #
13
+ # @return [String]
14
+ attr_accessor :subscriber_password
15
+
16
+ def initialize(region_specific=false)
17
+ @subscriber_username = UNSET_VALUE
18
+ @subscriber_password = UNSET_VALUE
19
+ end
20
+
21
+ def finalize!
22
+ # Try to get user & pass from environment variables; they
23
+ # will default to nil if the environment variables are not present.
24
+ @subscriber_username = ENV['SUB_USERNAME'] if @subscriber_username == UNSET_VALUE
25
+ @subscriber_password = ENV['SUB_PASSWORD'] if @subscriber_password == UNSET_VALUE
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Registration
5
+ class Config < Vagrant.plugin("2", :config)
6
+
7
+ # @return [Vagrant::UI::Colored]
8
+ attr_accessor :ui
9
+
10
+ def initialize(region_specific=false)
11
+ vagrant_version = Gem::Version.new(::Vagrant::VERSION)
12
+ if vagrant_version >= Gem::Version.new("1.5")
13
+ @ui = ::Vagrant::UI::Colored.new
14
+ @ui.opts[:target] = 'Registration'
15
+ elsif vagrant_version >= Gem::Version.new("1.2")
16
+ @ui = ::Vagrant::UI::Colored.new.scope('Registration')
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Registration
5
+ module Errors
6
+ class VagrantRHELError < Vagrant::Errors::VagrantError
7
+ error_namespace("vagrant_registration.errors")
8
+ end
9
+
10
+ class RegisterError < VagrantRegistrationError
11
+ error_key(:register)
12
+ end
13
+
14
+ class UnregisterError < VagrantRegistrationError
15
+ error_key(:unregister)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,65 @@
1
+ # This is a sanity check to make sure no one is attempting to install
2
+ # this into an early Vagrant version.
3
+ if Vagrant::VERSION < "1.2.0"
4
+ raise "The Vagrant RHEL plugin is only compatible with Vagrant 1.2+"
5
+ end
6
+
7
+ module VagrantPlugins
8
+ module Registration
9
+ class Plugin < Vagrant.plugin("2")
10
+ def initialize(app, env)
11
+ @app = app
12
+ end
13
+
14
+ class << self
15
+ def initialize(app, env)
16
+ @app = app
17
+ @logger = Log4r::Logger.new("vagrant_register::plugin")
18
+ end
19
+
20
+ def register(hook)
21
+ @logger.info("in register hook")
22
+ hook.after(::Vagrant::Action::Builtin::ConfigValidate,
23
+ VagrantPlugins::Registration::Action.action_register)
24
+ end
25
+
26
+ def unregister(hook)
27
+ @logger.info("in unregister hook")
28
+ hook.prepend(VagrantPlugins::Registration::Action.action_unregister)
29
+ end
30
+
31
+ def unregister_on_destroy(hook)
32
+ @logger.info("in unregister_on_destroy hook")
33
+ hook.after(::Vagrant::Action::Builtin::ConfigValidate,
34
+ VagrantPlugins::Registration::Action.action_unregister)
35
+ end
36
+
37
+ end
38
+
39
+ name "Registration"
40
+ description <<-DESC
41
+ This plugin adds register and unregister functionality to Vagrant Guests that
42
+ support the capability
43
+ DESC
44
+
45
+ @logger = Log4r::Logger.new("vagrant_register::plugin::setup")
46
+ @logger.info("attempting to register hooks on up")
47
+ action_hook(:registration_register, :machine_action_up, &method(:register))
48
+ action_hook(:registration_register, :machine_action_provision, &method(:register))
49
+
50
+ @logger.info("attempting to register hooks on halt")
51
+ action_hook(:registration_unregister, :machine_action_halt, &method(:unregister))
52
+ action_hook(:registration_unregister, :machine_action_destroy, &method(:unregister))
53
+
54
+ @logger.info("attempting to register hooks on destroy")
55
+ action_hook(:registration_unregister, :machine_action_destroy, &method(:unregister_on_destroy))
56
+
57
+ config(:registration) do
58
+ require_relative 'config'
59
+ Config
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Registration
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
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
data/locales/en.yml ADDED
@@ -0,0 +1,136 @@
1
+ en:
2
+ vagrant_aws:
3
+ already_status: |-
4
+ The machine is already %{status}.
5
+ elb:
6
+ adjusting: |-
7
+ Adjusting availability zones of ELB %{elb_name}...
8
+ registering: |-
9
+ Registering %{instance_id} at ELB %{elb_name}...
10
+ deregistering: |-
11
+ Deregistering %{instance_id} from ELB %{elb_name}...
12
+ ok: |-
13
+ ok
14
+ skipped: |-
15
+ skipped
16
+
17
+ launching_instance: |-
18
+ Launching an instance with the following settings...
19
+ launch_no_keypair: |-
20
+ Warning! You didn't specify a keypair to launch your instance with.
21
+ This can sometimes result in not being able to access your instance.
22
+ launch_vpc_warning: |-
23
+ Warning! You're launching this instance into a VPC without an
24
+ elastic IP. Please verify you're properly connected to a VPN so
25
+ you can access this machine, otherwise Vagrant will not be able
26
+ to SSH into it.
27
+ not_created: |-
28
+ Instance is not created. Please run `vagrant up` first.
29
+ ready: |-
30
+ Machine is booted and ready for use!
31
+ rsync_not_found_warning: |-
32
+ Warning! Folder sync disabled because the rsync binary is missing in the %{side}.
33
+ Make sure rsync is installed and the binary can be found in the PATH.
34
+ rsync_folder: |-
35
+ Rsyncing folder: %{hostpath} => %{guestpath}
36
+ starting: |-
37
+ Starting the instance...
38
+ stopping: |-
39
+ Stopping the instance...
40
+ terminating: |-
41
+ Terminating the instance...
42
+ waiting_for_ready: |-
43
+ Waiting for instance to become "ready"...
44
+ waiting_for_ssh: |-
45
+ Waiting for SSH to become available...
46
+ warn_networks: |-
47
+ Warning! The AWS provider doesn't support any of the Vagrant
48
+ high-level network configurations (`config.vm.network`). They
49
+ will be silently ignored.
50
+ warn_ssh_access: |-
51
+ Warning! Vagrant might not be able to SSH into the instance.
52
+ Please check your security groups settings.
53
+ will_not_destroy: |-
54
+ The instance '%{name}' will not be destroyed, since the confirmation
55
+ was declined.
56
+
57
+ config:
58
+ access_key_id_required: |-
59
+ An access key ID must be specified via "access_key_id"
60
+ ami_required: |-
61
+ An AMI must be configured via "ami" (region: #{region})
62
+ private_key_missing: |-
63
+ The specified private key for AWS could not be found
64
+ region_required: |-
65
+ A region must be specified via "region"
66
+ secret_access_key_required: |-
67
+ A secret access key is required via "secret_access_key"
68
+ subnet_id_required_with_public_ip: |-
69
+ If you assign a public IP address to an instance in a VPC, a subnet must be specifed via "subnet_id"
70
+
71
+ errors:
72
+ fog_error: |-
73
+ There was an error talking to AWS. The error message is shown
74
+ below:
75
+
76
+ %{message}
77
+ internal_fog_error: |-
78
+ There was an error talking to AWS. The error message is shown
79
+ below:
80
+
81
+ Error: %{error}
82
+ Response: %{response}
83
+ instance_ready_timeout: |-
84
+ The instance never became "ready" in AWS. The timeout currently
85
+ set waiting for the instance to become ready is %{timeout} seconds.
86
+ Please verify that the machine properly boots. If you need more time
87
+ set the `instance_ready_timeout` configuration on the AWS provider.
88
+ rsync_error: |-
89
+ There was an error when attempting to rsync a shared folder.
90
+ Please inspect the error message below for more info.
91
+
92
+ Host path: %{hostpath}
93
+ Guest path: %{guestpath}
94
+ Error: %{stderr}
95
+ mkdir_error: |-
96
+ There was an error when attempting to create a shared host folder.
97
+ Please inspect the error message below for more info.
98
+
99
+ Host path: %{hostpath}
100
+ Error: %{err}
101
+ elb_does_not_exist: |-
102
+ ELB configured for the instance does not exist
103
+
104
+ states:
105
+ short_not_created: |-
106
+ not created
107
+ long_not_created: |-
108
+ The EC2 instance is not created. Run `vagrant up` to create it.
109
+
110
+ short_stopped: |-
111
+ stopped
112
+ long_stopped: |-
113
+ The EC2 instance is stopped. Run `vagrant up` to start it.
114
+
115
+ short_stopping: |-
116
+ stopping
117
+ long_stopping: |-
118
+ The EC2 instance is stopping. Wait until is completely stopped to
119
+ run `vagrant up` and start it.
120
+
121
+ short_pending: |-
122
+ pending
123
+ long_pending: |-
124
+ The EC2 instance is pending a start (i.e. this is a transition state).
125
+
126
+ short_running: |-
127
+ running
128
+ long_running: |-
129
+ The EC2 instance is running. To stop this machine, you can run
130
+ `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
131
+
132
+ short_pending: |-
133
+ pending
134
+ long_pending: |-
135
+ The EC2 instance is still being initialized. To destroy this machine,
136
+ you can run `vagrant destroy`.
@@ -0,0 +1,14 @@
1
+ module VagrantPlugins
2
+ module GuestRedHat
3
+ module Cap
4
+ class Register
5
+ def self.register(machine)
6
+ username = machine.config.registration.subscriber_username
7
+ password = machine.config.registration.subscriber_password
8
+ command = "subscription-manager register --username=#{username} --password=#{password} --auto-attach"
9
+ 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)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module VagrantPlugins
2
+ module GuestRedHat
3
+ module Cap
4
+ class Unregister
5
+ def self.unregister(machine)
6
+ begin
7
+ if machine.communicate.ready?
8
+ machine.communicate.execute("subscription-manager unregister || :", sudo: true)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ # if !machine.communicate.ready?
19
+ # raise Vagrant::Errors::VMNotCreatedError
20
+ # end
21
+
22
+ # rescue IOError
23
+ # Ignore, this probably means connection closed because it
24
+ # shut down.
@@ -0,0 +1,17 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module GuestRedHat
5
+ class Plugin < Vagrant.plugin("2")
6
+ guest_capability("redhat", "register") do
7
+ require_relative "cap/register"
8
+ Cap::Register
9
+ end
10
+
11
+ guest_capability("redhat", "unregister") do
12
+ require_relative "cap/unregister"
13
+ Cap::Unregister
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,50 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require "vagrant-registration/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "vagrant-registration"
6
+ s.version = VagrantPlugins::Registration::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.license = "Apache-2.0"
9
+ s.authors = "Langdon White"
10
+ s.email = "langdon@fedoraproject.org"
11
+ s.summary = "Enables guests to have a registration capability"
12
+ s.description = "Enables guests to have a registration capability"
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "vagrant-registration"
16
+
17
+ # this gemspec is, and parsing out the ignored files from the gitignore.
18
+ # Note that the entire gitignore(5) syntax is not supported, specifically
19
+ # the "!" syntax, but it should mostly work correctly.
20
+ root_path = File.dirname(__FILE__)
21
+ all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
22
+ all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
23
+ gitignore_path = File.join(root_path, ".gitignore")
24
+ gitignore = File.readlines(gitignore_path)
25
+ gitignore.map! { |line| line.chomp.strip }
26
+ gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
27
+
28
+ unignored_files = all_files.reject do |file|
29
+ # Ignore any directories, the gemspec only cares about files
30
+ next true if File.directory?(file)
31
+
32
+ # Ignore any paths that match anything in the gitignore. We do
33
+ # two tests here:
34
+ #
35
+ # - First, test to see if the entire path matches the gitignore.
36
+ # - Second, match if the basename does, this makes it so that things
37
+ # like '.DS_Store' will match sub-directories too (same behavior
38
+ # as git).
39
+ #
40
+ gitignore.any? do |ignore|
41
+ File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
42
+ File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
43
+ end
44
+ end
45
+
46
+ s.files = unignored_files
47
+ s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
48
+ s.require_path = 'lib'
49
+ end
50
+
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-registration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Langdon White
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Enables guests to have a registration capability
14
+ email: langdon@fedoraproject.org
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - .gitignore
20
+ - CHANGELOG.md
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - Vagrantfile
27
+ - dummy.box
28
+ - lib/vagrant-registration.rb
29
+ - lib/vagrant-registration/action.rb
30
+ - lib/vagrant-registration/action/register.rb
31
+ - lib/vagrant-registration/action/unregister.rb
32
+ - lib/vagrant-registration/config.rb
33
+ - lib/vagrant-registration/env.rb
34
+ - lib/vagrant-registration/errors.rb
35
+ - lib/vagrant-registration/plugin.rb
36
+ - lib/vagrant-registration/version.rb
37
+ - locales/en.yml
38
+ - plugins/guests/redhat/cap/register.rb
39
+ - plugins/guests/redhat/cap/unregister.rb
40
+ - plugins/guests/redhat/plugin.rb
41
+ - vagrant-registration.gemspec
42
+ homepage:
43
+ licenses:
44
+ - Apache-2.0
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: 1.3.6
60
+ requirements: []
61
+ rubyforge_project: vagrant-registration
62
+ rubygems_version: 2.4.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Enables guests to have a registration capability
66
+ test_files: []