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 +4 -4
- data/Gemfile.lock +4 -4
- data/cloudstack-cli.gemspec +1 -1
- data/lib/cloudstack-cli/commands/router.rb +89 -76
- data/lib/cloudstack-cli/commands/server.rb +22 -27
- data/lib/cloudstack-cli/commands/system_vm.rb +3 -2
- data/lib/cloudstack-cli/commands/volume.rb +3 -1
- data/lib/cloudstack-cli/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 463f0fd4f677877f7369ad4de5fc7047dd854125
|
4
|
+
data.tar.gz: 32acd6310d8448cbb8e70df4bac657b290e9e17c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
3
|
+
revision: 56f489ce1649c6d2f6809382787de2ee48968655
|
4
4
|
branch: master
|
5
5
|
specs:
|
6
|
-
cloudstack_client (0.9.
|
6
|
+
cloudstack_client (0.9.3)
|
7
7
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
cloudstack-cli (0.
|
12
|
-
cloudstack_client (~> 0.9.
|
11
|
+
cloudstack-cli (0.14.0)
|
12
|
+
cloudstack_client (~> 0.9.3)
|
13
13
|
thor (~> 0.19.1)
|
14
14
|
|
15
15
|
GEM
|
data/cloudstack-cli.gemspec
CHANGED
@@ -1,67 +1,67 @@
|
|
1
1
|
class Router < CloudstackCli::Base
|
2
2
|
|
3
|
-
|
4
|
-
option :project
|
5
|
-
option :account
|
6
|
-
option :zone
|
7
|
-
option :status, desc: "
|
8
|
-
option :redundant_state, desc: "
|
9
|
-
|
10
|
-
option :
|
11
|
-
option :
|
12
|
-
|
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
|
-
|
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
|
-
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
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
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 "
|
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
|
-
|
121
|
-
|
122
|
-
|
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
|
-
|
130
|
-
|
142
|
+
def get_router(name)
|
143
|
+
unless router = client.get_router(name)
|
131
144
|
unless router = client.get_router(name, -1)
|
132
|
-
|
133
|
-
|
145
|
+
say "Can't find router with name #{name}.", :red
|
146
|
+
exit 1
|
134
147
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
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 :
|
5
|
-
option :
|
6
|
-
option :zone
|
7
|
-
option :
|
8
|
-
option :
|
9
|
-
option :
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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 "
|
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
|
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
|
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.
|
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-
|
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.
|
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.
|
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
|