oneacct-export 0.2.1 → 0.2.2

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: 524b14a0f4c51ba085b4f104054dcce81070c6f5
4
- data.tar.gz: cd2c0e62fb62505fd47dd6eecfc2cae241421353
3
+ metadata.gz: 4f3c538f8440a61bb9d37b9e046b8c0d0350de5e
4
+ data.tar.gz: 6032e05b202d5fd0623911d4bd49389e4dc489e2
5
5
  SHA512:
6
- metadata.gz: 1339fba2bb944512220a90c31ad71d132c11bd286b2252de0117e50d1989ecf0f669e37bc7f0f23a3a02be2e4bb5ac421e45fa2fcb5d06aef0058ebb77b8cc34
7
- data.tar.gz: 51102cc765d368c534240c974493f0323edb44f3450e9c8063bcdd43bcea80ac9ea232583debd1a1f0213008d93dec01698dc88ba254f91883cabcf23a4ab7a6
6
+ metadata.gz: b451ef989eaadb314cf04d9e2ad49f984d12eb3c852b6981ff9561ba2fa367e98507b5a480f642dcb60b6d1551b48d47eadcda26305fe3ee8526a652974980f6
7
+ data.tar.gz: 158799a83a2114d5cfb27468119cbf73540d947ac715c3cd1b650507410f03a8631297e3496032eb600edc5126361475d34d8193d5386d707a3116c469d57eef
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 TODO: Write your name
1
+ Copyright (c) 2014 CESNET
2
2
 
3
3
  MIT License
4
4
 
@@ -44,7 +44,7 @@ if options.groups_file
44
44
  if File.exist?(options.groups_file) && File.readable?(options.groups_file)
45
45
  file = File.open(options.groups_file, 'r')
46
46
  file.each_line do |line|
47
- groups[groups.keys.first] << line
47
+ groups[groups.keys.first] << line.strip
48
48
  end
49
49
  file.close
50
50
  else
