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,180 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../assert'
|
|
7
|
+
require_relative '../../transfer/error'
|
|
8
|
+
require 'json'
|
|
9
|
+
require 'time'
|
|
10
|
+
|
|
11
|
+
# Generated gRPC files (`rake tools:grpc`): `transferd_services_pb.rb` requires `transferd_pb` through the load path.
|
|
12
|
+
# Their folder is put first in the load path; the file is required by its absolute path.
|
|
13
|
+
grpc_folder = File.join(__dir__, 'grpc')
|
|
14
|
+
$LOAD_PATH.unshift(grpc_folder) unless $LOAD_PATH.include?(grpc_folder)
|
|
15
|
+
require File.join(grpc_folder, 'transferd_services_pb')
|
|
16
|
+
|
|
17
|
+
module Aspera
|
|
18
|
+
module Plugins
|
|
19
|
+
module Transferd
|
|
20
|
+
# Client of a running Transfer Daemon (`transferd`): gRPC calls, no CLI.
|
|
21
|
+
# Requires the optional gem `grpc`.
|
|
22
|
+
class Api
|
|
23
|
+
# Sends the API key of the daemon (`authentication` of its configuration) in the metadata `api_key` of each call
|
|
24
|
+
class ApiKeyInterceptor < GRPC::ClientInterceptor
|
|
25
|
+
# @param api_key [String] API key
|
|
26
|
+
def initialize(api_key)
|
|
27
|
+
super()
|
|
28
|
+
@api_key = api_key
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
%i[request_response client_streamer server_streamer bidi_streamer].each do |rpc_type|
|
|
32
|
+
define_method(rpc_type) do |metadata: nil, **_rest, &block|
|
|
33
|
+
metadata['api_key'] = @api_key
|
|
34
|
+
block.call
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Default timeout in seconds of the calls of `transfer_status` and `transfer_cancel` (`agent_params['timeout']`)
|
|
40
|
+
CALL_TIMEOUT_SEC = 10
|
|
41
|
+
# Status of the daemon → status of an asynchronous transfer (as other agents): other statuses are `running`
|
|
42
|
+
ASYNC_STATUS = {
|
|
43
|
+
COMPLETED: 'completed',
|
|
44
|
+
FAILED: 'failed',
|
|
45
|
+
CANCELED: 'cancelled',
|
|
46
|
+
UNKNOWN_STATUS: 'unknown'
|
|
47
|
+
}.freeze
|
|
48
|
+
# Statuses of the daemon after which a transfer does not change
|
|
49
|
+
FINAL_STATUSES = %i[COMPLETED FAILED CANCELED].freeze
|
|
50
|
+
# Time in the daemon is in microseconds, but some versions give milliseconds: values below this are milliseconds
|
|
51
|
+
MIN_USEC_EPOCH = 10**14
|
|
52
|
+
# Address of an endpoint given without address (e.g. `:55002`)
|
|
53
|
+
LOCAL_ADDRESS = '127.0.0.1'
|
|
54
|
+
|
|
55
|
+
private_constant :ASYNC_STATUS, :MIN_USEC_EPOCH, :LOCAL_ADDRESS
|
|
56
|
+
|
|
57
|
+
class << self
|
|
58
|
+
# @param url [String] Endpoint of a daemon, e.g. `127.0.0.1:55002`, or only its port, e.g. `:55002`
|
|
59
|
+
# @return [String] The endpoint, with address `127.0.0.1` if it has none
|
|
60
|
+
def endpoint(url)
|
|
61
|
+
url.match?(/\A:[0-9]+\z/) ? "#{LOCAL_ADDRESS}#{url}" : url
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Client of a daemon
|
|
65
|
+
# @param url [String] Endpoint of the daemon, e.g. `127.0.0.1:55002`, or `:55002` for address `127.0.0.1` (see `endpoint`)
|
|
66
|
+
# @param api_key [String, nil] API key, if the daemon has `authentication` enabled
|
|
67
|
+
# @param ca_file [String, nil] File with the certificate authority of the daemon (PEM), if the daemon has `tls` enabled
|
|
68
|
+
# @return [Transferd::Api::TransferService::Stub] gRPC client
|
|
69
|
+
def create_client(url, api_key: nil, ca_file: nil)
|
|
70
|
+
url = endpoint(url)
|
|
71
|
+
credentials = ca_file.nil? ? :this_channel_is_insecure : GRPC::Core::ChannelCredentials.new(File.read(ca_file))
|
|
72
|
+
return ::Transferd::Api::TransferService::Stub.new(url, credentials) if api_key.nil?
|
|
73
|
+
::Transferd::Api::TransferService::Stub.new(url, credentials, interceptors: [ApiKeyInterceptor.new(api_key)])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# @param agent_params [Hash] `url`: endpoint of the daemon (see `create_client`); optional `api_key`, `ca_file`
|
|
77
|
+
# @return [Transferd::Api::TransferService::Stub] Client of the daemon
|
|
78
|
+
def client(agent_params)
|
|
79
|
+
Aspera.assert(agent_params['url'].is_a?(String) && !agent_params['url'].empty?) { 'agent_params: missing url' }
|
|
80
|
+
create_client(agent_params['url'], api_key: agent_params['api_key'], ca_file: agent_params['ca_file'])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Re-query a previously started transfer from a running transferd daemon (unary call `QueryTransfer`).
|
|
84
|
+
# The daemon keeps a transfer for some time after its end (`workers.transfer_max_age` of its configuration): then it is `unknown`.
|
|
85
|
+
# @param transfer_id [String] Identifier of transfer, given by the daemon (`transfer_id`)
|
|
86
|
+
# @param agent_params [Hash] `url`: endpoint of the daemon, e.g. `127.0.0.1:55002`; optional `timeout`: seconds, `api_key`, `ca_file`
|
|
87
|
+
# @return [Hash] Normalized status: `status` (`running`, `completed`, `failed`, `cancelled`, or `unknown` if the daemon cannot tell),
|
|
88
|
+
# `bytes_transferred`, and when known: `state` (status of the daemon), `bytes_written` (by the receiver, with the bytes of a resumed transfer),
|
|
89
|
+
# `files_completed`, `rate_kbps` (average), `target_rate_kbps`,
|
|
90
|
+
# `elapsed_sec`, `started_at`, `ended_at`, `error_code`, `error`
|
|
91
|
+
def transfer_status(transfer_id, agent_params)
|
|
92
|
+
response = client(agent_params).query_transfer(::Transferd::Api::TransferInfoRequest.new(transferId: transfer_id), deadline: deadline(agent_params))
|
|
93
|
+
# An unknown transfer is not an exception: status is not set, and error has code 404
|
|
94
|
+
error = response.error&.description.to_s
|
|
95
|
+
return {'status' => 'unknown', 'bytes_transferred' => 0, 'error' => error} if response.status.eql?(:UNKNOWN_STATUS) && !error.empty?
|
|
96
|
+
normalize_status(response)
|
|
97
|
+
rescue GRPC::BadStatus => e
|
|
98
|
+
# Daemon not reachable, or timeout: the transfer may still run
|
|
99
|
+
{'status' => 'unknown', 'bytes_transferred' => 0, 'error' => "#{e.class.name.split('::').last}: #{e.details}"}
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Information on a running daemon (unary call `GetInfo`)
|
|
103
|
+
# @param agent_params [Hash] `url`: endpoint of the daemon; optional `timeout`: seconds, `api_key`, `ca_file`
|
|
104
|
+
# @return [Hash] Version of the API (`apiVersion`) and information on the instance (`info`)
|
|
105
|
+
# @raise [Aspera::Transfer::Error] The daemon is not reachable, or gave an error
|
|
106
|
+
def info(agent_params)
|
|
107
|
+
response = client(agent_params).get_info(::Transferd::Api::InstanceInfoRequest.new, deadline: deadline(agent_params))
|
|
108
|
+
error = response.error&.description.to_s
|
|
109
|
+
Aspera.assert(error.empty?, type: Aspera::Transfer::Error) { error }
|
|
110
|
+
JSON.parse(response.to_h.except(:error).to_json)
|
|
111
|
+
rescue GRPC::BadStatus => e
|
|
112
|
+
raise Aspera::Transfer::Error, "#{e.class.name.split('::').last}: #{e.details}"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Stop a transfer (call `StopTransfer`)
|
|
116
|
+
# @param transfer_id [String] Identifier of transfer, given by the daemon
|
|
117
|
+
# @param agent_params [Hash] `url`: endpoint of the daemon; optional `timeout`: seconds, `api_key`, `ca_file`
|
|
118
|
+
# @return [Boolean] `true`: stopped
|
|
119
|
+
# @raise [Aspera::Transfer::Error] The daemon did not stop it: unknown or terminated transfer
|
|
120
|
+
def transfer_cancel(transfer_id, agent_params)
|
|
121
|
+
response = client(agent_params).stop_transfer(::Transferd::Api::StopTransferRequest.new(transferId: [transfer_id]), deadline: deadline(agent_params))
|
|
122
|
+
result = response.stopResult.find { |item| item.transferId.eql?(transfer_id) }
|
|
123
|
+
Aspera.assert(!result.nil?, type: Aspera::Transfer::Error) { "transfer id=#{transfer_id}: no result of stop" }
|
|
124
|
+
Aspera.assert(result.stopped, type: Aspera::Transfer::Error) { result.error&.description || "transfer id=#{transfer_id}: not stopped" }
|
|
125
|
+
true
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @param response [Transferd::Api::QueryTransferResponse, Transferd::Api::TransferResponse] Response of the daemon
|
|
129
|
+
# @return [Hash] Normalized status, see `transfer_status`
|
|
130
|
+
def normalize_status(response)
|
|
131
|
+
info = response.transferInfo
|
|
132
|
+
result = {
|
|
133
|
+
'status' => ASYNC_STATUS.fetch(response.status, 'running'),
|
|
134
|
+
'state' => response.status.to_s.downcase,
|
|
135
|
+
'bytes_transferred' => info&.bytesTransferred.to_i
|
|
136
|
+
}
|
|
137
|
+
return result if info.nil?
|
|
138
|
+
result.merge!(
|
|
139
|
+
'bytes_written' => info.bytesWritten,
|
|
140
|
+
'files_completed' => info.filesCompleted,
|
|
141
|
+
'rate_kbps' => info.averageRateKbps,
|
|
142
|
+
'target_rate_kbps' => info.targetRateKbps,
|
|
143
|
+
'elapsed_sec' => info.elapsedUsec / 1_000_000.0,
|
|
144
|
+
'started_at' => epoch_time(info.startTimeUsec),
|
|
145
|
+
'ended_at' => epoch_time(info.endTimeUsec)
|
|
146
|
+
)
|
|
147
|
+
if FINAL_STATUSES.include?(response.status)
|
|
148
|
+
result['ended_at'] ||= Time.now.utc.iso8601
|
|
149
|
+
else
|
|
150
|
+
result.delete('ended_at')
|
|
151
|
+
end
|
|
152
|
+
error = info.errorDescription.to_s.strip
|
|
153
|
+
error = response.error&.description.to_s if error.empty?
|
|
154
|
+
unless error.empty?
|
|
155
|
+
result['error_code'] = info.errorCode
|
|
156
|
+
result['error'] = error
|
|
157
|
+
end
|
|
158
|
+
result.compact
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
private
|
|
162
|
+
|
|
163
|
+
# @param agent_params [Hash] Optional `timeout`: seconds
|
|
164
|
+
# @return [Time] Deadline of a call
|
|
165
|
+
def deadline(agent_params)
|
|
166
|
+
Time.now + (agent_params['timeout'] || CALL_TIMEOUT_SEC).to_f
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# @param value [Integer] Time since epoch, in microseconds or milliseconds, 0 if not known
|
|
170
|
+
# @return [String, nil] Time in ISO 8601, `nil` if not known
|
|
171
|
+
def epoch_time(value)
|
|
172
|
+
return if value.nil? || value <= 0
|
|
173
|
+
seconds = value >= MIN_USEC_EPOCH ? value / 1_000_000.0 : value / 1000.0
|
|
174
|
+
Time.at(seconds).utc.iso8601
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../assert'
|
|
7
|
+
require_relative 'api'
|
|
8
|
+
|
|
9
|
+
module Aspera
|
|
10
|
+
module Plugins
|
|
11
|
+
module Transferd
|
|
12
|
+
# Calls to a running Transfer Daemon with plain Ruby arguments: builds the gRPC requests, returns the gRPC responses.
|
|
13
|
+
# Used by code that must not know the generated gRPC classes (e.g. the emulator of the bundle `node`).
|
|
14
|
+
class Client
|
|
15
|
+
class << self
|
|
16
|
+
# Empty gRPC message, used as default when no message was received
|
|
17
|
+
# @param name [Symbol] `:transfer_info`, `:instance_info`, `:aspera_info` or `:license_info`
|
|
18
|
+
# @return [Google::Protobuf::AbstractMessage] message with default values
|
|
19
|
+
def empty_message(name)
|
|
20
|
+
case name
|
|
21
|
+
when :transfer_info then ::Transferd::Api::TransferInfo.new
|
|
22
|
+
when :instance_info then ::Transferd::Api::InstanceInfo.new
|
|
23
|
+
when :aspera_info then ::Transferd::Api::AsperaInfo.new
|
|
24
|
+
when :license_info then ::Transferd::Api::LicenseInfo.new
|
|
25
|
+
else Aspera.error_unexpected_value(name)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @param stub [Transferd::Api::TransferService::Stub] gRPC client of the daemon
|
|
31
|
+
def initialize(stub)
|
|
32
|
+
@stub = stub
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [Transferd::Api::InstanceInfoResponse] Information on the daemon
|
|
36
|
+
def instance_info
|
|
37
|
+
@stub.get_info(::Transferd::Api::InstanceInfoRequest.new)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Start a transfer and yield its events until the stream ends
|
|
41
|
+
# @param transfer_spec_json [String] transfer spec, as JSON
|
|
42
|
+
# @yieldparam response [Transferd::Api::TransferResponse] event
|
|
43
|
+
def start_with_monitor(transfer_spec_json, &block)
|
|
44
|
+
request = ::Transferd::Api::TransferRequest.new(
|
|
45
|
+
transferType: ::Transferd::Api::TransferType::FILE_REGULAR,
|
|
46
|
+
config: ::Transferd::Api::TransferConfig.new,
|
|
47
|
+
transferSpec: transfer_spec_json
|
|
48
|
+
)
|
|
49
|
+
@stub.start_transfer_with_monitor(request, &block)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# @param transfer_id [String] transfer to stop
|
|
53
|
+
# @return [Transferd::Api::StopTransferResponse]
|
|
54
|
+
def stop(transfer_id)
|
|
55
|
+
@stub.stop_transfer(::Transferd::Api::StopTransferRequest.new(transferId: [transfer_id]))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @param transfer_id [String] transfer to modify
|
|
59
|
+
# @param changes_json [String] new values of transfer spec fields, as JSON
|
|
60
|
+
# @return [Transferd::Api::TransferModificationResponse]
|
|
61
|
+
def modify(transfer_id, changes_json)
|
|
62
|
+
@stub.modify_transfer(::Transferd::Api::TransferModificationRequest.new(transferId: transfer_id, transferSpec: changes_json))
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -3,26 +3,27 @@
|
|
|
3
3
|
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
6
|
-
require_relative 'base'
|
|
7
|
-
require_relative '
|
|
8
|
-
require_relative '
|
|
6
|
+
require_relative '../../cli/plugins/base'
|
|
7
|
+
require_relative '../../cli/info'
|
|
8
|
+
require_relative '../../cli/special_values'
|
|
9
9
|
require_relative '../../ascp/installation'
|
|
10
|
-
require_relative '../../products/
|
|
10
|
+
require_relative '../../products/transferd'
|
|
11
11
|
require_relative '../../schema/documentation'
|
|
12
12
|
require_relative '../../log'
|
|
13
13
|
require_relative '../../assert'
|
|
14
|
+
require_relative 'service'
|
|
14
15
|
|
|
15
16
|
module Aspera
|
|
16
|
-
module
|
|
17
|
-
module
|
|
17
|
+
module Plugins
|
|
18
|
+
module Transferd
|
|
18
19
|
# Install the Transfer Daemon (`transferd`), run it as a system service, and query a running daemon
|
|
19
|
-
class
|
|
20
|
+
class Commands < Cli::Plugins::Base
|
|
20
21
|
application_name 'Transfer Daemon'
|
|
21
22
|
|
|
22
23
|
class << self
|
|
23
24
|
# Seam for the client commands: object that gives `info(params)`, `transfer_status(id, params)` and `transfer_cancel(id, params)`,
|
|
24
25
|
# with `params` a Hash with `url`, and optional `api_key`, `ca_file`.
|
|
25
|
-
# `nil` (default): `
|
|
26
|
+
# `nil` (default): `Api`, loaded on first use, because it requires the optional gem `grpc`.
|
|
26
27
|
# @return [#info, #transfer_status, #transfer_cancel, nil]
|
|
27
28
|
attr_accessor :daemon_client
|
|
28
29
|
end
|
|
@@ -32,12 +33,12 @@ module Aspera
|
|
|
32
33
|
command :list, description: 'List available SDK locations'
|
|
33
34
|
command :service, description: 'Manage the transfer daemon as a system service'
|
|
34
35
|
commands_under :service do
|
|
35
|
-
service_config_arg = {name: :config, type: Hash, mandatory: false, default: {}, schema:
|
|
36
|
+
service_config_arg = {name: :config, type: Hash, mandatory: false, default: {}, schema: Service::SERVICE_CONFIG}
|
|
36
37
|
command(
|
|
37
38
|
:spec, description: 'Show the transfer daemon configuration schema',
|
|
38
39
|
action: lambda do |**|
|
|
39
|
-
builder = Schema::Documentation.new(TerminalFormatter, Schema::Registry.instance.reader(
|
|
40
|
-
Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
40
|
+
builder = Schema::Documentation.new(Cli::TerminalFormatter, Schema::Registry.instance.reader(Service::DAEMON_CONFIG_SCHEMA)).build
|
|
41
|
+
Cli::Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
41
42
|
end
|
|
42
43
|
)
|
|
43
44
|
command(
|
|
@@ -50,8 +51,8 @@ module Aspera
|
|
|
50
51
|
arguments: [service_config_arg],
|
|
51
52
|
action: lambda do |config:, **|
|
|
52
53
|
transferd_service do |host, sdk_folder, dry_run|
|
|
53
|
-
steps =
|
|
54
|
-
|
|
54
|
+
steps = Service.configure(config, sdk_folder, host: host, dry_run: dry_run)
|
|
55
|
+
Service.check_version(sdk_folder, host: host)
|
|
55
56
|
transferd_service_steps(steps)
|
|
56
57
|
end
|
|
57
58
|
end
|
|
@@ -60,7 +61,7 @@ module Aspera
|
|
|
60
61
|
:status, description: 'Show the state of the service (the API key is not shown)',
|
|
61
62
|
arguments: [service_config_arg],
|
|
62
63
|
action: lambda do |config:, **|
|
|
63
|
-
transferd_service { |host, sdk_folder, _dry_run| Result::SingleObject.new(
|
|
64
|
+
transferd_service { |host, sdk_folder, _dry_run| Cli::Result::SingleObject.new(Service.status(config, sdk_folder, host: host)) }
|
|
64
65
|
end
|
|
65
66
|
)
|
|
66
67
|
command(
|
|
@@ -68,8 +69,8 @@ module Aspera
|
|
|
68
69
|
arguments: [service_config_arg],
|
|
69
70
|
action: lambda do |config:, **|
|
|
70
71
|
transferd_service do |host, _sdk_folder, dry_run|
|
|
71
|
-
purge =
|
|
72
|
-
transferd_service_steps(
|
|
72
|
+
purge = Service.service_options(config)['purge'].eql?(true)
|
|
73
|
+
transferd_service_steps(Service.uninstall(config, host: host, dry_run: dry_run, purge: purge))
|
|
73
74
|
end
|
|
74
75
|
end
|
|
75
76
|
)
|
|
@@ -78,7 +79,7 @@ module Aspera
|
|
|
78
79
|
arguments: [{name: :version}, service_config_arg],
|
|
79
80
|
action: lambda do |version:, config:, **|
|
|
80
81
|
transferd_service do |host, sdk_folder, dry_run|
|
|
81
|
-
transferd_service_steps(
|
|
82
|
+
transferd_service_steps(Service.use(config, sdk_folder, version, host: host, dry_run: dry_run))
|
|
82
83
|
end
|
|
83
84
|
end
|
|
84
85
|
)
|
|
@@ -86,25 +87,25 @@ module Aspera
|
|
|
86
87
|
:versions, description: 'List the installed versions of the SDK (SDK folder named current)',
|
|
87
88
|
action: lambda do |**|
|
|
88
89
|
sdk_folder = options.get_option(:sdk_folder, mandatory: true)
|
|
89
|
-
Result::ObjectList.new(
|
|
90
|
+
Cli::Result::ObjectList.new(Service.versions(sdk_folder), fields: %w[version folder current])
|
|
90
91
|
end
|
|
91
92
|
)
|
|
92
93
|
end
|
|
93
94
|
command :info, description: 'Show information on a running daemon',
|
|
94
|
-
action: ->(**) { Result::SingleObject.new(daemon_client.info(daemon_params)) }
|
|
95
|
+
action: ->(**) { Cli::Result::SingleObject.new(daemon_client.info(daemon_params)) }
|
|
95
96
|
command :transfers, description: 'Query the transfers of a running daemon'
|
|
96
97
|
commands_under :transfers do
|
|
97
98
|
command(
|
|
98
99
|
:show, description: 'Show the status of a transfer (the daemon keeps it for some time after its end)',
|
|
99
100
|
arguments: [{name: :transfer_id}],
|
|
100
|
-
action: ->(transfer_id:, **) { Result::SingleObject.new(daemon_client.transfer_status(transfer_id, daemon_params)) }
|
|
101
|
+
action: ->(transfer_id:, **) { Cli::Result::SingleObject.new(daemon_client.transfer_status(transfer_id, daemon_params)) }
|
|
101
102
|
)
|
|
102
103
|
command(
|
|
103
104
|
:cancel, description: 'Stop a transfer',
|
|
104
105
|
arguments: [{name: :transfer_id}],
|
|
105
106
|
action: lambda do |transfer_id:, **|
|
|
106
107
|
daemon_client.transfer_cancel(transfer_id, daemon_params)
|
|
107
|
-
Result::Status.new("Transfer #{transfer_id} stopped")
|
|
108
|
+
Cli::Result::Status.new("Transfer #{transfer_id} stopped")
|
|
108
109
|
end
|
|
109
110
|
)
|
|
110
111
|
end
|
|
@@ -114,33 +115,33 @@ module Aspera
|
|
|
114
115
|
option :ca_file, description: 'Client commands: certificate authority (PEM file) of the daemon, if its TLS is enabled'
|
|
115
116
|
|
|
116
117
|
# Install the transfer SDK (ascp + transferd) from a URL or using the default source.
|
|
117
|
-
# Version defaults to `Info::SDK_VERSION`; pass `LATEST` as argument to install the latest available version.
|
|
118
|
+
# Version defaults to `Cli::Info::SDK_VERSION`; pass `LATEST` as argument to install the latest available version.
|
|
118
119
|
# Nothing is done if this version is already installed in the SDK folder (not checked if option `sdk_url` is set).
|
|
119
120
|
# SDK locations are read once, and only if needed (each read is counted as a download in statistics):
|
|
120
121
|
# not if the given version is already installed, but always for `LATEST` (to know that version).
|
|
121
122
|
# Also called by the deprecated command `config ascp install`.
|
|
122
123
|
# @param version [String, nil] version to install; nil means use the default SDK version
|
|
123
|
-
# @return [Result::Status] installation result message
|
|
124
|
+
# @return [Cli::Result::Status] installation result message
|
|
124
125
|
def action_install(version: nil, **)
|
|
125
|
-
asked_version = version.nil? ? Info::SDK_VERSION : version
|
|
126
|
-
asked_version = nil if asked_version.eql?(SpecialValues::LATEST)
|
|
126
|
+
asked_version = version.nil? ? Cli::Info::SDK_VERSION : version
|
|
127
|
+
asked_version = nil if asked_version.eql?(Cli::SpecialValues::LATEST)
|
|
127
128
|
installation = Ascp::Installation.instance
|
|
128
129
|
url = sdk_url_option
|
|
129
130
|
if url.nil?
|
|
130
131
|
installed_version = installation.installed_sdk_version
|
|
131
132
|
location = installation.sdk_location_for_platform(version: asked_version) unless !installed_version.nil? && installed_version.eql?(asked_version)
|
|
132
133
|
wanted_version = location.nil? ? asked_version : location['version']
|
|
133
|
-
return Result::Status.new("Version #{wanted_version} is already installed in #{Products::Transferd.sdk_directory}") if installed_version.eql?(wanted_version)
|
|
134
|
+
return Cli::Result::Status.new("Version #{wanted_version} is already installed in #{Products::Transferd.sdk_directory}") if installed_version.eql?(wanted_version)
|
|
134
135
|
url = location['url']
|
|
135
136
|
end
|
|
136
137
|
name, ver, folder = installation.install_sdk(url: url, version: asked_version)
|
|
137
|
-
return Result::Status.new("Installed #{name} version #{ver} in #{folder}")
|
|
138
|
+
return Cli::Result::Status.new("Installed #{name} version #{ver} in #{folder}")
|
|
138
139
|
end
|
|
139
140
|
|
|
140
|
-
# @return [Result::ObjectList] The SDK locations
|
|
141
|
+
# @return [Cli::Result::ObjectList] The SDK locations
|
|
141
142
|
def action_list(**)
|
|
142
143
|
sdk_list = Ascp::Installation.instance.sdk_locations
|
|
143
|
-
Result::ObjectList.new(sdk_list, fields: sdk_list.first.keys - ['url'])
|
|
144
|
+
Cli::Result::ObjectList.new(sdk_list, fields: sdk_list.first.keys - ['url'])
|
|
144
145
|
end
|
|
145
146
|
|
|
146
147
|
private
|
|
@@ -151,11 +152,11 @@ module Aspera
|
|
|
151
152
|
injected = self.class.daemon_client
|
|
152
153
|
return injected unless injected.nil?
|
|
153
154
|
begin
|
|
154
|
-
require_relative '
|
|
155
|
+
require_relative 'api'
|
|
155
156
|
rescue LoadError => e
|
|
156
157
|
raise Cli::Error, "Commands that query a running daemon require the gem grpc (#{e.message}). Install it with: gem install grpc"
|
|
157
158
|
end
|
|
158
|
-
|
|
159
|
+
Api
|
|
159
160
|
end
|
|
160
161
|
|
|
161
162
|
# Parameters of the connection to the daemon: option `url` is mandatory, `api_key` and `ca_file` are optional.
|
|
@@ -165,7 +166,7 @@ module Aspera
|
|
|
165
166
|
from_transfer = transfer_agent_params
|
|
166
167
|
params = %w[url api_key ca_file].to_h { |key| [key, options.get_option(key.to_sym) || from_transfer[key]] }.compact
|
|
167
168
|
Aspera.assert(params.key?('url'), type: Cli::BadArgument) do
|
|
168
|
-
"Missing option #{Parser.option_name_to_line(:url)} (or #{Parser.option_name_to_line(:transfer)} with agent transferd and key url)"
|
|
169
|
+
"Missing option #{Cli::Parser.option_name_to_line(:url)} (or #{Cli::Parser.option_name_to_line(:transfer)} with agent transferd and key url)"
|
|
169
170
|
end
|
|
170
171
|
return params
|
|
171
172
|
end
|
|
@@ -180,27 +181,27 @@ module Aspera
|
|
|
180
181
|
# @return [String, nil] Value of option `sdk_url`, or nil to select the archive from the SDK locations (`DEF`)
|
|
181
182
|
def sdk_url_option
|
|
182
183
|
sdk_url = options.get_option(:sdk_url, mandatory: true)
|
|
183
|
-
return sdk_url.eql?(SpecialValues::DEF) ? nil : sdk_url
|
|
184
|
+
return sdk_url.eql?(Cli::SpecialValues::DEF) ? nil : sdk_url
|
|
184
185
|
end
|
|
185
186
|
|
|
186
187
|
# Common processing of the commands of `transferd service` that act on the system.
|
|
187
188
|
# Refuses to run if the system is not supported or the user is not root, unless `--dry-run=yes`.
|
|
188
|
-
# @yieldparam host [
|
|
189
|
+
# @yieldparam host [Service::Host] Access to the system
|
|
189
190
|
# @yieldparam sdk_folder [String] Option `sdk_folder`, or link `current` of the layout
|
|
190
191
|
# @yieldparam dry_run [Boolean] Option `dry_run`
|
|
191
192
|
def transferd_service
|
|
192
|
-
host =
|
|
193
|
+
host = Service::Host.new
|
|
193
194
|
dry_run = options.get_option(:dry_run)
|
|
194
|
-
|
|
195
|
+
Service.assert_supported(host, dry_run: dry_run)
|
|
195
196
|
sdk_folder = options.get_option(:sdk_folder, mandatory: true)
|
|
196
197
|
Aspera.assert(!Ascp::Installation.product_selector?(sdk_folder), type: Cli::BadArgument) { 'The service requires a SDK folder, not a product' }
|
|
197
198
|
yield(host, sdk_folder, dry_run)
|
|
198
199
|
end
|
|
199
200
|
|
|
200
201
|
# @param steps [Array<String>] Actions done, or to do with `--dry-run=yes`
|
|
201
|
-
# @return [Result] The list of actions, or a message if there is nothing to do
|
|
202
|
+
# @return [Cli::Result] The list of actions, or a message if there is nothing to do
|
|
202
203
|
def transferd_service_steps(steps)
|
|
203
|
-
steps.empty? ? Result::Status.new('Nothing to do') : Result::ValueList.new(steps, name: 'action')
|
|
204
|
+
steps.empty? ? Cli::Result::Status.new('Nothing to do') : Cli::Result::ValueList.new(steps, name: 'action')
|
|
204
205
|
end
|
|
205
206
|
|
|
206
207
|
# Implementation of `transferd service install`
|
|
@@ -208,17 +209,17 @@ module Aspera
|
|
|
208
209
|
# @param config [Hash] `CONFIG`
|
|
209
210
|
def transferd_service_install(config)
|
|
210
211
|
transferd_service do |host, sdk_folder, dry_run|
|
|
211
|
-
version =
|
|
212
|
+
version = Service.service_options(config)['version'] || Cli::Info::SDK_VERSION
|
|
212
213
|
sdk_url = sdk_url_option
|
|
213
214
|
installation = Ascp::Installation.instance
|
|
214
215
|
install_sdk =
|
|
215
|
-
if
|
|
216
|
+
if Service.layout?(sdk_folder)
|
|
216
217
|
->(folder) { installation.install_sdk(url: sdk_url, version: version, folder: folder) }
|
|
217
218
|
else
|
|
218
219
|
-> { installation.install_sdk(url: sdk_url, version: version) }
|
|
219
220
|
end
|
|
220
|
-
steps =
|
|
221
|
-
|
|
221
|
+
steps = Service.install(config, sdk_folder, host: host, dry_run: dry_run, install_sdk: install_sdk, version: version)
|
|
222
|
+
Service.check_version(sdk_folder, host: host)
|
|
222
223
|
transferd_service_steps(steps)
|
|
223
224
|
end
|
|
224
225
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../cli/deprecation'
|
|
7
|
+
require_relative '../../log'
|
|
8
|
+
require_relative 'commands'
|
|
9
|
+
|
|
10
|
+
module Aspera
|
|
11
|
+
module Plugins
|
|
12
|
+
module Transferd
|
|
13
|
+
# Mounted on plugin config (manifest `mounts`), after the modules of bundle `xfer`: the deprecated command `config transferd`,
|
|
14
|
+
# where config included it before the bundle (last command of config).
|
|
15
|
+
module ConfigCommands
|
|
16
|
+
# Instance of the plugin of this bundle (`Commands`, the class of the mount), for the deprecated command `config transferd`
|
|
17
|
+
# @return [Commands] Plugin instance
|
|
18
|
+
def transferd_commands_plugin(**)
|
|
19
|
+
Log.log.warn { "Command config transferd is #{Cli::Deprecation.new(last: Cli::Plugins::Config::DEPRECATED_LAST, message: 'use transferd')}" }
|
|
20
|
+
Commands.new(context: context)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
# Declare the deprecated command tree in the plugin class that includes the module
|
|
25
|
+
# @param base [Class] Plugin class (config)
|
|
26
|
+
def included(base)
|
|
27
|
+
base.class_exec do
|
|
28
|
+
# transferd sub-commands: moved to plugin `transferd`, kept as deprecated alias
|
|
29
|
+
# `transferd_commands_plugin`: instance of `Commands`, the class that declares the command tree
|
|
30
|
+
command :transferd, description: "Manage the transfer daemon (#{Cli::Deprecation.new(last: Cli::Plugins::Config::DEPRECATED_LAST, message: 'use plugin transferd')})",
|
|
31
|
+
mount: {plugin: Commands, instance: :transferd_commands_plugin, only: %i[install list service]}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: transferd
|
|
2
|
+
title: IBM Aspera Transfer Daemon
|
|
3
|
+
depends:
|
|
4
|
+
- xfer
|
|
5
|
+
# No `gems`: the gem `grpc` is needed only by the agent and the client commands (`api.rb`, loaded on use),
|
|
6
|
+
# the other commands (`install`, `list`, `service`) work without it
|
|
7
|
+
commands: true
|
|
8
|
+
schemas:
|
|
9
|
+
- key: transferd
|
|
10
|
+
file: schemas/transferd-config.schema.json
|
|
11
|
+
owned: true
|
|
12
|
+
source:
|
|
13
|
+
url: https://raw.githubusercontent.com/laurent-martin/aspera-api-examples/refs/heads/main/openapi/transferd-config.schema.json
|
|
14
|
+
- key: transferd_opts
|
|
15
|
+
file: schemas/options.yaml
|
|
16
|
+
owned: true
|
|
17
|
+
extensions:
|
|
18
|
+
agent:
|
|
19
|
+
- name: transferd
|
|
20
|
+
short: t
|
|
21
|
+
file: agent.rb
|
|
22
|
+
class: Agent
|
|
23
|
+
options_schema: schemas/agent_options.yaml
|
|
24
|
+
mounts:
|
|
25
|
+
- target: config
|
|
26
|
+
file: config_commands.rb
|
|
27
|
+
module: ConfigCommands
|