cloudstack-cli 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -8
- data/cloudstack-cli.gemspec +2 -3
- data/lib/cloudstack-cli/base.rb +24 -2
- data/lib/cloudstack-cli/cli.rb +1 -1
- data/lib/cloudstack-cli/commands/router.rb +1 -1
- data/lib/cloudstack-cli/commands/virtual_machine.rb +10 -6
- data/lib/cloudstack-cli/version.rb +1 -1
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ec8b7a8c50432a24255f725112f236d0a989085
|
4
|
+
data.tar.gz: da29cde686e0b1d81973bcf854a09c56ac72ef36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3a762d75d040d5e611a8dc669a19702cc5155f2d8af8b069d902000b3b2c2443c70247c55c406f462ae24c9720dcbc346fbeec5b225e12adfc0a9f4e54ccc40
|
7
|
+
data.tar.gz: 6d261e0788d3a79c3e3c5e559147028cc41a130d322227907dca27a24952f7a0d9a934587dd530ce47f4738862401a56c08323b2c3d045206ab0aca2f1c506c0
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../cloudstack_client/
|
3
3
|
specs:
|
4
|
-
cloudstack_client (1.
|
5
|
-
multi_json (~> 1.11)
|
4
|
+
cloudstack_client (1.3.1)
|
6
5
|
|
7
6
|
PATH
|
8
7
|
remote: .
|
9
8
|
specs:
|
10
|
-
cloudstack-cli (1.
|
11
|
-
cloudstack_client (~> 1.
|
12
|
-
multi_json (~> 1.11)
|
9
|
+
cloudstack-cli (1.4.0)
|
10
|
+
cloudstack_client (~> 1.3)
|
13
11
|
thor (~> 0.19)
|
14
12
|
|
15
13
|
GEM
|
16
14
|
remote: https://rubygems.org/
|
17
15
|
specs:
|
18
|
-
|
19
|
-
rake (10.5.0)
|
16
|
+
rake (11.1.1)
|
20
17
|
thor (0.19.1)
|
21
18
|
|
22
19
|
PLATFORMS
|
@@ -25,7 +22,7 @@ PLATFORMS
|
|
25
22
|
DEPENDENCIES
|
26
23
|
cloudstack-cli!
|
27
24
|
cloudstack_client!
|
28
|
-
rake (~>
|
25
|
+
rake (~> 11.1)
|
29
26
|
|
30
27
|
BUNDLED WITH
|
31
28
|
1.11.2
|
data/cloudstack-cli.gemspec
CHANGED
@@ -21,9 +21,8 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.require_paths = %w(lib)
|
22
22
|
gem.rdoc_options = %w[--line-numbers --inline-source]
|
23
23
|
|
24
|
-
gem.add_development_dependency('rake', '~>
|
24
|
+
gem.add_development_dependency('rake', '~> 11.1')
|
25
25
|
|
26
|
-
gem.add_dependency('cloudstack_client', '~> 1.
|
26
|
+
gem.add_dependency('cloudstack_client', '~> 1.3')
|
27
27
|
gem.add_dependency('thor', '~> 0.19')
|
28
|
-
gem.add_dependency('multi_json', '~> 1.11')
|
29
28
|
end
|
data/lib/cloudstack-cli/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "cloudstack-cli/thor_patch"
|
3
|
+
require "json"
|
3
4
|
require "yaml"
|
4
5
|
require "open-uri"
|
5
6
|
|
@@ -79,13 +80,34 @@ module CloudstackCli
|
|
79
80
|
end
|
80
81
|
|
81
82
|
def filter_by(objects, key, value)
|
82
|
-
objects.
|
83
|
+
if objects.size < 2
|
84
|
+
return objects
|
85
|
+
elsif !(objects.first.has_key? key)
|
86
|
+
keys = objects.first.keys.join(", ")
|
87
|
+
say "WARNING: Filter invalid, no key \"#{key}\" found.", :yellow
|
88
|
+
say("DEBUG: Supported keys are, #{keys}.", :magenta) if options[:debug]
|
89
|
+
return objects
|
90
|
+
end
|
91
|
+
objects.select do |object|
|
92
|
+
object[key.to_s] =~ /#{value}/i
|
93
|
+
end
|
94
|
+
rescue RegexpError => e
|
95
|
+
say "ERROR: Invalid regular expression in filter - #{e.message}", :red
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
|
99
|
+
def filter_objects(objects, filter = options[:filter])
|
100
|
+
filter.each do |key, value|
|
101
|
+
objects = filter_by(objects, key, value)
|
102
|
+
return objects if objects.size == 0
|
103
|
+
end
|
104
|
+
objects
|
83
105
|
end
|
84
106
|
|
85
107
|
def parse_file(file, extensions = %w(.json .yaml .yml))
|
86
108
|
handler = case File.extname(file)
|
87
109
|
when ".json"
|
88
|
-
Object.const_get "
|
110
|
+
Object.const_get "JSON"
|
89
111
|
when ".yaml", ".yml"
|
90
112
|
Object.const_get "YAML"
|
91
113
|
else
|
data/lib/cloudstack-cli/cli.rb
CHANGED
@@ -68,7 +68,7 @@ module CloudstackCli
|
|
68
68
|
|
69
69
|
data = client.send_request(params)
|
70
70
|
if options[:format] == 'json'
|
71
|
-
puts options[:pretty_print] ?
|
71
|
+
puts options[:pretty_print] ? JSON.pretty_generate(data) : data.to_json
|
72
72
|
else
|
73
73
|
puts data.to_yaml
|
74
74
|
end
|
@@ -169,7 +169,7 @@ class Router < CloudstackCli::Base
|
|
169
169
|
when :yaml
|
170
170
|
puts({'routers' => routers}.to_yaml)
|
171
171
|
when :json
|
172
|
-
say
|
172
|
+
say JSON.pretty_generate({ routers: routers })
|
173
173
|
else
|
174
174
|
table = [%w(
|
175
175
|
Name Zone Account/Project IP Linklocal-IP Status Version
|
@@ -7,10 +7,10 @@ class VirtualMachine < CloudstackCli::Base
|
|
7
7
|
option :project, desc: "name of the project"
|
8
8
|
option :zone, desc: "the name of the availability zone"
|
9
9
|
option :state, desc: "state of the virtual machine"
|
10
|
-
option :listall, desc: "list all virtual machines", default: true
|
11
|
-
option :storage_id, desc: "the storage ID where vm's volumes belong to"
|
12
10
|
option :host, desc: "the name of the hypervisor host the VM belong to"
|
13
|
-
option :
|
11
|
+
option :filter, type: :hash,
|
12
|
+
desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
|
13
|
+
option :listall, desc: "list all virtual machines", default: true
|
14
14
|
option :command,
|
15
15
|
desc: "command to execute for the given virtual machines",
|
16
16
|
enum: %w(START STOP REBOOT)
|
@@ -23,9 +23,13 @@ class VirtualMachine < CloudstackCli::Base
|
|
23
23
|
resolve_project
|
24
24
|
resolve_zone
|
25
25
|
resolve_host
|
26
|
-
|
27
|
-
options
|
26
|
+
resolve_iso
|
27
|
+
if options[:command]
|
28
|
+
command = options[:command].downcase
|
29
|
+
options.delete(:command)
|
30
|
+
end
|
28
31
|
virtual_machines = client.list_virtual_machines(options)
|
32
|
+
virtual_machines = filter_objects(virtual_machines) if options[:filter]
|
29
33
|
if virtual_machines.size < 1
|
30
34
|
puts "No virtual_machines found."
|
31
35
|
else
|
@@ -267,7 +271,7 @@ class VirtualMachine < CloudstackCli::Base
|
|
267
271
|
when :yaml
|
268
272
|
puts({'virtual_machines' => virtual_machines}.to_yaml)
|
269
273
|
when :json
|
270
|
-
say
|
274
|
+
say JSON.pretty_generate({ virtual_machines: virtual_machines })
|
271
275
|
else
|
272
276
|
with_i_name = virtual_machines.first['instancename']
|
273
277
|
with_h_name = virtual_machines.first['hostname']
|
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.
|
4
|
+
version: 1.4.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: 2016-03-
|
11
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '11.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '11.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cloudstack_client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.19'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: multi_json
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.11'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.11'
|
69
55
|
description: cloudstack-cli is a CloudStack API command line client written in Ruby.
|
70
56
|
email:
|
71
57
|
- nik.wolfgramm@gmail.com
|
@@ -148,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
134
|
version: '0'
|
149
135
|
requirements: []
|
150
136
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.4.5
|
137
|
+
rubygems_version: 2.4.5
|
152
138
|
signing_key:
|
153
139
|
specification_version: 4
|
154
140
|
summary: cloudstack-cli CloudStack API client
|