@@ -0,0 +1,11 @@
1
+ # Cron job running by default every two hours, at 45 minutes +/- 3
2
+ # minutes. The lock file can be enabled or disabled via:
3
+ #
4
+ # service oneacct-export-cron start
5
+ # chkconfig oneacct-export-cron on
6
+ #
7
+ # Note that the lock file not existing is a success (and
8
+ # over-all success is needed in order to prevent error
9
+ # messages from cron).
10
+
11
+ 42 */2 * * * apel [ ! -f /var/lock/oneacct-export-cron ] || /usr/bin/oneacct-export-cron
@@ -0,0 +1,63 @@
1
+ #!/bin/sh
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: oneacct-export-cron
5
+ # Required-Start: $remote_fs $syslog
6
+ # Required-Stop: $remote_fs $syslog
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: Enable hourly run of oneacct-export
10
+ # Description: This shell script enables the automatic use of oneacct-export
11
+ ### END INIT INFO
12
+
13
+ lockfile="/var/lock/oneacct-export-cron"
14
+ retval=0
15
+ name=`basename $0`
16
+
17
+ start() {
18
+ touch $lockfile
19
+ echo "Enabling periodic $name"
20
+ retval=0
21
+ }
22
+
23
+ stop() {
24
+ rm -f $lockfile
25
+ echo "Disabling periodic $name"
26
+ retval=0
27
+ }
28
+
29
+ restart() {
30
+ stop
31
+ start
32
+ }
33
+
34
+ case "$1" in
35
+ start)
36
+ start
37
+ ;;
38
+ stop)
39
+ stop
40
+ ;;
41
+ restart|force-reload)
42
+ restart
43
+ ;;
44
+ reload)
45
+ ;;
46
+ condrestart)
47
+ [ -f "$lockfile" ] && restart
48
+ ;;
49
+ status)
50
+ if [ -f "$lockfile" ] ; then
51
+ echo "Periodic $name is enabled"
52
+ retval=0
53
+ else
54
+ echo "Periodic $name is disabled"
55
+ retval=3
56
+ fi
57
+ ;;
58
+ *)
59
+ echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
60
+ retval=1
61
+ esac
62
+
63
+ exit $retval
@@ -0,0 +1,124 @@
1
+ #!/bin/sh
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: oneacct-export-sidekiq
5
+ # Required-Start: $local_fs $remote_fs $network $syslog $named
6
+ # Required-Stop: $local_fs $remote_fs $network $syslog $named
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: Start/stop oneacct-export sidekiq server
10
+ # Description: Start the sidekiq server required by oneacct-export.
11
+ ### END INIT INFO
12
+
13
+ run_dir="/var/run/oneacct-export"
14
+ log_dir="/var/log/oneacct-export"
15
+ conf_dir="/etc/oneacct-export"
16
+
17
+ omnibus_base_dir="/opt/oneacct-export"
18
+ embedded_base_dir="$omnibus_base_dir/embedded"
19
+ embedded_ruby_version=`$embedded_base_dir/bin/ruby -e "puts RUBY_VERSION.split('.').fill('0',2..2).join('.')"`
20
+ embedded_oneacct_version=`$omnibus_base_dir/bin/oneacct-export --version`
21
+ embedded_oneacct_dir="$embedded_base_dir/lib/ruby/gems/$embedded_ruby_version/gems/oneacct-export-$embedded_oneacct_version"
22
+
23
+ user="apel"
24
+ cmd="$omnibus_base_dir/bin/sidekiq -r $embedded_oneacct_dir/lib/one_worker.rb -C $conf_dir/sidekiq.yml"
25
+
26
+ name=`basename $0`
27
+ pid_file="$run_dir/sidekiq.init.pid"
28
+ stdout_log="$log_dir/sidekiq.init.stdout.log"
29
+ stderr_log="$log_dir/sidekiq.init.stderr.log"
30
+
31
+ retval=0
32
+
33
+ get_pid() {
34
+ cat "$pid_file"
35
+ }
36
+
37
+ is_running() {
38
+ [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
39
+ }
40
+
41
+ start() {
42
+ if is_running; then
43
+ echo "Already started"
44
+ else
45
+ echo "Starting $name ..."
46
+
47
+ cd "$run_dir"
48
+ sudo -u "$user" RAILS_ENV=production $cmd >> "$stdout_log" 2>> "$stderr_log" &
49
+
50
+ echo $! > "$pid_file"
51
+ if ! is_running; then
52
+ echo "Unable to start, see $stdout_log and $stderr_log"
53
+ retval=1
54
+ else
55
+ echo "Started"
56
+ fi
57
+ fi
58
+ }
59
+
60
+ stop() {
61
+ if is_running; then
62
+ echo "Stopping $name ..."
63
+
64
+ kill `get_pid`
65
+ for i in $(seq 1 15); do
66
+ if ! is_running; then
67
+ break
68
+ fi
69
+ echo -n "."
70
+ sleep 1
71
+ done
72
+
73
+ echo
74
+ if is_running; then
75
+ echo "Not stopped; may still be shutting down or shutdown may have failed"
76
+ retval=1
77
+ else
78
+ echo "Stopped"
79
+ if [ -f "$pid_file" ]; then
80
+ rm "$pid_file"
81
+ fi
82
+ fi
83
+ else
84
+ echo "Not running"
85
+ retval=1
86
+ fi
87
+ }
88
+
89
+ restart(){
90
+ stop
91
+
92
+ if is_running; then
93
+ echo "Unable to stop, will not attempt to start"
94
+ retval=1
95
+ else
96
+ start
97
+ fi
98
+ }
99
+
100
+ case "$1" in
101
+ start)
102
+ start
103
+ ;;
104
+ stop)
105
+ stop
106
+ ;;
107
+ restart)
108
+ restart
109
+ ;;
110
+ status)
111
+ if is_running; then
112
+ echo "Running"
113
+ else
114
+ echo "Stopped"
115
+ retval=3
116
+ fi
117
+ ;;
118
+ *)
119
+ echo "Usage: $name {start|stop|restart|status}"
120
+ retval=1
121
+ ;;
122
+ esac
123
+
124
+ exit $retval
@@ -0,0 +1,45 @@
1
+ #!/bin/sh
2
+
3
+ ##############################################################################
4
+ # Copyright (c) 2014 CESNET
5
+ #
6
+ # MIT License
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining
9
+ # a copy of this software and associated documentation files (the
10
+ # "Software"), to deal in the Software without restriction, including
11
+ # without limitation the rights to use, copy, modify, merge, publish,
12
+ # distribute, sublicense, and/or sell copies of the Software, and to
13
+ # permit persons to whom the Software is furnished to do so, subject to
14
+ # the following conditions:
15
+ #
16
+ # The above copyright notice and this permission notice shall be
17
+ # included in all copies or substantial portions of the Software.
18
+ #
19
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ ##############################################################################
27
+
28
+ conf_dir="/etc/oneacct-export"
29
+ omnibus_base_dir="/opt/oneacct-export"
30
+
31
+ week_start_epoch=$((`date +%s`-604800))
32
+ week_start_date=`date -d @$week_start_epoch +%F`
33
+
34
+ options="--records-from $week_start_date --blocking --timeout 2700"
35
+
36
+ if [ -f "$conf_dir/compat.one" ]; then
37
+ options="$options --compatibility-mode"
38
+ fi
39
+
40
+ if [ -f "$conf_dir/groups.allow" ]; then
41
+ options="$options --include-groups --group-file $conf_dir/groups.allow"
42
+ fi
43
+
44
+ export RAILS_ENV="production"
45
+ $omnibus_base_dir/bin/oneacct-export $options
@@ -1,3 +1,3 @@
1
1
  class OneacctExporter
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -30,12 +30,14 @@ class OneacctOpts
30
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
+ groups = [] unless groups
33
34
  options.include_groups = groups
34
35
  end
35
36
 
36
37
  opts.on('--exclude-groups GROUP1[,GROUP2,...]', Array,
37
38
  'Retrieves only records of virtual machines which '\
38
39
  "don't belong to the specified groups") do |groups|
40
+ groups = [] unless groups
39
41
  options.exclude_groups = groups
40
42
  end
41
43
 
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.1
4
+ version: 0.2.2
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-19 00:00:00.000000000 Z
11
+ date: 2014-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,6 +154,10 @@ files:
154
154
  - bin/oneacct-export
155
155
  - config/conf.yml
156
156
  - config/sidekiq.yml
157
+ - examples/etc/cron.d/oneacct-export
158
+ - examples/etc/init.d/oneacct-export-cron
159
+ - examples/etc/init.d/oneacct-export-sidekiq
160
+ - examples/usr/bin/oneacct-export-cron
157
161
  - lib/errors.rb
158
162
  - lib/errors/authentication_error.rb
159
163
  - lib/errors/resource_not_found_error.rb