cloudstack-cli 0.12.3 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0aaa064bdf46d5aa2eb58d9df7a3f1e538ad0fc
4
- data.tar.gz: 6bbd5c89739859be9cd154695dd65d24f978dfdd
3
+ metadata.gz: 59af9b18e579f5acce2144abcf2aff9db1affb2d
4
+ data.tar.gz: 49e7e5d576b28cd87ade5522a4541de96b662395
5
5
  SHA512:
6
- metadata.gz: 6dde868c6f42746e0d56295636bb05baa55fda0ea98938c375ef66b477e4bd3677f8807c115c7229f0d7eea029f624d41606db2bf8788d485c16398f55c2c122
7
- data.tar.gz: f2494582998bcf36d42fcb06d5ecf947cf5da52c095adfb899af1eac48f5b948b3e615a43dd0ae42e6f3bbb108da829ef1e5e26a6c160b2303fa1acb1edd67b1
6
+ metadata.gz: 420b6b48551919f82f1614e1f223012e8091cc80f01341fe79ad578457663c9e486acd594e5ba5d131a408e7bd45686e86600eabb480762feacce45fd7deeb0c
7
+ data.tar.gz: 04932a176b192b6f1f070abacfad2a86b91a1b6f560a898197f2d266b9b3d8e601addb0c73b9b9a049992dddc4a78bba5b42a30eb35aea7e5341782e3d02c6fc
@@ -1,15 +1,15 @@
1
1
  GIT
2
2
  remote: git@github.com:niwo/cloudstack_client.git
3
- revision: 7e6e2af2299cbb681b2fff8a065c8e91c06ea7ae
3
+ revision: 9bffcd5b7ed587973b09ced13fae52030b77ff72
4
4
  branch: master
5
5
  specs:
6
- cloudstack_client (0.8.0)
6
+ cloudstack_client (0.9.0)
7
7
 
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- cloudstack-cli (0.12.3)
12
- cloudstack_client (~> 0.8.0)
11
+ cloudstack-cli (0.13.0)
12
+ cloudstack_client (~> 0.9.0)
13
13
  thor (~> 0.19.1)
14
14
 
15
15
  GEM
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency('rake', '~> 10.4')
26
26
 
27
27
  gem.add_dependency('thor', '~> 0.19.1')
28
- gem.add_dependency('cloudstack_client', '~> 0.8.0')
28
+ gem.add_dependency('cloudstack_client', '~> 0.9.0')
29
29
  end
@@ -22,15 +22,20 @@ class Account < CloudstackCli::Base
22
22
  end
23
23
  end
24
24
 
25
- desc 'list [NAME]', 'list accounts (by name)'
26
- def list(name = nil)
27
- accounts = client.list_accounts(name: name)
25
+ desc 'list', 'list accounts'
26
+ def list
27
+ accounts = client.list_accounts
28
28
  if accounts.size < 1
29
29
  puts "No accounts found."
30
30
  else
31
- table = [["Name", "Type", "Domain"]]
31
+ table = [%w(Name Type Domain State)]
32
32
  accounts.each do |account|
33
- table << [account['name'], TYPES[account['accounttype']], account['domain']]
33
+ table << [
34
+ account['name'],
35
+ TYPES[account['accounttype']],
36
+ account['domain'],
37
+ account['state']
38
+ ]
34
39
  end
35
40
  print_table table
36
41
  say "Total number of accounts: #{accounts.size}"
@@ -36,6 +36,55 @@ class ResourceLimit < CloudstackCli::Base
36
36
  print_table table
37
37
  end
38
38
 
39
+ desc "refresh", "refresh resource counts"
40
+ option :domain, desc: "refresh resource for a specified domain"
41
+ option :account, desc: "refresh resource for a specified account"
42
+ option :project, desc: "refresh resource for a specified project"
43
+ option :type, desc: "specify type, see types for a list of types"
44
+ def refresh
45
+ set_domain_id if options[:domain]
46
+ options[:resource_type] = options[:type] if options[:type]
47
+
48
+ unless ['domain_id', 'account', 'project'].any? {|k| options.key?(k)}
49
+ say "Error: Please provide domain, account or project.", :red
50
+ exit 1
51
+ end
52
+
53
+ if resource_count = client.update_resource_count(options)
54
+ say "Sucessfully refreshed resource limits.", :green
55
+ else
56
+ say "Error refreshing resource limits.", :red
57
+ exit 1
58
+ end
59
+ end
60
+
61
+ desc "update", "update resource counts"
62
+ option :domain, desc: "update resource for a specified domain"
63
+ option :account, desc: "update resource for a specified account"
64
+ option :project, desc: "update resource for a specified project"
65
+ option :type,
66
+ desc: "specify type, see types for a list of types",
67
+ required: true
68
+ option :max,
69
+ desc: "Maximum resource limit.",
70
+ required: true
71
+ def update
72
+ set_domain_id if options[:domain]
73
+ options[:resource_type] = options[:type]
74
+
75
+ unless ['domain_id', 'account', 'project'].any? {|k| options.key?(k)}
76
+ say "Error: Please provide domain, account or project.", :red
77
+ exit 1
78
+ end
79
+
80
+ if resource_count = client.update_resource_limit(options)
81
+ say "Sucessfully updated resource limits.", :green
82
+ else
83
+ say "Error updating resource limits.", :red
84
+ exit 1
85
+ end
86
+ end
87
+
39
88
  desc "types", "show resource types"
40
89
  def types
41
90
  table = [['type', 'name']]
@@ -48,6 +97,7 @@ class ResourceLimit < CloudstackCli::Base
48
97
  no_commands do
49
98
 
50
99
  def resource_to_s(limit, entity)
100
+ return '-1 (unlimited)' if limit['max'] == -1
51
101
  value = RESOURCE_TYPES[limit['resourcetype']][:divider] ?
52
102
  (limit[entity] / RESOURCE_TYPES[limit['resourcetype']][:divider]).round(1) :
53
103
  limit[entity]
@@ -56,6 +106,15 @@ class ResourceLimit < CloudstackCli::Base
56
106
  value.to_s
57
107
  end
58
108
 
109
+ def set_domain_id
110
+ domains = client.list_domains(options[:domain])
111
+ if domains.size < 1
112
+ say "Domain #{options[:domain]} not found.", :red
113
+ else
114
+ options[:domain_id] = domains.first['id']
115
+ end
116
+ end
117
+
59
118
  end
60
119
 
61
120
  end
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "0.12.3"
2
+ VERSION = "0.13.0"
3
3
  end
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: 0.12.3
4
+ version: 0.13.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: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.8.0
61
+ version: 0.9.0
62
62
  type: :runtime
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: 0.8.0
68
+ version: 0.9.0
69
69
  description: cloudstack-cli is a CloudStack API command line client written in Ruby.
70
70
  email:
71
71
  - nik.wolfgramm@gmail.com