Class: Chef::Knife::AcropolisNetwork

Inherits:
Chef::Knife show all
Includes:
AcropolisBase
Defined in:
lib/chef/knife/acropolis_network_list.rb

Instance Method Summary collapse

Methods included from AcropolisBase

#delete, #get, included, #post, #validate

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/chef/knife/acropolis_network_list.rb', line 15

def run
  $stdout.sync = true
  
  network_list = [
    ui.color('UUID', :bold),
    ui.color('VLAN ID', :bold),
    ui.color('IP Address', :bold),
    ui.color('Prefix', :bold),
    ui.color('Gateway', :bold) 
  ]
    
  networks = get("/networks")
    info = JSON.parse(networks)
    info["entities"].each do |network|
      network_list << network["uuid"].to_s
      network_list << network["vlanId"].to_s
      network_list << network["ipConfig"]["networkAddress"].to_s
      network_list << network["ipConfig"]["prefixLength"].to_s
      network_list << network["ipConfig"]["defaultGateway"].to_s
    end
  print ui.list(network_list, :uneven_columns_across, 5)
end