Class: VagrantPlugins::Rackspace::Action::ListNetworks

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-rackspace/action/list_networks.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ListNetworks

Returns a new instance of ListNetworks.



5
6
7
# File 'lib/vagrant-rackspace/action/list_networks.rb', line 5

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/vagrant-rackspace/action/list_networks.rb', line 9

def call(env)
  compute_service = env[:rackspace_compute]
  env[:ui].info ('%-36s %-24s %s' % ['Network Name', 'Network CIDR', 'Network ID'])
  compute_service.networks.sort_by(&:label).each do |network|
    env[:ui].info ('%-36s %-24s %s' % [network.label, network.cidr, network.id])
  end
  @app.call(env)
end