Class: Mccloud::Command::ForwardCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/mccloud/command/forward.rb

Instance Attribute Summary

Attributes inherited from Base

#env

Instance Method Summary collapse

Methods inherited from Base

#initialize, register

Methods included from Helpers

#initialize_environment

Constructor Details

This class inherits a constructor from Mccloud::Command::Base

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mccloud/command/forward.rb', line 8

def execute
  env.load!
  threads=Array.new
  env.config.providers.each do |name,provider|
    env.logger.debug("Asking provider #{name} to forward ports from #{selection} to localhost")
    trap("INT") { puts "You've hit CTRL-C . Stopping server now"; exit }
    provider.on_selected_components("vm",selection) do |id,vm|
      fwds=vm.forward(options)
      unless fwds.nil?
        fwds.each do |f|
          threads << f
        end
      end
      threads.each { |thr| thr.join}
    end

  end

end