Sha256: aaacfa48276f7f091cd5cb8c8c6e2d96ed9b02cc1b428dbef0d035ce9d435193

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

class Network < CloudstackCli::Base

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

  desc "list", "list networks"
  option :project
  option :account, default: ""
  def list
    project = find_project if options[:project]

    networks = []
    if project
      networks = client.list_networks(project['id'])
    else
      networks = client.list_networks(-1, options[:account] != '' ? options[:account] : nil )
      networks + client.list_networks(nil, options[:account] != '' ? options[:account] : nil )
    end

    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudstack-cli-0.1.2 lib/cloudstack-cli/commands/network.rb
cloudstack-cli-0.1.1 lib/cloudstack-cli/commands/network.rb