Class: Aspera::Plugins::Transferd::Commands

Inherits:
Cli::Plugins::Base show all
Defined in:
lib/aspera/plugins/transferd/commands.rb

Overview

Install the Transfer Daemon (transferd), run it as a system service, and query a running daemon

Constant Summary

Constants inherited from Cli::Plugins::Base

Cli::Plugins::Base::FILTER_ARGS

Class Attribute Summary collapse

Attributes inherited from Cli::Plugins::Base

#context, #help_path

Instance Method Summary collapse

Methods inherited from Cli::Plugins::Base

#action_for, application_name, #bulk_result, #check_argument_access, command, command_registry, commands_under, #config, #crud_api, crud_commands, declare_options, define_action_method, #dispatch_child, #dispatch_from_registry, #dispatch_leaf, #dispatch_mount, #entity_create, #entity_delete, #entity_list, #entity_modify, entity_noun, #entity_res_path, #entity_show, #execute_action, #execute_leaf, file_matcher, #formatter, #generate_help, #http_config, include_mounts, #initialize, #invoke_action, operation_description, option_sources, option_specs, #options, #persistency, #poll_result, #presets, #progress_bar, #query_read_delete, register_option_spec, #resolve_argument, #resolve_arguments, #transfer, use_options, used_option_sources, #validate_registry

Methods included from Cli::Option::Declarator

#declare_options, #option, #option_specs, #register_option_spec

Constructor Details

This class inherits a constructor from Aspera::Cli::Plugins::Base

Class Attribute Details

.daemon_client ⇒ #info, ...

Seam for the client commands: object that gives info(params), transfer_status(id, params) and transfer_cancel(id, params), with params a Hash with url, and optional api_key, ca_file. nil (default): Api, loaded on first use, because it requires the optional gem grpc.

Returns:

  • (#info, #transfer_status, #transfer_cancel, nil)


28
29
30
# File 'lib/aspera/plugins/transferd/commands.rb', line 28

def daemon_client
  @daemon_client
end

Instance Method Details

#action_install(version: nil) ⇒ Cli::Result::Status

Install the transfer SDK (ascp + transferd) from a URL or using the default source. Version defaults to Cli::Info::SDK_VERSION; pass LATEST as argument to install the latest available version. Nothing is done if this version is already installed in the SDK folder (not checked if option sdk_url is set). SDK locations are read once, and only if needed (each read is counted as a download in statistics): not if the given version is already installed, but always for LATEST (to know that version). Also called by the deprecated command config ascp install.

Parameters:

  • version (String, nil) (defaults to: nil) —

    version to install; nil means use the default SDK version

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/aspera/plugins/transferd/commands.rb', line 125

def action_install(version: nil, **)
  asked_version = version.nil? ? Cli::Info::SDK_VERSION : version
  asked_version = nil if asked_version.eql?(Cli::SpecialValues::LATEST)
  installation = Ascp::Installation.instance
  url = sdk_url_option
  if url.nil?
    installed_version = installation.installed_sdk_version
    location = installation.sdk_location_for_platform(version: asked_version) unless !installed_version.nil? && installed_version.eql?(asked_version)
    wanted_version = location.nil? ? asked_version : location['version']
    return Cli::Result::Status.new("Version #{wanted_version} is already installed in #{Products::Transferd.sdk_directory}") if installed_version.eql?(wanted_version)
    url = location['url']
  end
  name, ver, folder = installation.install_sdk(url: url, version: asked_version)
  return Cli::Result::Status.new("Installed #{name} version #{ver} in #{folder}")
end

#action_list ⇒ Cli::Result::ObjectList

Returns The SDK locations.

Returns:



142
143
144
145
# File 'lib/aspera/plugins/transferd/commands.rb', line 142

def action_list(**)
  sdk_list = Ascp::Installation.instance.sdk_locations
  Cli::Result::ObjectList.new(sdk_list, fields: sdk_list.first.keys - ['url'])
end