cloudstack-cli 0.5.8 → 0.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: 1b80bad1dfc75be88c1e41485ba830238d3e6905
4
- data.tar.gz: 75a02bf7304b5a57b2eea1a1cf7d994ace7a8b62
3
+ metadata.gz: a83e808e4d6c14b9b83212dcc08626703a0955a6
4
+ data.tar.gz: 758f54540afe222f8a3e7d81b079c34cd2f40b75
5
5
  SHA512:
6
- metadata.gz: f3f1b99c24a31e4fb4cf689ebd336c61df93ffe1766a059df7f81ca0411f0d47e2f40d9fdad32155469c97f264bea9fe8e61199043667c80ffbcf8060cf42ba0
7
- data.tar.gz: 8ddceb29263913e464bb9f6b0b55b8a452a3fb9a072ff7cedcb21aa54e088779273a5f13cbfe19a97c319318be18a8000b257b35ddf4a0fe5e05d17cfcd73099
6
+ metadata.gz: b4c060f6132b9cb05a40c066eab6f59f1bb9370ef6056a629b1e3e289ac84381bfe3fe68d700a80fe7861e524e5dd60e26cd886a19539a09e1fdb63ae1420d2d
7
+ data.tar.gz: 83475400d4d05965c10a3ec8bb8636e29a31c5653149181c3a2760ec3e65d099d268f1e40fc5a0f0f7cce196d5837bf2ce0696388185fa6b626bc175cf8944ba
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- cloudstack-cli (0.5.8)
11
+ cloudstack-cli (0.6.0)
12
12
  cloudstack_client (~> 0.3, >= 0.3.6)
13
13
  thor (~> 0.18)
14
14
 
@@ -30,22 +30,24 @@ module CloudstackCli
30
30
  )
31
31
  end
32
32
 
33
- def load_configuration(config_file = options[:config_file], env = options[:environment])
33
+ def load_configuration(config_file = options[:config_file], env = options[:env])
34
34
  unless File.exists?(config_file)
35
35
  say "Configuration file #{config_file} not found.", :red
36
36
  say "Please run \'cs setup\' to create one."
37
37
  exit 1
38
38
  end
39
+
39
40
  begin
40
41
  config = YAML::load(IO.read(config_file))
41
42
  rescue
42
- error "Can't load configuration from file #{config_file}."
43
+ say "Can't load configuration from file #{config_file}.", :red
43
44
  exit 1
44
45
  end
46
+
47
+ env ||= config[:default]
45
48
  if env
46
- config = config[env]
47
- unless config
48
- error "Can't find environment #{env} in configuration file."
49
+ unless config = config[env]
50
+ say "Can't find environment #{env}.", :red
49
51
  exit 1
50
52
  end
51
53
  end
@@ -17,6 +17,7 @@ class Account < CloudstackCli::Base
17
17
  table << [account['name'], TYPES[account['accounttype']], account['domain']]
18
18
  end
19
19
  print_table table
20
+ say "Total number of accounts: #{accounts.size}"
20
21
  end
21
22
  end
22
23
 
@@ -14,6 +14,7 @@ class Cluster < CloudstackCli::Base
14
14
  ]
15
15
  end
16
16
  print_table table
17
+ say "Total number of clusters: #{clusters.size}"
17
18
  end
18
19
  end
19
20
 
@@ -17,6 +17,7 @@ class ComputeOffer < CloudstackCli::Base
17
17
  ]
18
18
  end
19
19
  print_table table
20
+ say "Total number of offerings: #{offerings.size}"
20
21
  end
21
22
  end
22
23
 
@@ -17,6 +17,7 @@ class DiskOffer < CloudstackCli::Base
17
17
  ]
18
18
  end
19
19
  print_table table
20
+ say "Total number of offerings: #{offerings.size}"
20
21
  end
21
22
  end
22
23
  end
@@ -11,6 +11,7 @@ class Domain < CloudstackCli::Base
11
11
  table << [domain['name'], domain['path']]
12
12
  end
13
13
  print_table table
14
+ say "Total number of domains: #{domains.size}"
14
15
  end
15
16
  end
16
17
 
@@ -2,11 +2,13 @@ class Environment < CloudstackCli::Base
2
2
 
3
3
  desc "list", "list cloudstack-cli environments"
4
4
  def list
5
- config = parse_configfile(options[:config_file])
6
- table = [%w(Name URL)]
7
- table << ["default", config[:url]]
5
+ config = parse_config_file
6
+ table = [%w(Name URL Default)]
7
+ table << ['-', config[:url], !config[:default]]
8
8
  config.each_key do |key|
9
- table << [key, config[key][:url]] unless key.class == Symbol
9
+ unless key.class == Symbol
10
+ table << [key, config[key][:url], key == config[:default]]
11
+ end
10
12
  end
11
13
  print_table table
12
14
  end
