From: Peter Palfrader Date: Mon, 25 Mar 2013 15:45:06 +0000 (+0100) Subject: /etc/bacula/bacula-volume-purge-action -> /etc/bacula/scripts/volume-purge-action X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=c024f71fb3000053e9501f83642c1ce5253c0869;p=dsa-puppet.git /etc/bacula/bacula-volume-purge-action -> /etc/bacula/scripts/volume-purge-action --- diff --git a/modules/bacula/files/bacula-volume-purge-action b/modules/bacula/files/bacula-volume-purge-action deleted file mode 100755 index 03c0822e..00000000 --- a/modules/bacula/files/bacula-volume-purge-action +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python - -# sends purge volume action=all to bacula using bconsole. -# list of storages is read from stdin - -# Copyright 2013 Peter Palfrader -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import optparse -import subprocess -import sys - - -parser = optparse.OptionParser() -parser.set_usage("%prog [options]") -parser.add_option("-v", "--verbose", dest="verbose", - default=False, action="store_true", - help="Be more verbose.") -(options, args) = parser.parse_args() - -if len(args) >= 1: - parser.print_help() - sys.exit(1) - -cmd = [] -for storage in sys.stdin: - s = storage.rstrip() - c = 'purge volume action=all allpools storage=%s'%(s,) - cmd.append(c) -if options.verbose: - for c in cmd: - print "Will run: %s"%(c,) - -p = subprocess.Popen(['bconsole'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) -(out, err) = p.communicate("\n".join(cmd)) -if p.returncode != 0: - raise Exception("bconsole failed. stdout:\n%s\nstderr:%s\n"%(out, err)) - -if options.verbose: - print "stdout:\n%s"%(out,) - -if err != "": - print >> sys.stderr, "bconsole said on stderr:\n%s\n"%(err,) - sys.exit(1) diff --git a/modules/bacula/files/volume-purge-action b/modules/bacula/files/volume-purge-action new file mode 100755 index 00000000..03c0822e --- /dev/null +++ b/modules/bacula/files/volume-purge-action @@ -0,0 +1,62 @@ +#!/usr/bin/python + +# sends purge volume action=all to bacula using bconsole. +# list of storages is read from stdin + +# Copyright 2013 Peter Palfrader +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import optparse +import subprocess +import sys + + +parser = optparse.OptionParser() +parser.set_usage("%prog [options]") +parser.add_option("-v", "--verbose", dest="verbose", + default=False, action="store_true", + help="Be more verbose.") +(options, args) = parser.parse_args() + +if len(args) >= 1: + parser.print_help() + sys.exit(1) + +cmd = [] +for storage in sys.stdin: + s = storage.rstrip() + c = 'purge volume action=all allpools storage=%s'%(s,) + cmd.append(c) +if options.verbose: + for c in cmd: + print "Will run: %s"%(c,) + +p = subprocess.Popen(['bconsole'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +(out, err) = p.communicate("\n".join(cmd)) +if p.returncode != 0: + raise Exception("bconsole failed. stdout:\n%s\nstderr:%s\n"%(out, err)) + +if options.verbose: + print "stdout:\n%s"%(out,) + +if err != "": + print >> sys.stderr, "bconsole said on stderr:\n%s\n"%(err,) + sys.exit(1) diff --git a/modules/bacula/manifests/director.pp b/modules/bacula/manifests/director.pp index 71bb38e1..6e1e11e2 100644 --- a/modules/bacula/manifests/director.pp +++ b/modules/bacula/manifests/director.pp @@ -63,9 +63,9 @@ class bacula::director inherits bacula { require => Package['bacula-console'] } - file { '/etc/bacula/bacula-volume-purge-action': + file { '/etc/bacula/scripts/volume-purge-action': mode => '0555', - source => 'puppet:///modules/bacula/bacula-volume-purge-action', + source => 'puppet:///modules/bacula/volume-purge-action', ; } file { '/etc/bacula/storages-list.d': @@ -78,6 +78,6 @@ class bacula::director inherits bacula { source => 'puppet:///files/empty/', } file { "/etc/cron.d/dsa-bacula-stuff": - content => "@daily root (cat /etc/bacula/storages-list.d/*.storage; echo '$bacula::bacula_filestor_name-catalog') | /etc/bacula/bacula-volume-purge-action\n"; + content => "@daily root (cat /etc/bacula/storages-list.d/*.storage; echo '$bacula::bacula_filestor_name-catalog') | /etc/bacula/scripts/volume-purge-action\n"; } }