cloudstack-cli 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cloudstack-cli/base.rb +11 -2
- data/lib/cloudstack-cli/commands/account.rb +19 -10
- data/lib/cloudstack-cli/commands/affinity_group.rb +18 -9
- data/lib/cloudstack-cli/commands/capacity.rb +1 -1
- data/lib/cloudstack-cli/commands/cluster.rb +18 -9
- data/lib/cloudstack-cli/commands/compute_offer.rb +14 -1
- data/lib/cloudstack-cli/commands/disk_offer.rb +23 -10
- data/lib/cloudstack-cli/commands/domain.rb +14 -5
- data/lib/cloudstack-cli/commands/host.rb +16 -7
- data/lib/cloudstack-cli/commands/ip_address.rb +14 -5
- data/lib/cloudstack-cli/commands/iso.rb +24 -11
- data/lib/cloudstack-cli/commands/job.rb +19 -10
- data/lib/cloudstack-cli/commands/load_balancer.rb +20 -11
- data/lib/cloudstack-cli/commands/network.rb +31 -21
- data/lib/cloudstack-cli/commands/physical_network.rb +19 -10
- data/lib/cloudstack-cli/commands/pod.rb +17 -8
- data/lib/cloudstack-cli/commands/port_rule.rb +21 -12
- data/lib/cloudstack-cli/commands/project.rb +21 -12
- data/lib/cloudstack-cli/commands/region.rb +17 -8
- data/lib/cloudstack-cli/commands/resource_limit.rb +12 -2
- data/lib/cloudstack-cli/commands/router.rb +2 -2
- data/lib/cloudstack-cli/commands/snapshot.rb +18 -9
- data/lib/cloudstack-cli/commands/ssh_key_pair.rb +13 -4
- data/lib/cloudstack-cli/commands/storage_pool.rb +30 -21
- data/lib/cloudstack-cli/commands/system_vm.rb +16 -7
- data/lib/cloudstack-cli/commands/template.rb +21 -12
- data/lib/cloudstack-cli/commands/user.rb +17 -8
- data/lib/cloudstack-cli/commands/virtual_machine.rb +3 -2
- data/lib/cloudstack-cli/commands/volume.rb +28 -15
- data/lib/cloudstack-cli/commands/zone.rb +17 -8
- data/lib/cloudstack-cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f07e2763e1098aebc86ef957def19af52e6439
|
4
|
+
data.tar.gz: c7351b039d23832d297e18f4b3fad768f5dcf7f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a043f85b78500aafed6ae9fed0e38629f18aa0a564ab832fe91f907576da8bcf91bfa8bb4aa47cf5c1399bf8c8b14af70537d03eb1d434693b308ae727275783
|
7
|
+
data.tar.gz: f100042e728db5621e03dd6defd85fa7e4e80f8875f0d2daaddd44874dce6f85c5f9a69bea09fe364b066ff3af4818ca131da047029e744c47c4b950ad739e32
|
data/Gemfile.lock
CHANGED
data/lib/cloudstack-cli/base.rb
CHANGED
@@ -80,7 +80,7 @@ module CloudstackCli
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def filter_by(objects, key, value)
|
83
|
-
if objects.size
|
83
|
+
if objects.size == 0
|
84
84
|
return objects
|
85
85
|
elsif !(keys = objects.map{|i| i.keys}.flatten.uniq).include?(key)
|
86
86
|
say "WARNING: Filter invalid, no key \"#{key}\" found.", :yellow
|
@@ -88,7 +88,7 @@ module CloudstackCli
|
|
88
88
|
return objects
|
89
89
|
end
|
90
90
|
objects.select do |object|
|
91
|
-
object[key.to_s] =~ /#{value}/i
|
91
|
+
object[key.to_s].to_s =~ /#{value}/i
|
92
92
|
end
|
93
93
|
rescue RegexpError => e
|
94
94
|
say "ERROR: Invalid regular expression in filter - #{e.message}", :red
|
@@ -103,6 +103,15 @@ module CloudstackCli
|
|
103
103
|
objects
|
104
104
|
end
|
105
105
|
|
106
|
+
def add_filters_to_options(command)
|
107
|
+
options[:filter].each do |filter_key, filter_value|
|
108
|
+
if client.api.params(command).find {|param| param["name"] == filter_key.downcase }
|
109
|
+
options[filter_key.downcase] = filter_value.gsub(/[^\w\s\.-]/, '')
|
110
|
+
options[:filter].delete(filter_key)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
106
115
|
def parse_file(file, extensions = %w(.json .yaml .yml))
|
107
116
|
handler = case File.extname(file)
|
108
117
|
when ".json"
|
@@ -21,22 +21,31 @@ class Account < CloudstackCli::Base
|
|
21
21
|
end
|
22
22
|
|
23
23
|
desc 'list', 'list accounts'
|
24
|
+
option :format, default: "table",
|
25
|
+
enum: %w(table json yaml)
|
24
26
|
def list
|
25
27
|
accounts = client.list_accounts(listall: true)
|
26
28
|
if accounts.size < 1
|
27
29
|
puts "No accounts found."
|
28
30
|
else
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
case options[:format].to_sym
|
32
|
+
when :yaml
|
33
|
+
puts({accounts: accounts}.to_yaml)
|
34
|
+
when :json
|
35
|
+
puts JSON.pretty_generate(accounts: accounts)
|
36
|
+
else
|
37
|
+
table = [%w(Name Type Domain State)]
|
38
|
+
accounts.each do |account|
|
39
|
+
table << [
|
40
|
+
account['name'],
|
41
|
+
TYPES[account['accounttype']],
|
42
|
+
account['domain'],
|
43
|
+
account['state']
|
44
|
+
]
|
45
|
+
end
|
46
|
+
print_table table
|
47
|
+
say "Total number of accounts: #{accounts.size}"
|
37
48
|
end
|
38
|
-
print_table table
|
39
|
-
say "Total number of accounts: #{accounts.size}"
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
@@ -6,22 +6,31 @@ class AffinityGroup < CloudstackCli::Base
|
|
6
6
|
option :type
|
7
7
|
option :listall
|
8
8
|
option :keyword
|
9
|
+
option :format, default: "table",
|
10
|
+
enum: %w(table json yaml)
|
9
11
|
def list
|
10
12
|
resolve_account
|
11
13
|
affinity_groups = client.list_affinity_groups(options)
|
12
14
|
if affinity_groups.size < 1
|
13
15
|
say "No affinity groups found."
|
14
16
|
else
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
]
|
17
|
+
case options[:format].to_sym
|
18
|
+
when :yaml
|
19
|
+
puts({affinity_groups: affinity_groups}.to_yaml)
|
20
|
+
when :json
|
21
|
+
puts JSON.pretty_generate(affinity_groups: affinity_groups)
|
22
|
+
else
|
23
|
+
table = [%w(Domain Account Name, Description, VMs)]
|
24
|
+
affinity_groups.each do |group|
|
25
|
+
table << [
|
26
|
+
group['domain'], group['account'],
|
27
|
+
group['name'], group['description'],
|
28
|
+
group['virtualmachineIds'] ? group['virtualmachineIds'].size : nil
|
29
|
+
]
|
30
|
+
end
|
31
|
+
print_table table
|
32
|
+
say "Total number of affinity groups: #{affinity_groups.size}"
|
22
33
|
end
|
23
|
-
print_table table
|
24
|
-
say "Total number of affinity groups: #{affinity_groups.size}"
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
@@ -13,7 +13,7 @@ class Capacity < CloudstackCli::Base
|
|
13
13
|
}
|
14
14
|
|
15
15
|
desc "list", "list system capacity"
|
16
|
-
option :zone, desc: "
|
16
|
+
option :zone, desc: "list capacity by zone"
|
17
17
|
option :type, desc: "specify type, see types for a list of types"
|
18
18
|
def list
|
19
19
|
resolve_zone if options[:zone]
|
@@ -2,22 +2,31 @@ class Cluster < CloudstackCli::Base
|
|
2
2
|
|
3
3
|
desc 'list', 'list clusters'
|
4
4
|
option :zone, desc: "lists clusters by zone"
|
5
|
+
option :format, default: "table",
|
6
|
+
enum: %w(table json yaml)
|
5
7
|
def list
|
6
8
|
resolve_zone if options[:zone]
|
7
9
|
clusters = client.list_clusters(options)
|
8
10
|
if clusters.size < 1
|
9
11
|
say "No clusters found."
|
10
12
|
else
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
]
|
13
|
+
case options[:format].to_sym
|
14
|
+
when :yaml
|
15
|
+
puts({clusters: clusters}.to_yaml)
|
16
|
+
when :json
|
17
|
+
puts JSON.pretty_generate(clusters: clusters)
|
18
|
+
else
|
19
|
+
table = [%w(Name Pod_Name Type Zone State)]
|
20
|
+
clusters.each do |cluster|
|
21
|
+
table << [
|
22
|
+
cluster['name'], cluster['podname'],
|
23
|
+
cluster['hypervisortype'], cluster['zonename'],
|
24
|
+
cluster['managedstate']
|
25
|
+
]
|
26
|
+
end
|
27
|
+
print_table table
|
28
|
+
say "Total number of clusters: #{clusters.size}"
|
18
29
|
end
|
19
|
-
print_table table
|
20
|
-
say "Total number of clusters: #{clusters.size}"
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
@@ -2,13 +2,26 @@ class ComputeOffer < CloudstackCli::Base
|
|
2
2
|
|
3
3
|
desc 'list', 'list compute offerings'
|
4
4
|
option :domain, desc: "the domain associated with the compute offering"
|
5
|
+
option :format, default: "table",
|
6
|
+
enum: %w(table json yaml)
|
7
|
+
option :filter, type: :hash,
|
8
|
+
desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
|
5
9
|
def list
|
6
10
|
resolve_domain
|
11
|
+
add_filters_to_options("listServiceOfferings") if options[:filter]
|
7
12
|
offerings = client.list_service_offerings(options)
|
13
|
+
offerings = filter_objects(offerings) if options[:filter]
|
8
14
|
if offerings.size < 1
|
9
15
|
puts "No offerings found."
|
10
16
|
else
|
11
|
-
|
17
|
+
case options[:format].to_sym
|
18
|
+
when :yaml
|
19
|
+
puts({compute_offers: offerings}.to_yaml)
|
20
|
+
when :json
|
21
|
+
puts JSON.pretty_generate(compute_offers: offerings)
|
22
|
+
else
|
23
|
+
print_compute_offerings(offerings)
|
24
|
+
end
|
12
25
|
end
|
13
26
|
end
|
14
27
|
|
@@ -2,23 +2,36 @@ class DiskOffer < CloudstackCli::Base
|
|
2
2
|
|
3
3
|
desc 'list', 'list disk offerings'
|
4
4
|
option :domain, desc: "the domain of the disk offering"
|
5
|
+
option :format, default: "table",
|
6
|
+
enum: %w(table json yaml)
|
7
|
+
option :filter, type: :hash,
|
8
|
+
desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
|
5
9
|
def list
|
6
10
|
resolve_domain
|
11
|
+
add_filters_to_options("listDiskOfferings") if options[:filter]
|
7
12
|
offerings = client.list_disk_offerings(options)
|
13
|
+
offerings = filter_objects(offerings) if options[:filter]
|
8
14
|
if offerings.size < 1
|
9
15
|
puts "No offerings found."
|
10
16
|
else
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
case options[:format].to_sym
|
18
|
+
when :yaml
|
19
|
+
puts({disk_offers: offerings}.to_yaml)
|
20
|
+
when :json
|
21
|
+
puts JSON.pretty_generate(disk_offers: offerings)
|
22
|
+
else
|
23
|
+
table = [["Name", "Displaytext", "Domain", "ID"]]
|
24
|
+
offerings.each do |offering|
|
25
|
+
table << [
|
26
|
+
offering["name"],
|
27
|
+
offering["displaytext"],
|
28
|
+
offering["domain"],
|
29
|
+
offering["id"]
|
30
|
+
]
|
31
|
+
end
|
32
|
+
print_table table
|
33
|
+
say "Total number of offerings: #{offerings.size}"
|
19
34
|
end
|
20
|
-
print_table table
|
21
|
-
say "Total number of offerings: #{offerings.size}"
|
22
35
|
end
|
23
36
|
end
|
24
37
|
end
|
@@ -1,17 +1,26 @@
|
|
1
1
|
class Domain < CloudstackCli::Base
|
2
2
|
|
3
3
|
desc 'list', 'list domains'
|
4
|
+
option :format, default: "table",
|
5
|
+
enum: %w(table json yaml)
|
4
6
|
def list
|
5
7
|
domains = client.list_domains
|
6
8
|
if domains.size < 1
|
7
9
|
puts "No domains found."
|
8
10
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
case options[:format].to_sym
|
12
|
+
when :yaml
|
13
|
+
puts({domains: domains}.to_yaml)
|
14
|
+
when :json
|
15
|
+
puts JSON.pretty_generate(domains: domains)
|
16
|
+
else
|
17
|
+
table = [%w(Name Path)]
|
18
|
+
domains.each do |domain|
|
19
|
+
table << [domain['name'], domain['path']]
|
20
|
+
end
|
21
|
+
print_table table
|
22
|
+
say "Total number of domains: #{domains.size}"
|
12
23
|
end
|
13
|
-
print_table table
|
14
|
-
say "Total number of domains: #{domains.size}"
|
15
24
|
end
|
16
25
|
end
|
17
26
|
|
@@ -3,20 +3,29 @@ class Host < CloudstackCli::Base
|
|
3
3
|
desc 'list', 'list hosts'
|
4
4
|
option :zone, desc: "lists hosts by zone"
|
5
5
|
option :type, desc: "the host type"
|
6
|
+
option :format, default: "table",
|
7
|
+
enum: %w(table json yaml)
|
6
8
|
def list
|
7
9
|
resolve_zone if options[:zone]
|
8
10
|
hosts = client.list_hosts(options)
|
9
11
|
if hosts.size < 1
|
10
12
|
say "No hosts found."
|
11
13
|
else
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
case options[:format].to_sym
|
15
|
+
when :yaml
|
16
|
+
puts({hosts: hosts}.to_yaml)
|
17
|
+
when :json
|
18
|
+
puts JSON.pretty_generate(hosts: hosts)
|
19
|
+
else
|
20
|
+
table = [["Zone", "Type", "Cluster", "Name"]]
|
21
|
+
hosts.each do |host|
|
22
|
+
table << [
|
23
|
+
host['zonename'], host['type'], host['clustername'], host['name']
|
24
|
+
]
|
25
|
+
end
|
26
|
+
print_table table
|
27
|
+
say "Total number of hosts: #{hosts.size}"
|
17
28
|
end
|
18
|
-
print_table table
|
19
|
-
say "Total number of hosts: #{hosts.size}"
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
@@ -29,6 +29,8 @@ class IpAddress < CloudstackCli::Base
|
|
29
29
|
option :project
|
30
30
|
option :account
|
31
31
|
option :listall
|
32
|
+
option :format, default: "table",
|
33
|
+
enum: %w(table json yaml)
|
32
34
|
def list
|
33
35
|
resolve_account
|
34
36
|
resolve_project
|
@@ -36,12 +38,19 @@ class IpAddress < CloudstackCli::Base
|
|
36
38
|
if addresses.size < 1
|
37
39
|
say "No ip addresses found."
|
38
40
|
else
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
case options[:format].to_sym
|
42
|
+
when :yaml
|
43
|
+
puts({ip_addresses: addresses}.to_yaml)
|
44
|
+
when :json
|
45
|
+
puts JSON.pretty_generate(ip_addresses: addresses)
|
46
|
+
else
|
47
|
+
table = [%w(ID Address Account Zone)]
|
48
|
+
addresses.each do |address|
|
49
|
+
table << [address["id"], address["ipaddress"], address["account"], address["zonename"]]
|
50
|
+
end
|
51
|
+
print_table table
|
52
|
+
say "Total number of addresses: #{addresses.size}"
|
42
53
|
end
|
43
|
-
print_table table
|
44
|
-
say "Total number of addresses: #{addresses.size}"
|
45
54
|
end
|
46
55
|
end
|
47
56
|
|
@@ -6,28 +6,41 @@ class Iso < CloudstackCli::Base
|
|
6
6
|
option :account, desc: 'account name'
|
7
7
|
option :type, desc: 'type of ISO',
|
8
8
|
enum: %w(featured self selfexecutable sharedexecutable executable community all)
|
9
|
+
option :format, default: "table",
|
10
|
+
enum: %w(table json yaml)
|
11
|
+
option :filter, type: :hash,
|
12
|
+
desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
|
9
13
|
def list
|
14
|
+
add_filters_to_options("listIsos") if options[:filter]
|
10
15
|
resolve_project
|
11
16
|
resolve_zone
|
12
17
|
resolve_account
|
13
18
|
options[:isofilter] = options[:type]
|
14
19
|
options.delete :type
|
15
20
|
isos = client.list_isos(options)
|
21
|
+
isos = filter_objects(isos) if options[:filter]
|
16
22
|
if isos.size < 1
|
17
23
|
puts "No ISO's found."
|
18
24
|
else
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
case options[:format].to_sym
|
26
|
+
when :yaml
|
27
|
+
puts({isos: isos}.to_yaml)
|
28
|
+
when :json
|
29
|
+
puts JSON.pretty_generate(isos: isos)
|
30
|
+
else
|
31
|
+
table = [%w(Name Zone Bootable Public Featured)]
|
32
|
+
isos.each do |iso|
|
33
|
+
table << [
|
34
|
+
iso['name'],
|
35
|
+
iso['zonename'],
|
36
|
+
iso['bootable'],
|
37
|
+
iso['ispublic'],
|
38
|
+
iso['isfeatured']
|
39
|
+
]
|
40
|
+
end
|
41
|
+
print_table(table)
|
42
|
+
say "Total number of ISO's: #{isos.size}"
|
28
43
|
end
|
29
|
-
print_table(table)
|
30
|
-
say "Total number of ISO's: #{isos.size}"
|
31
44
|
end
|
32
45
|
end
|
33
46
|
|
@@ -1,22 +1,31 @@
|
|
1
1
|
class Job < CloudstackCli::Base
|
2
2
|
|
3
3
|
desc 'list', 'list async jobs'
|
4
|
+
option :format, default: "table",
|
5
|
+
enum: %w(table json yaml)
|
4
6
|
def list
|
5
7
|
jobs = client.list_async_jobs
|
6
8
|
if jobs.size < 1
|
7
9
|
say "No jobs found."
|
8
10
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
case options[:format].to_sym
|
12
|
+
when :yaml
|
13
|
+
puts({jobs: jobs}.to_yaml)
|
14
|
+
when :json
|
15
|
+
puts JSON.pretty_generate(jobs: jobs)
|
16
|
+
else
|
17
|
+
table = [%w(Command Created Status ID User-ID)]
|
18
|
+
jobs.each do |job|
|
19
|
+
table << [
|
20
|
+
job['cmd'].split('.')[-1],
|
21
|
+
job['created'],
|
22
|
+
job['jobstatus'],
|
23
|
+
job['jobid'],
|
24
|
+
job['userid']
|
25
|
+
]
|
26
|
+
end
|
27
|
+
print_table table
|
18
28
|
end
|
19
|
-
print_table table
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
@@ -2,24 +2,33 @@ class LoadBalancer < CloudstackCli::Base
|
|
2
2
|
|
3
3
|
desc "list", "list load balancer rules"
|
4
4
|
option :project
|
5
|
+
option :format, default: "table",
|
6
|
+
enum: %w(table json yaml)
|
5
7
|
def list
|
6
8
|
resolve_project
|
7
9
|
rules = client.list_load_balancer_rules(options)
|
8
10
|
if rules.size < 1
|
9
11
|
puts "No load balancer rules found."
|
10
12
|
else
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
case options[:format].to_sym
|
14
|
+
when :yaml
|
15
|
+
puts({rules: rules}.to_yaml)
|
16
|
+
when :json
|
17
|
+
puts JSON.pretty_generate(rules: rules)
|
18
|
+
else
|
19
|
+
table = [%w(Name Public-IP Public-Port Private-Port Algorithm)]
|
20
|
+
rules.each do |rule|
|
21
|
+
table << [
|
22
|
+
rule['name'],
|
23
|
+
rule['publicip'],
|
24
|
+
rule['publicport'],
|
25
|
+
rule['privateport'],
|
26
|
+
rule['algorithm']
|
27
|
+
]
|
28
|
+
end
|
29
|
+
print_table table
|
30
|
+
say "Total number of rules: #{rules.count}"
|
20
31
|
end
|
21
|
-
print_table table
|
22
|
-
say "Total number of rules: #{rules.count}"
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
@@ -4,37 +4,47 @@ class Network < CloudstackCli::Base
|
|
4
4
|
option :project, desc: 'the project name of the network'
|
5
5
|
option :account, desc: 'the owner of the network'
|
6
6
|
option :zone, desc: 'the name of the zone the network belongs to'
|
7
|
-
option :type, desc: 'the type of the network'
|
8
7
|
option :showid, type: :boolean, desc: 'show the network id'
|
9
8
|
option :showvlan, type: :boolean, desc: 'show the VLAN'
|
9
|
+
option :filter, type: :hash,
|
10
|
+
desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
|
11
|
+
option :format, default: "table",
|
12
|
+
enum: %w(table json yaml)
|
10
13
|
def list
|
11
14
|
resolve_zone if options[:zone]
|
12
15
|
resolve_project
|
16
|
+
add_filters_to_options("listNetworks") if options[:filter]
|
13
17
|
networks = client.list_networks(options)
|
14
|
-
|
18
|
+
networks = filter_objects(networks) if options[:filter]
|
15
19
|
if networks.size < 1
|
16
20
|
puts "No networks found."
|
17
21
|
else
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
case options[:format].to_sym
|
23
|
+
when :yaml
|
24
|
+
puts({networks: networks}.to_yaml)
|
25
|
+
when :json
|
26
|
+
puts JSON.pretty_generate(networks: networks)
|
27
|
+
else
|
28
|
+
table = [%w(Name Displaytext Account/Project Zone Domain State Type Offering)]
|
29
|
+
table[0] << "ID" if options[:showid]
|
30
|
+
table[0] << "VLAN" if options[:showvlan]
|
31
|
+
networks.each do |network|
|
32
|
+
table << [
|
33
|
+
network["name"],
|
34
|
+
network["displaytext"],
|
35
|
+
network["account"] || network["project"],
|
36
|
+
network["zonename"],
|
37
|
+
network["domain"],
|
38
|
+
network["state"],
|
39
|
+
network["type"],
|
40
|
+
network["networkofferingname"]
|
41
|
+
]
|
42
|
+
table[-1] << network["id"] if options[:showid]
|
43
|
+
table[-1] << network["vlan"] if options[:showvlan]
|
44
|
+
end
|
45
|
+
print_table table
|
46
|
+
say "Total number of networks: #{networks.count}"
|
35
47
|
end
|
36
|
-
print_table table
|
37
|
-
say "Total number of networks: #{networks.count}"
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
@@ -2,6 +2,8 @@ class PhysicalNetwork < CloudstackCli::Base
|
|
2
2
|
|
3
3
|
desc "list", "list physical networks"
|
4
4
|
option :project
|
5
|
+
option :format, default: "table",
|
6
|
+
enum: %w(table json yaml)
|
5
7
|
def list
|
6
8
|
resolve_project
|
7
9
|
networks = client.list_physical_networks(options)
|
@@ -9,17 +11,24 @@ class PhysicalNetwork < CloudstackCli::Base
|
|
9
11
|
if networks.size < 1
|
10
12
|
puts "No networks found"
|
11
13
|
else
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
case options[:format].to_sym
|
15
|
+
when :yaml
|
16
|
+
puts({networks: networks}.to_yaml)
|
17
|
+
when :json
|
18
|
+
puts JSON.pretty_generate(networks: networks)
|
19
|
+
else
|
20
|
+
table = [['Name', 'State', 'Zone', 'ID']]
|
21
|
+
networks.each do |network|
|
22
|
+
table << [
|
23
|
+
network["name"],
|
24
|
+
network["state"],
|
25
|
+
zones.select{|zone| zone['id'] == network["zoneid"]}.first["name"],
|
26
|
+
network["id"]
|
27
|
+
]
|
28
|
+
end
|
29
|
+
print_table table
|
30
|
+
say "Total number of networks: #{networks.count}"
|
20
31
|
end
|
21
|
-
print_table table
|
22
|
-
say "Total number of networks: #{networks.count}"
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
@@ -2,21 +2,30 @@ class Pod < CloudstackCli::Base
|
|
2
2
|
|
3
3
|
desc 'list', 'list pods'
|
4
4
|
option :zone
|
5
|
+
option :format, default: "table",
|
6
|
+
enum: %w(table json yaml)
|
5
7
|
def list
|
6
8
|
resolve_zone
|
7
9
|
pods = client.list_pods(options)
|
8
10
|
if pods.size < 1
|
9
11
|
say "No pods found."
|
10
12
|
else
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
case options[:format].to_sym
|
14
|
+
when :yaml
|
15
|
+
puts({pods: pods}.to_yaml)
|
16
|
+
when :json
|
17
|
+
puts JSON.pretty_generate(pods: pods)
|
18
|
+
else
|
19
|
+
table = [["Name", "Start-IP", "End-IP", "Zone"]]
|
20
|
+
pods.each do |pod|
|
21
|
+
table << [
|
22
|
+
pod['name'], pod['startip'],
|
23
|
+
pod['endip'], pod['zonename']
|
24
|
+
]
|
25
|
+
end
|
26
|
+
print_table table
|
27
|
+
say "Total number of pods: #{pods.count}"
|
17
28
|
end
|
18
|
-
print_table table
|
19
|
-
say "Total number of pods: #{pods.count}"
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
@@ -44,25 +44,34 @@ class PortRule < CloudstackCli::Base
|
|
44
44
|
|
45
45
|
desc "list", "list portforwarding rules"
|
46
46
|
option :project
|
47
|
+
option :format, default: "table",
|
48
|
+
enum: %w(table json yaml)
|
47
49
|
def list
|
48
50
|
resolve_project
|
49
51
|
rules = client.list_port_forwarding_rules(options)
|
50
52
|
if rules.size < 1
|
51
53
|
puts "No rules found."
|
52
54
|
else
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
case options[:format].to_sym
|
56
|
+
when :yaml
|
57
|
+
puts({rules: rules}.to_yaml)
|
58
|
+
when :json
|
59
|
+
puts JSON.pretty_generate(rules: rules)
|
60
|
+
else
|
61
|
+
table = [["IP", "Server", "Public-Port", "Private-Port", "Protocol", "State"]]
|
62
|
+
rules.each do |rule|
|
63
|
+
table << [
|
64
|
+
rule['ipaddress'],
|
65
|
+
rule['virtualmachinename'],
|
66
|
+
print_ports(rule, 'public'),
|
67
|
+
print_ports(rule, 'private'),
|
68
|
+
rule['protocol'],
|
69
|
+
rule['state']
|
70
|
+
]
|
71
|
+
end
|
72
|
+
print_table table
|
73
|
+
say "Total number of rules: #{rules.count}"
|
63
74
|
end
|
64
|
-
print_table table
|
65
|
-
say "Total number of rules: #{rules.count}"
|
66
75
|
end
|
67
76
|
end
|
68
77
|
|
@@ -14,25 +14,34 @@ class Project < CloudstackCli::Base
|
|
14
14
|
|
15
15
|
desc "list", "list projects"
|
16
16
|
option :domain, desc: "List only resources belonging to the domain specified"
|
17
|
+
option :format, default: "table",
|
18
|
+
enum: %w(table json yaml)
|
17
19
|
def list
|
18
20
|
resolve_domain
|
19
21
|
projects = client.list_projects(options.merge listall: true)
|
20
22
|
if projects.size < 1
|
21
23
|
puts "No projects found."
|
22
24
|
else
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
case options[:format].to_sym
|
26
|
+
when :yaml
|
27
|
+
puts({projects: projects}.to_yaml)
|
28
|
+
when :json
|
29
|
+
puts JSON.pretty_generate(projects: projects)
|
30
|
+
else
|
31
|
+
table = [%w(Name Displaytext VMs CPU Memory Domain)]
|
32
|
+
projects.each do |project|
|
33
|
+
table << [
|
34
|
+
project['name'],
|
35
|
+
project['displaytext'],
|
36
|
+
project['vmtotal'],
|
37
|
+
project['cputotal'],
|
38
|
+
project['memorytotal'] / 1024,
|
39
|
+
project['domain']
|
40
|
+
]
|
41
|
+
end
|
42
|
+
print_table(table)
|
43
|
+
say "Total number of projects: #{projects.count}"
|
33
44
|
end
|
34
|
-
print_table(table)
|
35
|
-
say "Total number of projects: #{projects.count}"
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
@@ -1,20 +1,29 @@
|
|
1
1
|
class Region < CloudstackCli::Base
|
2
2
|
|
3
3
|
desc 'list', 'list regions'
|
4
|
+
option :format, default: "table",
|
5
|
+
enum: %w(table json yaml)
|
4
6
|
def list
|
5
7
|
regions = client.list_regions
|
6
8
|
if regions.size < 1
|
7
9
|
say "No regions found."
|
8
10
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
case options[:format].to_sym
|
12
|
+
when :yaml
|
13
|
+
puts({regions: regions}.to_yaml)
|
14
|
+
when :json
|
15
|
+
puts JSON.pretty_generate(regions: regions)
|
16
|
+
else
|
17
|
+
table = [%w(Name, Endpoint)]
|
18
|
+
regions.each do |region|
|
19
|
+
table << [
|
20
|
+
region['name'], region['endpoint']
|
21
|
+
]
|
22
|
+
end
|
23
|
+
print_table table
|
24
|
+
say "Total number of regions: #{regions.size}"
|
14
25
|
end
|
15
|
-
print_table table
|
16
|
-
say "Total number of regions: #{regions.size}"
|
17
26
|
end
|
18
27
|
end
|
19
28
|
|
20
|
-
end
|
29
|
+
end
|
@@ -18,6 +18,8 @@ class ResourceLimit < CloudstackCli::Base
|
|
18
18
|
option :account
|
19
19
|
option :project
|
20
20
|
option :type, desc: "specify type, see types for a list of types"
|
21
|
+
option :format, default: "table",
|
22
|
+
enum: %w(table json yaml)
|
21
23
|
def list
|
22
24
|
resolve_account
|
23
25
|
resolve_project
|
@@ -34,8 +36,16 @@ class ResourceLimit < CloudstackCli::Base
|
|
34
36
|
resource_to_s(limit, 'max')
|
35
37
|
]
|
36
38
|
end
|
37
|
-
|
38
|
-
|
39
|
+
|
40
|
+
case options[:format].to_sym
|
41
|
+
when :yaml
|
42
|
+
puts({resource_limits: limits}.to_yaml)
|
43
|
+
when :json
|
44
|
+
puts JSON.pretty_generate(resource_limits: limits)
|
45
|
+
else
|
46
|
+
table = table.insert(0, header)
|
47
|
+
print_table table
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
51
|
desc "refresh", "refresh resource counts"
|
@@ -167,9 +167,9 @@ class Router < CloudstackCli::Base
|
|
167
167
|
options[:format] ||= "table"
|
168
168
|
case options[:format].to_sym
|
169
169
|
when :yaml
|
170
|
-
puts({
|
170
|
+
puts({routers: routers}.to_yaml)
|
171
171
|
when :json
|
172
|
-
|
172
|
+
puts JSON.pretty_generate(routers: routers)
|
173
173
|
else
|
174
174
|
table = [%w(
|
175
175
|
Name Zone Account/Project IP Linklocal-IP Status Version
|
@@ -6,6 +6,8 @@ class Snapshot < CloudstackCli::Base
|
|
6
6
|
option :domain, desc: "the domain name of the snapshot's account"
|
7
7
|
option :listall, default: true, desc: "list all resources the caller has rights on"
|
8
8
|
option :state, desc: "filter snapshots by state"
|
9
|
+
option :format, default: "table",
|
10
|
+
enum: %w(table json yaml)
|
9
11
|
def list
|
10
12
|
resolve_account
|
11
13
|
resolve_project
|
@@ -14,16 +16,23 @@ class Snapshot < CloudstackCli::Base
|
|
14
16
|
if snapshots.size < 1
|
15
17
|
say "No snapshots found."
|
16
18
|
else
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
]
|
19
|
+
case options[:format].to_sym
|
20
|
+
when :yaml
|
21
|
+
puts({snapshots: snapshots}.to_yaml)
|
22
|
+
when :json
|
23
|
+
puts JSON.pretty_generate(snapshots: snapshots)
|
24
|
+
else
|
25
|
+
table = [%w(Account Name Volume Created Type State)]
|
26
|
+
snapshots = filter_by(snapshots, :state, options[:state]) if options[:state]
|
27
|
+
snapshots.each do |snapshot|
|
28
|
+
table << [
|
29
|
+
snapshot['account'], snapshot['name'], snapshot['volumename'],
|
30
|
+
snapshot['created'], snapshot['snapshottype'], snapshot['state']
|
31
|
+
]
|
32
|
+
end
|
33
|
+
print_table table
|
34
|
+
say "Total number of snapshots: #{snapshots.size}"
|
24
35
|
end
|
25
|
-
print_table table
|
26
|
-
say "Total number of snapshots: #{snapshots.size}"
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
@@ -4,6 +4,8 @@ class SshKeyPair < CloudstackCli::Base
|
|
4
4
|
option :listall, default: true
|
5
5
|
option :account
|
6
6
|
option :project
|
7
|
+
option :format, default: "table",
|
8
|
+
enum: %w(table json yaml)
|
7
9
|
def list
|
8
10
|
resolve_account
|
9
11
|
resolve_project
|
@@ -11,11 +13,18 @@ class SshKeyPair < CloudstackCli::Base
|
|
11
13
|
if pairs.size < 1
|
12
14
|
say "No ssh key pairs found."
|
13
15
|
else
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
case options[:format].to_sym
|
17
|
+
when :yaml
|
18
|
+
puts({ssh_key_pairs: pairs}.to_yaml)
|
19
|
+
when :json
|
20
|
+
puts JSON.pretty_generate(ssh_key_pairs: pairs)
|
21
|
+
else
|
22
|
+
table = [["Name", "Fingerprint"]]
|
23
|
+
pairs.each do |pair|
|
24
|
+
table << [pair['name'], pair['fingerprint']]
|
25
|
+
end
|
26
|
+
print_table table
|
17
27
|
end
|
18
|
-
print_table table
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
@@ -5,34 +5,43 @@ class StoragePool < CloudstackCli::Base
|
|
5
5
|
option :name, desc: "name of the storage pool"
|
6
6
|
option :keyword, desc: "list by keyword"
|
7
7
|
option :state, desc: "filter by state (Up, Maintenance)"
|
8
|
+
option :format, default: "table",
|
9
|
+
enum: %w(table json yaml)
|
8
10
|
def list
|
9
11
|
resolve_zone
|
10
12
|
storage_pools = client.list_storage_pools(options)
|
11
13
|
if storage_pools.size < 1
|
12
14
|
say "No storage pools found."
|
13
15
|
else
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
table << [
|
27
|
-
|
28
|
-
|
29
|
-
total
|
30
|
-
|
31
|
-
storage_pool['
|
32
|
-
|
16
|
+
case options[:format].to_sym
|
17
|
+
when :yaml
|
18
|
+
puts({storage_pools: storage_pools}.to_yaml)
|
19
|
+
when :json
|
20
|
+
puts JSON.pretty_generate(storage_pools: storage_pools)
|
21
|
+
else
|
22
|
+
storage_pools = filter_by(storage_pools, "state", options[:state]) if options[:state]
|
23
|
+
table = [%w(Name Pod State Zone)]
|
24
|
+
table[0] << "Size [GB]"
|
25
|
+
table[0] << "Used [GB]"
|
26
|
+
table[0] << "Used [%]"
|
27
|
+
table[0] << "Alocated [GB]"
|
28
|
+
table[0] << "Alocated [%]"
|
29
|
+
table[0] << "Type"
|
30
|
+
storage_pools.each do |storage_pool|
|
31
|
+
total = storage_pool['disksizetotal'] / 1024**3
|
32
|
+
used = (storage_pool['disksizeused'] / 1024**3) rescue 0
|
33
|
+
allocated = (storage_pool['disksizeallocated'] / 1024**3) rescue 0
|
34
|
+
table << [
|
35
|
+
storage_pool['name'], storage_pool['podname'],
|
36
|
+
storage_pool['state'], storage_pool['zonename'],
|
37
|
+
total, used, (100.0 / total * used).round(0),
|
38
|
+
allocated, (100.0 / total * allocated).round(0),
|
39
|
+
storage_pool['type']
|
40
|
+
]
|
41
|
+
end
|
42
|
+
print_table table
|
43
|
+
say "Total number of storage_pools: #{storage_pools.size}"
|
33
44
|
end
|
34
|
-
print_table table
|
35
|
-
say "Total number of storage_pools: #{storage_pools.size}"
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
@@ -5,20 +5,29 @@ class SystemVm < CloudstackCli::Base
|
|
5
5
|
option :state, desc: "state of the system VM"
|
6
6
|
option :type, desc: "the system VM type.",
|
7
7
|
enum: %w(consoleproxy secondarystoragevm)
|
8
|
+
option :format, default: "table",
|
9
|
+
enum: %w(table json yaml)
|
8
10
|
def list
|
9
11
|
resolve_zone
|
10
12
|
vms = client.list_system_vms(options)
|
11
13
|
if vms.size < 1
|
12
14
|
say "No system VM's found."
|
13
15
|
else
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
case options[:format].to_sym
|
17
|
+
when :yaml
|
18
|
+
puts({system_vms: vms}.to_yaml)
|
19
|
+
when :json
|
20
|
+
puts JSON.pretty_generate(system_vms: vms)
|
21
|
+
else
|
22
|
+
table = [%w(Name Zone State Type)]
|
23
|
+
vms.each do |vm|
|
24
|
+
table << [
|
25
|
+
vm['name'], vm['zonename'], vm['state'], vm['systemvmtype']
|
26
|
+
]
|
27
|
+
end
|
28
|
+
print_table table
|
29
|
+
say "Total number of system VM's: #{vms.size}"
|
19
30
|
end
|
20
|
-
print_table table
|
21
|
-
say "Total number of system VM's: #{vms.size}"
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
@@ -6,6 +6,8 @@ class Template < CloudstackCli::Base
|
|
6
6
|
option :type,
|
7
7
|
enum: %w(featured self self-executable executable community all),
|
8
8
|
default: "featured"
|
9
|
+
option :format, default: "table",
|
10
|
+
enum: %w(table json yaml)
|
9
11
|
def list(type='featured')
|
10
12
|
resolve_project
|
11
13
|
resolve_zone
|
@@ -14,19 +16,26 @@ class Template < CloudstackCli::Base
|
|
14
16
|
if templates.size < 1
|
15
17
|
puts "No templates found."
|
16
18
|
else
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
case options[:format].to_sym
|
20
|
+
when :yaml
|
21
|
+
puts({templates: templates}.to_yaml)
|
22
|
+
when :json
|
23
|
+
puts JSON.pretty_generate(templates: templates)
|
24
|
+
else
|
25
|
+
table = [%w(Name Created Zone Featured Public Format)]
|
26
|
+
templates.each do |template|
|
27
|
+
table << [
|
28
|
+
template['name'],
|
29
|
+
Time.parse(template['created']).strftime("%F"),
|
30
|
+
template['zonename'],
|
31
|
+
template['isfeatured'],
|
32
|
+
template['ispublic'],
|
33
|
+
template['format']
|
34
|
+
]
|
35
|
+
end
|
36
|
+
print_table(table)
|
37
|
+
say "Total number of templates: #{templates.size}"
|
27
38
|
end
|
28
|
-
print_table(table)
|
29
|
-
say "Total number of templates: #{templates.size}"
|
30
39
|
end
|
31
40
|
end
|
32
41
|
|
@@ -3,21 +3,30 @@ class User < CloudstackCli::Base
|
|
3
3
|
desc 'list', 'list users'
|
4
4
|
option :listall
|
5
5
|
option :account
|
6
|
+
option :format, default: "table",
|
7
|
+
enum: %w(table json yaml)
|
6
8
|
def list
|
7
9
|
resolve_account
|
8
10
|
users = client.list_users(options)
|
9
11
|
if users.size < 1
|
10
12
|
say "No users found."
|
11
13
|
else
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
case options[:format].to_sym
|
15
|
+
when :yaml
|
16
|
+
puts({users: users}.to_yaml)
|
17
|
+
when :json
|
18
|
+
puts JSON.pretty_generate(users: users)
|
19
|
+
else
|
20
|
+
table = [["Account", "Type", "Name", "Email", "State", "Domain"]]
|
21
|
+
users.each do |user|
|
22
|
+
table << [
|
23
|
+
user['account'], Account::TYPES[user['accounttype']], "#{user['firstname']} #{user['lastname']}",
|
24
|
+
user['email'], user['state'], user['domain']
|
25
|
+
]
|
26
|
+
end
|
27
|
+
print_table table
|
28
|
+
say "Total number of users: #{users.size}"
|
18
29
|
end
|
19
|
-
print_table table
|
20
|
-
say "Total number of users: #{users.size}"
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
@@ -19,6 +19,7 @@ class VirtualMachine < CloudstackCli::Base
|
|
19
19
|
option :format, default: "table",
|
20
20
|
enum: %w(table json yaml)
|
21
21
|
def list
|
22
|
+
add_filters_to_options("listVirtualMachines") if options[:filter]
|
22
23
|
resolve_account
|
23
24
|
resolve_project
|
24
25
|
resolve_zone
|
@@ -269,9 +270,9 @@ class VirtualMachine < CloudstackCli::Base
|
|
269
270
|
def print_virtual_machines(virtual_machines)
|
270
271
|
case options[:format].to_sym
|
271
272
|
when :yaml
|
272
|
-
puts({
|
273
|
+
puts({virtual_machines: virtual_machines}.to_yaml)
|
273
274
|
when :json
|
274
|
-
|
275
|
+
puts JSON.pretty_generate(virtual_machines: virtual_machines)
|
275
276
|
else
|
276
277
|
with_i_name = virtual_machines.first['instancename']
|
277
278
|
with_h_name = virtual_machines.first['hostname']
|
@@ -7,30 +7,43 @@ class Volume < CloudstackCli::Base
|
|
7
7
|
option :keyword, desc: 'list by keyword'
|
8
8
|
option :name, desc: 'name of the disk volume'
|
9
9
|
option :type, desc: 'type of disk volume (ROOT or DATADISK)'
|
10
|
+
option :filter, type: :hash,
|
11
|
+
desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
|
12
|
+
option :format, default: "table",
|
13
|
+
enum: %w(table json yaml)
|
10
14
|
def list
|
11
15
|
resolve_project
|
12
16
|
resolve_account
|
13
17
|
resolve_zone
|
18
|
+
add_filters_to_options("listVolumes") if options[:filter]
|
14
19
|
volumes = client.list_volumes(options)
|
20
|
+
volumes = filter_objects(volumes) if options[:filter]
|
15
21
|
if volumes.size < 1
|
16
22
|
say "No volumes found."
|
17
23
|
else
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
case options[:format].to_sym
|
25
|
+
when :yaml
|
26
|
+
puts({volumes: volumes}.to_yaml)
|
27
|
+
when :json
|
28
|
+
puts JSON.pretty_generate(volumes: volumes)
|
29
|
+
else
|
30
|
+
table = [%w(Name Type Size VM Storage Offeringname Zone Status)]
|
31
|
+
table.first << 'Project' if options[:project]
|
32
|
+
volumes.each do |volume|
|
33
|
+
table << [
|
34
|
+
volume['name'], volume['type'],
|
35
|
+
(volume['size'] / 1024**3).to_s + 'GB',
|
36
|
+
volume['vmname'],
|
37
|
+
volume['storage'],
|
38
|
+
volume['diskofferingname'],
|
39
|
+
volume['zonename'],
|
40
|
+
volume['state']
|
41
|
+
]
|
42
|
+
table.last << volume['project'] if options[:project]
|
43
|
+
end
|
44
|
+
print_table(table)
|
45
|
+
say "Total number of volumes: #{volumes.size}"
|
31
46
|
end
|
32
|
-
print_table(table)
|
33
|
-
say "Total number of volumes: #{volumes.size}"
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
@@ -1,21 +1,30 @@
|
|
1
1
|
class Zone < CloudstackCli::Base
|
2
2
|
|
3
3
|
desc "list", "list zones"
|
4
|
+
option :format, default: "table",
|
5
|
+
enum: %w(table json yaml)
|
4
6
|
def list
|
5
7
|
zones = client.list_zones
|
6
8
|
if zones.size < 1
|
7
9
|
puts "No projects found"
|
8
10
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
]
|
11
|
+
case options[:format].to_sym
|
12
|
+
when :yaml
|
13
|
+
puts({zones: zones}.to_yaml)
|
14
|
+
when :json
|
15
|
+
puts JSON.pretty_generate(zones: zones)
|
16
|
+
else
|
17
|
+
table = [%w(Name Network-Type Description)]
|
18
|
+
zones.each do |zone|
|
19
|
+
table << [
|
20
|
+
zone['name'],
|
21
|
+
zone['networktype'],
|
22
|
+
zone['description']
|
23
|
+
]
|
24
|
+
end
|
25
|
+
print_table(table)
|
16
26
|
end
|
17
27
|
end
|
18
|
-
print_table(table)
|
19
28
|
end
|
20
29
|
|
21
30
|
end
|