Class: VagrantPlugins::ProviderZone::Command::ZloginConsole

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-zones/command/zlogin_console.rb

Overview

This is used to acces the zone via console, zlogin

Instance Method Summary collapse

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-zones/command/zlogin_console.rb', line 8

def execute
  options = {}
  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant zone console zlogin [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
  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 = 'no'
    kill = 'no'
    exit = { detach: detach, kill: kill }
    driver.console(@env.ui, 'zlogin', options[:ip], options[:port], exit)
  end
end