cloudstack-cli 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dca280248642a4b0440722aa5d8e13b74da1c54b
4
- data.tar.gz: 58d752847f7147069fd208c80c179d4ccb52b2f2
3
+ metadata.gz: 0e275c44c299b822462e77ba0d69ea939587ba99
4
+ data.tar.gz: 16635f34c875017d6c27c4a1ebd9be6a7c915c9a
5
5
  SHA512:
6
- metadata.gz: e6e1d8707a7e78bb69ec5baa4b3551b4e52f8e749ca32adb7c95bc834c5624c829b52a5c37e90938c1751bd73fb02441f8cdd83ff9b3a98fd5f24d108f8995d5
7
- data.tar.gz: 7fd57dd577d8ee3c1df569d957fde135172ee17a1e537b02575f7b9f05de311ded780993d00fd7cde43769cf4e2e8d7986263d3db35df48d8562b9c89e2136ed
6
+ metadata.gz: 4463ce0856dff7467b679260510438122d4ddc170024341e4c735d34fda447fde6ec70f6445fd144459bda487ef0f19ed50a9bf8f66e23780b87bfa02eb43bdf
7
+ data.tar.gz: 1a0ea872edcbc76720cd98f510a43452a4fce2ad4598a0a207f449707da7bafd0849b79cc3cbbbb51b625a8d4588c61e96c7189f6830487d41ca0ce71e5ae386
data/Gemfile.lock CHANGED
@@ -1,24 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudstack-cli (1.0.2)
5
- cloudstack_client (~> 1.0.3)
4
+ cloudstack-cli (1.0.5)
5
+ cloudstack_client (~> 1.0.4)
6
6
  thor (~> 0.19.1)
7
7
 
8
8
  PATH
9
9
  remote: ../cloudstack_client/
10
10
  specs:
11
- cloudstack_client (1.0.3)
11
+ cloudstack_client (1.0.4)
12
12
  msgpack (~> 0.5.11)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- json (1.8.3)
18
17
  msgpack (0.5.12)
19
18
  rake (10.4.2)
20
19
  rdoc (4.2.0)
21
- json (~> 1.4)
22
20
  thor (0.19.1)
23
21
 
24
22
  PLATFORMS
@@ -31,4 +29,4 @@ DEPENDENCIES
31
29
  rdoc (~> 4.2)
32
30
 
33
31
  BUNDLED WITH
34
- 1.10.3
32
+ 1.10.5
data/README.md CHANGED
@@ -71,7 +71,7 @@ Bootsraps a server using a template and creating port-forwarding rules for port
71
71
  $ cloudstack-cli server create server-01 --template CentOS-6.4-x64-v1.4 --zone DC1 --offering 1cpu_1gb --port-rules :22 :80
