cloudstack-cli 0.13.1 → 0.14.0

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: 5cae23abc9a8273ab51dabe0a7547b53c571fd45
4
- data.tar.gz: b6fb172ab5e198a54dd94bfd9e20ef341e71a4a9
3
+ metadata.gz: 463f0fd4f677877f7369ad4de5fc7047dd854125
4
+ data.tar.gz: 32acd6310d8448cbb8e70df4bac657b290e9e17c
5
5
  SHA512:
6
- metadata.gz: 1903a80864f56b3b7abfecd72752a43a1c50d27bd360af0b4df1292c6f7150d28cf38822cff14534a27b83c8a02f6b1dc781d9822670903ef4b9dcc70185386f
7
- data.tar.gz: 86d74efc92137546e33906aa635abdcb5e3ff33c48d84f1fcd85563ffcbba438ac1fc0845f45eb9d3978423c0a3621306022a377add695129da15807651c06b3
6
+ metadata.gz: 688f24864400caaab25304529d080f2d52454d1dd1626f7f0fce6468bb6357e826b1d7ef12a76c8aa499c12cf9025289e735069906a28a4c198e65ef5aed4ea8
7
+ data.tar.gz: f37bb9bebce58335f78c3ea050719703ba1e96655ac7e9d4cb752d8b5dca403aacb5f6eb887031ae0b3d3f14c9041ff031946a36016f2945b6377a0344a31510
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  GIT
2
2
  remote: git@github.com:niwo/cloudstack_client.git
3
- revision: b6fdbc1a50a06f3596b1e07c0e7973cb34bbf203
3
+ revision: 56f489ce1649c6d2f6809382787de2ee48968655
4
4
  branch: master
5
5
  specs:
6
- cloudstack_client (0.9.2)
6
+ cloudstack_client (0.9.3)
7
7
 
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- cloudstack-cli (0.13.1)
12
- cloudstack_client (~> 0.9.2)
11
+ cloudstack-cli (0.14.0)
12
+ cloudstack_client (~> 0.9.3)
13
13
  thor (~> 0.19.1)
14
14
 
15
15
  GEM
@@ -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', '~> 0.9.2')
28
+ gem.add_dependency('cloudstack_client', '~> 0.9.3')
29
29
  end
@@ -1,67 +1,67 @@
1
1
  class Router < CloudstackCli::Base
2
2
 
3
- desc "list", "list virtual routers"
4
- option :project
5
- option :account
6
- option :zone
7
- option :status, desc: "Running or Stopped"
8
- option :redundant_state, desc: "master, backup, fault or unknown"
9
- option :listall, type: :boolean
10
- option :showid, type: :boolean
11
- option :command, desc: "command to execute for each router: START or STOP"
12
- option :reverse, type: :boolean, default: false, desc: "reverse listing of routers"
3
+ desc "list", "list virtual routers"
4
+ option :project, desc: "name of the project"
5
+ option :account, desc: "name of the account"
6
+ option :zone, desc: "name of the zone"
7
+ option :status, desc: "the status of the router"
8
+ option :redundant_state, desc: "the state of redundant virtual router",
9
+ enum: %w(master backup fault unknown)
10
+ option :listall, type: :boolean, desc: "list all routers"
11
+ option :showid, type: :boolean, desc: "display the router ID"
12
+ option :reverse, type: :boolean, default: false, desc: "reverse listing of routers"
13
+ option :command,
14
+ desc: "command to execute for each router",
15
+ enum: %w(START STOP REBOOT)
16
+ option :concurrency, type: :numeric, default: 10, aliases: '-C',
17
+ desc: "number of concurrent command to execute"
13
18
  def list
14
19
  projectid = find_project['id'] if options[:project]
