Sha256: 1b6d54abbfe6765e1707f61a7ea9bf3d1f187db72f12b54dfef71e39306fa987

Contents?: true

Size: 934 Bytes

Versions: 25

Compression:

Stored size: 934 Bytes

Contents

class PhysicalNetwork < CloudstackCli::Base

  desc "list", "list physical networks"
  option :project
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    resolve_project
    networks = client.list_physical_networks(options)
    zones = client.list_zones
    if networks.size < 1
      puts "No networks found"
    else
      case options[:format].to_sym
      when :yaml
        puts({networks: networks}.to_yaml)
      when :json
        puts JSON.pretty_generate(networks: networks)
      else
        table = [['Name', 'State', 'Zone', 'ID']]
        networks.each do |network|
          table << [
            network["name"],
            network["state"],
            zones.select{|zone| zone['id'] == network["zoneid"]}.first["name"],
            network["id"]
          ]
        end
        print_table table
        say "Total number of networks: #{networks.count}"
      end
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.10 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/commands/physical_network.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/commands/physical_network.rb