@@ -15,54 +17,98 @@ class Environment < CloudstackCli::Base
15
17
  option :url
16
18
  option :api_key
17
19
  option :secret_key
20
+ option :default, type: :boolean
18
21
  def add(env = options[:environment])
19
22
  config = {}
20
23
  unless options[:url]
21
- say "Add a new environment (#{env || 'default'})."
24
+ say "Add a new environment...", :green
25
+ say "Environment name: #{env}" if env
22
26
  say "What's the URL of your Cloudstack API?", :yellow
23
27
  say "Example: https://my-cloudstack-service/client/api/", :green
24
28
  config[:url] = ask("URL:", :magenta)
25
29
  end
30
+
26
31
  unless options[:api_key]
27
32
  config[:api_key] = ask("API Key:", :magenta)
28
33
  end
34
+
29
35
  unless options[:secret_key]
30
36
  config[:secret_key] = ask("Secret Key:", :magenta)
31
37
  end
38
+
32
39
  if env
33
40
  config = {env => config}
41
+ config[:default] = env if options[:default]
34
42
  end
43
+
35
44
  if File.exists? options[:config_file]
36
- old_config = parse_configfile(options[:config_file])
37
- say "Warning: #{options[:config_file]} already exists.", :red
38
- exit unless yes?("Do you want to merge your settings? [y/N]", :red)
45
+ newfile = true
46
+ old_config = parse_config_file
47
+ if !env || old_config.has_key?(env)
48
+ say "This environment already exists!", :red
49
+ exit unless yes?("Do you want to override your settings? [y/N]", :yellow)
50
+ end
39
51
  config = old_config.merge(config)
40
52
  end
41
- File.open(options[:config_file], 'w+') {|f| f.write(config.to_yaml) }
42
- say "OK, config-file written to #{options[:config_file]}.", :green
53
+
54
+ write_config_file(config)
55
+ if newfile
56
+ say "OK. Created configuration file at #{options[:config_file]}.", :green
57
+ else
58
+ say "Added environment #{env}", :green
59
+ end
43
60
  end
44
61
 
45
62
  desc "delete", "delete a Cloudstack connection"
46
- def delete(name)
47
- config = parse_configfile(options[:config_file])
48
- exit unless yes?("Do you really want delete environment #{name}? [y/N]", :red)
49
- config.delete(name)
50
- File.open(options[:config_file], 'w+') {|f| f.write(config.to_yaml) }
51
- say "OK.", :green
63
+ def delete(env)
64
+ config = parse_config_file
65
+ if config.delete(env)
66
+ exit unless yes?("Do you really want to delete environment #{env}? [y/N]", :yellow)
67
+ config.delete :default if config[:default] == env
68
+ write_config_file(config)
69
+ say "OK.", :green
70
+ else
71
+ say "Environment #{env} does not exist.", :red
72
+ end
73
+ end
74
+
75
+ desc "default ENV", "set the default environment"
76
+ def default(env)
77
+ config = parse_config_file
78
+ if env == '-'
79
+ config.delete :default
80
+ else
81
+ unless config.has_key?(env)
82
+ say "Environment #{env} does not exist.", :red
83
+ exit 1
84
+ end
85
+ config[:default] = env
86
+ end
87
+ write_config_file(config)
88
+ say "Default environment set to #{env}."
52
89
  end
53
90
 
54
91
  no_commands do
55
92
 
56
- def parse_configfile(file)
57
- if File.exists? file
93
+ def parse_config_file
94
+ if File.exists? options[:config_file]
58
95
  begin
59
- return YAML::load(IO.read(file))
96
+ return YAML::load(IO.read(options[:config_file]))
60
97
  rescue
61
- say "Error loading configuration from file #{file}.", :red
98
+ say "Error loading configuration from file #{options[:config_file]}.", :red
62
99
  exit 1
63
100
  end
64
101
  else
65
- say "Can't load configuration from file #{file}.", :red
102
+ say "Can't load configuration from file #{options[:config_file]}.", :red
103
+ exit 1
104
+ end
105
+ end
106
+
107
+ def write_config_file(config)
108
+ begin
109
+ return File.open(options[:config_file], 'w+') {|f| f.write(config.to_yaml) }
110
+ rescue
111
+ say "Can't open configuration file #{options[:config_file]} for writing.", :red
66
112
  exit 1
67
113
  end
68
114
  end
@@ -14,6 +14,7 @@ class Host < CloudstackCli::Base
14
14
  ]
15
15
  end
16
16
  print_table table
17
+ say "Total number of hosts: #{hosts.size}"
17
18
  end
18
19
  end
19
20
 
@@ -32,6 +32,7 @@ class IpAddress < CloudstackCli::Base
32
32
  table << [address["ipaddress"], address["account"], address["zonename"]]
33
33
  end
34
34
  print_table table
35
+ say "Total number of addresses: #{addresses.size}"
35
36
  end
36
37
  end