15
- routers = client.list_routers(
16
- {
17
- account: options[:account],
18
- projectid: projectid,
19
- status: options[:status],
20
- zone: options[:zone]
21
- }
22
- )
23
-
24
- if options[:listall]
25
- projects = client.list_projects
26
- projects.each do |project|
27
- routers = routers + client.list_routers(
28
- {
29
- account: options[:account],
30
- projectid: project['id'],
31
- status: options[:status],
32
- zone: options[:zone]
33
- }
34
- )
35
- end
36
- end
37
-
38
- if options[:redundant_state]
39
- routers = filter_by(routers, 'redundantstate', options[:redundant_state].downcase)
40
- end
41
-
42
- routers.reverse! if options[:reverse]
43
-
44
- print_routers(routers, options)
45
-
46
- if options[:command]
47
- case options[:command].downcase
48
- when "start"
49
- exit unless yes?("\nStart the router(s) above? [y/N]:", :magenta)
50
- jobs = routers.map do |router|
51
- {id: client.start_router(router['id'], async: false)['jobid'], name: "Start router #{router['name']}"}
52
- end
53
- when "stop"
54
- exit unless yes?("\nStop the router(s) above? [y/N]:", :magenta)
55
- jobs = routers.map do |router|
56
- {id: client.stop_router(router['id'], async: false)['jobid'], name: "Stop router #{router['name']}"}
57
- end
58
- else
59
- say "\nCommand #{options[:command]} not supported.", :red
60
- exit 1
61
- end
62
- puts
63
- watch_jobs(jobs)
64
- end
20
+ routers = client.list_routers(
21
+ {
22
+ account: options[:account],
23
+ projectid: projectid,
24
+ status: options[:status],
25
+ zone: options[:zone]
26
+ }
27
+ )
28
+
29
+ if options[:listall]
30
+ projects = client.list_projects
31
+ projects.each do |project|
32
+ routers = routers + client.list_routers(
33
+ {
34
+ account: options[:account],
35
+ projectid: project['id'],
36
+ status: options[:status],
37
+ zone: options[:zone]
38
+ }
39
+ )
40
+ end
41
+ end
42
+
43
+ if options[:redundant_state]
44
+ routers = filter_by(routers, 'redundantstate', options[:redundant_state].downcase)
45
+ end
46
+
47
+ routers.reverse! if options[:reverse]
48
+ print_routers(routers, options)
49
+
50
+ if options[:command]
51
+ command = options[:command].downcase
52
+ unless %w(start stop reboot).include?(command)
53
+ say "\nCommand #{options[:command]} not supported.", :red
54
+ exit 1
55
+ end
56
+ exit unless yes?("\n#{command.capitalize} the router(s) above? [y/N]:", :magenta)
57
+ routers.each_slice(options[:concurrency]) do | batch |
58
+ jobs = batch.map do |router|
59
+ {id: client.send("#{command}_router", router['id'], async: false)['jobid'], name: "#{command.capitalize} router #{router['name']}"}
60
+ end
61
+ puts
62
+ watch_jobs(jobs)
63
+ end
64
+ end
65
65
  end
66
66
 
67
67
  desc "stop NAME [NAME2 ..]", "stop virtual router(s)"
@@ -70,9 +70,9 @@ class Router < CloudstackCli::Base
70
70
  routers = names.map {|name| get_router(name)}
71
71
  print_routers(routers)
72
72
  exit unless options[:force] || yes?("\nStop router(s) above? [y/N]:", :magenta)
73
- jobs = routers.map do |router|
74
- {id: client.stop_router(router['id'], async: false)['jobid'], name: "Stop router #{router['name']}"}
75
- end
73
+ jobs = routers.map do |router|
74
+ {id: client.stop_router(router['id'], async: false)['jobid'], name: "Stop router #{router['name']}"}
75
+ end
76
76
  puts
77
77
  watch_jobs(jobs)
78
78
  end
@@ -83,14 +83,27 @@ class Router < CloudstackCli::Base
83
83
  routers = names.map {|name| get_router(name)}
84
84
  print_routers(routers)
85
85
  exit unless options[:force] || yes?("\nStart router(s) above? [y/N]:", :magenta)
86
- jobs = routers.map do |router|
86
+ jobs = routers.map do |router|
87
87
  {id: client.start_router(router['id'], async: false)['jobid'], name: "Start router #{router['name']}"}
