Class: Nifty::TransferMethods::Opennebula::Cp
- Inherits:
-
Nifty::TransferMethod
- Object
- Nifty::TransferMethod
- Nifty::TransferMethods::Opennebula::Cp
- Defined in:
- lib/nifty/transfer_methods/opennebula/cp.rb
Overview
Copy transfer method Copies file to the destination and clens it after the event is processed
Instance Attribute Summary
Attributes inherited from Nifty::TransferMethod
Class Method Summary collapse
Instance Method Summary collapse
- #clean_copy(file) ⇒ Object
-
#initialize(destination) ⇒ Cp
constructor
A new instance of Cp.
- #transfer(file) ⇒ Object
Methods inherited from Nifty::TransferMethod
Constructor Details
#initialize(destination) ⇒ Cp
Returns a new instance of Cp.
22 23 24 25 26 27 |
# File 'lib/nifty/transfer_methods/opennebula/cp.rb', line 22 def initialize(destination) fail Nifty::Errors::TransferMethods::DestinationNotDirectoryError, "Destination #{destination.inspect} is not a directory" unless (destination && File.directory?(destination)) fail Nifty::Errors::TransferMethods::DestinationNotWritableError, "Destination directory #{destination.inspect} is not writable" unless File.writable?(destination) super(destination) end |
Class Method Details
.backend ⇒ Object
16 17 18 |
# File 'lib/nifty/transfer_methods/opennebula/cp.rb', line 16 def backend Nifty::Backends::Opennebula end |
.description ⇒ Object
11 12 13 |
# File 'lib/nifty/transfer_methods/opennebula/cp.rb', line 11 def description 'Copy transfer method - copies images localy within one host' end |
.transfer_method? ⇒ Boolean
6 7 8 |
# File 'lib/nifty/transfer_methods/opennebula/cp.rb', line 6 def transfer_method? true end |
Instance Method Details
#clean_copy(file) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/nifty/transfer_methods/opennebula/cp.rb', line 39 def clean_copy(file) df = destination_file file logger.debug("Deleting files #{df.inspect}") FileUtils.rm df rescue SystemCallError => ex logger.warn("Cannot delete file #{df.inspect}, #{ex.}") end |
#transfer(file) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/nifty/transfer_methods/opennebula/cp.rb', line 30 def transfer(file) super(file) logger.debug("Copying file #{file.inspect} to destination #{destination.inspect}") FileUtils.cp file, destination destination_file file end |