cloudstack-cli 1.5.13 → 1.6.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: 3a77b3508e84ccc8f0ad9b92ff84fe5e10b9bb83
4
- data.tar.gz: 834996a13819ef70aab36bc65847cd2e1bb9ca6e
3
+ metadata.gz: 0301d4bcecdf17de018258aff0d4640feb06df0b
4
+ data.tar.gz: 6fdc68888e0e3b8bc6fef745b577031aaf633a2c
5
5
  SHA512:
6
- metadata.gz: a0083726e513a42e1502684789684dbc1db227e6fc0c5eec3210d64c3f7a494bcc8f67cd35586fd00c69e83b9c08358594ef9875fd328b499ed209ccc375bb48
7
- data.tar.gz: e767d1a9e01e929cc88f7d3484a1eb80c78c501a9d2eed36d51fd16437ada39fa98e1656972c3e180b7214f5a3cac3d399cfa271731dbd7c6fce1d4b3c940e5d
6
+ metadata.gz: 4ebfda74fea9fd907d7ff9f14225f8060e12679a137a46343d0752c122bd3be21a670c26e40f82a1cdfe3c6341e6e931e1dc9ae33fc51913119bd054a4c83bf5
7
+ data.tar.gz: d31110292fd60b72618aaa1d445fb87cf4ddb25ef8a072b615a58de14d62729fb73f92c766c2a47b00e48db270e67a5cb02bfd5d9319343a2f7ad77c8229a3a0
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: ../cloudstack_client/
3
3
  specs:
4
- cloudstack_client (1.4.3)
4
+ cloudstack_client (1.5.3)
5
5
 
6
6
  PATH
7
7
  remote: .
8
8
  specs:
