Class: VpnChoice
Overview
TODO:NLA Move this to another class, properly namespaced.
Defined Under Namespace
Classes: AttachmentExecution, ConnectAttachmentExecution, CreateAttachmentExecution, UseAttachmentExecution
Instance Attribute Summary collapse
-
#attachment ⇒ Object
readonly
Returns the value of attribute attachment.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#execution ⇒ Object
readonly
Returns the value of attribute execution.
-
#iface ⇒ Object
readonly
Returns the value of attribute iface.
-
#vm ⇒ Object
readonly
Returns the value of attribute vm.
-
#vpn ⇒ Object
readonly
Returns the value of attribute vpn.
Instance Method Summary collapse
- #choose ⇒ Object
-
#initialize(env, vpn, vm) ⇒ VpnChoice
constructor
A new instance of VpnChoice.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(env, vpn, vm) ⇒ VpnChoice
Returns a new instance of VpnChoice.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 9 def initialize(env, vpn, vm) @env = env @vpn = vpn @vm = vm @iface = vm.interfaces.select(&:network).tap do |ifaces| unless vpn.nat_enabled? ifaces.select! {|i| vpn.subsumes?(i.network) } end end.first @execution = AttachmentExecution.make(env, vpn, iface) end |
Instance Attribute Details
#attachment ⇒ Object (readonly)
Returns the value of attribute attachment.
7 8 9 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 7 def @attachment end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 7 def env @env end |
#execution ⇒ Object (readonly)
Returns the value of attribute execution.
7 8 9 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 7 def execution @execution end |
#iface ⇒ Object (readonly)
Returns the value of attribute iface.
7 8 9 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 7 def iface @iface end |
#vm ⇒ Object (readonly)
Returns the value of attribute vm.
7 8 9 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 7 def vm @vm end |
#vpn ⇒ Object (readonly)
Returns the value of attribute vpn.
7 8 9 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 7 def vpn @vpn end |
Instance Method Details
#choose ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 31 def choose execution.execute @iface = vm.reload.interfaces.detect{|i| i.id == iface.id } host = iface.address_for(vpn) port = 22 #TODO:NLA Use constant [host, port] end |
#to_s ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 21 def to_s "#{execution.verb} VPN: #{vpn.name}".tap do |ret| if vpn.nat_enabled? ret << " (NAT-enabled)" else ret << " (local subnet: #{vpn.local_subnet})" end end end |
#valid? ⇒ Boolean
41 42 43 |
# File 'lib/vagrant-skytap/api/vpn.rb', line 41 def valid? true end |