Sha256: 062916440ca8556e38302fd3dd3e6837fcade77688c5097149bb2096f3b235c5

Contents?: true

Size: 1.56 KB

Versions: 54

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require 'resolv'
module VagrantPlugins
  module ProviderZone
    module Command
      # This is used to start a WebVNC console to the guest
      class WebVNCConsole < Vagrant.plugin('2', :command)
        def execute
          options = {}
          opts = OptionParser.new do |o|
            o.banner = 'Usage: vagrant zone console webvnc [options]'
            o.on('--ip <host_ip>', 'Specify host IP to listen on') do |p|
              options[:ip] = p
            end
            o.on('--port <port>', 'Specify port to listen on') do |p|
              options[:port] = p
            end
            o.on('--detach <yes/no>', 'Run console server in background') do |p|
              options[:detach] = p
            end
            o.on('--kill <yes/no>', 'Kill the previous background console session') do |p|
              options[:kill] = p
            end
          end

          argv = parse_options(opts)
          return unless argv

          unless argv.length <= 4
            @env.ui.info(opts.help)
            return
          end

          options[:port] = nil unless options[:port] =~ /\d/
          with_target_vms(argv, provider: :zone) do |machine|
            driver = machine.provider.driver
            detach = 'yes'
            detach = 'no' unless options[:detach] == 'yes'
            kill = 'yes'
            kill = 'no' unless options[:kill] == 'yes'
            exit = { detach: detach, kill: kill }
            driver.console(@env.ui, 'webvnc', options[:ip], options[:port], exit)
          end
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
vagrant-zones-0.1.55 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.54 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.52 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.48 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.46 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.44 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.12 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.10 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.9 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.8 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.41 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.1.3 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.0.12 lib/vagrant-zones/command/webvnc_console.rb
vagrant-zones-0.0.1 lib/vagrant-zones/command/webvnc_console.rb