Class: Network

Inherits:
Thor
  • Object
show all
Includes:
CommandLineReporter
Defined in:
lib/cloudstack-cli/commands/network.rb

Instance Method Summary collapse

Instance Method Details

#create(name) ⇒ Object



5
6
7
8
# File 'lib/cloudstack-cli/commands/network.rb', line 5

def create(name)


end

#listObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cloudstack-cli/commands/network.rb', line 13

def list
  cs_cli = CloudstackCli::Helper.new(options[:config])
  if options[:project]
    project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first
    raise "Project '#{options[:project]}' not found" unless project
  end
  
  if options[:physical]
    networks = cs_cli.physical_networks
    if networks.size < 1
      puts "No networks found"
    else
      table(border: true) do
        row do
          column 'ID', width: 40
          column 'Name', width: 30
          column 'Zone ID', width: 14 unless options[:project]
          column 'State'
        end
        networks.each do |network|
          row do
            column network["id"]
            column network["name"]
            column network["zoneid"]
            column network["state"]
          end
        end
      end
    end
  else
    networks = cs_cli.networks(project ? project['id'] : -1)
    if networks.size < 1
      puts "No networks found"
    else
      table(border: true) do
        row do
          column 'ID', width: 40
          column 'Name', width: 30
          column 'Displaytext', width: 30
          column 'Account', width: 14 unless options[:project]
          column 'Project', width: 14 if options[:listall] || options[:project]
          column 'State'
        end
        networks.each do |network|
          row do
            column network["id"]
            column network["name"]
            column network["displaytext"]
            column network["account"] unless options[:project]
            column network["project"] if options[:listall] || options[:project]
            column network["state"]
          end
        end
      end
    end
  end

  
end