Class: VagrantPlugins::Openstack::Command::NetworkList

Inherits:
OpenstackCommand show all
Defined in:
lib/vagrant-openstack-provider/command/network_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenstackCommand

#before_cmd

Methods included from Utils

#display_item_list, #display_table

Methods inherited from AbstractCommand

#before_cmd, #execute, #initialize, #normalize_args

Constructor Details

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

Class Method Details

.synopsisObject



7
8
9
# File 'lib/vagrant-openstack-provider/command/network_list.rb', line 7

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

Instance Method Details

#cmd(name, argv, env) ⇒ Object



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

def cmd(name, argv, env)
  fail Errors::UnrecognizedArgForCommand, cmd: name, arg: argv[1] if argv.size > 1
  if argv.size == 0
    networks = env[:openstack_client].neutron.get_private_networks(env)
  elsif argv[0] == 'all'
    networks = env[:openstack_client].neutron.get_all_networks(env)
  else
    fail Errors::UnrecognizedArgForCommand, cmd: name, arg: argv[0]
  end
  display_item_list(env, networks)
end