37
38
 
@@ -25,6 +25,7 @@ class Iso < CloudstackCli::Base
25
25
  table << [iso['name'], iso['zonename'], iso['bootable']]
26
26
  end
27
27
  print_table(table)
28
+ say "Total number of isos: #{isos.size}"
28
29
  end
29
30
  end
30
31
 
@@ -15,6 +15,7 @@ class LoadBalancer < CloudstackCli::Base
15
15
  table << [rule['name'], rule['publicip'], rule['publicport']]
16
16
  end
17
17
  print_table table
18
+ say "Total number of rules: #{rules.count}"
18
19
  end
19
20
  end
20
21
 
@@ -51,6 +51,7 @@ class Network < CloudstackCli::Base
51
51
  table[-1] << network["vlan"] if options[:showvlan]
52
52
  end
53
53
  print_table table
54
+ say "Total number of networks: #{networks.count}"
54
55
  end
55
56
  end
56
57
 
@@ -19,6 +19,7 @@ class PhysicalNetwork < CloudstackCli::Base
19
19
  ]
20
20
  end
21
21
  print_table table
22
+ say "Total number of networks: #{networks.count}"
22
23
  end
23
24
  end
24
25
 
@@ -14,6 +14,7 @@ class Pod < CloudstackCli::Base
14
14
  ]
15
15
  end
16
16
  print_table table
17
+ say "Total number of pods: #{pods.count}"
17
18
  end
18
19
  end
19
20
 
@@ -55,6 +55,7 @@ class PortRule < CloudstackCli::Base
55
55
  ]
56
56
  end
57
57
  print_table table
58
+ say "Total number of rules: #{rules.count}"
58
59
  end
59
60
  end
60
61
 
@@ -24,6 +24,7 @@ class Project < CloudstackCli::Base
24
24
  table << [project['name'], project['displaytext'], project['domain']]
25
25
  end
26
26
  print_table(table)
27
+ say "Total number of projects: #{projects.count}"
27
28
  end
28
29
  end
29
30
 
@@ -161,7 +161,7 @@ class Router < CloudstackCli::Base
161
161
  end
162
162
  print_table table
163
163
  puts
164
- say "Number of routers: #{routers.size}"
164
+ say "Total number of routers: #{routers.size}"
165
165
  end
166
166
  end
167
167
  end
@@ -18,6 +18,7 @@ class Snapshot < CloudstackCli::Base
18
18
  ]
19
19
  end
20
20
  print_table table
21
+ say "Total number of snapshots: #{snapshots.size}"
21
22
  end
22
23
  end
23
24
 
@@ -16,13 +16,14 @@ class Template < CloudstackCli::Base
16
16
  zone_id: zone ? zone['id'] : nil
17
17
  )
18
18
  if templates.size < 1
19
- puts "No templates found"
19
+ puts "No templates found."
20
20
  else
21
21
  table = [["Name", "Zone", "Format"]]
22
22
  templates.each do |template|
23
23
  table << [template['name'], template['zonename'], template['format']]
24
24
  end
25
25
  print_table(table)
26
+ say "Total number of templates: #{templates.size}"
26
27
  end
27
28
  end
28
29
 
@@ -22,6 +22,7 @@ class User < CloudstackCli::Base
22
22
  ]
23
23
  end
24
24
  print_table table
25
+ say "Total number of users: #{users.size}"
25
26
  end
26
27
  end
27
28
 
@@ -23,6 +23,7 @@ class Volume < CloudstackCli::Base
23
23
  ]
24
24
  end
25
25
  print_table(table)
26
+ say "Total number of volumes: #{volumes.size}"
26
27
  end
27
28
  end
28
29
 
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "0.5.8"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm
@@ -14,62 +14,62 @@ dependencies:
14
14
  name: rdoc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.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
26
  version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.18'
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
54
  version: '0.18'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cloudstack_client
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.3'
62
- - - '>='
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: 0.3.6
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ~>
69
+ - - "~>"
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0.3'
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 0.3.6
75
75
  description: cloudstack-cli is a CloudStack API client written in Ruby.
@@ -80,7 +80,7 @@ executables:
80
80
  extensions: []
81
81
  extra_rdoc_files: []
82
82
  files:
83
- - .gitignore
83
+ - ".gitignore"
84
84
  - Gemfile
85
85
  - Gemfile.lock
86
86
  - LICENSE.txt
@@ -125,23 +125,23 @@ licenses:
125
125
  metadata: {}
126
126
  post_install_message:
127
127
  rdoc_options:
128
- - --line-numbers
129
- - --inline-source
128
+ - "--line-numbers"
129
+ - "--inline-source"
130
130
  require_paths:
131
131
  - lib
132
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - '>='
134
+ - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: 1.9.3
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - '>='
139
+ - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.0.3
144
+ rubygems_version: 2.2.0
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: cloudstack-cli CloudStack API client