oneacct-export 0.4.2 → 0.4.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: cbb6f93cdabe253f898feaff7aa924dc5bbbffa7
4
- data.tar.gz: 57bb740a6f19b3656a1c06c420d6ea3810535ba5
3
+ metadata.gz: 3d05de90f6c075741a02dee7cc02b1ec10633935
4
+ data.tar.gz: 232870fe469a478ac67710257be3768da938806d
5
5
  SHA512:
6
- metadata.gz: 5eb5405b239359b3bda92ea4a895bd8eb5cb409e273918a9ea8a437579164b9877e4d8d80cab34f60dd71649b71a724e7c6f54853abea5cddf825d2aaddf51ab
7
- data.tar.gz: 0863fe3000a3d01131846d3d128d62e6977e39775e887a2fe25c5694c356803de5184d7ba0d8a169cab74cd30d16c51b55c876a0b5d9cccea33256b1d30e0b09
6
+ metadata.gz: 930ffdb5223cd34c6b0b26929d2be5d321602dad5555cafa73d633611caf7b5874f8f991b0298d129ec869404c14a75b3b7e7752923168755285cd9746f74986
7
+ data.tar.gz: 4e17fba48c83dbbf1bcb6c6ffe40b6eaaadf5da82d510767cd2724a62844c3ec6525816719ce525cc37aec78866b8db1273c925624a5d691e11c0ffdba95805d
@@ -14,3 +14,7 @@ matrix:
14
14
  branches:
15
15
  only:
16
16
  - master
17
+
18
+ install: 'gem install bundler -v ">= 1.7.12" && bundle install --jobs=3 --retry=5'
19
+
20
+ sudo: false
data/README.md CHANGED
@@ -116,6 +116,33 @@ INHERIT_IMAGE_ATTR = "VMCATCHER_EVENT_SL_CHECKSUM_SHA512"
116
116
  INHERIT_IMAGE_ATTR = "VMCATCHER_EVENT_HV_VERSION"
117
117
  ~~~
118
118
 
