cloudstack_client 1.4.3 → 1.5.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: 08aaf88aa708acd6d7eae2254c90a1ff922c48db
4
- data.tar.gz: bb82a1ee284c5e84f0d4c7ccde73191a00f0f9f5
3
+ metadata.gz: f1821ae743081017bcc2364d49c2143aa32232fe
4
+ data.tar.gz: fc7ecb150733a64483c8b140c17d0193c562e5d2
5
5
  SHA512:
6
- metadata.gz: 6196310487a1c9ca57b291dff4c5d948a5c611635a8e296f33c4b548684edeac584f37be378b7443ade41fa08481498b235c59ed82b8607afe8b50a59bd410c4
7
- data.tar.gz: dda2ccd1fcf7532cbbf32d879f842f106faf5b6b8d31e61ec10873c72e8022c541d2f2edc3b87ba4639241717480290b275bdabf79f9fb05669ed5bce9121b4b
6
+ metadata.gz: 771a583ce86206fbce47659de1c78cacab3a3512340fa603d8ce3291cf1b685502e2075d7adf2df76bfdccd5b9318ee0a7cd7809c19ad88d9c9db32e5cc5a6a3
7
+ data.tar.gz: 779249793d7cfc062b72b767f69c0f26ed7ebae87d18287ef629e1c836c3b4888e202ebe32554305513d98bb1cbda1108fbaa2d0f193c4f2a5298f5af31c7d30
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudstack_client (1.4.3)
4
+ cloudstack_client (1.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  bond (0.5.1)
10
- minitest (5.8.4)
11
- rake (11.1.2)
10
+ minitest (5.10.1)
11
+ rake (12.0.0)
12
12
  ripl (0.7.1)
13
13
  bond (~> 0.5.1)
14
- thor (0.19.1)
14
+ thor (0.19.4)
15
15
 
16
16
  PLATFORMS
17
17
  ruby
18
18
 
19
19
  DEPENDENCIES
20
20
  cloudstack_client!
21
- minitest (~> 5.8)
22
- rake (~> 11.1)
21
+ minitest (~> 5.9)
22
+ rake (~> 12.0)
23
23
  ripl (~> 0.7)
24
24
  thor (~> 0.19)
25
25
 
26
26
  BUNDLED WITH
27
- 1.12.0
27
+ 1.13.7
data/README.md CHANGED
@@ -92,7 +92,7 @@ $ gzip data/4.5.json
92
92
  ```
93
93
 
94
94
  ## References
95
- - [Apache CloudStack API documentation](http://cloudstack.apache.org/docs/api/)
95
+ - [Apache CloudStack API documentation](http://cloudstack.apache.org/docs/api/)
96
96
 
97
97
  ## Contributing
98
98
 
@@ -104,6 +104,6 @@ $ gzip data/4.5.json
104
104
 
105
105
  ## License
106
106
 
107
- Copyright (c) 2014-2016, Nik Wolfgramm
107
+ Copyright (c) 2014-2017, Nik Wolfgramm
108
108
 
109
109
  Released under the MIT License. See the [LICENSE](https://raw.github.com/niwo/cloudstack_client/master/LICENSE.txt) file for further details.
@@ -20,8 +20,8 @@ Gem::Specification.new do |gem|
20
20
  gem.require_paths = ["lib"]
21
21
  gem.rdoc_options = %w[--line-numbers --inline-source]
22
22
 
23
- gem.add_development_dependency('rake', '~> 11.1')
23
+ gem.add_development_dependency('rake', '~> 12.0')
24
24
  gem.add_development_dependency('thor', '~> 0.19')
25
25
  gem.add_development_dependency('ripl', '~> 0.7')
26
- gem.add_development_dependency('minitest', '~> 5.8')
26
+ gem.add_development_dependency('minitest', '~> 5.9')
27
27
  end
@@ -1,4 +1,5 @@
1
1
  require "cloudstack_client/client"
2
+ require "cloudstack_client/configuration"
2
3
  require "yaml"
3
4
  require "json"
4
5
 
@@ -98,14 +99,13 @@ module CloudstackClient
98
99
  puts " try: list_virtual_machines state: \"running\""
99
100
 
100
101
  ARGV.clear
101
- env = options[:env] ? options[:env] : load_configuration.last
102
- Ripl.config[:prompt] = "#{env} >> "
102
+ Ripl.config[:prompt] = "#{@config[:environment]} >> "
103
103
  Ripl.start binding: cs_client.instance_eval{ binding }
104
104
  end
105
105
 
106
106
  no_commands do
107
107
  def client(opts = {})
108
- @config ||= load_configuration.first
108
+ @config ||= CloudstackClient::Configuration.load(options)
109
109
  @client ||= CloudstackClient::Client.new(
110
110
  @config[:url],
111
111
  @config[:api_key],
@@ -113,35 +113,6 @@ module CloudstackClient
113
113
  opts
114
114
  )
115
115
  end
116
-
117
- def load_configuration(config_file = options[:config_file], env = options[:env])
118
- unless File.exists?(config_file)
119
- say "Configuration file #{config_file} not found.", :red
120
- say "Please run 'cloudstack-cli environment add' to create one."
121
- exit 1
122
- end
123
-
124
- begin
125
- config = YAML::load(IO.read(config_file))
126
- rescue
127
- say "Can't load configuration from file #{config_file}.", :red
128
- exit 1
129
- end
130
-
131
- if env ||= config[:default]
132
- unless config = config[env]
133
- say "Can't find environment #{env}.", :red
134
- exit 1
135
- end
136
- end
137
-
138
- unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
139
- say "The environment #{env || '\'-\''} does not contain all required keys.", :red
140
- exit 1
141
- end
142
- return config, env
143
- end
144
-
145
116
  end # no_commands
146
117
 
147
118
  end # class
@@ -0,0 +1,33 @@
1
+ module CloudstackClient
2
+ require "yaml"
3
+
4
+ module Configuration
5
+ def self.load(configuration)
6
+ unless File.exists?(configuration[:config_file])
7
+ message = "Configuration file '#{configuration[:config_file]}' not found."
8
+ raise message
9
+ end
10
+ begin
11
+ config = YAML::load(IO.read(configuration[:config_file]))
12
+ rescue => e
13
+ message = "Can't load configuration from file '#{configuration[:config_file]}'."
14
+ message += "Message: #{e.message}" if configuration[:debug]
15
+ message += "Backtrace:\n\t#{e.backtrace.join("\n\t")}" if configuration[:debug]
16
+ raise message
17
+ end
18
+
19
+ env ||= config[:default]
20
+ if env
21
+ unless config = config[env]
22
+ raise "Can't find environment #{env}."
23
+ end
24
+ end
25
+
26
+ unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
27
+ message = "The environment #{env || '\'-\''} does not contain all required keys."
28
+ raise message
29
+ end
30
+ config.merge(environment: env)
31
+ end
32
+ end
33
+ end
@@ -3,7 +3,6 @@ require "openssl"
3
3
  require "uri"
4
4
  require "cgi"
5
5
  require "net/http"
6
- require "net/https"
7
6
  require "json"
8
7
 
9
8
  module CloudstackClient
@@ -1,3 +1,3 @@
1
1
  module CloudstackClient
2
- VERSION = "1.4.3"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -0,0 +1,29 @@
1
+ require "test_helper"
2
+ require "cloudstack_client/configuration"
3
+
4
+ describe CloudstackClient::Configuration do
5
+
6
+ before do
7
+ @config1 = CloudstackClient::Configuration.load({
8
+ config_file: "#{File.expand_path File.dirname(__FILE__)}/data/cloudstack-cli-1.yml",
9
+ debug: true
10
+ })
11
+ @config2 = CloudstackClient::Configuration.load({
12
+ config_file: "#{File.expand_path File.dirname(__FILE__)}/data/cloudstack-cli-2.yml",
13
+ debug: true
14
+ })
15
+ end
16
+
17
+ describe "when the configuration is loaded without env" do
18
+ it "must use the default env'" do
19
+ @config1[:environment].must_equal "test1"
20
+ end
21
+ end
22
+
23
+ describe "when only one env is present" do
24
+ it "must use the one existing configuration'" do
25
+ @config2[:api_key].must_equal "test-test-test-test-test-test-test-test-test-test-test-test-test-test-test-test-test"
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,10 @@
1
+ ---
2
+ :default: test1
3
+ test1:
4
+ :url: https://cloud.swisstxt.ch/client/api/
5
+ :api_key: test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1
6
+ :secret_key: test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1
7
+ test2:
8
+ :url: http://testcloud.stxt.media.int/client/api
9
+ :api_key: test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2
10
+ :secret_key: test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2
@@ -0,0 +1,4 @@
1
+ ---
2
+ :url: https://cloud.swisstxt.ch/client/api
3
+ :api_key: test-test-test-test-test-test-test-test-test-test-test-test-test-test-test-test-test
4
+ :secret_key: test-test-test-test-test-test-test-test-test-test-test-test-test-test-test-test-test
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.3
4
+ version: 1.5.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-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '11.1'
19
+ version: '12.0'
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: '11.1'
26
+ version: '12.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.8'
61
+ version: '5.9'
62
62
  type: :development
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: '5.8'
68
+ version: '5.9'
69
69
  description: CloudStack API client written in Ruby
70
70
  email:
71
71
  - nik.wolfgramm@gmail.com
@@ -88,6 +88,7 @@ files:
88
88
  - lib/cloudstack_client/api.rb
89
89
  - lib/cloudstack_client/cli.rb
90
90
  - lib/cloudstack_client/client.rb
91
+ - lib/cloudstack_client/configuration.rb
91
92
  - lib/cloudstack_client/connection.rb
92
93
  - lib/cloudstack_client/error.rb
93
94
  - lib/cloudstack_client/utils.rb
@@ -95,8 +96,11 @@ files:
95
96
  - test/api_test.rb
96
97
  - test/benchmark.rb
97
98
  - test/client_test.rb
99
+ - test/configuration_test.rb
98
100
  - test/data/0.42.json
99
101
  - test/data/0.42.json.gz
102
+ - test/data/cloudstack-cli-1.yml
103
+ - test/data/cloudstack-cli-2.yml
100
104
  - test/test_helper.rb
101
105
  homepage: https://github.com/niwo/cloudstack_client
102
106
  licenses:
@@ -120,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
124
  version: '0'
121
125
  requirements: []
122
126
  rubyforge_project:
123
- rubygems_version: 2.4.5
127
+ rubygems_version: 2.5.2
124
128
  signing_key:
125
129
  specification_version: 4
126
130
  summary: CloudStack API client written in Ruby
@@ -128,6 +132,9 @@ test_files:
128
132
  - test/api_test.rb
129
133
  - test/benchmark.rb
130
134
  - test/client_test.rb
135
+ - test/configuration_test.rb
131
136
  - test/data/0.42.json
132
137
  - test/data/0.42.json.gz
138
+ - test/data/cloudstack-cli-1.yml
139
+ - test/data/cloudstack-cli-2.yml
133
140
  - test/test_helper.rb