oneacct-export 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/one_worker.rb +8 -5
- data/lib/oneacct_exporter/version.rb +1 -1
- data/lib/oneacct_opts.rb +0 -1
- data/lib/templates/apel-0.2.erb +1 -1
- data/mock/one_worker_MEMORY_0.xml +1 -1
- data/mock/one_worker_MEMORY_missing.xml +0 -1
- data/mock/one_worker_MEMORY_nan.xml +1 -1
- data/spec/one_worker_spec.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a9aff4b9c721de7af9275953ae9b5954c38cca
|
4
|
+
data.tar.gz: 071f245ec9f4475a9c8d1be9ba4c3dad15787b86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2b407955c1258694a8c3dec4b8dc544869aa8fde701ce893c95de5f6df76b25fa0d55debb9313958d6d757ef47e66756a55bed5cdd7a5cf0aedaa1284e465b7
|
7
|
+
data.tar.gz: 80e68e3c321cfec4288709a639a28c22b1b60f939e919a716872f4b869142f255fd8fff7160596e9c771fd0340419fc05df57c118fd533fcf66f045174dbb89f
|
data/lib/one_worker.rb
CHANGED
@@ -25,7 +25,7 @@ class OneWorker
|
|
25
25
|
# Prepare data that are common for every virtual machine
|
26
26
|
def common_data
|
27
27
|
common_data = {}
|
28
|
-
common_data['endpoint'] = Settings['endpoint']
|
28
|
+
common_data['endpoint'] = Settings['endpoint'].chomp('/')
|
29
29
|
common_data['site_name'] = Settings['site_name']
|
30
30
|
common_data['cloud_type'] = Settings['cloud_type']
|
31
31
|
|
@@ -125,15 +125,14 @@ class OneWorker
|
|
125
125
|
suspend = (end_time - start_time) - data['duration'].to_i unless end_time == 0
|
126
126
|
data['suspend'] = parse(suspend.to_s, NUMBER)
|
127
127
|
|
128
|
-
|
129
|
-
data['cpu_count'] = parse(vcpu, NON_ZERO, '1')
|
128
|
+
data['cpu_count'] = parse(vm['TEMPLATE/VCPU'], NON_ZERO, '1')
|
130
129
|
|
131
130
|
net_tx = parse(vm['NET_TX'], NUMBER, 0)
|
132
131
|
data['network_inbound'] = (net_tx.to_i / B_IN_GB).round
|
133
132
|
net_rx = parse(vm['NET_RX'], NUMBER, 0)
|
134
133
|
data['network_outbound'] = (net_rx.to_i / B_IN_GB).round
|
135
134
|
|
136
|
-
data['memory'] = parse(vm['MEMORY'], NUMBER, '0')
|
135
|
+
data['memory'] = parse(vm['TEMPLATE/MEMORY'], NUMBER, '0')
|
137
136
|
|
138
137
|
data['image_name'] = parse(image_map[vm['TEMPLATE/DISK[1]/IMAGE_ID']], STRING, nil)
|
139
138
|
data['image_name'] = parse(mixin(vm), STRING) unless data['image_name']
|
@@ -168,7 +167,11 @@ class OneWorker
|
|
168
167
|
def sum_rstime(vm)
|
169
168
|
rstime = 0
|
170
169
|
vm.each 'HISTORY_RECORDS/HISTORY' do |h|
|
171
|
-
next unless h['RSTIME'] && h['RETIME'] && h['
|
170
|
+
next unless h['RSTIME'] && h['RETIME'] && h['RSTIME'] != '0'
|
171
|
+
if h['RETIME'] == '0'
|
172
|
+
rstime += Time.now.to_i - h['RSTIME'].to_i
|
173
|
+
next
|
174
|
+
end
|
172
175
|
if h['RSTIME'].to_i > h['RETIME'].to_i
|
173
176
|
logger.warn('Skipping malformed record. '\
|
174
177
|
"VM with id #{vm['ID']} has wrong CpuDuration.")
|
data/lib/oneacct_opts.rb
CHANGED
@@ -127,7 +127,6 @@ class OneacctOpts
|
|
127
127
|
Settings['output'] && Settings.output['output_dir'] && Settings.output['output_type']
|
128
128
|
fail ArgumentError, 'Missing some mandatory parameters. Check your configuration file.'
|
129
129
|
end
|
130
|
-
Settings['endpoint'].chop! if Settings['endpoint'].end_with?('/')
|
131
130
|
|
132
131
|
#make sure log file is specified while loggin to file
|
133
132
|
if Settings['logging'] && Settings.logging['log_type'] == 'file' &&
|
data/lib/templates/apel-0.2.erb
CHANGED
@@ -13,7 +13,7 @@ FQAN: NULL
|
|
13
13
|
<% end -%>
|
14
14
|
Status: <%= vm['status']%>
|
15
15
|
StartTime: <%= vm['start_time'].to_i%>
|
16
|
-
EndTime: <%= vm['end_time'].to_i%>
|
16
|
+
EndTime: <%= vm['end_time'].to_s == vm['end_time'] ? vm['end_time'] : vm['end_time'].to_i%>
|
17
17
|
SuspendDuration: <%= vm['suspend']%>
|
18
18
|
WallDuration: <%= vm['duration']%>
|
19
19
|
CpuDuration: <%= vm['duration']%>
|
data/spec/one_worker_spec.rb
CHANGED
@@ -358,6 +358,7 @@ describe OneWorker do
|
|
358
358
|
before :example do
|
359
359
|
data['cpu_count'] = '1'
|
360
360
|
data['image_name'] = 'NULL'
|
361
|
+
data['memory'] = '0'
|
361
362
|
end
|
362
363
|
|
363
364
|
let(:filename) { 'one_worker_TEMPLATE_missing.xml' }
|
@@ -606,10 +607,14 @@ describe OneWorker do
|
|
606
607
|
end
|
607
608
|
|
608
609
|
context 'vm with RETIME that is 0' do
|
610
|
+
before :example do
|
611
|
+
allow(Time).to receive(:now) { 1383741716 }
|
612
|
+
end
|
613
|
+
|
609
614
|
let(:filename) { 'one_worker_RETIME_0.xml' }
|
610
615
|
|
611
|
-
it 'returns
|
612
|
-
expect(subject.sum_rstime(vm)).to eq(
|
616
|
+
it 'returns difference between current time and start of the virtual machine' do
|
617
|
+
expect(subject.sum_rstime(vm)).to eq(42)
|
613
618
|
end
|
614
619
|
end
|
615
620
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneacct-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Kimle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|