88
88
  end
89
89
  puts
90
90
  watch_jobs(jobs)
91
91
  end
92
92
 
93
- desc "start NAME [NAME2 ..]", "restart virtual router(s) (stop and start)"
93
+ desc "reboot NAME [NAME2 ..]", "reboot virtual router(s)"
94
+ option :force, desc: "start without asking", type: :boolean, aliases: '-f'
95
+ def reboot(*names)
96
+ routers = names.map {|name| get_router(name)}
97
+ print_routers(routers)
98
+ exit unless options[:force] || yes?("\nReboot router(s) above? [y/N]:", :magenta)
99
+ jobs = routers.map do |router|
100
+ {id: client.reboot_router(router['id'], async: false)['jobid'], name: "Reboot router #{router['name']}"}
101
+ end
102
+ puts
103
+ watch_jobs(jobs)
104
+ end
105
+
106
+ desc "restart NAME [NAME2 ..]", "restart virtual router(s) (stop and start)"
94
107
  option :force, desc: "restart without asking", type: :boolean, aliases: '-f'
95
108
  def restart(*names)
96
109
  routers = names.map {|name| get_router(name)}
@@ -117,24 +130,24 @@ class Router < CloudstackCli::Base
117
130
  routers = names.map {|name| get_router(name)}
118
131
  print_routers(routers)
119
132
  exit unless options[:force] || yes?("\nDestroy router(s) above? [y/N]:", :magenta)
120
- jobs = routers.map do |router|
121
- {id: client.destroy_router(router['id'], async: false)['jobid'], name: "Destroy router #{router['name']}"}
122
- end
133
+ jobs = routers.map do |router|
134
+ {id: client.destroy_router(router['id'], async: false)['jobid'], name: "Destroy router #{router['name']}"}
135
+ end
123
136
  puts
124
137
  watch_jobs(jobs)
125
138
  end
126
139
 
127
140
  no_commands do
128
141
 
129
- def get_router(name)
130
- unless router = client.get_router(name)
142
+ def get_router(name)
143
+ unless router = client.get_router(name)
131
144
  unless router = client.get_router(name, -1)
132
- say "Can't find router with name #{name}.", :red
133
- exit 1
145
+ say "Can't find router with name #{name}.", :red
146
+ exit 1
134
147
  end
135
- end
136
- router
137
- end
148
+ end
149
+ router
150
+ end
138
151
 
139
152
  def print_routers(routers, options = {})
140
153
  if routers.size < 1
@@ -166,4 +179,4 @@ class Router < CloudstackCli::Base
166
179
  end
167
180
  end
168
181
 
169
- end
182
+ end
@@ -1,14 +1,18 @@
1
1
  class Server < CloudstackCli::Base
2
2
 
3
3
  desc "list", "list servers"
4
- option :project
5
- option :account
6
- option :zone
7
- option :command, desc: "command to execute for each server: START, STOP or RESTART"
8
- option :state
9
- option :listall
10
- option :storage_id
4
+ option :account, desc: "name of the account"
5
+ option :project, desc: "name of the project"
6
+ option :zone, desc: "the name of the availability zone"
7
+ option :state, desc: "state of the virtual machine"
8
+ option :listall, desc: "list all servers"
9
+ option :storage_id, desc: "the storage ID where vm's volumes belong to"
11
10
  option :keyword, desc: "filter by keyword"
11
+ option :command,
12
+ desc: "command to execute for each server",
13
+ enum: %w(START STOP REBOOT)
14
+ option :concurrency, type: :numeric, default: 10, aliases: '-C',
15
+ desc: "number of concurrent command to execute"
12
16
  def list
13
17
  if options[:project]
14
18
  project_id = find_project['id']
@@ -37,30 +41,21 @@ class Server < CloudstackCli::Base
37
41
 
38
42
  if options[:command]
39
43
  args = { project_id: project_id, sync: true, account: options[:account] }
