Sha256: 55046102c187ab29c207c9efef0d289fbe0024e0f3f85a5023051443b798f093

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

class Network < CloudstackCli::Base

  desc "create NAME", "create network"
  def create(name)
    # TODO
  end

  desc "list", "list networks"
  option :project
  option :physical, type: :boolean
  def list
    project = find_project if options[:project]
    if options[:physical]
      networks = client.list_physical_networks
      if networks.size < 1
        puts "No networks found"
      else
        table = [['Name', 'State', 'ID', 'Zone ID']]
        networks.each do |network|
          table << [
            network["name"],
            network["state"],
            network["id"],
            network["zoneid"] 
          ]
        end
        print_table table
      end
    else
      networks = client.list_networks(project ? project['id'] : -1)
      if networks.size < 1
        puts "No networks found"
      else
        table = [["Name", "Displaytext", "Account", "Project", "State", "ID"]]
        networks.each do |network|
          table << [
            network["name"],
            network["displaytext"],
            network["account"],
            network["project"],
            network["state"],
            network["id"]
          ]
        end
        print_table table
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloudstack-cli-0.1.0 lib/cloudstack-cli/commands/network.rb