Class: VagrantPlugins::Skytap::Connection::VpnChoice::VPNAttachmentExecution

Inherits:
Execution
  • Object
show all
Defined in:
lib/vagrant-skytap/connection/vpn_choice.rb

Overview

To communicate with the guest VM over a VPN, the guest’s network must be both attached and connected to the VPN. The various subclasses perform different REST calls depending on which of these conditions are already met.

Instance Attribute Summary collapse

Attributes inherited from Execution

#env, #iface

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Execution

#execute, #make, #verb

Constructor Details

#initialize(env, iface, vpn, attachment = nil) ⇒ VPNAttachmentExecution

Returns a new instance of VPNAttachmentExecution.



81
82
83
84
85
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 81

def initialize(env, iface, vpn, attachment=nil)
  super
  @vpn = vpn
  @attachment = attachment
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



67
68
69
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 67

def attachment
  @attachment
end

#vpnObject (readonly)

Returns the value of attribute vpn.



67
68
69
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 67

def vpn
  @vpn
end

Class Method Details

.make(env, iface, vpn) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 69

def self.make(env, iface, vpn)
  attachment = iface.attachment_for(vpn)

  if attachment.try(:connected?)
    UseExecution.new(env, iface, vpn, attachment)
  elsif attachment
    ConnectAndUseExecution.new(env, iface, vpn, attachment)
  else
    AttachConnectAndUseExecution.new(env, iface, vpn)
  end
end

Instance Method Details

#messageObject



87
88
89
90
91
92
93
94
95
96
# File 'lib/vagrant-skytap/connection/vpn_choice.rb', line 87

def message
  "#{verb}: #{vpn.name}".tap do |ret|
    if vpn.nat_enabled?
      ret << " " << I18n.t("vagrant_skytap.connections.vpn_attachment.nat_enabled")
    else
      ret << " " << I18n.t("vagrant_skytap.connections.vpn_attachment.local_subnet",
        local_subnet: vpn.local_subnet)
    end
  end
end