vagrant-zones 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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/codeql-analysis.yml +72 -0
  6. data/.github/workflows/lint-release-and-publish.yml +70 -0
  7. data/.github/workflows/ruby-lint.yml +35 -0
  8. data/.gitignore +35 -0
  9. data/.rspec +2 -0
  10. data/.rubocop.yml +143 -0
  11. data/CHANGELOG.md +0 -0
  12. data/CODE_OF_CONDUCT.md +128 -0
  13. data/CONTRIBUTING.md +96 -0
  14. data/Gemfile +14 -0
  15. data/LICENSE +651 -0
  16. data/PULL_REQUEST_TEMPLATE.md +39 -0
  17. data/README.md +81 -0
  18. data/RELEASE.md +15 -0
  19. data/Rakefile +32 -0
  20. data/SECURITY.md +19 -0
  21. data/docs/CNAME +1 -0
  22. data/docs/_config.yml +1 -0
  23. data/docs/css/main.css +55 -0
  24. data/docs/css/styles.css +8678 -0
  25. data/docs/index.html +127 -0
  26. data/lib/vagrant-zones/action/create.rb +29 -0
  27. data/lib/vagrant-zones/action/destroy.rb +27 -0
  28. data/lib/vagrant-zones/action/halt.rb +24 -0
  29. data/lib/vagrant-zones/action/import.rb +112 -0
  30. data/lib/vagrant-zones/action/is_created.rb +22 -0
  31. data/lib/vagrant-zones/action/network.rb +26 -0
  32. data/lib/vagrant-zones/action/not_created.rb +20 -0
  33. data/lib/vagrant-zones/action/package.rb +134 -0
  34. data/lib/vagrant-zones/action/prepare_nfs_valid_ids.rb +24 -0
  35. data/lib/vagrant-zones/action/restart.rb +53 -0
  36. data/lib/vagrant-zones/action/setup.rb +26 -0
  37. data/lib/vagrant-zones/action/shutdown.rb +47 -0
  38. data/lib/vagrant-zones/action/start.rb +25 -0
  39. data/lib/vagrant-zones/action/wait_till_boot.rb +59 -0
  40. data/lib/vagrant-zones/action/wait_till_up.rb +65 -0
  41. data/lib/vagrant-zones/action.rb +204 -0
  42. data/lib/vagrant-zones/command/configure_snapshots.rb +49 -0
  43. data/lib/vagrant-zones/command/console.rb +63 -0
  44. data/lib/vagrant-zones/command/create_snapshots.rb +46 -0
  45. data/lib/vagrant-zones/command/delete_snapshots.rb +38 -0
  46. data/lib/vagrant-zones/command/guest_power_controls.rb +58 -0
  47. data/lib/vagrant-zones/command/list_snapshots.rb +44 -0
  48. data/lib/vagrant-zones/command/restart_guest.rb +29 -0
  49. data/lib/vagrant-zones/command/shutdown_guest.rb +29 -0
  50. data/lib/vagrant-zones/command/vnc_console.rb +48 -0
  51. data/lib/vagrant-zones/command/webvnc_console.rb +49 -0
  52. data/lib/vagrant-zones/command/zfssnapshot.rb +67 -0
  53. data/lib/vagrant-zones/command/zlogin_console.rb +40 -0
  54. data/lib/vagrant-zones/command/zone.rb +73 -0
  55. data/lib/vagrant-zones/config.rb +78 -0
  56. data/lib/vagrant-zones/driver.rb +1710 -0
  57. data/lib/vagrant-zones/errors.rb +61 -0
  58. data/lib/vagrant-zones/executor.rb +38 -0
  59. data/lib/vagrant-zones/plugin.rb +79 -0
  60. data/lib/vagrant-zones/provider.rb +83 -0
  61. data/lib/vagrant-zones/util/subprocess.rb +31 -0
  62. data/lib/vagrant-zones/util/timer.rb +19 -0
  63. data/lib/vagrant-zones/version.rb +7 -0
  64. data/lib/vagrant-zones.rb +29 -0
  65. data/locales/en.yml +326 -0
  66. data/vagrant-zones.gemspec +51 -0
  67. metadata +412 -0
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module ProviderZone
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 zone 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: :zone) 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 ProviderZone
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 zone 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: :zone) 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 ProviderZone
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 zone 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: :zone) 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,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module ProviderZone
5
+ module Command
6
+ # This is used to manage ZFS snapshtos for the zone
7
+ class ZFSSnapshot < 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(:list) do
13
+ require File.expand_path('list_snapshots', __dir__)
14
+ ListSnapshots
15
+ end
16
+ @subcommands.register(:create) do
17
+ require File.expand_path('create_snapshots', __dir__)
18
+ CreateSnapshots
19
+ end
20
+ @subcommands.register(:delete) do
21
+ require File.expand_path('delete_snapshots', __dir__)
22
+ DeleteSnapshots
23
+ end
24
+ @subcommands.register(:configure) do
25
+ require File.expand_path('configure_snapshots', __dir__)
26
+ ConfigureSnapshots
27
+ end
28
+ super(argv, env)
29
+ end
30
+
31
+ def execute
32
+ if @main_args.include?('-h') || @main_args.include?('--help')
33
+ # Print the help for all the vagrant-zones commands.
34
+ return help
35
+ end
36
+
37
+ command_class = @subcommands.get(:create) if @sub_command.nil?
38
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
39
+
40
+ subargs = @sub_args unless @sub_args.nil?
41
+ @logger.debug("Invoking command class: #{command_class} #{subargs.inspect}")
42
+
43
+ # Initialize and execute the command class
44
+ command_class.new(subargs, @env).execute
45
+ end
46
+
47
+ def help
48
+ opts = OptionParser.new do |subopts|
49
+ subopts.banner = 'Usage: vagrant zone zfssnapshot <subcommand> [<args>]'
50
+ subopts.separator ''
51
+ subopts.separator 'Available subcommands:'
52
+ # Add the available subcommands as separators in order to print them
53
+ # out as well.
54
+ keys = []
55
+ @subcommands.each { |key, _value| keys << key.to_s }
56
+ keys.sort.each do |key|
57
+ subopts.separator " #{key}"
58
+ end
59
+ subopts.separator ''
60
+ subopts.separator 'For help on any individual subcommand run `vagrant zone zfssnapshot <subcommand> -h`'
61
+ end
62
+ @env.ui.info(opts.help, :prefix => false)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module ProviderZone
5
+ module Command
6
+ # This is used to acces the zone via console, zlogin
7
+ class ZloginConsole < Vagrant.plugin('2', :command)
8
+ def execute
9
+ options = {}
10
+ opts = OptionParser.new do |o|
11
+ o.banner = 'Usage: vagrant zone console zlogin [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
+ end
19
+
20
+ argv = parse_options(opts)
21
+ return unless argv
22
+
23
+ unless argv.length <= 4
24
+ @env.ui.info(opts.help)
25
+ return
26
+ end
27
+
28
+ options[:port] = nil unless options[:port] =~ /\d/
29
+ with_target_vms(argv, provider: :zone) do |machine|
30
+ driver = machine.provider.driver
31
+ detach = 'no'
32
+ kill = 'no'
33
+ exit = { detach: detach, kill: kill }
34
+ driver.console(@env.ui, 'zlogin', options[:ip], options[:port], exit)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vagrant-zones/action'
4
+
5
+ module VagrantPlugins
6
+ module ProviderZone
7
+ module Command
8
+ # This is used manage the zone where vagrant cannot
9
+ class Zone < Vagrant.plugin('2', :command)
10
+ def self.synopsis
11
+ 'Manage zones and query zone 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(:zfssnapshot) do
20
+ require File.expand_path('zfssnapshot', __dir__)
21
+ ZFSSnapshot
22
+ end
23
+ @subcommands.register(:control) do
24
+ require File.expand_path('guest_power_controls', __dir__)
25
+ GuestPowerControls
26
+ end
27
+ @subcommands.register(:console) do
28
+ require File.expand_path('console', __dir__)
29
+ Console
30
+ end
31
+ super(argv, env)
32
+ end
33
+
34
+ def execute
35
+ if @main_args.include?('-h') || @main_args.include?('--help')
36
+ # Print the help for all the vagrant-zones commands.
37
+ return help
38
+ end
39
+
40
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
41
+ return help if !command_class || !@sub_command
42
+
43
+ @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
44
+
45
+ # Initialize and execute the command class
46
+ command_class.new(@sub_args, @env).execute
47
+ end
48
+
49
+ def help
50
+ opts = OptionParser.new do |subopts|
51
+ subopts.banner = 'Usage: vagrant zone <subcommand> [<args>]'
52
+ subopts.separator ''
53
+ subopts.separator 'Available subcommands:'
54
+
55
+ # Add the available subcommands as separators in order to print them
56
+ # out as well.
57
+ keys = []
58
+ @subcommands.each { |key, _value| keys << key.to_s }
59
+
60
+ keys.sort.each do |key|
61
+ subopts.separator " #{key}"
62
+ end
63
+
64
+ subopts.separator ''
65
+ subopts.separator 'For help on any individual subcommand run `vagrant zone <subcommand> -h`'
66
+ end
67
+
68
+ @env.ui.info(opts.help, :prefix => false)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,78 @@
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 ProviderZone
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, :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, :clean_shutdown_time, :dhcp, :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
11
+
12
+ # rubocop:enable Layout/LineLength
13
+
14
+ def initialize
15
+ super
16
+ @brand = 'bhyve'
17
+ @additional_disks = UNSET_VALUE
18
+ @autoboot = true
19
+ @kernel = UNSET_VALUE
20
+ @boxshortname = UNSET_VALUE
21
+ @cdroms = nil
22
+ @shared_dir = nil
23
+ @os_type = 'generic'
24
+ @lcheck = UNSET_VALUE
25
+ @booted_string = UNSET_VALUE
26
+ @winbooted_string = UNSET_VALUE
27
+ @allowed_address = true
28
+ @alcheck = 'login: '
29
+ @winalcheck = 'EVENT: The CMD command is now available.'
30
+ @winlcheck = 'EVENT: The CMD command is now available.'
31
+ @zunlockbootkey = ''
32
+ @zunlockboot = false
33
+ @safe_restart = nil
34
+ @safe_shutdown = nil
35
+ @debug_boot = nil
36
+ @debug = nil
37
+ @shared_disk_enabled = true
38
+ @consoleport = nil
39
+ @consolehost = '0.0.0.0'
40
+ @console_onboot = 'false'
41
+ @console = 'webvnc'
42
+ @memory = '4G'
43
+ @diskif = 'virtio-blk'
44
+ @netif = 'virtio-net-viona'
45
+ @cpus = 2
46
+ @cpu_configuration = 'simple'
47
+ @complex_cpu_conf = UNSET_VALUE
48
+ @boot = UNSET_VALUE
49
+ @hostbridge = 'i440fx'
50
+ @acpi = 'on'
51
+ @setup_wait = 90
52
+ @box = UNSET_VALUE
53
+ @clean_shutdown_time = 300
54
+ @dns = [{ 'nameserver' => '1.1.1.1' }, { 'nameserver' => '1.0.0.1' }]
55
+ @vmtype = 'production'
56
+ @partition_id = '0000'
57
+ @sshport = '22'
58
+ @rdpport = '3389'
59
+ @vagrant_user = 'vagrant'
60
+ @vagrant_user_pass = 'vagrant'
61
+ @vagrant_user_private_key_path = './id_rsa'
62
+ @xhci_enabled = 'off'
63
+ @override = false
64
+ @cloud_init_enabled = false
65
+ @cloud_init_conf = 'on'
66
+ @cloud_init_dnsdomain = nil
67
+ @cloud_init_password = nil
68
+ @cloud_init_resolvers = nil
69
+ @cloud_init_sshkey = nil
70
+ @private_network = nil
71
+ @firmware_type = 'compatability'
72
+ @vm_type = 'production'
73
+ @setup_method = nil
74
+ @snapshot_script = '/opt/vagrant/bin/Snapshooter.sh'
75
+ end
76
+ end
77
+ end
78
+ end