119
+ ###Configure benchmark host attributes in OpenNebula
120
+ In order to recognize and fill `BenchmarkType` and `Benchmark` APEL v0.4 fields,
121
+ two attributes have to be set for every host in OpenNebula:
122
+ * `BENCHMARK_TYPE` - represents benchmark's type. For example: `HEP-SPEC06`
123
+ * `BENCHMARK_VALUES` - represents a map of virtual machine instance types and
124
+ their measured values of said benchmark formatted as JSON. For example:
125
+ ```
126
+ {
127
+ "http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#atlas":312.39,
128
+ "http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#extra_large":146.64,
129
+ "http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#goliath":255.80,
130
+ "http://fedcloud.egi.eu/occi/compute/flavour/1.0#large":84.46
131
+ }
132
+ ```
133
+ Virtual machine instance types are in form of OCCI `scheme#term` of `resource_tpl` mixins.
134
+ You can list your mixins via OCCI cli utility with command
135
+ ```
136
+ occi --endpoint $ENDPOINT -a list -r resource_tpl
137
+ ```
138
+
139
+ To check whether the value is correctly formatted use one of the JSON format validators and formatters, for example
140
+ [https://jsonformatter.curiousconcept.com/](https://jsonformatter.curiousconcept.com/).
141
+
142
+ Both attributes can be set both for clusters and hosts in OpenNebula with hosts'
143
+ attributes taking precedence. If attributes are set only for cluster, all hosts
144
+ within the cluster will be assigned these values.
145
+
119
146
  ###Set Rails environment variable according to your environment
120
147
  You have to set system environment variable `RAILS_ENV` to one of the
121
148
  values production, development or test. OneacctExport is not a Rails
@@ -147,9 +174,10 @@ Usage oneacct-export [options]
147
174
 
148
175
  --records-from TIME Retrieves only records newer than TIME
149
176
  --records-to TIME Retrieves only records older than TIME
150
- --include-groups GROUP1[,GROUP2,...]
177
+ --records-for PERIOD Retrieves only records within the time PERIOD
178
+ --include-groups [GROUP1,GROUP2,...]
151
179
  Retrieves only records of virtual machines which belong to the specified groups
152
- --exclude-groups GROUP1[,GROUP2,...]
180
+ --exclude-groups [GROUP1,GROUP2,...]
153
181
  Retrieves only records of virtual machines which don't belong to the specified groups
154
182
  --group-file FILE If --include-groups or --exclude-groups specified, loads groups from file FILE
155
183
  -b, --[no-]blocking Run in a blocking mode - wait until all submitted jobs are processed
@@ -159,6 +187,19 @@ Usage oneacct-export [options]
159
187
  -v, --version Shows version
160
188
  ```
161
189
 
190
+ ###Package specific scripts
191
+ When installed from packages build via [omnibus packaging for OneacctExport](https://github.com/EGI-FCTF/omnibus-oneacct-export),
192
+ both Sidekiq and OneacctExport are automatically registered as cron jobs to run
193
+ periodically. Cron job managing OneacctExport uses a bash script which is
194
+ simplifying OneacctExport interface for most common use cases. After the installation,
195
+ script can be found in `/usr/bin/oneacct-export-cron`. Script can accept command line options
196
+ `--week|-w` (default), `--two-weeks`, `--month|-m`, `--two-months`, `--six-months`, `--year|-y` and `--all|-a`
197
+ which sets age of retrieved records accordingly. There is also a set of files
198
+ which when present in `/opt/oneacct-export/` directory serves as a configuration shortcut:
199
+ * `compat.one` - turns on compatibility mode (same as OneacctExport option `--compatibility-mode`)
200
+ * `groups.include` - contains list of groups to include (same as combination of OneacctExport options `--include-groups` and `--group-file`)
201
+ * `groups.exclude` - contains list of groups to exclude (same as combination of OneacctExport options `--exclude-groups` and `--group-file`)
202
+
162
203
  ##Code Documentation
163
204
  [Code Documentation for OneacctExport by YARD](http://rubydoc.info/github/EGI-FCTF/oneacct_export/)
164
205
 
@@ -178,4 +219,3 @@ To change the log level of `oneacct-export` and `sidekiq` you have to set the en
178
219
  ```bash
179
220
  export ONEACCT_EXPORT_LOG_LEVEL=DEBUG
180
221
  ```
181
-
@@ -2,7 +2,7 @@
2
2
  defaults: &defaults
3
3
  output:
4
4
  output_dir: /var/spool/apel/outgoing/00000000 # Directory for outgoing messages
5
- output_type: apel-0.2 # Format of outgoing messages. Choices are: apel-0.2, pbs-0.1, logstash-0.1
5
+ output_type: apel-0.4 # Format of outgoing messages. Choices are: apel-0.2, apel-0.4, pbs-0.1, logstash-0.1
6
6
  num_of_vms_per_file: 500 # Maximum number of virtual machine records per one output file
7
7
  apel: # Options for apel output format
8
8
  site_name: Undefined # Usually a short provider name, e.g. CESNET
@@ -16,6 +16,8 @@ class OneDataAccessor
16
16
  include InputValidator
17
17
 
18
18
  STATE_DONE = '6'
19
+ BENCHMARK_TYPE_XPATH = 'TEMPLATE/BENCHMARK_TYPE'
20
+ BENCHMARK_VALUES_XPATH = 'TEMPLATE/BENCHMARK_VALUES'
19
21
 
20
22
  attr_reader :log, :batch_size, :client, :compatibility
21
23
  attr_accessor :start_vm_id
@@ -197,45 +199,55 @@ class OneDataAccessor
197
199
  #
198
200
  # @return [Hash] hosts' IDs and hash with benchmark name and value
199
201
  def benchmark_map
202
+ map = {}
200
203
  host_pool = OpenNebula::HostPool.new(@client)
201
204
  rc = host_pool.info
202
205
  check_retval(rc, Errors::ResourceRetrievalError)
203
206
 
204
- bench_map = {}
205
-
206
207
  host_pool.each do |host|
207
- structure = {}
208
- benchmark_values = nil
209
- benchmark_type = nil
210
-
211
- if (benchmark_type = host['TEMPLATE/BENCHMARK_TYPE'])
212
- benchmark_values = host['TEMPLATE/BENCHMARK_VALUES'].split(/\s*\n\s*/)
213
- else
214
- cluster_id = host['CLUSTER_ID'].to_i
215
-
216
- unless cluster_id == -1
217
- searched_cluster = OpenNebula::Cluster.new(OpenNebula::Cluster.build_xml(cluster_id), @client)
218
- rc = searched_cluster.info
219
- check_retval(rc, Errors::ResourceRetrievalError)
220
-
221
- if (benchmark_type = searched_cluster['TEMPLATE/BENCHMARK_TYPE'])
222
- benchmark_values = searched_cluster['TEMPLATE/BENCHMARK_VALUES'].split(/\s*\n\s*/)
223
- end
224
- end
208
+ benchmark = benchmark_values(host)
209
+ if benchmark.empty?
210
+ cluster = cluster_for_host(host)
211
+ benchmark = benchmark_values(cluster) if cluster
225
212
  end
226
213
 
227
- if benchmark_values
228
- mixins = {}
229
- benchmark_values.each do |value|
230
- values = value.split(/\s+/, 2)
231
- mixins[values[0]] = values[1]
232
- end
233
- structure = { :benchmark_type => benchmark_type, :mixins => mixins }
234
- end
214
+ map[host['ID']] = benchmark
215
+ end
235
216
 
236
- bench_map[host['ID']] = structure
217
+ map
218
+ end
219
+
220
+ # Returns benchmark type and values of specified entity
221
+ #
222
+ # @param [OpenNebula::PoolElement] entity
223
+ # @return [Hash] benchmark type and values in form of hash
224
+ def benchmark_values(entity)
225
+ benchmark_type = entity[BENCHMARK_TYPE_XPATH]
226
+ return {} unless benchmark_type
227
+
228
+ mixins = {}
229
+ benchmark_values = entity[BENCHMARK_VALUES_XPATH]
230
+ if benchmark_values
231
+ mixins = JSON.parse(benchmark_values, :max_nesting => 1)
237
232
  end
238
233
 
239
- bench_map
234
+ { :benchmark_type => benchmark_type, :mixins => mixins }
235
+ end
236
+
237
+ # Returns object representing a cluster for specified host
238
+ #
239
+ # @param [OpenNebula::Host] host
240
+ # @return [OpenNebula::Cluster] host's cluster
241
+ def cluster_for_host(host)
242
+ cluster_id = host['CLUSTER_ID'].to_i
243
+
244
+ # host without cluster
245
+ return nil if cluster_id == -1
246
+
247
+ cluster = OpenNebula::Cluster.new(OpenNebula::Cluster.build_xml(cluster_id), @client)
248
+ rc = cluster.info
249
+ check_retval(rc, Errors::ResourceRetrievalError)
250
+
251
+ cluster
240
252
  end
241
253
  end
@@ -279,16 +279,17 @@ class OneWorker
279
279
  #
280
280
  # @return [Hash] benchmark type and value or both can be nil
281
281
  def search_benchmark(vm, benchmark_map)
282
- nil_benchmark = { :benchmark_type => nil, :benchmark_value => nil }
283
282
  map = benchmark_map[vm['HISTORY_RECORDS/HISTORY[last()]/HID']]
284
- return nil_benchmark unless map
285
- return nil_benchmark unless vm['USER_TEMPLATE/OCCI_COMPUTE_MIXINS']
283
+
284
+ return {} unless vm['USER_TEMPLATE/OCCI_COMPUTE_MIXINS']
285
+ return {} if map.nil? || map.empty?
286
286
 
287
287
  occi_compute_mixins = vm['USER_TEMPLATE/OCCI_COMPUTE_MIXINS'].split(/\s+/)
288
288
  occi_compute_mixins.each do |mixin|
289
289
  return { :benchmark_type => map[:benchmark_type], :benchmark_value => map[:mixins][mixin] } if map[:mixins].has_key?(mixin)
290
290
  end
291
- nil_benchmark
291
+
292
+ {}
292
293
  end
293
294
 
294
295
  private
@@ -1,3 +1,3 @@
1
1
  class OneacctExporter
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
@@ -20,7 +20,7 @@
20
20
  </VNETS>
21
21
  <TEMPLATE>
22
22
  <BENCHMARK_TYPE>bench_type_cluster_1</BENCHMARK_TYPE>
23
- <BENCHMARK_VALUES>mixin1 21.7</BENCHMARK_VALUES>
23
+ <BENCHMARK_VALUES>{"mixin1": 21.7}</BENCHMARK_VALUES>
24
24
  <RESERVED_CPU><![CDATA[]]></RESERVED_CPU>
25
25
  <RESERVED_MEM><![CDATA[8388608]]></RESERVED_MEM>
26
26
  </TEMPLATE>
@@ -49,7 +49,7 @@
49
49
  <TEMPLATE>
50
50
  <ARCH><![CDATA[x86_64]]></ARCH>
51
51
  <BENCHMARK_TYPE>bench_type_1</BENCHMARK_TYPE>
52
- <BENCHMARK_VALUES>mixin1 36.9</BENCHMARK_VALUES>
52
+ <BENCHMARK_VALUES>{"mixin1": 36.9}</BENCHMARK_VALUES>
53
53
  <CPUSPEED><![CDATA[1200]]></CPUSPEED>
54
54
  <ERROR><![CDATA[Thu Nov 19 11:56:06 2015 : Error monitoring Host whatever.in.czech.republic.cz (21): -]]></ERROR>
55
55
  <HOSTNAME><![CDATA[whatever.in.czech.republic.cz]]></HOSTNAME>
@@ -49,8 +49,7 @@
49
49
  <TEMPLATE>
50
50
  <ARCH><![CDATA[x86_64]]></ARCH>
51
51
  <BENCHMARK_TYPE>bench_type_2</BENCHMARK_TYPE>
52
- <BENCHMARK_VALUES>mixin1 788.6
53
- mixin2 123.123</BENCHMARK_VALUES>
52
+ <BENCHMARK_VALUES>{"mixin1": 788.6, "mixin2": 123.123}</BENCHMARK_VALUES>
54
53
  <CPUSPEED><![CDATA[1200]]></CPUSPEED>
55
54
  <ERROR><![CDATA[Thu Nov 19 11:56:06 2015 : Error monitoring Host whatever.in.czech.republic.cz (21): -]]></ERROR>
56
55
  <HOSTNAME><![CDATA[whatever.in.czech.republic.cz]]></HOSTNAME>
@@ -453,7 +453,7 @@ describe OneDataAccessor do
453
453
  context 'with correct data on a host with one benchmark value' do
454
454
  let(:host_filename) { 'one_data_accessor_host_01.xml' }
455
455
  let(:expected) { { '1' => { :benchmark_type => 'bench_type_1',
456
- :mixins => { 'mixin1' => '36.9' } } } }
456
+ :mixins => { 'mixin1' => 36.9 } } } }
457
457
 
458
458
  it 'creates correct benchmark_map' do
459
459
  expect(subject.benchmark_map).to eq(expected)
@@ -463,7 +463,7 @@ describe OneDataAccessor do
463
463
  context 'with correct data on a host with two benchmark values' do
464
464
  let(:host_filename) { 'one_data_accessor_host_02.xml' }
465
465
  let(:expected) { { '2' => { :benchmark_type => 'bench_type_2',
466
- :mixins => { 'mixin1' => '788.6', 'mixin2' => '123.123' } } } }
466
+ :mixins => { 'mixin1' => 788.6, 'mixin2' => 123.123 } } } }
467
467
 
468
468
  it 'creates correct benchmark_map' do
469
469
  expect(subject.benchmark_map).to eq(expected)
@@ -478,7 +478,7 @@ describe OneDataAccessor do
478
478
  let(:host_filename) { 'one_data_accessor_host_03.xml' }
479
479
  let(:cluster_filename) { 'one_data_accessor_cluster_01.xml' }
480
480
  let(:expected) { { '3' => { :benchmark_type => 'bench_type_cluster_1',
481
- :mixins => { 'mixin1' => '21.7' } } } }
481
+ :mixins => { 'mixin1' => 21.7 } } } }
482
482
 
483
483
  it 'creates correct benchmark_map' do
484
484
  expect(subject.benchmark_map).to eq(expected)
@@ -602,7 +602,7 @@ describe OneWorker do
602
602
  context 'with empty benchmark_map' do
603
603
  let(:filename) { 'one_worker_vm_search_benchmark_01.xml' }
604
604
  let(:benchmark_map) { {} }
605
- let(:expected) { { :benchmark_type => nil, :benchmark_value => nil } }
605
+ let(:expected) { {} }
606
606
 
607
607
  it 'returns array with two nil items' do
608
608
  expect(subject.search_benchmark(vm, benchmark_map)).to eq(expected)
@@ -611,7 +611,7 @@ describe OneWorker do
611
611
 
612
612
  context 'with no data for the virtual machine in benchmark_map' do
613
613
  let(:filename) { 'one_worker_vm_search_benchmark_02.xml' }
614
- let(:expected) { { :benchmark_type => nil, :benchmark_value => nil } }
614
+ let(:expected) { {} }
615
615
 
616
616
  it 'returns array with two nil items' do
617
617
  expect(subject.search_benchmark(vm, benchmark_map)).to eq(expected)
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.4.2
4
+ version: 0.4.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: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler