Class: VagrantPlugins::Skytap::Connection::VpnChoice
- Defined in:
- lib/vagrant-skytap/connection/vpn_choice.rb
Defined Under Namespace
Classes: AttachConnectAndUseExecution, ConnectAndUseExecution, UseExecution, VPNAttachmentExecution
Instance Attribute Summary collapse
-
#attachment ⇒ Object
readonly
Returns the value of attribute attachment.
-
#vm ⇒ Object
readonly
Returns the value of attribute vm.
-
#vpn ⇒ Object
readonly
Returns the value of attribute vpn.
Attributes inherited from Choice
#env, #execution, #iface, #validation_error_message
Instance Method Summary collapse
- #choose ⇒ Object
-
#initialize(env, vpn, vm) ⇒ VpnChoice
constructor
A new instance of VpnChoice.
-
#select_interface(vm, vpn) ⇒ API::Interface
Finds an interface on the guest VM which is connected to a network which lies inside the VPN’s subnet.
Methods inherited from Choice
Constructor Details
#initialize(env, vpn, vm) ⇒ VpnChoice
Returns a new instance of VpnChoice.
32 33 34 35 36 37 38 |
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 32 def initialize(env, vpn, vm) @env = env @vpn = vpn @vm = vm @iface = select_interface(vm, vpn) @execution = VPNAttachmentExecution.make(env, iface, vpn) end |
Instance Attribute Details
#attachment ⇒ Object (readonly)
Returns the value of attribute attachment.
30 31 32 |
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 30 def end |
#vm ⇒ Object (readonly)
Returns the value of attribute vm.
30 31 32 |
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 30 def vm @vm end |
#vpn ⇒ Object (readonly)
Returns the value of attribute vpn.
30 31 32 |
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 30 def vpn @vpn end |
Instance Method Details
#choose ⇒ Object
55 56 57 58 59 60 |
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 55 def choose execution.execute @iface = vm.reload.get_interface_by_id(iface.id) host = iface.address_for(vpn) [host, DEFAULT_PORT] end |
#select_interface(vm, vpn) ⇒ API::Interface
Finds an interface on the guest VM which is connected to a network which lies inside the VPN’s subnet. If the VPN is NAT enabled, this method simply returns the first interface.
47 48 49 50 51 52 53 |
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 47 def select_interface(vm, vpn) vm.interfaces.select(&:network).tap do |ifaces| unless vpn.nat_enabled? ifaces.select! {|i| vpn.subsumes?(i.network) } end end.first end |