Class: VagrantPlugins::Lightsail::Action::ConfigurePorts
- Inherits:
-
Object
- Object
- VagrantPlugins::Lightsail::Action::ConfigurePorts
- Defined in:
- lib/vagrant-lightsail/action/configure_ports.rb
Overview
This configures ports on instance
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _) ⇒ ConfigurePorts
constructor
A new instance of ConfigurePorts.
Constructor Details
#initialize(app, _) ⇒ ConfigurePorts
Returns a new instance of ConfigurePorts.
8 9 10 11 |
# File 'lib/vagrant-lightsail/action/configure_ports.rb', line 8 def initialize(app, _) @app = app @logger = Log4r::Logger.new('vagrant_lightsail::action::configure_ports') end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-lightsail/action/configure_ports.rb', line 13 def call(env) port_info = env[:machine].provider_config.port_info port_info.each do |pi| env[:lightsail_client].open_instance_public_ports( port_info: pi, instance_name: env[:machine].id ) env[:ui].info I18n.t 'vagrant_lightsail.port_open', proto: pi[:protocol], port_no_from: pi[:from_port], port_no_to: pi[:to_port] rescue Aws::Lightsail::Errors::InvalidInputException => e env[:ui].info I18n.t 'vagrant_lightsail.port_open_fail', proto: pi[:protocol], port_no_from: pi[:from_port], port_no_to: pi[:to_port], error: e.to_s rescue Aws::Lightsail::Errors => e raise Errors::LightailError, message: e end @app.call(env) end |