40
- case options[:command].downcase
41
- when "start"
42
- exit unless yes?("\nStart the server(s) above? [y/N]:", :magenta)
43
- jobs = servers.map do |server|
44
- {id: client.start_server(server['name'], args)['jobid'], name: "Start server #{server['name']}"}
45
- end
46
- when "stop"
47
- exit unless yes?("\nStop the server(s) above? [y/N]:", :magenta)
48
- jobs = servers.map do |server|
49
- {id: client.stop_server(server['name'], args)['jobid'], name: "Stop server #{server['name']}"}
50
- end
51
- when "restart"
52
- exit unless yes?("\nRestart the server(s) above? [y/N]:", :magenta)
53
- jobs = servers.map do |server|
54
- {id: client.reboot_server(server['name'], args)['jobid'], name: "Restart server #{server['name']}"}
55
- end
56
- else
57
- say "\nCommand #{options[:command]} not supported.", :red
58
- exit 1
44
+ command = options[:command].downcase
45
+ unless %w(start stop reboot).include?(command)
46
+ say "\nCommand #{options[:command]} not supported.", :red
47
+ exit 1
48
+ end
49
+ exit unless yes?("\n#{command.capitalize} the server(s) above? [y/N]:", :magenta)
50
+ servers.each_slice(options[:concurrency]) do | batch |
51
+ jobs = batch.map do |server|
52
+ {id: client.send("#{command}_server", server['name'], args)['jobid'], name: "#{command.capitalize} server #{server['name']}"}
59
53
  end
60
54
  puts
61
55
  watch_jobs(jobs)
62
56
  end
63
57
  end
58
+ end
64
59
  end
65
60
 
66
61
  desc "show NAME", "show detailed infos about a server"
@@ -183,7 +178,7 @@ class Server < CloudstackCli::Base
183
178
  puts
184
179
  end
185
180
 
186
- desc "reboot NAME", "reboot a server"
181
+ desc "restart NAME", "restart a server"
187
182
  option :project
188
183
  option :account
189
184
  option :force
@@ -1,7 +1,8 @@
1
1
  class SystemVm < CloudstackCli::Base
2
2
 
3
- desc 'list', 'list system vms'
4
- option :zone
3
+ desc 'list', 'list system VMs'
4
+ option :zone, desc: "the name of the availability zone"
5
+ option :state, desc: "state of the system VM"
5
6
  def list
6
7
  vms = client.list_system_vms(options)
7
8
  if vms.size < 1
@@ -3,6 +3,7 @@ class Volume < CloudstackCli::Base
3
3
  desc "list", "list volumes"
4
4
  option :project, desc: 'list resources by project'
5
5
  option :account, desc: 'list resources by account'
6
+ option :zone, desc: "the name of the availability zone"
6
7
  option :keyword, desc: 'list by keyword'
7
8
  option :name, desc: 'name of the disk volume'
8
9
  option :type, desc: 'type of disk volume (ROOT or DATADISK)'
@@ -12,7 +13,7 @@ class Volume < CloudstackCli::Base
12
13
  if volumes.size < 1
13
14
  say "No volumes found."
14
15
  else
15
- table = [%w(Name Type Size VM Storage Offeringname Status)]
16
+ table = [%w(Name Type Size VM Storage Offeringname Zone Status)]
16
17
  volumes.each do |volume|
17
18
  table << [
18
19
  volume['name'], volume['type'],
@@ -20,6 +21,7 @@ class Volume < CloudstackCli::Base
20
21
  volume['vmname'],
21
22
  volume['storage'],
22
23
  volume['diskofferingname'],
24
+ volume['zonename'],
23
25
  volume['state']
24
26
  ]
25
27
  end
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "0.13.1"
2
+ VERSION = "0.14.0"
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: 0.13.1
4
+ version: 0.14.0
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-02-13 00:00:00.000000000 Z
11
+ date: 2015-03-09 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: 0.9.2
61
+ version: 0.9.3
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: 0.9.2
68
+ version: 0.9.3
69
69
  description: cloudstack-cli is a CloudStack API command line client written in Ruby.
70
70
  email:
71
71
  - nik.wolfgramm@gmail.com