72
72
  ```
73
73
 
74
- ### Example: Run a any custom API command
74
+ ### Example: Run any custom API command
75
75
 
76
76
  Run the "listAlerts" command against the Cloudstack API with an argument of type=8:
77
77
 
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ require "bundler/gem_tasks"
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency('rake', '~> 10.4')
26
26
 
27
27
  gem.add_dependency('thor', '~> 0.19.1')
28
- gem.add_dependency('cloudstack_client', '~> 1.0.3')
28
+ gem.add_dependency('cloudstack_client', '~> 1.0.4')
29
29
  end
@@ -13,14 +13,23 @@ class Project < CloudstackCli::Base
13
13
  end
14
14
 
15
15
  desc "list", "list projects"
16
+ option :domain, desc: "List only resources belonging to the domain specified"
16
17
  def list
17
- projects = client.list_projects(listall: true)
18
+ resolve_domain
19
+ projects = client.list_projects(options.merge listall: true)
18
20
  if projects.size < 1
19
21
  puts "No projects found."
20
22
  else
21
- table = [["Name", "Displaytext", "Domain"]]
23
+ table = [%w(Name Displaytext VMs CPU Memory Domain)]
22
24
  projects.each do |project|
23
- table << [project['name'], project['displaytext'], project['domain']]
25
+ table << [
26
+ project['name'],
27
+ project['displaytext'],
28
+ project['vmtotal'],
29
+ project['cputotal'],
30
+ project['memorytotal'] / 1024,
31
+ project['domain']
32
+ ]
24
33
  end
25
34
  print_table(table)
26
35
  say "Total number of projects: #{projects.count}"
@@ -8,7 +8,6 @@ class Router < CloudstackCli::Base
8
8
  option :redundant_state, desc: "the state of redundant virtual router",
9
9
  enum: %w(master backup fault unknown)
10
10
  option :listall, type: :boolean, desc: "list all routers", default: true
11
- option :showid, type: :boolean, desc: "display the router ID"
12
11
  option :reverse, type: :boolean, default: false, desc: "reverse listing of routers"
13
12
  option :command,
14
13
  desc: "command to execute for each router",
@@ -17,6 +16,8 @@ class Router < CloudstackCli::Base
17
16
  desc: "number of concurrent command to execute"
18
17
  option :format, default: "table",
19
18
  enum: %w(table json yaml)
19
+ option :showid, type: :boolean, desc: "display the router ID"
20
+ option :verbose, aliases: '-V', desc: "display additional fields"
20
21
  def list
21
22
  resolve_project
22
23
  resolve_zone
@@ -24,7 +25,8 @@ class Router < CloudstackCli::Base
24
25
 
25
26
  routers = client.list_routers(options)
26
27
 
27
- if options[:listall]
28
+ # show all routers unless project or account is set
29
+ if options[:listall] && !options[:project] && !options[:account]
28
30
  client.list_projects(listall: true).each do |project|
29
31
  routers = routers + client.list_routers(
30
32
  options.merge(projectid: project['id'])
@@ -33,7 +35,11 @@ class Router < CloudstackCli::Base
33
35
  end
34
36
 
35
37
  if options[:redundant_state]
36
- routers = filter_by(routers, 'redundantstate', options[:redundant_state].downcase)
38
+ routers = filter_by(
39
+ routers,
40
+ 'redundantstate',
41
+ options[:redundant_state].downcase
42
+ )
37
43
  end
38
44
 
39
45
  routers.reverse! if options[:reverse]
@@ -52,7 +58,6 @@ class Router < CloudstackCli::Base
52
58
  enum: %w(table json yaml)
53
59
  def list_from_file(file)
54
60
  routers = parse_file(file)["routers"]
55
-
56
61
  routers.reverse! if options[:reverse]
57
62
  print_routers(routers, options)
58
63
  execute_router_commands(options[:command].downcase, routers) if options[:command]
@@ -154,24 +159,30 @@ class Router < CloudstackCli::Base
154
159
  say JSON.pretty_generate(routers: routers)
155
160
  else
156
161
  table = [%w(
157
- ID Name Zone Account Project Redundant-State IP Linklocal-IP Status Redundant Offering
162
+ Name Zone Account/Project IP Linklocal-IP Status
158
163
  )]
159
- table[0].delete('ID') unless options[:showid]
164
+ table[0].unshift('ID') if options[:showid]
165
+ if options[:verbose]
166
+ table[0].push('Redundant-State', 'Requ-Upgrade', 'Version', 'Offering')
167
+ end
160
168
  routers.each do |router|
161
169
  table << [
162
- router["id"],
163
170
  router["name"],
164
171
  router["zonename"],
165
- router["account"],
166
- router["project"],
167
- router["redundantstate"],
168
- router["nic"] && router["nic"].first ? router["nic"].first['ipaddress'] : "",
169
- router["linklocalip"],
170
- router["state"],
171
- router["isredundantrouter"],
172
- router["serviceofferingname"]
172
+ router["project"] || router["account"],
173
+ router["nic"] && router["nic"].first ? router["nic"].first['ipaddress'] : "-",
174
+ router["linklocalip"] || "-",
175
+ router["state"]
173
176
  ]
174
- table[-1].delete_at(0) unless table[0].index "ID"
177
+ table[-1].unshift(router["id"]) if options[:showid]
178
+ if options[:verbose]
179
+ table[-1].push(
180
+ print_redundant_state(router),
181
+ router["requiresupgrade"] || "-",
182
+ router["version"] || "-",
183
+ router["serviceofferingname"]
184
+ )
185
+ end
175
186
  end
176
187
  print_table table
177
188
  puts
@@ -180,6 +191,10 @@ class Router < CloudstackCli::Base
180
191
  end
181
192
  end
182
193
 
194
+ def print_redundant_state(router)
195
+ router["isredundantrouter"] == "true" ? router["redundantstate"] : "non-redundant"
196
+ end
197
+
183
198
  def execute_router_commands(command, routers)
184
199
  unless %w(start stop reboot).include?(command)
185
200
  say "\nCommand #{options[:command]} not supported.", :red
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-18 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.3
61
+ version: 1.0.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.3
68
+ version: 1.0.4
69
69
  description: cloudstack-cli is a CloudStack API command line client written in Ruby.
70
70
  email:
71
71
  - nik.wolfgramm@gmail.com