aspera-cli 4.29.1 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -4
- data/CHANGELOG.md +119 -0
- data/CONTRIBUTING.md +8 -1
- data/README.md +2 -0
- data/TODO.md +4 -5
- data/bin/asession +2 -2
- data/docs/README.md +616 -86
- data/docs/test-mcp-with-ai.md +4 -0
- data/lib/aspera/agent/base.rb +62 -6
- data/lib/aspera/agent/factory.rb +127 -20
- data/lib/aspera/ascp/data_repository.rb +71 -0
- data/lib/aspera/ascp/installation.rb +16 -11
- data/lib/aspera/ascp/log_analyzer/lines.rb +4 -4
- data/lib/aspera/ascp/log_analyzer/log_file.rb +5 -3
- data/lib/aspera/ascp/log_analyzer/records.rb +11 -6
- data/lib/aspera/ascp/log_analyzer.rb +43 -18
- data/lib/aspera/ascp/log_locations.rb +2 -2
- data/lib/aspera/assert.rb +8 -0
- data/lib/aspera/bundle_registry.rb +528 -0
- data/lib/aspera/cli/argument.rb +110 -0
- data/lib/aspera/cli/bool_value.rb +41 -0
- data/lib/aspera/cli/bootstrapper.rb +31 -24
- data/lib/aspera/cli/command/mount.rb +53 -0
- data/lib/aspera/cli/command/registry.rb +434 -0
- data/lib/aspera/cli/command.rb +95 -0
- data/lib/aspera/cli/command_line.rb +91 -91
- data/lib/aspera/cli/complete.rb +22 -0
- data/lib/aspera/cli/completion_actions.rb +28 -26
- data/lib/aspera/cli/context.rb +29 -6
- data/lib/aspera/cli/error.rb +39 -0
- data/lib/aspera/cli/extended_value.rb +25 -4
- data/lib/aspera/cli/formatter.rb +8 -8
- data/lib/aspera/cli/hints.rb +17 -52
- data/lib/aspera/cli/http.rb +17 -12
- data/lib/aspera/cli/mailer.rb +7 -24
- data/lib/aspera/cli/mcp/tool.rb +10 -2
- data/lib/aspera/cli/option/declarator.rb +80 -0
- data/lib/aspera/cli/option/registry.rb +74 -0
- data/lib/aspera/cli/option/source.rb +38 -0
- data/lib/aspera/cli/option/type.rb +37 -0
- data/lib/aspera/cli/option/value.rb +376 -0
- data/lib/aspera/cli/option.rb +78 -0
- data/lib/aspera/cli/options.schema.yaml +28 -783
- data/lib/aspera/cli/parser.rb +73 -41
- data/lib/aspera/cli/plugins/base.rb +122 -42
- data/lib/aspera/cli/plugins/basic_auth.rb +13 -2
- data/lib/aspera/cli/plugins/config.rb +101 -167
- data/lib/aspera/cli/plugins/factory.rb +139 -43
- data/lib/aspera/cli/plugins/mcp.rb +61 -54
- data/lib/aspera/cli/plugins/oauth.rb +19 -6
- data/lib/aspera/cli/poll.rb +14 -20
- data/lib/aspera/cli/preset_actions.rb +11 -3
- data/lib/aspera/cli/preset_manager.rb +16 -6
- data/lib/aspera/cli/result.rb +2 -2
- data/lib/aspera/cli/runner.rb +71 -99
- data/lib/aspera/cli/secret_finder.rb +1 -1
- data/lib/aspera/cli/security.rb +102 -4
- data/lib/aspera/{preview/terminal.rb → cli/terminal_image.rb} +93 -94
- data/lib/aspera/cli/vault_manager.rb +3 -3
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/cli/wizard.rb +9 -3
- data/lib/aspera/coverage.rb +1 -2
- data/lib/aspera/line_logger.rb +35 -6
- data/lib/aspera/log.rb +3 -2
- data/lib/aspera/oauth/client/base.rb +19 -1
- data/lib/aspera/oauth/client/factory.rb +1 -7
- data/lib/aspera/plugin.schema.yaml +178 -0
- data/lib/aspera/plugins/alee/api.rb +25 -0
- data/lib/aspera/{cli/plugins/alee.rb → plugins/alee/commands.rb} +10 -8
- data/lib/aspera/plugins/alee/plugin.yaml +3 -0
- data/lib/aspera/plugins/aoc/admin_resources.rb +148 -0
- data/lib/aspera/plugins/aoc/api.rb +783 -0
- data/lib/aspera/{cli/plugins/aoc.rb → plugins/aoc/commands.rb} +404 -330
- data/lib/aspera/plugins/aoc/graphql.rb +45 -0
- data/lib/aspera/plugins/aoc/plugin.yaml +31 -0
- data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +15042 -7076
- data/lib/aspera/plugins/aoc/schemas/options.yaml +47 -0
- data/lib/aspera/plugins/ats/api.rb +51 -0
- data/lib/aspera/{cli/plugins/ats.rb → plugins/ats/commands.rb} +33 -33
- data/lib/aspera/plugins/ats/plugin.yaml +6 -0
- data/lib/aspera/plugins/connect/agent.rb +199 -0
- data/lib/aspera/plugins/connect/plugin.yaml +11 -0
- data/lib/aspera/plugins/connect/schemas/agent_options.yaml +6 -0
- data/lib/aspera/{cli/plugins/console.rb → plugins/console/commands.rb} +41 -33
- data/lib/aspera/plugins/console/plugin.yaml +8 -0
- data/lib/aspera/plugins/cos/api.rb +114 -0
- data/lib/aspera/{cli/plugins/cos.rb → plugins/cos/commands.rb} +19 -16
- data/lib/aspera/plugins/cos/plugin.yaml +9 -0
- data/lib/aspera/plugins/cos/schemas/options.yaml +30 -0
- data/lib/aspera/plugins/desktop/agent.rb +165 -0
- data/lib/aspera/plugins/desktop/plugin.yaml +11 -0
- data/lib/aspera/plugins/desktop/schemas/agent_options.yaml +6 -0
- data/lib/aspera/plugins/direct/agent.rb +518 -0
- data/lib/aspera/plugins/direct/plugin.yaml +11 -0
- data/lib/aspera/plugins/direct/schemas/agent_options.yaml +86 -0
- data/lib/aspera/plugins/faspex4/gateway_options.rb +18 -0
- data/lib/aspera/plugins/faspex4/gw_servlet.rb +122 -0
- data/lib/aspera/plugins/faspex4/plugin.yaml +7 -0
- data/lib/aspera/plugins/faspex4/schemas/options.yaml +57 -0
- data/lib/aspera/plugins/faspex5/api.rb +269 -0
- data/lib/aspera/{cli/plugins/faspex5.rb → plugins/faspex5/commands.rb} +152 -114
- data/lib/aspera/plugins/faspex5/faspex4_post_proc_servlet.rb +241 -0
- data/lib/aspera/plugins/faspex5/plugin.yaml +14 -0
- data/lib/aspera/{schema → plugins/faspex5/schemas}/IBM Aspera Faspex API-5.0-enhanced.yaml +279 -76
- data/lib/aspera/plugins/faspex5/schemas/options.yaml +87 -0
- data/lib/aspera/{cli/plugins/faspio.rb → plugins/faspio/commands.rb} +11 -7
- data/lib/aspera/plugins/faspio/plugin.yaml +8 -0
- data/lib/aspera/{schema → plugins/faspio/schemas}/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +4 -2
- data/lib/aspera/plugins/httpgw/agent.rb +126 -0
- data/lib/aspera/plugins/httpgw/api.rb +411 -0
- data/lib/aspera/{cli/plugins/httpgw.rb → plugins/httpgw/commands.rb} +9 -9
- data/lib/aspera/plugins/httpgw/plugin.yaml +12 -0
- data/lib/aspera/plugins/httpgw/schemas/agent_options.yaml +24 -0
- data/lib/aspera/plugins/node/agent.rb +184 -0
- data/lib/aspera/plugins/node/api.rb +699 -0
- data/lib/aspera/{cli/plugins/node.rb → plugins/node/commands.rb} +166 -141
- data/lib/aspera/plugins/node/emulator.rb +774 -0
- data/lib/aspera/plugins/node/plugin.yaml +20 -0
- data/lib/aspera/plugins/node/schemas/agent_options.yaml +20 -0
- data/lib/aspera/plugins/node/schemas/options.yaml +190 -0
- data/lib/aspera/{cli/plugins/orchestrator.rb → plugins/orchestrator/commands.rb} +139 -110
- data/lib/aspera/plugins/orchestrator/plugin.yaml +34 -0
- data/lib/aspera/{schema → plugins/orchestrator/schemas}/IBM Aspera Orchestrator API-v1-enhanced.yaml +486 -16
- data/lib/aspera/plugins/orchestrator/schemas/options.yaml +143 -0
- data/lib/aspera/plugins/orchestrator/workflow_checker.rb +692 -0
- data/lib/aspera/{cli/plugins/preview.rb → plugins/preview/commands.rb} +53 -51
- data/lib/aspera/plugins/preview/file_types.rb +121 -0
- data/lib/aspera/plugins/preview/generator.rb +350 -0
- data/lib/aspera/plugins/preview/plugin.yaml +12 -0
- data/lib/aspera/{preview/options.schema.yaml → plugins/preview/schemas/options.yaml} +1 -1
- data/lib/aspera/plugins/preview/utils.rb +213 -0
- data/lib/aspera/plugins/server/ascmd.rb +374 -0
- data/lib/aspera/{cli/plugins/server.rb → plugins/server/commands.rb} +48 -32
- data/lib/aspera/plugins/server/plugin.yaml +9 -0
- data/lib/aspera/plugins/server/schemas/options.yaml +30 -0
- data/lib/aspera/{cli/plugins/shares.rb → plugins/shares/commands.rb} +29 -21
- data/lib/aspera/plugins/shares/plugin.yaml +10 -0
- data/lib/aspera/plugins/shares/shares_web.rb +97 -0
- data/lib/aspera/plugins/transferd/agent.rb +258 -0
- data/lib/aspera/plugins/transferd/api.rb +180 -0
- data/lib/aspera/plugins/transferd/client.rb +67 -0
- data/lib/aspera/{cli/plugins/transferd.rb → plugins/transferd/commands.rb} +43 -42
- data/lib/aspera/plugins/transferd/config_commands.rb +38 -0
- data/lib/aspera/plugins/transferd/plugin.yaml +27 -0
- data/lib/aspera/plugins/transferd/product.rb +146 -0
- data/lib/aspera/plugins/transferd/schemas/agent_options.yaml +31 -0
- data/lib/aspera/plugins/transferd/schemas/options.yaml +80 -0
- data/lib/aspera/plugins/transferd/service.rb +617 -0
- data/lib/aspera/plugins/xfer/ascp_actions.rb +131 -0
- data/lib/aspera/plugins/xfer/ascp_logs_actions.rb +198 -0
- data/lib/aspera/plugins/xfer/async_transfer_store.rb +131 -0
- data/lib/aspera/plugins/xfer/config_commands.rb +119 -0
- data/lib/aspera/plugins/xfer/helper.rb +19 -0
- data/lib/aspera/plugins/xfer/plugin.yaml +42 -0
- data/lib/aspera/plugins/xfer/schemas/agent_extension.schema.yaml +26 -0
- data/lib/aspera/plugins/xfer/schemas/options.yaml +125 -0
- data/lib/aspera/plugins/xfer/sync_actions.rb +253 -0
- data/lib/aspera/plugins/xfer/transfer_actions.rb +176 -0
- data/lib/aspera/plugins/xfer/transfer_agent.rb +505 -0
- data/lib/aspera/products/cli_v3.rb +34 -0
- data/lib/aspera/products/connect.rb +1 -1
- data/lib/aspera/products/drive.rb +29 -0
- data/lib/aspera/products/hsts.rb +34 -0
- data/lib/aspera/products/transferd.rb +25 -3
- data/lib/aspera/products.rb +54 -0
- data/lib/aspera/prompt.rb +184 -0
- data/lib/aspera/proxy_auto_config.rb +3 -3
- data/lib/aspera/rest/aspera_errors.rb +4 -38
- data/lib/aspera/rest/error_analyzer.rb +6 -2
- data/lib/aspera/rest/list.rb +4 -5
- data/lib/aspera/schema/reader.rb +15 -0
- data/lib/aspera/schema/registry.rb +239 -45
- data/lib/aspera/schema/validator.rb +63 -17
- data/lib/aspera/sealed_hash.rb +4 -0
- data/lib/aspera/secret/hider.rb +159 -24
- data/lib/aspera/secret/reference.rb +8 -0
- data/lib/aspera/secret/resolver.rb +8 -4
- data/lib/aspera/secret/store/base.rb +10 -9
- data/lib/aspera/secret/store/encrypted_hash.rb +6 -6
- data/lib/aspera/secret/store/hashicorp_vault.rb +3 -3
- data/lib/aspera/secret/store/keeper.rb +2 -2
- data/lib/aspera/secret/store/macos_security.rb +2 -3
- data/lib/aspera/secret/store/one_password_api.rb +2 -2
- data/lib/aspera/secret/store/one_password_cli.rb +3 -3
- data/lib/aspera/secret/store/secret_service.rb +2 -2
- data/lib/aspera/ssl.rb +3 -3
- data/lib/aspera/standard_input.rb +20 -0
- data/lib/aspera/{schema → sync}/async_tables.yaml +1 -1
- data/lib/aspera/sync/database.rb +7 -0
- data/lib/aspera/sync/log_parser.rb +138 -0
- data/lib/aspera/sync/operations.rb +59 -34
- data/lib/aspera/transfer/command_line_builder.rb +248 -0
- data/lib/aspera/transfer/command_line_converter.rb +37 -0
- data/lib/aspera/transfer/faux_file.rb +2 -2
- data/lib/aspera/transfer/parameters.rb +9 -10
- data/lib/aspera/transfer/spec.rb +28 -1
- data/lib/aspera/transfer/spec.schema.yaml +30 -5
- data/lib/aspera/units/decimal.rb +1 -1
- data/lib/aspera/units/timestamp.rb +84 -0
- data/lib/aspera/uri_reader.rb +2 -2
- data/lib/aspera/web_auth/paste.rb +2 -2
- data/lib/aspera/web_server_simple.rb +10 -4
- data.tar.gz.sig +0 -0
- metadata +137 -80
- metadata.gz.sig +0 -0
- data/lib/aspera/agent/connect.rb +0 -188
- data/lib/aspera/agent/desktop.rb +0 -154
- data/lib/aspera/agent/direct.rb +0 -496
- data/lib/aspera/agent/httpgw.rb +0 -100
- data/lib/aspera/agent/node.rb +0 -166
- data/lib/aspera/agent/transferd.rb +0 -341
- data/lib/aspera/api/alee.rb +0 -19
- data/lib/aspera/api/aoc.rb +0 -776
- data/lib/aspera/api/ats.rb +0 -49
- data/lib/aspera/api/cos_node.rb +0 -107
- data/lib/aspera/api/faspex.rb +0 -258
- data/lib/aspera/api/httpgw.rb +0 -409
- data/lib/aspera/api/node.rb +0 -684
- data/lib/aspera/ascmd.rb +0 -248
- data/lib/aspera/cli/ascp_actions.rb +0 -113
- data/lib/aspera/cli/ascp_logs_actions.rb +0 -188
- data/lib/aspera/cli/async_transfer_store.rb +0 -129
- data/lib/aspera/cli/command_registry.rb +0 -371
- data/lib/aspera/cli/command_spec.rb +0 -273
- data/lib/aspera/cli/option_declarator.rb +0 -74
- data/lib/aspera/cli/option_registry.rb +0 -72
- data/lib/aspera/cli/option_types.rb +0 -120
- data/lib/aspera/cli/option_value.rb +0 -345
- data/lib/aspera/cli/prompt.rb +0 -186
- data/lib/aspera/cli/sync_actions.rb +0 -181
- data/lib/aspera/cli/transfer_actions.rb +0 -98
- data/lib/aspera/cli/transfer_agent.rb +0 -348
- data/lib/aspera/command_line_builder.rb +0 -244
- data/lib/aspera/command_line_converter.rb +0 -35
- data/lib/aspera/data_repository.rb +0 -69
- data/lib/aspera/faspex_gw.rb +0 -172
- data/lib/aspera/faspex_postproc.rb +0 -237
- data/lib/aspera/graphql.rb +0 -41
- data/lib/aspera/node_emulator.rb +0 -758
- data/lib/aspera/oauth/client/shares_web.rb +0 -94
- data/lib/aspera/orchestrator_workflow_checker.rb +0 -688
- data/lib/aspera/preview/file_types.rb +0 -119
- data/lib/aspera/preview/generator.rb +0 -345
- data/lib/aspera/preview/utils.rb +0 -211
- data/lib/aspera/products/other.rb +0 -92
- data/lib/aspera/products/transferd_service.rb +0 -610
- /data/lib/aspera/{data → ascp/data}/1 +0 -0
- /data/lib/aspera/{data → ascp/data}/2 +0 -0
- /data/lib/aspera/{data → ascp/data}/3 +0 -0
- /data/lib/aspera/{data → ascp/data}/4 +0 -0
- /data/lib/aspera/{data → ascp/data}/5 +0 -0
- /data/lib/aspera/{data → ascp/data}/6 +0 -0
- /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_account.graphql +0 -0
- /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_usage.graphql +0 -0
- /data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +0 -0
- /data/lib/aspera/{schema → plugins/console/schemas}/IBM Aspera Console-enhanced.yaml +0 -0
- /data/lib/aspera/{schema → plugins/node/schemas}/IBM Aspera Node API-4.4.6.yaml +0 -0
- /data/lib/aspera/{preview → plugins/preview}/image_error.png +0 -0
- /data/lib/aspera/{preview → plugins/preview}/video_error.png +0 -0
- /data/lib/aspera/{schema → plugins/shares/schemas}/IBM_Aspera_Shares.yaml +0 -0
- /data/lib/{transferd_pb.rb → aspera/plugins/transferd/grpc/transferd_pb.rb} +0 -0
- /data/lib/{transferd_services_pb.rb → aspera/plugins/transferd/grpc/transferd_services_pb.rb} +0 -0
- /data/lib/aspera/{schema → plugins/transferd/schemas}/transferd-config.schema.json +0 -0
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../agent/factory'
|
|
7
|
+
require_relative '../../bundle_registry'
|
|
8
|
+
require_relative '../../schema/registry'
|
|
9
|
+
require_relative '../../ascp/installation'
|
|
10
|
+
require_relative '../../cli/argument'
|
|
11
|
+
require_relative '../../cli/error'
|
|
12
|
+
require_relative '../../cli/hints'
|
|
13
|
+
require_relative '../../cli/option/declarator'
|
|
14
|
+
require_relative '../../cli/result'
|
|
15
|
+
require_relative '../../cli/version'
|
|
16
|
+
require_relative '../../transfer/error'
|
|
17
|
+
require_relative '../../transfer/parameters'
|
|
18
|
+
require_relative '../../transfer/result'
|
|
19
|
+
require_relative '../../transfer/spec'
|
|
20
|
+
require_relative '../../cli/info'
|
|
21
|
+
require_relative 'async_transfer_store'
|
|
22
|
+
require_relative '../../log'
|
|
23
|
+
require_relative '../../assert'
|
|
24
|
+
require_relative '../../secret/hider'
|
|
25
|
+
require_relative '../../cli/security'
|
|
26
|
+
require 'securerandom'
|
|
27
|
+
|
|
28
|
+
module Aspera
|
|
29
|
+
module Plugins
|
|
30
|
+
module Xfer
|
|
31
|
+
# The Transfer agent is a common interface to start a transfer using
|
|
32
|
+
# one of the supported transfer agents.
|
|
33
|
+
# Provide CLI options to select one of the transfer agents (FASP/ascp client)
|
|
34
|
+
# Service `transfer` of the bundle (manifest `services`): created once per context, see `Cli::Context#service`
|
|
35
|
+
class TransferAgent
|
|
36
|
+
# Plugins store transfer result using this key and use `result_transfer_multiple`
|
|
37
|
+
STATUS_FIELD = 'status'
|
|
38
|
+
# Schema of option `transfer`, in the schemas of the bundle (manifest `schemas`): its variants are the agents (extension point `agent`)
|
|
39
|
+
TRANSFER_OPTION_SCHEMA = 'transfer_opts:components.schemas.TransferAgentOptions'
|
|
40
|
+
# `@args` special value for --sources : read file list from arguments
|
|
41
|
+
FILE_LIST_FROM_ARGS = '@args'
|
|
42
|
+
# `@ts` special value for --sources : read file list from transfer spec (--ts)
|
|
43
|
+
FILE_LIST_FROM_TRANSFER_SPEC = '@ts'
|
|
44
|
+
FILE_LIST_OPTIONS = [FILE_LIST_FROM_ARGS, FILE_LIST_FROM_TRANSFER_SPEC, 'Array'].freeze
|
|
45
|
+
DEFAULT_TRANSFER_NOTIFY_TEMPLATE = <<~END_OF_TEMPLATE
|
|
46
|
+
From: <%=from_name%> <<%=from_email%>>
|
|
47
|
+
To: <<%=to%>>
|
|
48
|
+
Subject: <%=subject%>
|
|
49
|
+
|
|
50
|
+
Transfer is: <%=status%>
|
|
51
|
+
|
|
52
|
+
<%=ts.to_yaml%>
|
|
53
|
+
END_OF_TEMPLATE
|
|
54
|
+
CP4I_REMOTE_HOST_LB = 'N/A'
|
|
55
|
+
# Folder of the configuration folder for file lists used by transfers
|
|
56
|
+
FILE_LIST_FOLDER_NAME = 'filelists'
|
|
57
|
+
# Transfer spec parameters overridden by option `ts`
|
|
58
|
+
TS_DEFAULTS = {
|
|
59
|
+
'create_dir' => true,
|
|
60
|
+
'resume_policy' => 'sparse_csum'
|
|
61
|
+
}.freeze
|
|
62
|
+
private_constant :FILE_LIST_FROM_TRANSFER_SPEC,
|
|
63
|
+
:FILE_LIST_OPTIONS,
|
|
64
|
+
:DEFAULT_TRANSFER_NOTIFY_TEMPLATE,
|
|
65
|
+
:FILE_LIST_FOLDER_NAME,
|
|
66
|
+
:TS_DEFAULTS
|
|
67
|
+
|
|
68
|
+
extend Cli::Option::Declarator
|
|
69
|
+
|
|
70
|
+
option :ts, description: 'Override transfer spec values', schema: Schema::Registry::TRANSFER_SPEC, on_set: :user_transfer_spec=
|
|
71
|
+
option :to_folder, description: 'Destination folder for transferred files', complete: :destination_folder
|
|
72
|
+
option :sources, description: "How list of transferred files is provided (#{FILE_LIST_OPTIONS.join(',')})", default: FILE_LIST_FROM_ARGS
|
|
73
|
+
option :src_type, description: 'Type of file list', allowed: %i[list pair], default: :list
|
|
74
|
+
option :transfer, description: 'Transfer agent type, or agent parameters with optional agent key', allowed: [Hash, String], shorthand: 'agent', schema: TRANSFER_OPTION_SCHEMA
|
|
75
|
+
option :transfer_info, description: 'Parameters for transfer agent', deprecation: {last: '4.26.2', message: 'use --transfer instead'}, schema: TRANSFER_OPTION_SCHEMA
|
|
76
|
+
|
|
77
|
+
class << self
|
|
78
|
+
# Process the typed result of a finished (or submitted) transfer.
|
|
79
|
+
# @param transfer_result [Aspera::Transfer::Result] typed result from `start`
|
|
80
|
+
# @raise [StandardError] if the transfer failed
|
|
81
|
+
# @return [Cli::Result] CLI result object
|
|
82
|
+
def result_transfer(transfer_result)
|
|
83
|
+
case transfer_result
|
|
84
|
+
when Aspera::Transfer::Result::Async
|
|
85
|
+
return Cli::Result::SingleObject.new(transfer_result.to_h)
|
|
86
|
+
when Aspera::Transfer::Result::Error
|
|
87
|
+
raise transfer_result.exception
|
|
88
|
+
when Aspera::Transfer::Result::Success
|
|
89
|
+
return Cli::Result::Nothing.new
|
|
90
|
+
when Aspera::Transfer::Result::DryRun
|
|
91
|
+
# Secrets are hidden by the formatter, as in any result
|
|
92
|
+
return Cli::Result::SingleObject.new(transfer_result.transfer_spec)
|
|
93
|
+
else
|
|
94
|
+
raise "Unexpected transfer result type: #{transfer_result.class}"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Result of a command that creates an object and transfers its files, e.g. `packages send`.
|
|
99
|
+
# @param object [Hash] Created object
|
|
100
|
+
# @param transfer_result [Aspera::Transfer::Result] Typed result from `start`
|
|
101
|
+
# @raise [StandardError] if the transfer failed
|
|
102
|
+
# @return [Cli::Result::SingleObject] The object, with field `transfer` (`job_id`) if the transfer is asynchronous
|
|
103
|
+
def result_object_transfer(object, transfer_result)
|
|
104
|
+
status = result_transfer(transfer_result)
|
|
105
|
+
object = object.merge('transfer' => status.data) if status.is_a?(Cli::Result::SingleObject)
|
|
106
|
+
Cli::Result::SingleObject.new(object)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Used when one command executes several transfer jobs (each job being possibly multi session)
|
|
110
|
+
# @param status_table [Array] [{STATUS_FIELD=>Aspera::Transfer::Result,...},...]
|
|
111
|
+
# @return [Cli::Result] a status object suitable as command result
|
|
112
|
+
def result_transfer_multiple(status_table)
|
|
113
|
+
failed_result = nil
|
|
114
|
+
status_table.each do |item|
|
|
115
|
+
tr = item[STATUS_FIELD]
|
|
116
|
+
case tr
|
|
117
|
+
when Aspera::Transfer::Result::Error
|
|
118
|
+
failed_result ||= tr
|
|
119
|
+
item[STATUS_FIELD] = tr.exception.message
|
|
120
|
+
when Aspera::Transfer::Result::Success
|
|
121
|
+
item[STATUS_FIELD] = 'success'
|
|
122
|
+
when Aspera::Transfer::Result::Async
|
|
123
|
+
item[STATUS_FIELD] = "async:#{tr.job_id}"
|
|
124
|
+
when Aspera::Transfer::Result::DryRun
|
|
125
|
+
item[STATUS_FIELD] = 'dry_run'
|
|
126
|
+
else
|
|
127
|
+
item[STATUS_FIELD] = tr.to_s
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
raise failed_result.exception unless failed_result.nil?
|
|
131
|
+
return Cli::Result::ObjectList.new(status_table)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# @param context [Cli::Context] Application context
|
|
136
|
+
def initialize(context)
|
|
137
|
+
Aspera.assert_type(context, Cli::Context) { 'context' }
|
|
138
|
+
Aspera.assert_type(context.options, Cli::Parser) { 'context.options' }
|
|
139
|
+
@context = context
|
|
140
|
+
# Runtime of transfers: SDK downloads refer to the version of the gem, file lists are in the configuration folder (if any, else a temporary folder)
|
|
141
|
+
Ascp::Installation.instance.referer_url = "#{Cli::Info::GEM_URL}/versions/#{Cli::VERSION}"
|
|
142
|
+
Aspera::Transfer::Parameters.file_list_folder = File.join(@context.main_folder, FILE_LIST_FOLDER_NAME) unless @context.main_folder.nil?
|
|
143
|
+
# Command line can override transfer spec
|
|
144
|
+
@user_transfer_spec = TS_DEFAULTS.dup
|
|
145
|
+
# the currently selected transfer agent
|
|
146
|
+
@agent = nil
|
|
147
|
+
# source/destination pair, like "paths" of transfer spec
|
|
148
|
+
@transfer_paths = nil
|
|
149
|
+
# HTTPGW URL provided by webapp
|
|
150
|
+
@httpgw_url_lambda = nil
|
|
151
|
+
# Instance variables used by `on_set` callbacks are set above
|
|
152
|
+
self.class.declare_options(@context.options, target: self)
|
|
153
|
+
@context.options.parse_options!
|
|
154
|
+
@notification_cb = nil
|
|
155
|
+
if !@context.options.get_option(:notify_to).nil?
|
|
156
|
+
@notification_cb = ->(transfer_spec, global_status) do
|
|
157
|
+
@context.mailer.send_email_template(email_template_default: DEFAULT_TRANSFER_NOTIFY_TEMPLATE, values: {
|
|
158
|
+
subject: "#{Cli::Info::CMD_NAME} transfer: #{global_status}",
|
|
159
|
+
status: global_status,
|
|
160
|
+
ts: transfer_spec
|
|
161
|
+
})
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
attr_reader :user_transfer_spec
|
|
167
|
+
|
|
168
|
+
# Argument shown in the help of a command with `transfer_paths`: the files are read by `ts_source_paths`
|
|
169
|
+
# @param direction [Symbol] `:send` (files to upload) or `:receive` (remote paths to download)
|
|
170
|
+
# @return [Cli::Argument] Description of the list of files, depending on option `sources`
|
|
171
|
+
def paths_argument(direction)
|
|
172
|
+
description =
|
|
173
|
+
case direction
|
|
174
|
+
when :receive then "Remote path(s) to download (default --sources=#{FILE_LIST_FROM_ARGS}; see also --to-folder)"
|
|
175
|
+
when :send then "Source file(s) to upload (default --sources=#{FILE_LIST_FROM_ARGS}; see also --src-type, --to-folder)"
|
|
176
|
+
else Aspera.error_unexpected_value(direction) { 'transfer_paths' }
|
|
177
|
+
end
|
|
178
|
+
Cli::Argument.new(name: :source_file, description: description, mandatory: false, multiple: true)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# `on_set` callback of option `ts`: values override defaults
|
|
182
|
+
# @param value [Hash] transfer spec parameters
|
|
183
|
+
def user_transfer_spec=(value)
|
|
184
|
+
@user_transfer_spec = TS_DEFAULTS.merge(value)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# @return [Hash] agent type (key `agent`) and agent parameters, from options `transfer` and deprecated `transfer_info`
|
|
188
|
+
def transfer_options
|
|
189
|
+
result = @context.options.get_option(:transfer_info).deep_merge(@context.options.get_option(:transfer))
|
|
190
|
+
# e.g. the `url` of agent `node` from one option, its `password` from the other
|
|
191
|
+
Cli::Security.instance.check_credentials_in(result, what: 'option transfer')
|
|
192
|
+
result
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Options to create the `direct` agent that runs the local `async` program for a `sync` command.
|
|
196
|
+
# `sync` always uses the `direct` agent, whatever the `agent` key of option `transfer`, so the parameters of
|
|
197
|
+
# `transfer` (and the deprecated `transfer_info`) are forwarded only when they are those of the `direct` agent
|
|
198
|
+
# (its default); parameters meant for another agent (e.g. the `url` of `node`) are ignored. For `async`, `quiet`
|
|
199
|
+
# and `spawn_timeout_sec` have an effect; the `ascp`-only parameters (e.g. `ascp_args`, `wss`, `resume`) do not.
|
|
200
|
+
# The base options (e.g. `progress`, `config_dir`) are always given, as for any agent.
|
|
201
|
+
# @return [Hash] options for `Aspera::Agent::Factory.create(:direct, ...)`
|
|
202
|
+
def sync_agent_options
|
|
203
|
+
raw_type = transfer_options['agent']
|
|
204
|
+
agent_options = raw_type.nil? || raw_type.to_s.eql?('direct') ? transfer_options.except('agent', 'asynchronous').symbolize_keys : {}
|
|
205
|
+
agent_options[:trusted_certs] = @context.http_config.trusted_cert_locations unless agent_options.key?(:trusted_certs)
|
|
206
|
+
agent_options.merge(base_agent_options)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def agent_instance=(instance)
|
|
210
|
+
@agent = instance
|
|
211
|
+
# Name of the agent is found from the instance when needed, see `agent_name`
|
|
212
|
+
@agent_type = nil
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# @return [String] Name of the agent in use (resolved name, not an abbreviation of option `transfer`), also if the instance was given
|
|
216
|
+
def agent_name
|
|
217
|
+
@agent_type ||= Aspera::Agent::Factory.instance.agent_name(agent_instance)&.to_s
|
|
218
|
+
Aspera.assert(@agent_type) { "unknown agent class: #{agent_instance.class}" }
|
|
219
|
+
@agent_type
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# analyze options and create new agent if not already created or set
|
|
223
|
+
def agent_instance
|
|
224
|
+
return @agent unless @agent.nil?
|
|
225
|
+
# agent type: from composite option 'agent' key, default :direct
|
|
226
|
+
raw_type = transfer_options['agent'] || :direct
|
|
227
|
+
# An agent of an unavailable bundle is given as is: creating it tells why it is unavailable
|
|
228
|
+
agent_type = Aspera::Agent::Factory.instance.unavailable_reason(raw_type).nil? ? Cli::Parser.get_from_list(raw_type.to_s, 'transfer agent', Aspera::Agent::Factory::ALL.keys) : raw_type.to_s
|
|
229
|
+
# set keys as symbols, strip internal keys not forwarded to the agent constructor
|
|
230
|
+
agent_options = transfer_options.except('agent', 'asynchronous').symbolize_keys
|
|
231
|
+
# get agent instance
|
|
232
|
+
begin
|
|
233
|
+
agent_class = Aspera::Agent::Factory.instance.agent_class(agent_type)
|
|
234
|
+
# A transfer agent that runs on the local host (local `ascp`, a local daemon, a local application) is refused at level `high`:
|
|
235
|
+
# at `high`, transfers use a remote agent (e.g. `node`, or `transferd` attached to a remote daemon) that the user controls.
|
|
236
|
+
# Checked before the base options are built: the decision needs only the agent parameters (e.g. the daemon `url`).
|
|
237
|
+
unless Cli::Security.instance.allowed?(agent_class.required_security_level(agent_options))
|
|
238
|
+
raise Cli::BadArgument,
|
|
239
|
+
"transfer agent #{agent_type}: runs on the local host, disabled by security level #{Cli::Security.instance.level}. " \
|
|
240
|
+
'Use a remote agent (--transfer.agent=node, or --transfer.agent=transferd with a url to a remote daemon), or a lower security level'
|
|
241
|
+
end
|
|
242
|
+
# Same base options for every agent, each agent uses those it needs (see `Aspera::Agent::Base#initialize`)
|
|
243
|
+
# JRuby: given value, else trusted certificates of the HTTP configuration
|
|
244
|
+
agent_options[:trusted_certs] = @context.http_config.trusted_cert_locations unless agent_options.key?(:trusted_certs)
|
|
245
|
+
agent_options.merge!(base_agent_options)
|
|
246
|
+
self.agent_instance = Aspera::Agent::Factory.instance.create(agent_type, agent_options)
|
|
247
|
+
@agent_type = agent_type.to_s
|
|
248
|
+
rescue BundleRegistry::Unavailable => e
|
|
249
|
+
# Agent of a bundle that cannot be loaded (e.g. missing gem): same error as an unavailable plugin
|
|
250
|
+
raise Cli::Error, e.message
|
|
251
|
+
end
|
|
252
|
+
Log.log.debug { "transfer agent is a #{@agent.class}" }
|
|
253
|
+
return @agent
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Get destination folder
|
|
257
|
+
# @param direction [String] `send`` or `receive``
|
|
258
|
+
# @return [String] Destination folder for transfers (with default based on direction)
|
|
259
|
+
def destination_folder(direction)
|
|
260
|
+
dest_folder = @context.options.get_option(:to_folder)
|
|
261
|
+
# do not expand path, if user wants to expand path: user @path:
|
|
262
|
+
return dest_folder unless dest_folder.nil?
|
|
263
|
+
dest_folder = @user_transfer_spec['destination_root']
|
|
264
|
+
return dest_folder unless dest_folder.nil?
|
|
265
|
+
# default: / on remote, . on local
|
|
266
|
+
case direction.to_s
|
|
267
|
+
when Aspera::Transfer::Spec::DIRECTION_SEND then dest_folder = '/'
|
|
268
|
+
when Aspera::Transfer::Spec::DIRECTION_RECEIVE then dest_folder = '.'
|
|
269
|
+
else Aspera.error_unexpected_value(direction)
|
|
270
|
+
end
|
|
271
|
+
return dest_folder
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# @return [Array] list of source files
|
|
275
|
+
def source_list
|
|
276
|
+
return ts_source_paths.map do |i|
|
|
277
|
+
i['source']
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# @param httpgw_url_proc [Proc]
|
|
282
|
+
def httpgw_url_cb=(httpgw_url_proc)
|
|
283
|
+
Aspera.assert_type(httpgw_url_proc, Proc) { 'httpgw_url_cb' }
|
|
284
|
+
@httpgw_url_lambda = httpgw_url_proc
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Transform the list of paths to a list of hash with source/dest
|
|
288
|
+
# @param file_list [Array<Hash>]
|
|
289
|
+
def list_to_paths(file_list)
|
|
290
|
+
source_type = @context.options.get_option(:src_type, mandatory: true)
|
|
291
|
+
@transfer_paths =
|
|
292
|
+
case source_type
|
|
293
|
+
when :list
|
|
294
|
+
# when providing a list, just specify source
|
|
295
|
+
file_list.map { |i| {'source' => i} }
|
|
296
|
+
when :pair
|
|
297
|
+
Aspera.assert(file_list.length.even?, type: Cli::BadArgument) { "When using pair, provide an even number of paths: #{file_list.length}" }
|
|
298
|
+
file_list.each_slice(2).map { |s, d| {'source' => s, 'destination' => d} }
|
|
299
|
+
else Aspera.error_unexpected_value(source_type)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# This is how the list of files to be transferred is specified
|
|
304
|
+
# get paths suitable for transfer spec from command line
|
|
305
|
+
# computation is done only once, cache is kept in @transfer_paths
|
|
306
|
+
# @param default [nil, Array<String>] If set, used as default file for --sources=@args
|
|
307
|
+
# @return [Array, nil] of Hash {source: (mandatory), destination: (optional)}
|
|
308
|
+
def ts_source_paths(default: nil)
|
|
309
|
+
# return cache if set
|
|
310
|
+
return @transfer_paths unless @transfer_paths.nil?
|
|
311
|
+
# start with lower priority : get paths from transfer spec on command line
|
|
312
|
+
@transfer_paths = @user_transfer_spec['paths'] if @user_transfer_spec.key?('paths')
|
|
313
|
+
# is there a source list option ?
|
|
314
|
+
sources = @context.options.get_option(:sources)
|
|
315
|
+
@transfer_paths =
|
|
316
|
+
case sources
|
|
317
|
+
when FILE_LIST_FROM_ARGS
|
|
318
|
+
Log.log.debug('getting file list as parameters')
|
|
319
|
+
Aspera.assert_type(default, Array, NilClass)
|
|
320
|
+
# get remaining arguments
|
|
321
|
+
list = @context.options.get_next_argument('source file list', multiple: true, default: default)
|
|
322
|
+
raise Cli::BadArgument, 'specify at least one file on command line or use ' \
|
|
323
|
+
"--sources=#{FILE_LIST_FROM_TRANSFER_SPEC} to use transfer spec" if !list.is_a?(Array) || list.empty?
|
|
324
|
+
list_to_paths(list)
|
|
325
|
+
when FILE_LIST_FROM_TRANSFER_SPEC
|
|
326
|
+
Log.log.debug('assume list provided in transfer spec')
|
|
327
|
+
special_case_direct_with_list =
|
|
328
|
+
(transfer_options['agent'] || :direct).to_sym.eql?(:direct) &&
|
|
329
|
+
Aspera::Transfer::Parameters.ascp_args_file_list?(transfer_options['ascp_args'])
|
|
330
|
+
Aspera.assert(!@transfer_paths.nil? || special_case_direct_with_list, type: Cli::BadArgument) { 'transfer spec on command line must have sources' }
|
|
331
|
+
# can be nil
|
|
332
|
+
@transfer_paths
|
|
333
|
+
when Array
|
|
334
|
+
Log.log.debug('getting file list as extended value')
|
|
335
|
+
Aspera.assert_array_all(sources, String, type: Cli::BadArgument) { 'sources must be a Array of String' }
|
|
336
|
+
list_to_paths(sources)
|
|
337
|
+
else Aspera.error_unexpected_value(sources) { 'sources' }
|
|
338
|
+
end
|
|
339
|
+
Log.dump(:paths, @transfer_paths)
|
|
340
|
+
return @transfer_paths
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Start a transfer and wait for completion, plugins shall use this method
|
|
344
|
+
# @param transfer_spec [Hash] transfer specification
|
|
345
|
+
# @param oauth_api [Rest::Client, nil] API whose OAuth token renews the bearer token of the transfer, if rejected
|
|
346
|
+
def start(transfer_spec, oauth_api: nil)
|
|
347
|
+
# check parameters
|
|
348
|
+
Aspera.assert_type(transfer_spec, Hash) { 'transfer_spec' }
|
|
349
|
+
raise "Wrong remote host: #{CP4I_REMOTE_HOST_LB}" if transfer_spec['remote_host'].eql?(CP4I_REMOTE_HOST_LB)
|
|
350
|
+
# process :src option
|
|
351
|
+
case transfer_spec['direction']
|
|
352
|
+
when Aspera::Transfer::Spec::DIRECTION_RECEIVE
|
|
353
|
+
# init default if required in any case
|
|
354
|
+
@user_transfer_spec['destination_root'] ||= destination_folder(transfer_spec['direction'])
|
|
355
|
+
when Aspera::Transfer::Spec::DIRECTION_SEND
|
|
356
|
+
if transfer_spec.dig('tags', Aspera::Transfer::Spec::TAG_RESERVED, 'node', 'access_key')
|
|
357
|
+
# gen4
|
|
358
|
+
@user_transfer_spec.delete('destination_root') if @user_transfer_spec.key?('destination_root_id')
|
|
359
|
+
elsif transfer_spec.key?('token')
|
|
360
|
+
# gen3
|
|
361
|
+
# in that case, destination is set in return by application (API/upload_setup)
|
|
362
|
+
# but to_folder was used in initial API call
|
|
363
|
+
@user_transfer_spec.delete('destination_root')
|
|
364
|
+
else
|
|
365
|
+
# init default if required
|
|
366
|
+
@user_transfer_spec['destination_root'] ||= destination_folder(transfer_spec['direction'])
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
# update command line paths, unless destination already has one
|
|
370
|
+
@user_transfer_spec['paths'] = transfer_spec['paths'] || ts_source_paths
|
|
371
|
+
# updated transfer spec with command line
|
|
372
|
+
application_host = transfer_spec['remote_host']
|
|
373
|
+
transfer_spec.deep_merge!(@user_transfer_spec)
|
|
374
|
+
# The credentials of the transfer spec of the command are for its host
|
|
375
|
+
Cli::Security.instance.check_transfer_host(transfer_spec, @user_transfer_spec, application_host: application_host)
|
|
376
|
+
# Files are written where the client chooses, see Security: only for an agent that writes on the local system
|
|
377
|
+
receives_locally = transfer_spec['direction'].eql?(Aspera::Transfer::Spec::DIRECTION_RECEIVE) && agent_instance.local_destination?
|
|
378
|
+
transfer_spec['destination_root'] = Cli::Security.instance.writable_path(transfer_spec['destination_root']) if receives_locally && transfer_spec['destination_root']
|
|
379
|
+
# resolve pseudo-parameter: target_rate -> target_rate_kbps (overrides target_rate_kbps if both are present)
|
|
380
|
+
Aspera::Transfer::Spec.resolve_target_rate(transfer_spec)
|
|
381
|
+
Aspera::Transfer::Spec.stringify_exclude_times(transfer_spec)
|
|
382
|
+
# recursively remove values that are nil (user wants to delete)
|
|
383
|
+
transfer_spec.deep_do { |hash, key, value, _unused| hash.delete(key) if value.nil? }
|
|
384
|
+
# if TS from app has content_protection (e.g. F5), that means content is protected: ask password if not provided
|
|
385
|
+
transfer_spec['content_protection_password'] = @context.options.prompt_user_input('content protection password', sensitive: true) if transfer_spec['content_protection'].eql?('decrypt') && !transfer_spec.key?('content_protection_password')
|
|
386
|
+
# Secrets of transfer spec (e.g. `token` from the application) are hidden wherever they appear (logs, results)
|
|
387
|
+
Secret::Hider.instance.add_secrets_in(transfer_spec)
|
|
388
|
+
# Option `dry_run`: no transfer, the final transfer spec is the result
|
|
389
|
+
return Aspera::Transfer::Result.dry_run(transfer_spec) if dry_run?
|
|
390
|
+
# Renews the bearer token of the transfer: only possible with OAuth
|
|
391
|
+
token_regenerator = -> { oauth_api.oauth.renewed_authorization } if oauth_api&.auth_params&.fetch(:type, nil).eql?(:oauth2)
|
|
392
|
+
# create transfer agent
|
|
393
|
+
agent_instance.start_transfer(transfer_spec, token_regenerator: token_regenerator)
|
|
394
|
+
# --- async mode ---
|
|
395
|
+
if transfer_options['asynchronous']
|
|
396
|
+
# In-process agents (direct, httpgw) expose last_job_id directly.
|
|
397
|
+
# Remote-daemon agents do not override last_job_id (returns nil): generate a UUID.
|
|
398
|
+
agent_type = agent_name
|
|
399
|
+
job_id = agent_instance.last_job_id || SecureRandom.uuid
|
|
400
|
+
# Base agent_params from transfer options (strip internal keys), and connection details resolved by the agent (daemon agents)
|
|
401
|
+
agent_params = transfer_options.except('agent', 'asynchronous').merge(agent_instance.async_params)
|
|
402
|
+
# Register an in-process agent reference for direct/httpgw agents so that
|
|
403
|
+
# config transfer status can re-query them while the same process is alive
|
|
404
|
+
# (e.g. MCP server mode). The ref is stored in AsyncTransferStore's memory map,
|
|
405
|
+
# never on disk.
|
|
406
|
+
async_store.register_agent_ref(job_id, agent_instance) if agent_instance.in_process?
|
|
407
|
+
async_store.write(job_id, {
|
|
408
|
+
'job_id' => job_id,
|
|
409
|
+
'agent_type' => agent_type,
|
|
410
|
+
'transfer_id' => agent_instance.transfer_id.to_s,
|
|
411
|
+
'agent_params' => agent_params,
|
|
412
|
+
'status' => 'running',
|
|
413
|
+
'bytes_transferred' => 0,
|
|
414
|
+
'started_at' => Time.now.utc.iso8601,
|
|
415
|
+
'ended_at' => nil,
|
|
416
|
+
'error' => nil
|
|
417
|
+
})
|
|
418
|
+
# The result gives the job_id and status
|
|
419
|
+
Log.log.debug { "Async transfer started: job_id=#{job_id}, agent=#{agent_type}" }
|
|
420
|
+
return Aspera::Transfer::Result.async(job_id: job_id)
|
|
421
|
+
end
|
|
422
|
+
# --- synchronous mode (default) ---
|
|
423
|
+
result = agent_instance.wait_for_completion
|
|
424
|
+
@notification_cb&.call(transfer_spec, result)
|
|
425
|
+
return result
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# @return [Boolean] `true` if option `dry_run` is set: transfers are not started (see `start`)
|
|
429
|
+
def dry_run?
|
|
430
|
+
@context.options.get_option(:dry_run)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
# For a command that changes something before its transfer (e.g. creates a package), or that does not transfer with `start`:
|
|
434
|
+
# fail before any change with option `dry_run`
|
|
435
|
+
# @raise [Cli::BadArgument] if option `dry_run` is set
|
|
436
|
+
def assert_no_dry_run
|
|
437
|
+
Aspera.assert(!dry_run?, type: Cli::BadArgument) { 'Option dry_run is not supported by this command' }
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
# shut down if agent requires it
|
|
441
|
+
def shutdown
|
|
442
|
+
@agent.shutdown if @agent.respond_to?(:shutdown)
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
# Lazy accessor for the async transfer store (shared with TransferActions via context.transfer).
|
|
446
|
+
def async_store
|
|
447
|
+
@async_store ||= AsyncTransferStore.new(@context.persistency)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
private
|
|
451
|
+
|
|
452
|
+
# Base options given to every agent: plain values and callable objects (Proc), see `Aspera::Agent::Base#initialize`
|
|
453
|
+
# @return [Hash] base options
|
|
454
|
+
def base_agent_options
|
|
455
|
+
{
|
|
456
|
+
progress: @context.progress_bar,
|
|
457
|
+
# Option `progress_bar` not set: an agent that displays its own progress (direct, not `quiet`) does not use it
|
|
458
|
+
progress_default: @context.options.option_def(:progress_bar).source.eql?(:default),
|
|
459
|
+
config_dir: @context.main_folder,
|
|
460
|
+
check_ignore_cb: ->(host, port) { @context.http_config.ignore_cert?(host, port) },
|
|
461
|
+
# Values of the default preset of a plugin (e.g. node agent without `url`)
|
|
462
|
+
preset_lookup: ->(plugin) do
|
|
463
|
+
param_set_name = @context.presets.plugin_default_name(plugin)
|
|
464
|
+
Aspera.assert(!param_set_name.nil?, type: Cli::BadArgument) { "No default #{plugin} configured. Please specify #{Cli::Parser.option_name_to_line(:transfer)}.url or #{Cli::Parser.option_name_to_line(:transfer)}" }
|
|
465
|
+
@context.presets.by_name(param_set_name)
|
|
466
|
+
end,
|
|
467
|
+
# URL given by the web application (httpgw agent without `url`)
|
|
468
|
+
url_provider: @httpgw_url_lambda
|
|
469
|
+
}
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
# A failed transfer exits with its own code
|
|
473
|
+
Cli::ExitCode.add_error(Aspera::Transfer::Error, label: 'Transfer', code: Cli::ExitCode::TRANSFER)
|
|
474
|
+
Cli::Hints.add(
|
|
475
|
+
exception: Aspera::Transfer::Error,
|
|
476
|
+
match: 'Remote host is not who we expected',
|
|
477
|
+
remediation: [
|
|
478
|
+
'For this specific error, refer to:',
|
|
479
|
+
"#{Cli::Info::SRC_URL}#error-remote-host-is-not-who-we-expected",
|
|
480
|
+
'Add this to arguments:',
|
|
481
|
+
%q{--ts=@json:'{"sshfp":null}'"}
|
|
482
|
+
]
|
|
483
|
+
)
|
|
484
|
+
Cli::Hints.add(
|
|
485
|
+
exception: RuntimeError,
|
|
486
|
+
match: /unexpected last event type: INIT/,
|
|
487
|
+
remediation: [
|
|
488
|
+
'ascp exited unexpectedly',
|
|
489
|
+
'it might be due to SSH handshake failure',
|
|
490
|
+
'one can check SSH connection using ssh command'
|
|
491
|
+
]
|
|
492
|
+
)
|
|
493
|
+
# Raised by `TransferAgent#start`
|
|
494
|
+
Cli::Hints.add(
|
|
495
|
+
exception: RuntimeError,
|
|
496
|
+
match: /Wrong remote host:/,
|
|
497
|
+
remediation: [
|
|
498
|
+
'If remote node is Cloud Pak For Integration',
|
|
499
|
+
'Make sure that a LoadBalancer is active on cluster',
|
|
500
|
+
'Check the external address of Aspera tcp-proxy Pod'
|
|
501
|
+
]
|
|
502
|
+
)
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../environment'
|
|
7
|
+
|
|
8
|
+
module Aspera
|
|
9
|
+
module Products
|
|
10
|
+
# Aspera CLI version 3 (deprecated)
|
|
11
|
+
class CliV3
|
|
12
|
+
APP_NAME = 'Aspera CLI (deprecated)'
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# standard folder locations
|
|
16
|
+
def locations
|
|
17
|
+
case Aspera::Environment.instance.os
|
|
18
|
+
when Aspera::Environment::OS_WINDOWS then [{
|
|
19
|
+
app_root: File.join('C:', 'Program Files', 'Aspera', 'cli'),
|
|
20
|
+
log_root: File.join('C:', 'Program Files', 'Aspera', 'cli', 'var', 'log')
|
|
21
|
+
}]
|
|
22
|
+
when Aspera::Environment::OS_MACOS then [{
|
|
23
|
+
app_root: File.join(Dir.home, 'Applications', 'Aspera CLI'),
|
|
24
|
+
log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera')
|
|
25
|
+
}]
|
|
26
|
+
else [{ # other: Linux and Unix family
|
|
27
|
+
app_root: File.join(Dir.home, '.aspera', 'cli')
|
|
28
|
+
}]
|
|
29
|
+
end.map { |i| {expected: APP_NAME}.merge(i) }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -68,7 +68,7 @@ module Aspera
|
|
|
68
68
|
Log.dump(:javascript, connect_versions_javascript)
|
|
69
69
|
# get javascript object only
|
|
70
70
|
found = connect_versions_javascript.match(/^.*? = (.*);/)
|
|
71
|
-
Aspera.assert(!found.nil?, type:
|
|
71
|
+
Aspera.assert(!found.nil?, type: Aspera::Error) { 'Problem when getting connect versions from internet' }
|
|
72
72
|
all_data = JSON.parse(found[1])
|
|
73
73
|
@connect_versions = all_data['entries']
|
|
74
74
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../environment'
|
|
7
|
+
|
|
8
|
+
module Aspera
|
|
9
|
+
module Products
|
|
10
|
+
# Aspera Drive (deprecated), macOS only
|
|
11
|
+
class Drive
|
|
12
|
+
APP_NAME = 'Aspera Drive (deprecated)'
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# standard folder locations, empty if the product does not exist on this OS
|
|
16
|
+
def locations
|
|
17
|
+
case Aspera::Environment.instance.os
|
|
18
|
+
when Aspera::Environment::OS_MACOS then [{
|
|
19
|
+
app_root: File.join('', 'Applications', 'Aspera Drive.app'),
|
|
20
|
+
log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera_Drive'),
|
|
21
|
+
sub_bin: File.join('Contents', 'Resources')
|
|
22
|
+
}]
|
|
23
|
+
else []
|
|
24
|
+
end.map { |i| {expected: APP_NAME}.merge(i) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../environment'
|
|
7
|
+
|
|
8
|
+
module Aspera
|
|
9
|
+
module Products
|
|
10
|
+
# IBM Aspera High-Speed Transfer Server
|
|
11
|
+
class Hsts
|
|
12
|
+
APP_NAME = 'IBM Aspera High-Speed Transfer Server'
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# standard folder locations
|
|
16
|
+
def locations
|
|
17
|
+
case Aspera::Environment.instance.os
|
|
18
|
+
when Aspera::Environment::OS_WINDOWS then [{
|
|
19
|
+
app_root: File.join('C:', 'Program Files', 'Aspera', 'Enterprise Server'),
|
|
20
|
+
log_root: File.join('C:', 'Program Files', 'Aspera', 'Enterprise Server', 'var', 'log')
|
|
21
|
+
}]
|
|
22
|
+
when Aspera::Environment::OS_MACOS then [{
|
|
23
|
+
app_root: File.join('', 'Library', 'Aspera'),
|
|
24
|
+
log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera')
|
|
25
|
+
}]
|
|
26
|
+
else [{ # other: Linux and Unix family
|
|
27
|
+
app_root: File.join('', 'opt', 'aspera')
|
|
28
|
+
}]
|
|
29
|
+
end.map { |i| {expected: APP_NAME}.merge(i) }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -15,6 +15,10 @@ module Aspera
|
|
|
15
15
|
V2_DAEMON_NAME = 'transferd'
|
|
16
16
|
# folders to extract from SDK archive
|
|
17
17
|
RUNTIME_FOLDERS = %w[bin lib sbin aspera].freeze
|
|
18
|
+
# Configuration file of the service installed by `transferd service install`, also the default of the daemon
|
|
19
|
+
SERVICE_CONFIG_FILE = '/etc/transferd/transferd.json'
|
|
20
|
+
# Files `<name>.<port>.optport` where the daemon started with port zero writes its port, in its `runtime_dir` (from 1.1.7)
|
|
21
|
+
PORT_FILE_PATTERN = '*.optport'
|
|
18
22
|
class << self
|
|
19
23
|
# standard folder locations
|
|
20
24
|
def locations
|
|
@@ -43,7 +47,26 @@ module Aspera
|
|
|
43
47
|
return File.join(sdk_directory, Environment.instance.exe_file(V2_DAEMON_NAME))
|
|
44
48
|
end
|
|
45
49
|
|
|
46
|
-
#
|
|
50
|
+
# Port of a daemon started locally with port zero, from the file it writes in its `runtime_dir` once it listens (from 1.1.7)
|
|
51
|
+
# @param runtime_dir [String] Folder `runtime_dir` of the daemon, used by this daemon only
|
|
52
|
+
# @return [Integer, nil] Port of the file, `nil`: no file (version before 1.1.7, or not listening yet), or file being written (empty)
|
|
53
|
+
# @raise [AssertError] The file has no port, or there are several: retrying does not help
|
|
54
|
+
def daemon_port_from_file(runtime_dir)
|
|
55
|
+
# `base`: the path of the folder is not a pattern
|
|
56
|
+
files = Dir.glob(PORT_FILE_PATTERN, base: runtime_dir).map { |name| File.join(runtime_dir, name) }
|
|
57
|
+
return if files.empty?
|
|
58
|
+
Aspera.assert(files.length.eql?(1)) { "Several port files in #{runtime_dir}: #{files.join(', ')}" }
|
|
59
|
+
# The file is created, then written
|
|
60
|
+
content = File.read(files.first)
|
|
61
|
+
return if content.empty?
|
|
62
|
+
Aspera.assert(content.match?(/\A[0-9]+\z/)) { "No port in file #{files.first}" }
|
|
63
|
+
Log.log.debug { "Got port #{content} from #{files.first}" }
|
|
64
|
+
return content.to_i
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Port of a daemon started locally with port zero, from its log: transferd before 1.1.7 writes it only there (see `daemon_port_from_file`)
|
|
68
|
+
# @param log_file [String] Log file (standard output) of a daemon started locally
|
|
69
|
+
# @return [Integer, nil] Port of the last line of the API server, `nil`: not listening yet
|
|
47
70
|
def daemon_port_from_log(log_file)
|
|
48
71
|
result = nil
|
|
49
72
|
# if port is zero, a dynamic port was created, get it
|
|
@@ -56,8 +79,7 @@ module Aspera
|
|
|
56
79
|
end
|
|
57
80
|
end
|
|
58
81
|
end
|
|
59
|
-
|
|
60
|
-
Log.log.debug { "Got port #{result} from log" }
|
|
82
|
+
Log.log.debug { "Got port #{result} from log" } unless result.nil?
|
|
61
83
|
return result
|
|
62
84
|
end
|
|
63
85
|
end
|