9
- cloudstack-cli (1.5.12)
10
- cloudstack_client (~> 1.4.3)
9
+ cloudstack-cli (1.6.0)
10
+ cloudstack_client (~> 1.5.3)
11
11
  thor (~> 0.19.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- minitest (5.10.1)
16
+ minitest (5.10.2)
17
17
  rake (12.0.0)
18
18
  thor (0.19.4)
19
19
 
data/README.md CHANGED
@@ -17,7 +17,8 @@ $ gem install cloudstack-cli
17
17
 
18
18
  ### Create a cloudstack-cli environment
19
19
 
20
- cloudstack-cli expects to find a configuration file with the API URL and your CloudStack credentials in your home directory named .cloudstack-cli.yml. If the file is located elsewhere you can specify the location using the --config option.
20
+ cloudstack-cli expects to find a configuration file with the API URL and your CloudStack credentials in your home directory named .cloudstack.yml (or .cloudstack-cli.yml).
21
+ If the file is located elsewhere you can specify the location using the --config-file option.
21
22
 
22
23
  *Create your initial environment, which defines your connection options:*
23
24
 
@@ -48,17 +49,23 @@ $ cloudstack-cli environment default [environment-name]
48
49
 
49
50
  see `cloudstack-cli help environment` for more options.
50
51
 
51
- Example content of the configuration file:
52
+ Example configuration file:
52
53
 
53
54
  ```yaml
54
- :url: "https://my-cloudstack-server/client/api/"
55
- :api_key: "cloudstack-api-key"
56
- :secret_key: "cloudstack-api-secret"
55
+ # default environment
56
+ :default: production
57
57
 
58
+ # production environment
59
+ production:
60
+ :url: "https://my-cloudstack-server/client/api/"
61
+ :api_key: "cloudstack-api-key"
62
+ :secret_key: "cloudstack-api-secret"
63
+
64
+ # test environment
58
65
  test:
59
- :url: "http://my-cloudstack-testserver/client/api/"
60
- :api_key: "cloudstack-api-key"
61
- :secret_key: "cloudstack-api-secret"
66
+ :url: "http://my-cloudstack-testserver/client/api/"
67
+ :api_key: "cloudstack-api-key"
68
+ :secret_key: "cloudstack-api-secret"
62
69
  ```
63
70
 
64
71
  ### Shell tab auto-completion
@@ -24,6 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency('rake', '~> 12.0')
25
25
  gem.add_development_dependency('minitest', '~> 5.9')
26
26
 
27
- gem.add_dependency('cloudstack_client', '~> 1.4.3')
27
+ gem.add_dependency('cloudstack_client', '~> 1.5.3')
28
28
  gem.add_dependency('thor', '~> 0.19.4')
29
29
  end
@@ -1,4 +1,5 @@
1
1
  require "cloudstack_client"
2
+ require "cloudstack_client/configuration"
2
3
 
3
4
  require "cloudstack-cli/version"
4
5
  require "cloudstack-cli/helper"
@@ -49,34 +49,12 @@ module CloudstackCli
49
49
  @client
50
50
  end
51
51
 
52
- def load_configuration(config_file = options[:config_file], env = options[:env])
53
- unless File.exists?(config_file)
54
- say "Configuration file #{config_file} not found.", :red
55
- say "Please run \'cs environment add\' to create one."
56
- exit 1
57
- end
58
-
59
- begin
60
- config = YAML::load(IO.read(config_file))
61
- rescue
62
- say "Can't load configuration from file #{config_file}.", :red
63
- exit 1
64
- end
65
-
66
- env ||= config[:default]
67
- if env
68
- unless config = config[env]
69
- say "Can't find environment #{env}.", :red
70
- exit 1
71
- end
72
- end
73
-
74
- unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
75
- say "The environment #{env || '\'-\''} does not contain all required keys.", :red
76
- say "Please check with 'cloudstack-cli environment list' and set a valid default environment."
77
- exit 1
78
- end
79
- config
52
+ def load_configuration
53
+ CloudstackClient::Configuration.load(options)
54
+ rescue CloudstackClient::ConfigurationError => e
55
+ say "Error: ", :red
56
+ say e.message
57
+ exit 1
80
58
  end
81
59
 
82
60
  def filter_by(objects, key, value)
@@ -91,7 +69,8 @@ module CloudstackCli
91
69
  object[key.to_s].to_s =~ /#{value}/i
92
70
  end
93
71
  rescue RegexpError => e
94
- say "ERROR: Invalid regular expression in filter - #{e.message}", :red
72
+ say "ERROR: ", :red
73
+ say "Invalid regular expression in filter - #{e.message}"
95
74
  exit 1
96
75
  end
97
76
 
@@ -119,21 +98,23 @@ module CloudstackCli
119
98
  when ".yaml", ".yml"
120
99
  Object.const_get "YAML"
121
100
  else
122
- say "File extension #{File.extname(file)} not supported. Supported extensions are #{extensions.join(', ')}", :red
101
+ say "ERROR: ", :red
102
+ say "File extension #{File.extname(file)} not supported. Supported extensions are #{extensions.join(', ')}"
123
103
  exit
124
104
  end
125
105
  begin
126
106
  return handler.load open(file){|f| f.read}
127
107
  rescue SystemCallError
128
- say "Can't find the file #{file}.", :red
108
+ say "ERROR: ", :red
109
+ say "Can't find the file '#{file}'."
129
110
  exit 1
130
111
  rescue => e
131
- say "Error parsing #{File.extname(file)} file:", :red
132
- say e.message
112
+ say "ERROR: ", :red
113
+ say "Can't parse file '#{file}': #{e.message}"
133
114
  exit 1
134
115
  end
135
116
  end
136
117
  end
137
-
118
+
138
119
  end # class
139
120
  end # module
@@ -5,9 +5,9 @@ module CloudstackCli
5
5
  package_name "cloudstack-cli"
6
6
 
7
7
  class_option :config_file,
8
- default: File.join(Dir.home, '.cloudstack-cli.yml'),
8
+ default: CloudstackClient::Configuration.locate_config_file,
9
9
  aliases: '-c',
10
- desc: 'Location of your cloudstack-cli configuration file'
10
+ desc: 'Location of your cloudstack configuration file'
11
11
 
12
12
  class_option :env,
13
13
  aliases: '-e',
@@ -17,11 +17,14 @@ class User < CloudstackCli::Base
17
17
  when :json
18
18
  puts JSON.pretty_generate(users: users)
19
19
  else
20
- table = [["Account", "Type", "Name", "Email", "State", "Domain"]]
20
+ table = [%w(Account Type Name Username Email State Domain)]
21
21
  users.each do |user|
22
22
  table << [
23
- user['account'], Account::TYPES[user['accounttype']], "#{user['firstname']} #{user['lastname']}",
24
- user['email'], user['state'], user['domain']
23
+ user['account'],
24
+ Account::TYPES[user['accounttype']],
25
+ "#{user['firstname']} #{user['lastname']}",
26
+ user['username'], user['email'],
27
+ user['state'], user['domain']
25
28
  ]
26
29
  end
27
30
  print_table table
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "1.5.13"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -1,4 +1,3 @@
1
- ---
2
1
  :default: development
3
2
  development:
4
3
  :url: http://127.0.0.1:8080/client/api
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ require "minitest/autorun"
5
5
  require "minitest/pride"
6
6
 
7
7
  # make the config file setup awailable to all specs
8
- CONFIG = "--config-file=#{File.expand_path('cloudstack-cli.yml', File.dirname(__FILE__))}"
8
+ CONFIG = "--config-file=#{File.expand_path('cloudstack.yml', File.dirname(__FILE__))}"
9
9
  ZONE = "Sandbox-simulator"
10
10
  TEMPLATE = "CentOS 5.3(64-bit) no GUI (Simulator)"
11
11
  OFFERING_S = "Small Instance"
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.5.13
4
+ version: 1.6.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: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.4.3
47
+ version: 1.5.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.4.3
54
+ version: 1.5.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -128,8 +128,8 @@ files:
128
128
  - lib/cloudstack-cli/option_resolver.rb
129
129
  - lib/cloudstack-cli/thor_patch.rb
130
130
  - lib/cloudstack-cli/version.rb
131
- - spec/cloudstack-cli.yml
132
131
  - spec/cloudstack-cli/commands/virtual_machine_spec.rb
132
+ - spec/cloudstack.yml
133
133
  - spec/fixtures/stack.yml
134
134
  - spec/spec_helper.rb
135
135
  homepage: http://github.com/niwo/cloudstack-cli
@@ -159,7 +159,7 @@ signing_key:
159
159
  specification_version: 4
160
160
  summary: cloudstack-cli CloudStack API client
161
161
  test_files:
162
- - spec/cloudstack-cli.yml
163
162
  - spec/cloudstack-cli/commands/virtual_machine_spec.rb
163
+ - spec/cloudstack.yml
164
164
  - spec/fixtures/stack.yml
165
165
  - spec/spec_helper.rb