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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f3c538f8440a61bb9d37b9e046b8c0d0350de5e
4
- data.tar.gz: 6032e05b202d5fd0623911d4bd49389e4dc489e2
3
+ metadata.gz: a2a9aff4b9c721de7af9275953ae9b5954c38cca
4
+ data.tar.gz: 071f245ec9f4475a9c8d1be9ba4c3dad15787b86
5
5
  SHA512:
6
- metadata.gz: b451ef989eaadb314cf04d9e2ad49f984d12eb3c852b6981ff9561ba2fa367e98507b5a480f642dcb60b6d1551b48d47eadcda26305fe3ee8526a652974980f6
7
- data.tar.gz: 158799a83a2114d5cfb27468119cbf73540d947ac715c3cd1b650507410f03a8631297e3496032eb600edc5126361475d34d8193d5386d707a3116c469d57eef
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
- vcpu = vm['TEMPLATE/VCPU']
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['RETIME'] != '0' && h['RSTIME'] != '0'
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.")
@@ -1,3 +1,3 @@
1
1
  class OneacctExporter
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
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' &&
@@ -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']%>
@@ -62,7 +62,7 @@
62
62
  <FEATURES>
63
63
  <ACPI><![CDATA[no]]></ACPI>
64
64
  </FEATURES>
65
- <MEMORY><![CDATA[1024]]></MEMORY>
65
+ <MEMORY><![CDATA[0]]></MEMORY>
66
66
  <NAME><![CDATA[one-36551]]></NAME>
67
67
  <NIC>
68
68
  <BRIDGE><![CDATA[xenbr0]]></BRIDGE>
@@ -61,7 +61,6 @@
61
61
  <FEATURES>
62
62
  <ACPI><![CDATA[no]]></ACPI>
63
63
  </FEATURES>
64
- <MEMORY><![CDATA[1024]]></MEMORY>
65
64
  <NAME><![CDATA[one-36551]]></NAME>
66
65
  <NIC>
67
66
  <BRIDGE><![CDATA[xenbr0]]></BRIDGE>
@@ -62,7 +62,7 @@
62
62
  <FEATURES>
63
63
  <ACPI><![CDATA[no]]></ACPI>
64
64
  </FEATURES>
65
- <MEMORY><![CDATA[1024]]></MEMORY>
65
+ <MEMORY><![CDATA[not_a_number]]></MEMORY>
66
66
  <NAME><![CDATA[one-36551]]></NAME>
67
67
  <NIC>
68
68
  <BRIDGE><![CDATA[xenbr0]]></BRIDGE>
@@ -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 0' do
612
- expect(subject.sum_rstime(vm)).to eq(0)
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.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-21 00:00:00.000000000 Z
11
+ date: 2014-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler