kakin 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: ebf422b2753f94442bbec430a675014094d0081e20420b7f7f397c21a4fd9aa4
4
- data.tar.gz: b19d006bc6c4202f00d7bf889f0149148f1b0bea636fbe07581d881a2a9c724f
3
+ metadata.gz: 3f4cbb82bf72ff7739687b18cb6a6c2d059a8d5b4630cffbd464760154e336d8
4
+ data.tar.gz: fb806dbb427e76cd69cf59350faf790633f0e6584dfb4d667a7e2b7dbf7ff91b
5
5
  SHA512:
6
- metadata.gz: cd7f094711b96910701a9eb7194640582a3c523e94eeae4f01831dca3d1fe3ca6a20a231628b17cfc6f32915154365f083fa95265bea4254fbf8c8d5bb7fd61e
7
- data.tar.gz: 36290ac5d2a916babf88bee40af0afbc03f54d16929663501104da2084af7bd4bbeb1c6234088e8f9f08e052eaf974f21cce337df53106072d3e4306887c4543
6
+ metadata.gz: 3ea58c1be161a984a54b026bd749497215920e2b7fc7ba4dd3a7427e6c168da1497be417a41df0958e5cfaf186fac64dff1af417d65bfb0cbd299b6314107975
7
+ data.tar.gz: 759198768dc66b2fb180a47d962a406505e8a36a39a7a421368e99570c75d8db5a8269358a9ad64707f058ee99fe738d08cd6b84f243a9c3562f3b7a918561bc
@@ -3,3 +3,6 @@ memory_mb_per_hour: 0.0009765625
3
3
  disk_gb_per_hour: 1
4
4
  cost_per_ip: 1
5
5
  ip_regexp: ^192.128
6
+ volume_cost_per_gb:
7
+ type_1: 1
8
+ type_2: 1.5
@@ -139,5 +139,36 @@ module Kakin
139
139
 
140
140
  puts YAML.dump(result)
141
141
  end
142
+
143
+ option :f, type: :string, banner: "<file>", desc: "cost define file(yaml)", required: true
144
+ option :t, type: :string, banner: "<tenant>", desc: "specify tenant", default: ""
145
+ desc 'volume', 'volume usage'
146
+ def volume
147
+ Kakin::Configuration.setup
148
+ yaml = YAML.load_file(options[:f])
149
+
150
+ result = Hash.new
151
+ tenants = unless options[:t].empty?
152
+ Yao::Tenant.list(name: options[:t])
153
+ else
154
+ Yao::Tenant.list
155
+ end
156
+ tenants = [tenants] unless tenants.is_a?(Array)
157
+ volume_types = Yao::VolumeType.list
158
+ volumes = Yao::Volume.list_detail(all_tenants: true)
159
+
160
+ tenants.each do |tenant|
161
+ result[tenant.name] ||= {}
162
+ volume_types.each do |volume_type|
163
+ total = volumes.select { |volume| volume.tenant_id == tenant.id && volume.volume_type == volume_type.name }.map(&:size).sum
164
+ result[tenant.name][volume_type.name] = {
165
+ 'total': total,
166
+ 'total_usage': total * yaml['volume_cost_per_gb'][volume_type.name]
167
+ }
168
+ end
169
+ end
170
+
171
+ puts YAML.dump(result)
172
+ end
142
173
  end
143
174
  end
@@ -1,3 +1,3 @@
1
1
  module Kakin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kakin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - buty4649
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-09-06 00:00:00.000000000 Z
12
+ date: 2018-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor