oneacct-export 0.2.3 → 0.2.4
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 +4 -4
- data/examples/etc/init.d/oneacct-export-sidekiq +11 -1
- data/examples/usr/bin/oneacct-export-cron +30 -3
- data/lib/one_worker.rb +2 -1
- data/lib/oneacct_exporter/log.rb +1 -1
- data/lib/oneacct_exporter/version.rb +1 -1
- data/lib/oneacct_opts.rb +2 -2
- data/spec/one_worker_spec.rb +13 -0
- 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: 20c8592380b1a81b852587aa9eb4a9c11d598c11
|
4
|
+
data.tar.gz: 4bc47dffdaf71c19a772ab48ebfa68a007dc48ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47e53b053ddb384a3ae52e28c4a75e29a17b79e5a3e5c48830e0e894961af1767492cb0aae5598ec9da1f03f80cd4b816fc22ab8e0aff5f7d9cc15b6632bf4fc
|
7
|
+
data.tar.gz: 65685875ef2b0d41cbaaa0eb89d2309701a93eabef7d1a3beb6bf56fcda15c958e9eac1547c19b3dbbd5907b95af8dae51a306ac5b826e0c613c71a664d02ef1
|
@@ -30,6 +30,16 @@ stderr_log="$log_dir/sidekiq.init.stderr.log"
|
|
30
30
|
|
31
31
|
retval=0
|
32
32
|
|
33
|
+
if [ "x$SSL_CERT_DIR" = "x" ]; then
|
34
|
+
SSL_CERT_DIR="/etc/grid-security/certificates"
|
35
|
+
fi
|
36
|
+
|
37
|
+
if [ "x$DEBUG" = "x1" ]; then
|
38
|
+
ONEACCT_EXPORT_LOG_LEVEL="DEBUG"
|
39
|
+
else
|
40
|
+
ONEACCT_EXPORT_LOG_LEVEL="ERROR"
|
41
|
+
fi
|
42
|
+
|
33
43
|
get_pid() {
|
34
44
|
cat "$pid_file"
|
35
45
|
}
|
@@ -45,7 +55,7 @@ start() {
|
|
45
55
|
echo "Starting $name ..."
|
46
56
|
|
47
57
|
cd "$run_dir"
|
48
|
-
sudo -u "$user" RAILS_ENV=production $cmd >> "$stdout_log" 2>> "$stderr_log" &
|
58
|
+
sudo -u "$user" RAILS_ENV=production SSL_CERT_DIR=$SSL_CERT_DIR ONEACCT_EXPORT_LOG_LEVEL=$ONEACCT_EXPORT_LOG_LEVEL $cmd >> "$stdout_log" 2>> "$stderr_log" &
|
49
59
|
|
50
60
|
echo $! > "$pid_file"
|
51
61
|
if ! is_running; then
|
@@ -31,15 +31,42 @@ omnibus_base_dir="/opt/oneacct-export"
|
|
31
31
|
week_start_epoch=$((`date +%s`-604800))
|
32
32
|
week_start_date=`date -d @$week_start_epoch +%F`
|
33
33
|
|
34
|
-
|
34
|
+
if [ "x$1" = "x--all" ] || [ "x$1" = "x-all" ]; then
|
35
|
+
# export all available accounting records
|
36
|
+
options="--blocking --timeout 3600"
|
37
|
+
else
|
38
|
+
# export only records from the last 7 days
|
39
|
+
options="--records-from $week_start_date --blocking --timeout 1800"
|
40
|
+
fi
|
35
41
|
|
36
42
|
if [ -f "$conf_dir/compat.one" ]; then
|
37
43
|
options="$options --compatibility-mode"
|
38
44
|
fi
|
39
45
|
|
40
|
-
if [ -f "$conf_dir/groups.
|
41
|
-
|
46
|
+
if [ -f "$conf_dir/groups.include" ]; then
|
47
|
+
groups_include="YES"
|
48
|
+
options="$options --include-groups --group-file $conf_dir/groups.include"
|
49
|
+
fi
|
50
|
+
|
51
|
+
if [ -f "$conf_dir/groups.exclude" ]; then
|
52
|
+
if [ "x$groups_include" = "xYES" ]; then
|
53
|
+
echo "'groups.include' and 'groups.exclude' cannot be combined. Pick only one!"
|
54
|
+
exit 1
|
55
|
+
fi
|
56
|
+
|
57
|
+
options="$options --exclude-groups --group-file $conf_dir/groups.exclude"
|
58
|
+
fi
|
59
|
+
|
60
|
+
if [ "x$DEBUG" = "x1" ]; then
|
61
|
+
export ONEACCT_EXPORT_LOG_LEVEL="DEBUG"
|
62
|
+
echo "$omnibus_base_dir/bin/oneacct-export $options"
|
63
|
+
echo "(see log files in /var/log/oneacct-export for details)"
|
42
64
|
fi
|
43
65
|
|
44
66
|
export RAILS_ENV="production"
|
67
|
+
|
68
|
+
if [ "x$SSL_CERT_DIR" = "x" ]; then
|
69
|
+
export SSL_CERT_DIR="/etc/grid-security/certificates"
|
70
|
+
fi
|
71
|
+
|
45
72
|
$omnibus_base_dir/bin/oneacct-export $options
|
data/lib/one_worker.rb
CHANGED
@@ -135,7 +135,8 @@ class OneWorker
|
|
135
135
|
data['memory'] = parse(vm['TEMPLATE/MEMORY'], NUMBER, '0')
|
136
136
|
|
137
137
|
data['image_name'] = parse(image_map[vm['TEMPLATE/DISK[1]/IMAGE_ID']], STRING, nil)
|
138
|
-
data['image_name'] = parse(mixin(vm), STRING) unless data['image_name']
|
138
|
+
data['image_name'] = parse(mixin(vm), STRING, nil) unless data['image_name']
|
139
|
+
data['image_name'] = parse(vm['TEMPLATE/DISK[1]/IMAGE_ID'], STRING) unless data['image_name']
|
139
140
|
|
140
141
|
data
|
141
142
|
end
|
data/lib/oneacct_exporter/log.rb
CHANGED
@@ -6,7 +6,7 @@ class OneacctExporter
|
|
6
6
|
if ENV['ONEACCT_EXPORT_LOG_LEVEL'] && Logger::Severity.const_defined?(ENV['ONEACCT_EXPORT_LOG_LEVEL'])
|
7
7
|
logger.level = Logger::Severity.const_get ENV['ONEACCT_EXPORT_LOG_LEVEL']
|
8
8
|
else
|
9
|
-
logger.level = Logger::
|
9
|
+
logger.level = Logger::ERROR
|
10
10
|
end
|
11
11
|
|
12
12
|
logger
|
data/lib/oneacct_opts.rb
CHANGED
@@ -27,14 +27,14 @@ class OneacctOpts
|
|
27
27
|
options.records_to = time
|
28
28
|
end
|
29
29
|
|
30
|
-
opts.on('--include-groups GROUP1
|
30
|
+
opts.on('--include-groups [GROUP1,GROUP2,...]', Array,
|
31
31
|
'Retrieves only records of virtual machines which '\
|
32
32
|
'belong to the specified groups') do |groups|
|
33
33
|
groups = [] unless groups
|
34
34
|
options.include_groups = groups
|
35
35
|
end
|
36
36
|
|
37
|
-
opts.on('--exclude-groups GROUP1
|
37
|
+
opts.on('--exclude-groups [GROUP1,GROUP2,...]', Array,
|
38
38
|
'Retrieves only records of virtual machines which '\
|
39
39
|
"don't belong to the specified groups") do |groups|
|
40
40
|
groups = [] unless groups
|
data/spec/one_worker_spec.rb
CHANGED
@@ -536,6 +536,19 @@ describe OneWorker do
|
|
536
536
|
end
|
537
537
|
end
|
538
538
|
|
539
|
+
context 'vm without IMAGE_ID mapping' do
|
540
|
+
before :example do
|
541
|
+
data['image_name'] = '31'
|
542
|
+
end
|
543
|
+
|
544
|
+
let(:image_map) { { 'non_existing_id' => 'name' } }
|
545
|
+
let(:filename) { 'one_worker_valid_machine.xml' }
|
546
|
+
|
547
|
+
it 'replaces image name with IMAGE_ID' do
|
548
|
+
expect(subject.process_vm(vm, user_map, image_map)).to eq(data)
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
539
552
|
context 'vm with USER_TEMPLATE/OCCI_COMPUTE_MIXINS' do
|
540
553
|
let(:filename) { 'one_worker_vm4.xml' }
|
541
554
|
let(:image_name) { 'http://occi.localhost/occi/infrastructure/os_tpl#uuid_monitoring_20' }
|
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.4
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|