Sha256: 8d825d28c002973f02aee937f6a70fb4cc19754667c05c6b0e734286a9497a44

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

class Network < CloudstackCli::Base

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

  desc "list", "list networks"
  option :project
  option :account
  option :showid, type: :boolean
  def list
    project = find_project if options[:project]
    networks = []
    if project
      networks = client.list_networks(project['id'])
    elsif options[:account]
      networks = client.list_networks(account: options[:account])
    else
      networks = client.list_networks(project_id: -1)
    end

    if networks.size < 1
      puts "No networks found"
    else
      table = [["Name", "Displaytext", "Account", "Project", "Domain", "State"]]
      table[0] << "ID" if options[:showid]
      networks.each do |network|
        table << [
          network["name"],
          network["displaytext"],
          network["account"],
          network["project"],
          network["domain"],
          network["state"]
        ]
        table[-1] << network["id"] if options[:showid]
      end
      print_table table
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cloudstack-cli-0.1.5 lib/cloudstack-cli/commands/network.rb
cloudstack-cli-0.1.4 lib/cloudstack-cli/commands/network.rb
cloudstack-cli-0.1.3 lib/cloudstack-cli/commands/network.rb