Class: OsCtld::SendReceive::Commands::Transfer
- Inherits:
-
Base
- Object
- Commands::Base
- Base
- OsCtld::SendReceive::Commands::Transfer
- Includes:
- OsCtl::Lib::Utils::Log, OsCtl::Lib::Utils::System, Utils::Container, Utils::Receive
- Defined in:
- lib/osctld/send_receive/commands/receive_transfer.rb
Instance Attribute Summary
Attributes inherited from Commands::Base
#client, #client_handler, #id, #opts
Instance Method Summary collapse
Methods included from Utils::Container
#format_unavailable_repositories, #get_image_path, #get_image_path!, #get_repositories, #image_not_found_message, #image_spec, #image_unavailable_message, #remove_accounting_cgroups
Methods included from Utils::Receive
#check_auth_pubkey, #receive_pipeline_error
Methods inherited from Base
#base_execute, handle, #receive_pipeline_error, #validate_protocol_version!, #validate_send_log_protocol!
Methods inherited from Commands::Base
#base_execute, #call_cmd, #call_cmd!, #error, #error!, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!
Constructor Details
This class inherits a constructor from OsCtld::Commands::Base
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/osctld/send_receive/commands/receive_transfer.rb', line 14 def execute ct = SendReceive::Tokens.find_container(opts[:token]) error!('container not found') unless ct error!('the pool is disabled') unless ct.pool.active? ct.manipulate(self, block: true) do error!('this container is not staged') if ct.state != :staged if !ct.send_log || !ct.send_log.can_receive_continue?(:transfer) error!('invalid send sequence') elsif !check_auth_pubkey(opts[:key_pool], opts[:key_name], ct) error!('authentication key mismatch') end validate_send_log_protocol!(ct) begin ct.state = :complete if opts[:start] call_cmd!( Commands::Container::Start, id: ct.id, pool: ct.pool.name, force: true ) end rescue StandardError rollback_failed_receive_transfer(ct) raise end ct.exclusively do ct.send_log.state = :transfer ct.save_config end end ok end |
#rollback_failed_receive_transfer(ct) ⇒ Object (protected)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/osctld/send_receive/commands/receive_transfer.rb', line 57 def rollback_failed_receive_transfer(ct) Console.remove(ct) ct. ct.mounts.shared_dir.remove ct.mounts.prune ct.unmount(force: true) remove_accounting_cgroups(ct) if AppArmor.enabled? ct.apparmor.destroy_namespace ct.apparmor.unload_profile end ct.stopped ct.exclusively do ct.state = :staged ct.save_config end end |