vagrant-local 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.github/workflows/lint-release-and-publish-nightly.yml +73 -0
- data/.github/workflows/lint-release-and-publish.yml +71 -0
- data/.github/workflows/ruby-lint.yml +35 -0
- data/.gitignore +35 -0
- data/.rspec +2 -0
- data/.rubocop.yml +143 -0
- data/CHANGELOG.md +32 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +97 -0
- data/Gemfile +26 -0
- data/LICENSE +651 -0
- data/PULL_REQUEST_TEMPLATE.md +39 -0
- data/README.md +92 -0
- data/RELEASE.md +22 -0
- data/Rakefile +32 -0
- data/SECURITY.md +19 -0
- data/ansible.cfg +5 -0
- data/docs/CNAME +1 -0
- data/docs/_config.yml +1 -0
- data/docs/css/main.css +55 -0
- data/docs/css/styles.css +8678 -0
- data/docs/index.html +125 -0
- data/lib/vagrant-local/action/create.rb +27 -0
- data/lib/vagrant-local/action/destroy.rb +25 -0
- data/lib/vagrant-local/action/halt.rb +24 -0
- data/lib/vagrant-local/action/import.rb +27 -0
- data/lib/vagrant-local/action/is_created.rb +22 -0
- data/lib/vagrant-local/action/network.rb +24 -0
- data/lib/vagrant-local/action/network_cleanup.rb +26 -0
- data/lib/vagrant-local/action/not_created.rb +20 -0
- data/lib/vagrant-local/action/package.rb +135 -0
- data/lib/vagrant-local/action/restart.rb +27 -0
- data/lib/vagrant-local/action/setup.rb +24 -0
- data/lib/vagrant-local/action/shutdown.rb +47 -0
- data/lib/vagrant-local/action/start.rb +25 -0
- data/lib/vagrant-local/action/wait_till_boot.rb +47 -0
- data/lib/vagrant-local/action/wait_till_up.rb +65 -0
- data/lib/vagrant-local/action.rb +187 -0
- data/lib/vagrant-local/command/guest_power_controls.rb +58 -0
- data/lib/vagrant-local/command/local.rb +69 -0
- data/lib/vagrant-local/command/restart_guest.rb +29 -0
- data/lib/vagrant-local/command/shutdown_guest.rb +29 -0
- data/lib/vagrant-local/command/vnc_console.rb +48 -0
- data/lib/vagrant-local/command/webvnc_console.rb +49 -0
- data/lib/vagrant-local/config.rb +55 -0
- data/lib/vagrant-local/driver.rb +208 -0
- data/lib/vagrant-local/errors.rb +84 -0
- data/lib/vagrant-local/executor.rb +38 -0
- data/lib/vagrant-local/plugin.rb +76 -0
- data/lib/vagrant-local/provider.rb +83 -0
- data/lib/vagrant-local/util/subprocess.rb +31 -0
- data/lib/vagrant-local/util/timer.rb +19 -0
- data/lib/vagrant-local/version.rb +8 -0
- data/lib/vagrant-local.rb +29 -0
- data/locales/en.yml +187 -0
- data/vagrant-zones.gemspec +37 -0
- metadata +191 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'log4r'
|
4
|
+
require 'vagrant-local/util/timer'
|
5
|
+
require 'vagrant/util/retryable'
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module ProviderLocal
|
9
|
+
module Action
|
10
|
+
# This is used wait till the instance is booted
|
11
|
+
class WaitTillUp
|
12
|
+
include Vagrant::Util::Retryable
|
13
|
+
|
14
|
+
def initialize(app, _env)
|
15
|
+
@logger = Log4r::Logger.new('vagrant_local::action::import')
|
16
|
+
@app = app
|
17
|
+
end
|
18
|
+
|
19
|
+
def terminate(env)
|
20
|
+
return unless env[:machine].state.id != :not_created
|
21
|
+
|
22
|
+
# If we're not supposed to destroy on error then just return
|
23
|
+
return unless env[:destroy_on_error]
|
24
|
+
|
25
|
+
if env[:halt_on_error]
|
26
|
+
halt_env = env.dup
|
27
|
+
halt_env.delete(:interrupted)
|
28
|
+
halt_env[:config_validate] = false
|
29
|
+
env[:action_runner].run(Action.action_halt, halt_env)
|
30
|
+
else
|
31
|
+
destroy_env = env.dup
|
32
|
+
destroy_env.delete(:interrupted)
|
33
|
+
destroy_env[:config_validate] = false
|
34
|
+
destroy_env[:force_confirm_destroy] = true
|
35
|
+
env[:action_runner].run(Action.action_destroy, destroy_env)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def call(env)
|
40
|
+
@machine = env[:machine]
|
41
|
+
@driver = @machine.provider.driver
|
42
|
+
ui = env[:ui]
|
43
|
+
# Initialize metrics if they haven't been
|
44
|
+
env[:metrics] ||= {}
|
45
|
+
env[:metrics]['instance_ssh_time'] = Util::Timer.time do
|
46
|
+
retryable(on: Errors::TimeoutError, tries: 60) do
|
47
|
+
# If we're interrupted don't worry about waiting
|
48
|
+
next if env[:interrupted]
|
49
|
+
|
50
|
+
loop do
|
51
|
+
break if env[:interrupted]
|
52
|
+
break if env[:machine].communicate.ready?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
# if interrupted above, just terminate immediately
|
57
|
+
return terminate(env) if env[:interrupted]
|
58
|
+
|
59
|
+
ui.info(I18n.t('vagrant_local.ssh_ready') + " in #{env[:metrics]['instance_ssh_time']} Seconds")
|
60
|
+
@app.call(env)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'vagrant/action/builder'
|
4
|
+
require 'log4r'
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module ProviderLocal
|
8
|
+
# Run actions against the machine
|
9
|
+
module Action
|
10
|
+
include Vagrant::Action::Builtin
|
11
|
+
@logger = Log4r::Logger.new('vagrant_local::action')
|
12
|
+
|
13
|
+
# This action is called to bring the box up from nothing.
|
14
|
+
def self.action_up
|
15
|
+
Vagrant::Action::Builder.new.tap do |b|
|
16
|
+
b.use Call, IsCreated do |env, b2|
|
17
|
+
if env[:result]
|
18
|
+
env[:halt_on_error] = true
|
19
|
+
b2.use action_start
|
20
|
+
elsif !env[:result]
|
21
|
+
b2.use Create
|
22
|
+
b2.use Start
|
23
|
+
b2.use WaitTillBoot
|
24
|
+
b2.use Setup
|
25
|
+
b2.use WaitTillUp
|
26
|
+
b2.use Provision
|
27
|
+
b2.use SetHostname
|
28
|
+
b2.use SyncedFolders
|
29
|
+
b2.use SyncedFolderCleanup
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Assuming VM is created, just start it. This action is not called directly by any subcommand.
|
36
|
+
def self.action_start
|
37
|
+
Vagrant::Action::Builder.new.tap do |b|
|
38
|
+
b.use Call, IsState, :running do |env, b1|
|
39
|
+
if env[:result]
|
40
|
+
b1.use Message, I18n.t('vagrant_local.states.is_running')
|
41
|
+
next
|
42
|
+
end
|
43
|
+
b1.use Call, IsState, :uncleaned do |env2, b2|
|
44
|
+
b2.use Cleanup if env2[:result]
|
45
|
+
end
|
46
|
+
b1.use Start
|
47
|
+
b1.use WaitTillUp
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.action_restart
|
53
|
+
Vagrant::Action::Builder.new.tap do |b|
|
54
|
+
b.use Call, IsCreated do |_env, b2|
|
55
|
+
b2.use Call, IsState, :stopped do |env2, b3|
|
56
|
+
unless env2[:result]
|
57
|
+
b3.use WaitTillUp
|
58
|
+
b3.use Restart
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.action_shutdown
|
66
|
+
Vagrant::Action::Builder.new.tap do |b|
|
67
|
+
b.use Call, IsCreated do |_env, b2|
|
68
|
+
b2.use Call, IsState, :stopped do |env2, b3|
|
69
|
+
unless env2[:result]
|
70
|
+
b3.use WaitTillUp
|
71
|
+
b3.use Shutdown
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# This is the action that is primarily responsible for halting the virtual machine.
|
79
|
+
def self.action_halt
|
80
|
+
Vagrant::Action::Builder.new.tap do |b|
|
81
|
+
b.use Call, IsCreated do |env, b2|
|
82
|
+
unless env[:result]
|
83
|
+
b2.use NotCreated
|
84
|
+
next
|
85
|
+
end
|
86
|
+
b2.use Halt if env[:result]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# This action is called to SSH into the machine.
|
92
|
+
def self.action_ssh
|
93
|
+
Vagrant::Action::Builder.new.tap do |b|
|
94
|
+
b.use SSHExec
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.action_ssh_run
|
99
|
+
Vagrant::Action::Builder.new.tap do |b|
|
100
|
+
b.use SSHRun
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# This action is called when you try to package an existing virtual machine to an box image.
|
105
|
+
def self.action_package
|
106
|
+
Vagrant::Action::Builder.new.tap do |b|
|
107
|
+
b.use Package
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.
|
112
|
+
def self.action_destroy
|
113
|
+
Vagrant::Action::Builder.new.tap do |b|
|
114
|
+
b.use Call, IsCreated do |_env, b2|
|
115
|
+
# unless env[:result]
|
116
|
+
# b2.use NotCreated
|
117
|
+
# next
|
118
|
+
# end
|
119
|
+
b2.use Halt
|
120
|
+
b2.use Destroy
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# This action is called when `vagrant provision` is called.
|
126
|
+
def self.action_provision
|
127
|
+
Vagrant::Action::Builder.new.tap do |b|
|
128
|
+
b.use Call, IsCreated do |_env, b2|
|
129
|
+
b2.use Call, IsState, :running do |_env2, b3|
|
130
|
+
b3.use Provision
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# This is the action implements the reload command It uses the halt and start actions
|
137
|
+
def self.action_reload
|
138
|
+
Vagrant::Action::Builder.new.tap do |b|
|
139
|
+
b.use Call, IsCreated do |env, b2|
|
140
|
+
unless env[:result]
|
141
|
+
b2.use NotCreated
|
142
|
+
next
|
143
|
+
end
|
144
|
+
b2.use action_halt
|
145
|
+
b2.use action_start
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.action_box_outdated
|
151
|
+
Builder.new.tap do |b|
|
152
|
+
b.use Builtin::BoxCheckOutdated
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# This is the action that will remove a box given a name (and optionally
|
157
|
+
# a provider). This middleware sequence is built-in to Vagrant. Plugins
|
158
|
+
# can hook into this like any other middleware sequence.
|
159
|
+
def self.action_box_remove
|
160
|
+
Builder.new.tap do |b|
|
161
|
+
b.use Builtin::BoxRemove
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
action_root = Pathname.new(File.expand_path('action', __dir__))
|
166
|
+
autoload :Import, action_root.join('import')
|
167
|
+
autoload :Create, action_root.join('create')
|
168
|
+
autoload :Network, action_root.join('network')
|
169
|
+
autoload :Setup, action_root.join('setup')
|
170
|
+
autoload :Start, action_root.join('start')
|
171
|
+
autoload :NetworkingCleanup, action_root.join('network_cleanup')
|
172
|
+
autoload :IsCreated, action_root.join('is_created')
|
173
|
+
autoload :NotCreated, action_root.join('not_created')
|
174
|
+
autoload :CreateSnapshots, action_root.join('create_zfs_snapshots')
|
175
|
+
autoload :DeleteSnapshots, action_root.join('delete_zfs_snapshots')
|
176
|
+
autoload :ConfigureSnapshots, action_root.join('configure_zfs_snapshots')
|
177
|
+
autoload :Halt, action_root.join('halt')
|
178
|
+
autoload :Destroy, action_root.join('destroy')
|
179
|
+
autoload :WaitTillBoot, action_root.join('wait_till_boot')
|
180
|
+
autoload :WaitTillUp, action_root.join('wait_till_up')
|
181
|
+
autoload :Restart, action_root.join('restart')
|
182
|
+
autoload :Shutdown, action_root.join('shutdown')
|
183
|
+
autoload :PrepareNFSValidIds, action_root.join('prepare_nfs_valid_ids.rb')
|
184
|
+
autoload :Package, action_root.join('package.rb')
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderLocal
|
5
|
+
module Command
|
6
|
+
# This is used to manage the power controls for the instance
|
7
|
+
class GuestPowerControls < Vagrant.plugin('2', :command)
|
8
|
+
def initialize(argv, env)
|
9
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
10
|
+
|
11
|
+
@subcommands = Vagrant::Registry.new
|
12
|
+
@subcommands.register(:restart) do
|
13
|
+
require File.expand_path('restart_guest', __dir__)
|
14
|
+
RestartGuest
|
15
|
+
end
|
16
|
+
@subcommands.register(:shutdown) do
|
17
|
+
require File.expand_path('shutdown_guest', __dir__)
|
18
|
+
ShutdownGuest
|
19
|
+
end
|
20
|
+
super(argv, env)
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute
|
24
|
+
if @main_args.include?('-h') || @main_args.include?('--help')
|
25
|
+
# Print the help for all the vagrant-local commands.
|
26
|
+
return help
|
27
|
+
end
|
28
|
+
|
29
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
30
|
+
return help if !command_class || !@sub_command
|
31
|
+
|
32
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
33
|
+
|
34
|
+
# Initialize and execute the command class
|
35
|
+
command_class.new(@sub_args, @env).execute
|
36
|
+
end
|
37
|
+
|
38
|
+
def help
|
39
|
+
opts = OptionParser.new do |subopts|
|
40
|
+
subopts.banner = 'Usage: vagrant local control <subcommand> [<args>]'
|
41
|
+
subopts.separator ''
|
42
|
+
subopts.separator 'Available subcommands:'
|
43
|
+
# Add the available subcommands as separators in order to print them
|
44
|
+
# out as well.
|
45
|
+
keys = []
|
46
|
+
@subcommands.each { |(key, _value)| keys << key.to_s }
|
47
|
+
keys.sort.each do |key|
|
48
|
+
subopts.separator " #{key}"
|
49
|
+
end
|
50
|
+
subopts.separator ''
|
51
|
+
subopts.separator 'For help on any individual subcommand run `vagrant local control <subcommand> -h`'
|
52
|
+
end
|
53
|
+
@env.ui.info(opts.help, :prefix => false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'vagrant-local/action'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module ProviderLocal
|
7
|
+
module Command
|
8
|
+
# This is used manage the host where vagrant cannot
|
9
|
+
class Local < Vagrant.plugin('2', :command)
|
10
|
+
def self.synopsis
|
11
|
+
'Manage host and query host information'
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(argv, env)
|
15
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
16
|
+
|
17
|
+
@subcommands = Vagrant::Registry.new
|
18
|
+
|
19
|
+
@subcommands.register(:control) do
|
20
|
+
require File.expand_path('guest_power_controls', __dir__)
|
21
|
+
GuestPowerControls
|
22
|
+
end
|
23
|
+
@subcommands.register(:console) do
|
24
|
+
require File.expand_path('console', __dir__)
|
25
|
+
Console
|
26
|
+
end
|
27
|
+
super(argv, env)
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute
|
31
|
+
if @main_args.include?('-h') || @main_args.include?('--help')
|
32
|
+
# Print the help for all the vagrant-local commands.
|
33
|
+
return help
|
34
|
+
end
|
35
|
+
|
36
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
37
|
+
return help if !command_class || !@sub_command
|
38
|
+
|
39
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
40
|
+
|
41
|
+
# Initialize and execute the command class
|
42
|
+
command_class.new(@sub_args, @env).execute
|
43
|
+
end
|
44
|
+
|
45
|
+
def help
|
46
|
+
opts = OptionParser.new do |subopts|
|
47
|
+
subopts.banner = 'Usage: vagrant local <subcommand> [<args>]'
|
48
|
+
subopts.separator ''
|
49
|
+
subopts.separator 'Available subcommands:'
|
50
|
+
|
51
|
+
# Add the available subcommands as separators in order to print them
|
52
|
+
# out as well.
|
53
|
+
keys = []
|
54
|
+
@subcommands.each { |(key, _value)| keys << key.to_s }
|
55
|
+
|
56
|
+
keys.sort.each do |key|
|
57
|
+
subopts.separator " #{key}"
|
58
|
+
end
|
59
|
+
|
60
|
+
subopts.separator ''
|
61
|
+
subopts.separator 'For help on any individual subcommand run `vagrant local <subcommand> -h`'
|
62
|
+
end
|
63
|
+
|
64
|
+
@env.ui.info(opts.help, :prefix => false)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderLocal
|
5
|
+
module Command
|
6
|
+
# This is used to restart the guest from inside the guest
|
7
|
+
class RestartGuest < Vagrant.plugin('2', :command)
|
8
|
+
def execute
|
9
|
+
opts = OptionParser.new do |o|
|
10
|
+
o.banner = 'Usage: vagrant local control restart [options]'
|
11
|
+
end
|
12
|
+
|
13
|
+
argv = parse_options(opts)
|
14
|
+
return unless argv
|
15
|
+
|
16
|
+
unless argv.empty?
|
17
|
+
@env.ui.info(opts.help)
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
## Wait for VM up
|
22
|
+
with_target_vms(argv, provider: :local) do |machine|
|
23
|
+
machine.action('restart')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderLocal
|
5
|
+
module Command
|
6
|
+
# This is used to shutdown the guest from inside the guest
|
7
|
+
class ShutdownGuest < Vagrant.plugin('2', :command)
|
8
|
+
def execute
|
9
|
+
opts = OptionParser.new do |o|
|
10
|
+
o.banner = 'Usage: vagrant local control shutdown [options]'
|
11
|
+
end
|
12
|
+
|
13
|
+
argv = parse_options(opts)
|
14
|
+
return unless argv
|
15
|
+
|
16
|
+
unless argv.empty?
|
17
|
+
@env.ui.info(opts.help)
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
## Wait for VM up
|
22
|
+
with_target_vms(argv, provider: :local) do |machine|
|
23
|
+
machine.action('shutdown')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderLocal
|
5
|
+
module Command
|
6
|
+
# This is used to start a VNC console to the guest
|
7
|
+
class VNCConsole < Vagrant.plugin('2', :command)
|
8
|
+
def execute
|
9
|
+
options = {}
|
10
|
+
opts = OptionParser.new do |o|
|
11
|
+
o.banner = 'Usage: vagrant local console vnc [options]'
|
12
|
+
o.on('--ip <host_ip>', 'Specify host IP to listen on') do |p|
|
13
|
+
options[:ip] = p
|
14
|
+
end
|
15
|
+
o.on('--port <port>', 'Specify port to listen on') do |p|
|
16
|
+
options[:port] = p
|
17
|
+
end
|
18
|
+
o.on('--detach <yes/no>', 'Run console server in background') do |p|
|
19
|
+
options[:detach] = p
|
20
|
+
end
|
21
|
+
o.on('--kill <yes/no>', 'Kill the previous background console session') do |p|
|
22
|
+
options[:kill] = p
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
argv = parse_options(opts)
|
27
|
+
return unless argv
|
28
|
+
|
29
|
+
unless argv.length <= 4
|
30
|
+
@env.ui.info(opts.help)
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
options[:port] = nil unless options[:port] =~ /\d/
|
35
|
+
with_target_vms(argv, provider: :local) do |machine|
|
36
|
+
driver = machine.provider.driver
|
37
|
+
detach = 'yes'
|
38
|
+
detach = 'no' unless options[:detach] == 'yes'
|
39
|
+
kill = 'yes'
|
40
|
+
kill = 'no' unless options[:kill] == 'yes'
|
41
|
+
exit = { detach: detach, kill: kill }
|
42
|
+
driver.console(@env.ui, 'vnc', options[:ip], options[:port], exit)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'resolv'
|
4
|
+
module VagrantPlugins
|
5
|
+
module ProviderLocal
|
6
|
+
module Command
|
7
|
+
# This is used to start a WebVNC console to the guest
|
8
|
+
class WebVNCConsole < Vagrant.plugin('2', :command)
|
9
|
+
def execute
|
10
|
+
options = {}
|
11
|
+
opts = OptionParser.new do |o|
|
12
|
+
o.banner = 'Usage: vagrant local console webvnc [options]'
|
13
|
+
o.on('--ip <host_ip>', 'Specify host IP to listen on') do |p|
|
14
|
+
options[:ip] = p
|
15
|
+
end
|
16
|
+
o.on('--port <port>', 'Specify port to listen on') do |p|
|
17
|
+
options[:port] = p
|
18
|
+
end
|
19
|
+
o.on('--detach <yes/no>', 'Run console server in background') do |p|
|
20
|
+
options[:detach] = p
|
21
|
+
end
|
22
|
+
o.on('--kill <yes/no>', 'Kill the previous background console session') do |p|
|
23
|
+
options[:kill] = p
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
argv = parse_options(opts)
|
28
|
+
return unless argv
|
29
|
+
|
30
|
+
unless argv.length <= 4
|
31
|
+
@env.ui.info(opts.help)
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
options[:port] = nil unless options[:port] =~ /\d/
|
36
|
+
with_target_vms(argv, provider: :local) do |machine|
|
37
|
+
driver = machine.provider.driver
|
38
|
+
detach = 'yes'
|
39
|
+
detach = 'no' unless options[:detach] == 'yes'
|
40
|
+
kill = 'yes'
|
41
|
+
kill = 'no' unless options[:kill] == 'yes'
|
42
|
+
exit = { detach: detach, kill: kill }
|
43
|
+
driver.console(@env.ui, 'webvnc', options[:ip], options[:port], exit)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'vagrant'
|
4
|
+
## Do not Modify this File! Modify the Hosts.yml, Hosts.rb, or Vagrantfile!
|
5
|
+
module VagrantPlugins
|
6
|
+
module ProviderLocal
|
7
|
+
# This is used define the variables for the project
|
8
|
+
class Config < Vagrant.plugin('2', :config)
|
9
|
+
# rubocop:disable Layout/LineLength
|
10
|
+
attr_accessor :brand, :autoboot, :setup_method, :safe_restart, :allowed_address, :post_provision_boot, :safe_shutdown, :boxshortname, :kernel, :debug, :debug_boot, :private_network, :winalcheck, :winlcheck, :lcheck, :alcheck, :snapshot_script, :diskif, :netif, :cdroms, :disk1path, :disk1size, :cpus, :cpu_configuration, :boot, :complex_cpu_conf, :memory, :vagrant_user, :vagrant_user_private_key_path, :setup_wait, :on_demand_vnics, :clean_shutdown_time, :dhcp4, :vagrant_user_pass, :firmware_type, :vm_type, :partition_id, :shared_disk_enabled, :shared_dir, :acpi, :os_type, :console, :consolehost, :consoleport, :console_onboot, :hostbridge, :sshport, :rdpport, :override, :additional_disks, :cloud_init_resolvers, :cloud_init_enabled, :cloud_init_dnsdomain, :cloud_init_password, :cloud_init_sshkey, :cloud_init_conf, :dns, :box, :vagrant_cloud_creator, :winbooted_string, :booted_string, :zunlockbootkey, :zunlockboot, :xhci_enabled, :login_wait
|
11
|
+
|
12
|
+
# rubocop:enable Layout/LineLength
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super
|
16
|
+
@brand = 'bhyve'
|
17
|
+
@additional_disks = UNSET_VALUE
|
18
|
+
@autoboot = true
|
19
|
+
@post_provision_boot = false
|
20
|
+
@kernel = nil
|
21
|
+
@boxshortname = UNSET_VALUE
|
22
|
+
@cdroms = nil
|
23
|
+
@shared_dir = nil
|
24
|
+
@os_type = 'generic'
|
25
|
+
@debug_boot = nil
|
26
|
+
@debug = nil
|
27
|
+
@consoleport = nil
|
28
|
+
@consolehost = '0.0.0.0'
|
29
|
+
@console_onboot = 'false'
|
30
|
+
@console = 'webvnc'
|
31
|
+
@memory = '2G'
|
32
|
+
@diskif = 'virtio-blk'
|
33
|
+
@netif = 'virtio-net-viona'
|
34
|
+
@cpus = 1
|
35
|
+
@boot = UNSET_VALUE
|
36
|
+
@setup_wait = 90
|
37
|
+
@box = UNSET_VALUE
|
38
|
+
@clean_shutdown_time = 300
|
39
|
+
@vmtype = 'production'
|
40
|
+
@partition_id = '0000'
|
41
|
+
@sshport = '22'
|
42
|
+
@rdpport = '3389'
|
43
|
+
@vagrant_user = 'vagrant'
|
44
|
+
@vagrant_user_pass = 'vagrant'
|
45
|
+
@vagrant_user_private_key_path = './id_rsa'
|
46
|
+
@xhci_enabled = 'off'
|
47
|
+
@override = false
|
48
|
+
@login_wait = 5
|
49
|
+
@private_network = nil
|
50
|
+
@vm_type = 'production'
|
51
|
+
@setup_method = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|