cloudstack_client 1.4.0 → 1.4.1
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 +1 -1
- data/README.md +2 -2
- data/Rakefile +1 -0
- data/lib/cloudstack_client/cli.rb +14 -1
- data/lib/cloudstack_client/connection.rb +15 -3
- data/lib/cloudstack_client/error.rb +1 -0
- data/lib/cloudstack_client/utils.rb +3 -3
- data/lib/cloudstack_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fff1252133afca0d217d2dba42a9ef41f9d0124
|
4
|
+
data.tar.gz: 8004e1b1557234b62fde004cbd1461f7fc42f4fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b12dc68ad181f9b03338814820d2951779ff5fe994db00ebc63128bd8bdc22c90a93e562297cc713fbea477458e144f5ff471bcac9f4e55bcad2f43ab6b9546
|
7
|
+
data.tar.gz: 0379fd6f4294c0d93cfa500f56fd4133e1b1448046c0ebf20b7c20d85f87e7cae39aa5d407411ad85eec97a5645478d7dabad1e74f79959d96943cdef39f4970
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,7 +31,7 @@ require "cloudstack_client"
|
|
31
31
|
cs = CloudstackClient::Client.new(
|
32
32
|
"https://cloudstack.local/client/api",
|
33
33
|
"API_KEY",
|
34
|
-
"
|
34
|
+
"SECRET_KEY"
|
35
35
|
)
|
36
36
|
|
37
37
|
cs.list_virtual_machines(state: "running").each do |server|
|
@@ -47,7 +47,7 @@ end
|
|
47
47
|
cs = CloudstackClient::Client.new(
|
48
48
|
"https://cloudstack.local/client/api",
|
49
49
|
"API_KEY",
|
50
|
-
"
|
50
|
+
"SECRET_KEY",
|
51
51
|
{
|
52
52
|
api_path: "~/cloudstack",
|
53
53
|
api_version: "4.6"
|
data/Rakefile
CHANGED
@@ -34,6 +34,19 @@ module CloudstackClient
|
|
34
34
|
desc: 'enable debug output',
|
35
35
|
type: :boolean
|
36
36
|
|
37
|
+
# rescue error globally
|
38
|
+
def self.start(given_args=ARGV, config={})
|
39
|
+
super
|
40
|
+
rescue => e
|
41
|
+
error_class = e.class.name.split('::')
|
42
|
+
if error_class.size == 2 && error_class.first == "CloudstackClient"
|
43
|
+
puts "\e[31mERROR\e[0m: #{error_class.last} - #{e.message}"
|
44
|
+
puts e.backtrace if ARGV.include? "--debug"
|
45
|
+
else
|
46
|
+
raise
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
37
50
|
desc "version", "Print cloudstack_client version number"
|
38
51
|
def version
|
39
52
|
say "cloudstack_client version #{CloudstackClient::VERSION}"
|
@@ -123,7 +136,7 @@ module CloudstackClient
|
|
123
136
|
end
|
124
137
|
|
125
138
|
unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
|
126
|
-
say "The environment #{env || '\'-\''}
|
139
|
+
say "The environment #{env || '\'-\''} does not contain all required keys.", :red
|
127
140
|
exit 1
|
128
141
|
end
|
129
142
|
return config, env
|
@@ -13,15 +13,19 @@ module CloudstackClient
|
|
13
13
|
attr_accessor :api_url, :api_key, :secret_key, :verbose, :debug
|
14
14
|
attr_accessor :async_poll_interval, :async_timeout
|
15
15
|
|
16
|
+
DEF_POLL_INTERVAL = 2.0
|
17
|
+
DEF_ASYNC_TIMEOUT = 400
|
18
|
+
|
16
19
|
def initialize(api_url, api_key, secret_key, options = {})
|
17
20
|
@api_url = api_url
|
18
21
|
@api_key = api_key
|
19
22
|
@secret_key = secret_key
|
20
23
|
@verbose = options[:quiet] ? false : true
|
21
24
|
@debug = options[:debug] ? true : false
|
22
|
-
@async_poll_interval = options[:async_poll_interval] ||
|
23
|
-
@async_timeout = options[:async_timeout] ||
|
25
|
+
@async_poll_interval = options[:async_poll_interval] || DEF_POLL_INTERVAL
|
26
|
+
@async_timeout = options[:async_timeout] || DEF_ASYNC_TIMEOUT
|
24
27
|
@options = options
|
28
|
+
validate_input!
|
25
29
|
end
|
26
30
|
|
27
31
|
##
|
@@ -127,12 +131,20 @@ module CloudstackClient
|
|
127
131
|
|
128
132
|
private
|
129
133
|
|
134
|
+
def validate_input!
|
135
|
+
raise InputError, "API URL not set." if @api_url == nil
|
136
|
+
raise InputError, "API KEY not set." if @api_key == nil
|
137
|
+
raise InputError, "API SECRET KEY not set." if @secret_key == nil
|
138
|
+
raise InputError, "ASYNC POLL INTERVAL must be at least 1." if @async_poll_interval < 1.0
|
139
|
+
raise InputError, "ASYNC TIMEOUT must be at least 60." if @async_timeout < 60
|
140
|
+
end
|
141
|
+
|
130
142
|
def max_tries
|
131
143
|
(@async_timeout / @async_poll_interval).round
|
132
144
|
end
|
133
145
|
|
134
146
|
def escape(input)
|
135
|
-
CGI.escape(input.to_s).gsub('+', '%20').gsub(' ','%20')
|
147
|
+
CGI.escape(input.to_s).gsub('+', '%20').gsub(' ', '%20')
|
136
148
|
end
|
137
149
|
|
138
150
|
end
|
@@ -17,11 +17,11 @@ module CloudstackClient
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def print_debug_output(output,
|
20
|
+
def print_debug_output(output, separator = '-' * 80)
|
21
21
|
puts
|
22
|
-
puts
|
22
|
+
puts separator
|
23
23
|
puts output
|
24
|
-
puts
|
24
|
+
puts separator
|
25
25
|
puts
|
26
26
|
end
|
27
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
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-04-
|
11
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|