Class: VagrantPlugins::Deltacloud::Command::NetworkList

Inherits:
AbstractCommand show all
Includes:
Utils
Defined in:
lib/vagrant-deltacloud-provider/command/network_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#display_item_list, #display_table, #get_ip_address

Methods inherited from AbstractCommand

#execute, #initialize, #normalize_args

Constructor Details

This class inherits a constructor from VagrantPlugins::Deltacloud::Command::AbstractCommand

Class Method Details

.synopsisObject



10
11
12
# File 'lib/vagrant-deltacloud-provider/command/network_list.rb', line 10

def self.synopsis
  I18n.t('vagrant_deltacloud.command.network_list_synopsis')
end

Instance Method Details

#cmd(name, argv, env) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-deltacloud-provider/command/network_list.rb', line 13

def cmd(name, argv, env)
  fail Errors::UnrecognizedArgForCommand, cmd: name, arg: argv[1] if argv.size > 1
  networks = env[:deltacloud_client].list_networks(env)
  rows = []
  networks.each do |n|
    rows << [n.id, n.name, n.status, n.address_blocks, n.subnets.map { |s| s.to_s }]
  end
  display_table(env, ['Id', 'Name', 'Status', 'Address blocks', 'Subnets'], rows)
end