Class: PublicIpChoice

Inherits:
Object show all
Defined in:
lib/vagrant-skytap/api/public_ip.rb

Overview

TODO:NLA Move this to another class, properly namespaced.

Defined Under Namespace

Classes: AttachAndUseExecution, AttachmentExecution, UseAttachmentExecution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, ip, iface) ⇒ PublicIpChoice

Returns a new instance of PublicIpChoice.



7
8
9
10
11
12
# File 'lib/vagrant-skytap/api/public_ip.rb', line 7

def initialize(env, ip, iface)
  @env = env
  @ip = ip
  @iface = iface
  @execution = AttachmentExecution.make(env, ip, iface)
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/vagrant-skytap/api/public_ip.rb', line 5

def env
  @env
end

#executionObject (readonly)

Returns the value of attribute execution.



5
6
7
# File 'lib/vagrant-skytap/api/public_ip.rb', line 5

def execution
  @execution
end

#ifaceObject (readonly)

Returns the value of attribute iface.



5
6
7
# File 'lib/vagrant-skytap/api/public_ip.rb', line 5

def iface
  @iface
end

#ipObject (readonly)

Returns the value of attribute ip.



5
6
7
# File 'lib/vagrant-skytap/api/public_ip.rb', line 5

def ip
  @ip
end

Instance Method Details

#chooseObject



24
25
26
27
28
29
30
# File 'lib/vagrant-skytap/api/public_ip.rb', line 24

def choose
  execution.execute

  host = ip.address
  port = 22 #TODO:NLA Use constant.
  [host, port]
end

#to_sObject



14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-skytap/api/public_ip.rb', line 14

def to_s
  "#{execution.verb} public IP: #{ip.address}".tap do |ret|
    if ip.deployed?
      ret << ' (attached and deployed to another VM)'
    elsif ip.attached?
      ret << ' (attached to another VM)'
    end
  end
end

#valid?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/vagrant-skytap/api/public_ip.rb', line 32

def valid?
  true
end