Class: Puppet::Application::Filebucket
- Inherits:
-
Puppet::Application
- Object
- Puppet::Application
- Puppet::Application::Filebucket
- Defined in:
- lib/puppet/application/filebucket.rb
Constant Summary
Constants inherited from Puppet::Application
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Attributes inherited from Puppet::Application
Instance Method Summary collapse
Methods inherited from Puppet::Application
[], banner, clear!, clear?, controlled_run, exit, find, #handlearg, #help, #initialize, interrupted?, #main, #name, option, option_parser_commands, #parse_options, #preinit, restart!, restart_requested?, #run, run_mode, #set_run_mode, should_not_parse_config, should_parse_config, #should_parse_config?, should_parse_config?, stop!, stop_requested?
Methods included from Util
activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Constructor Details
This class inherits a constructor from Puppet::Application
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
13 14 15 |
# File 'lib/puppet/application/filebucket.rb', line 13 def args @args end |
Instance Method Details
#backup ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/application/filebucket.rb', line 28 def backup args.each do |file| unless FileTest.exists?(file) $stderr.puts "#{file}: no such file" next end unless FileTest.readable?(file) $stderr.puts "#{file}: cannot read file" next end md5 = @client.backup(file) puts "#{file}: #{md5}" end end |
#get ⇒ Object
22 23 24 25 26 |
# File 'lib/puppet/application/filebucket.rb', line 22 def get md5 = args.shift out = @client.getfile(md5) print out end |
#restore ⇒ Object
43 44 45 46 47 |
# File 'lib/puppet/application/filebucket.rb', line 43 def restore file = args.shift md5 = args.shift @client.restore(file, md5) end |
#run_command ⇒ Object
15 16 17 18 19 20 |
# File 'lib/puppet/application/filebucket.rb', line 15 def run_command @args = command_line.args command = args.shift return send(command) if %w{get backup restore}.include? command help end |
#setup ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/puppet/application/filebucket.rb', line 49 def setup Puppet::Log.newdestination(:console) @client = nil @server = nil Signal.trap(:INT) do $stderr.puts "Cancelling" exit(1) end if [:debug] Puppet::Log.level = :debug elsif [:verbose] Puppet::Log.level = :info end # Now parse the config Puppet.parse_config exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? require 'puppet/file_bucket/dipper' begin if [:local] or [:bucket] path = [:bucket] || Puppet[:bucketdir] @client = Puppet::FileBucket::Dipper.new(:Path => path) else @client = Puppet::FileBucket::Dipper.new(:Server => Puppet[:server]) end rescue => detail $stderr.puts detail puts detail.backtrace if Puppet[:trace] exit(1) end end |