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,131 @@
|
|
|
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 '../../schema/registry'
|
|
8
|
+
require_relative '../../schema/reader'
|
|
9
|
+
require_relative '../../schema/documentation'
|
|
10
|
+
require_relative '../../ascp/session_errors'
|
|
11
|
+
require_relative '../../ascp/installation'
|
|
12
|
+
require_relative '../../cli/option/type'
|
|
13
|
+
require_relative '../../cli/special_values'
|
|
14
|
+
require_relative 'transfer_agent'
|
|
15
|
+
|
|
16
|
+
module Aspera
|
|
17
|
+
module Plugins
|
|
18
|
+
module Xfer
|
|
19
|
+
# Mounted on plugin config (manifest `mounts`): ASCP / Transferd related actions
|
|
20
|
+
module AscpActions
|
|
21
|
+
TRANSFERD_APP_NAME = 'sdk'
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
# Options of `ascp`, in the plugin class that includes the module (config): before its option `smtp`
|
|
25
|
+
# @param base [Class] Plugin class
|
|
26
|
+
def included(base)
|
|
27
|
+
base.option(:sdk_url, description: 'Ascp: URL to get Aspera Transfer Executables', default: Cli::SpecialValues::DEF, security: :low, before: :smtp)
|
|
28
|
+
base.option(:locations_url, description: 'Ascp: URLs to get download locations of Aspera Transfer Daemon', allowed: Cli::Option::Type::STRING_ARRAY, default: Ascp::Installation.instance.transferd_urls, on_set: Ascp::Installation.instance.method(:transferd_urls=), security: :low, before: :smtp)
|
|
29
|
+
base.option(:sdk_folder, description: 'Ascp: Path to folder with ascp (or product with "product:")', on_set: Ascp::Installation.instance.method(:sdk_folder=), complete: :folder, security: :low, before: :smtp)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Set the SDK directory, checking default and former locations
|
|
34
|
+
# If a product is selected for `ascp`, the SDK directory is still needed (keys, conf, transferd)
|
|
35
|
+
def set_sdk_dir
|
|
36
|
+
sdk_folder = options.get_option(:sdk_folder)
|
|
37
|
+
product_selected = Ascp::Installation.product_selector?(sdk_folder)
|
|
38
|
+
return unless sdk_folder.nil? || product_selected
|
|
39
|
+
@sdk_default_location = true
|
|
40
|
+
Log.log.debug('SDK folder is not set, checking default')
|
|
41
|
+
sdk_dir = self.class.default_app_main_folder(app_name: TRANSFERD_APP_NAME)
|
|
42
|
+
Log.log.debug { "Checking: #{sdk_dir}" }
|
|
43
|
+
if !Dir.exist?(sdk_dir)
|
|
44
|
+
Log.log.debug { "No such folder: #{sdk_dir}" }
|
|
45
|
+
former_sdk_folder = File.join(self.class.default_app_main_folder(app_name: Cli::Info::CMD_NAME), TRANSFERD_APP_NAME)
|
|
46
|
+
Log.log.debug { "Checking: #{former_sdk_folder}" }
|
|
47
|
+
sdk_dir = former_sdk_folder if Dir.exist?(former_sdk_folder)
|
|
48
|
+
end
|
|
49
|
+
Log.log.debug { "Using: #{sdk_dir}" }
|
|
50
|
+
if product_selected
|
|
51
|
+
Products::Transferd.sdk_directory = sdk_dir
|
|
52
|
+
else
|
|
53
|
+
options.set_option(:sdk_folder, sdk_dir, source: :default)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def action_ascp_info(**)
|
|
58
|
+
Secret::Hider.instance.add_secret_keys(Ascp::DataRepository::ELEMENTS)
|
|
59
|
+
data = Ascp::Installation.instance.ascp_info
|
|
60
|
+
data['ts'] = transfer.user_transfer_spec
|
|
61
|
+
Ascp::DataRepository::ELEMENTS.each_with_object(data) { |i, h| h[i.to_s] = Ascp::DataRepository.instance.item(i) }
|
|
62
|
+
Cli::Result::SingleObject.new(data)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def action_ascp_schema(agent_name: nil, **)
|
|
66
|
+
schema = Aspera::Transfer::Spec::SCHEMA.current.merge({'$comment'=>'DO NOT EDIT, this file was generated from the YAML.'})
|
|
67
|
+
schema['properties'] = schema['properties'].select { |_k, v| Aspera::Transfer::CommandLineBuilder.supported_by_agent(agent_name, v) } unless agent_name.nil?
|
|
68
|
+
schema['properties'] = schema['properties'].sort.to_h
|
|
69
|
+
Cli::Result::SingleObject.new(schema)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# @param kind [Symbol] `management`: codes of the management port, `session`: codes of sessions, as `errcode` in logs
|
|
73
|
+
def action_ascp_errors(kind: :management, **)
|
|
74
|
+
return Cli::Result::ObjectList.new(Ascp::SessionErrors.list) if kind.eql?(:session)
|
|
75
|
+
error_data = []
|
|
76
|
+
Ascp::Management::ERRORS.each_pair do |code, prop|
|
|
77
|
+
error_data.push(code: code, mnemonic: prop[:c], retry: prop[:r], info: prop[:a])
|
|
78
|
+
end
|
|
79
|
+
Cli::Result::ObjectList.new(error_data)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# @param agent [Symbol] Name of an agent
|
|
83
|
+
# @return [String, nil] Schema of the parameters of the agent: component `<Name>AgentOptions` of the schema of option `transfer` (declared by the bundle that provides the agent); `nil` if none or if it has no parameter
|
|
84
|
+
def agent_schema_key(agent)
|
|
85
|
+
# Variant of `TransferAgentOptions`, see `Schema::Registry#add_variants`
|
|
86
|
+
component = "#{agent.to_s.snake_to_capital}AgentOptions"
|
|
87
|
+
key = TransferAgent::TRANSFER_OPTION_SCHEMA.split(':', 2).first
|
|
88
|
+
schema = Schema::Registry.instance.reader(key)['components']['schemas'][component]
|
|
89
|
+
return if schema.nil? || schema['properties'].to_h.empty?
|
|
90
|
+
"#{key}:components.schemas.#{component}"
|
|
91
|
+
end
|
|
92
|
+
private :agent_schema_key
|
|
93
|
+
|
|
94
|
+
def action_agents_list(**)
|
|
95
|
+
rows = Aspera::Agent::Factory::ALL.map do |sym, names|
|
|
96
|
+
schema_key = agent_schema_key(sym)
|
|
97
|
+
param_names =
|
|
98
|
+
if schema_key
|
|
99
|
+
Schema::Registry.instance.reader(schema_key).current['properties']&.keys&.sort&.join(', ') || ''
|
|
100
|
+
else
|
|
101
|
+
''
|
|
102
|
+
end
|
|
103
|
+
{
|
|
104
|
+
'name' => sym.to_s,
|
|
105
|
+
'short' => names[:short].to_s,
|
|
106
|
+
'parameters' => param_names
|
|
107
|
+
}
|
|
108
|
+
end.sort_by { |r| r['name'] }
|
|
109
|
+
Cli::Result::ObjectList.new(rows, fields: %w[name short parameters])
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def action_agents_show(agent_name:, **)
|
|
113
|
+
names = Aspera::Agent::Factory::ALL[agent_name]
|
|
114
|
+
schema_key = agent_schema_key(agent_name)
|
|
115
|
+
Cli::Result::SingleObject.new({
|
|
116
|
+
'name' => agent_name.to_s,
|
|
117
|
+
'short' => names[:short].to_s,
|
|
118
|
+
'description' => schema_key ? Schema::Registry.instance.reader(schema_key).current['description'].to_s : '(no configurable parameters)'
|
|
119
|
+
})
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def action_agents_parameters(agent_name:, **)
|
|
123
|
+
schema_key = agent_schema_key(agent_name)
|
|
124
|
+
return Cli::Result::Nothing.new if schema_key.nil?
|
|
125
|
+
builder = Schema::Documentation.new(Cli::TerminalFormatter, Schema::Registry.instance.reader(schema_key)).build
|
|
126
|
+
Cli::Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../schema/registry'
|
|
7
|
+
require_relative '../../assert'
|
|
8
|
+
require_relative '../../log'
|
|
9
|
+
require_relative '../../standard_input'
|
|
10
|
+
|
|
11
|
+
module Aspera
|
|
12
|
+
module Plugins
|
|
13
|
+
module Xfer
|
|
14
|
+
# Mounted on plugin config (manifest `mounts`), included by other plugins: commands of `ascp logs`, analysis of `ascp` log files (sessions, statistics and diagnostics)
|
|
15
|
+
module AscpLogsActions
|
|
16
|
+
# Schema of option `ascp_logs`, in the schemas of the bundle (manifest `schemas`)
|
|
17
|
+
OPTIONS_SCHEMA = 'transfer_opts:components.schemas.AscpLogsOptions'
|
|
18
|
+
LOG_FILES = [{name: :paths, description: 'Log files (gzip supported), `-` for standard input, or folders with log files', multiple: true, complete: :file, access: :read, stdin: true}].freeze
|
|
19
|
+
# Command => description, and default fields
|
|
20
|
+
LISTS = {
|
|
21
|
+
sessions: ['Sessions, with diagnostics', %w[pid session user direction peer status error error_category start transmitted_bytes average_rate loss_rate diagnostics]],
|
|
22
|
+
diagnostics: ['Diagnostics of sessions: id, severity, message', nil],
|
|
23
|
+
multi_sessions: ['Multi-session transfers: sessions with the same transfer identifier', nil],
|
|
24
|
+
snapshots: ['Aggregate rates (bps) per period', nil],
|
|
25
|
+
snapshot_sessions: ['Rates (bps) of sessions per period', nil],
|
|
26
|
+
peers: ['Sessions and errors by peer address', nil],
|
|
27
|
+
transfers: ['Transferred files', %w[session peer start path size status error]],
|
|
28
|
+
licenses: ['Licenses of local and peer systems', nil],
|
|
29
|
+
overdrives: ['Sessions with loss due to overdriving of network or storage, by peer', nil]
|
|
30
|
+
}.freeze
|
|
31
|
+
# Kind of record of log lines => description, and default fields
|
|
32
|
+
RECORDS = {
|
|
33
|
+
samples: ['Periodic statistics of sessions: `Receiver bl` or `Sender bl` line, with its `DS Qs` line', %w[time pid side rate.t rate.c rate.n prog.t prog.e]],
|
|
34
|
+
sessions: ['Sessions: `Session Start`, `Params`, `Stop` and `Statistics` lines, with license, MTU and rate lines of the process', %w[uuid pid start stop op status errstr user peer targetrate effective_rate]],
|
|
35
|
+
transfers: ['Files: `Transfer Start` and `Transfer Stop` lines', %w[uuid start stop op status file size rate]]
|
|
36
|
+
}.freeze
|
|
37
|
+
RECORD_KIND = {name: :kind, description: RECORDS.map { |kind, (description, _)| "#{kind}: #{description}" }.join(', '), allowed: RECORDS.keys}.freeze
|
|
38
|
+
# Default values of option `ascp_logs` (see schema `AscpLogsOptions`)
|
|
39
|
+
DEFAULTS = {'period' => 1, 'zero_bytes' => false, 'mtu' => nil, 'resolve' => false, 'thresholds' => {}, 'timezone' => nil, 'health_minutes' => 60, 'remote_max_size' => 268_435_456}.freeze
|
|
40
|
+
private_constant :LOG_FILES, :LISTS, :RECORDS, :RECORD_KIND, :DEFAULTS
|
|
41
|
+
# When a plugin class includes AscpLogsActions, register the :ascp_logs option
|
|
42
|
+
# in that class's DSL registry so Base#initialize auto-declares it,
|
|
43
|
+
# and add the class-level DSL methods of ClassMethods.
|
|
44
|
+
class << self
|
|
45
|
+
def included(base)
|
|
46
|
+
base.option(:ascp_logs, description: 'Ascp: log analysis (dot-notation: period, zero_bytes, mtu, resolve, thresholds, timezone, health_minutes, remote_max_size)', schema: OPTIONS_SCHEMA)
|
|
47
|
+
base.extend(ClassMethods)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Class-level DSL methods added to the plugin class that includes AscpLogsActions.
|
|
52
|
+
module ClassMethods
|
|
53
|
+
# DSL class method: declare the `logs` node and its commands.
|
|
54
|
+
# @param parent [Symbol, Array<Symbol>] path relative to current scope, e.g. :logs
|
|
55
|
+
# @param arguments [Array<Hash>] argument that gives the log files (default: local files)
|
|
56
|
+
def ascp_logs_commands(parent, arguments: LOG_FILES)
|
|
57
|
+
commands_under(parent, description: 'Analyze ascp log files') do
|
|
58
|
+
command(:summary, description: 'Statistics and findings', arguments: arguments, action: :action_ascp_logs_summary)
|
|
59
|
+
command(:health, description: 'Health check for monitoring', arguments: arguments, action: :action_ascp_logs_health)
|
|
60
|
+
LISTS.each do |name, (description, fields)|
|
|
61
|
+
command(name, description: description, arguments: arguments, action: ->(paths:, **) { Cli::Result::ObjectList.new(analyze_ascp_logs(paths).public_send(name), fields: fields) })
|
|
62
|
+
end
|
|
63
|
+
command(:records, description: 'Log lines parsed into records, with the field names of the log', arguments: [RECORD_KIND] + arguments, action: :action_ascp_logs_records)
|
|
64
|
+
command(:fields, description: 'Description of the fields of records', arguments: [RECORD_KIND], action: :action_ascp_logs_fields)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Local log files: of installed products, of `ascp` in `PATH`, and default locations
|
|
70
|
+
def action_ascp_logs_find(**)
|
|
71
|
+
require_relative '../../ascp/log_locations'
|
|
72
|
+
products = begin
|
|
73
|
+
Ascp::Installation.instance.installed_products
|
|
74
|
+
rescue StandardError => e
|
|
75
|
+
Log.log.debug { "No installed product: #{e.message}" }
|
|
76
|
+
[]
|
|
77
|
+
end
|
|
78
|
+
Cli::Result::ObjectList.new(Ascp::LogLocations.find(products), fields: %w[path size modified source])
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def action_ascp_logs_summary(paths:, **)
|
|
82
|
+
Cli::Result::SingleObject.new(analyze_ascp_logs(paths).summary)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Health check for monitoring. Reports failed sessions and low efficiency sessions over the last N minutes.
|
|
86
|
+
# @param paths [Array<String>] Log files or folders
|
|
87
|
+
# @param now [Time, Integer, nil] Current reference time (can be injected for testing)
|
|
88
|
+
# @return [Aspera::Cli::Result::ObjectList] Nagios status list
|
|
89
|
+
def action_ascp_logs_health(paths:, now: nil, **)
|
|
90
|
+
require_relative '../../nagios'
|
|
91
|
+
analyzer = analyze_ascp_logs(paths)
|
|
92
|
+
params = ascp_logs_params
|
|
93
|
+
health_minutes = params['health_minutes'].to_i
|
|
94
|
+
|
|
95
|
+
ref_time = now ? now.to_i : Time.now.to_i
|
|
96
|
+
|
|
97
|
+
failed_count = 0
|
|
98
|
+
low_efficiency_count = 0
|
|
99
|
+
|
|
100
|
+
analyzer.log_files.each do |log_file|
|
|
101
|
+
windows_log = log_file.path.match?(/\w:/)
|
|
102
|
+
log_file.sessions.each do |s|
|
|
103
|
+
start_time = s[:start]
|
|
104
|
+
next unless start_time && start_time >= (ref_time - health_minutes * 60) && start_time <= ref_time
|
|
105
|
+
|
|
106
|
+
s.report(windows_log: windows_log)
|
|
107
|
+
failed_count += 1 if s[:status] == 'failed'
|
|
108
|
+
low_efficiency_count += 1 if s.diagnostics.any? { |d| d['id'] == 'low_efficiency' }
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
nagios = Nagios.new
|
|
113
|
+
msg = "#{failed_count} failed, #{low_efficiency_count} low efficiency in last #{health_minutes} min"
|
|
114
|
+
if failed_count.positive?
|
|
115
|
+
nagios.add_critical('ascp logs', msg)
|
|
116
|
+
elsif low_efficiency_count.positive?
|
|
117
|
+
nagios.add_warning('ascp logs', msg)
|
|
118
|
+
else
|
|
119
|
+
nagios.add_ok('ascp logs', msg)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
Cli::Result::ObjectList.new(nagios.status_list)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def action_ascp_logs_records(kind:, paths:, **)
|
|
126
|
+
require_relative '../../ascp/log_analyzer'
|
|
127
|
+
ascp_logs_files(paths) do |files|
|
|
128
|
+
check_ascp_logs_paths(files)
|
|
129
|
+
Cli::Result::ObjectList.new(Ascp::LogAnalyzer::Records.list(kind, files, timezone: ascp_logs_params['timezone'], readable: ascp_logs_readable), fields: RECORDS[kind].last)
|
|
130
|
+
end
|
|
131
|
+
rescue ParameterError => e
|
|
132
|
+
raise Cli::BadArgument, e.message
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def action_ascp_logs_fields(kind:, **)
|
|
136
|
+
require_relative '../../ascp/log_analyzer'
|
|
137
|
+
require_relative '../../schema/documentation'
|
|
138
|
+
builder = Schema::Documentation.new(Cli::TerminalFormatter, Schema::Registry.instance.reader(Ascp::LogAnalyzer::Records::SCHEMAS[kind])).build
|
|
139
|
+
Cli::Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
private
|
|
143
|
+
|
|
144
|
+
# @param paths [Array<String>] log files or folders
|
|
145
|
+
# @return [Aspera::Ascp::LogAnalyzer]
|
|
146
|
+
def analyze_ascp_logs(paths)
|
|
147
|
+
require_relative '../../ascp/log_analyzer'
|
|
148
|
+
params = ascp_logs_params
|
|
149
|
+
user_thresholds = (params['thresholds'] || {}).transform_keys(&:to_s)
|
|
150
|
+
analyzer = Ascp::LogAnalyzer.new(
|
|
151
|
+
period: params['period'] * 60,
|
|
152
|
+
zero_bytes: params['zero_bytes'],
|
|
153
|
+
mtu: params['mtu'],
|
|
154
|
+
resolve: params['resolve'],
|
|
155
|
+
thresholds: user_thresholds,
|
|
156
|
+
timezone: params['timezone']
|
|
157
|
+
)
|
|
158
|
+
ascp_logs_files(paths) do |files|
|
|
159
|
+
check_ascp_logs_paths(files)
|
|
160
|
+
files.each do |path|
|
|
161
|
+
Log.log.debug { "Analyzing: #{path}" }
|
|
162
|
+
analyzer.add(path, readable: ascp_logs_readable)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
analyzer.warnings.each { |warning| Log.log.warn(warning) }
|
|
166
|
+
analyzer
|
|
167
|
+
rescue ParameterError => e
|
|
168
|
+
raise Cli::BadArgument, e.message
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Local log files or folders to analyze, for the paths given as arguments.
|
|
172
|
+
# A plugin that gets logs elsewhere (e.g. `server logs`) redefines this method: files exist only during the block.
|
|
173
|
+
# @param paths [Array<String>] arguments of the command
|
|
174
|
+
# @yieldparam files [Array<String>] local log files or folders
|
|
175
|
+
def ascp_logs_files(paths)
|
|
176
|
+
yield(paths)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# @return [Hash] value of option `ascp_logs`, with defaults
|
|
180
|
+
def ascp_logs_params
|
|
181
|
+
DEFAULTS.merge((options.get_option(:ascp_logs) || {}).transform_keys(&:to_s))
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# A folder given as argument is checked against the security level (`access: :read`), and so is each file or folder found in it,
|
|
185
|
+
# which can be a symbolic link outside of the allowed paths: those are skipped.
|
|
186
|
+
# @return [#call] tells if a file or folder found in a folder can be read
|
|
187
|
+
def ascp_logs_readable = Cli::Security.instance.method(:readable_path?)
|
|
188
|
+
|
|
189
|
+
# The standard input (`-`, `StandardInput`) is read by the analyzer
|
|
190
|
+
def check_ascp_logs_paths(paths)
|
|
191
|
+
paths.each do |path|
|
|
192
|
+
Aspera.assert(path.is_a?(StandardInput) || File.exist?(path), type: Cli::BadArgument) { "No such file or folder: #{path}" }
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../log'
|
|
7
|
+
require_relative '../../secret/hider'
|
|
8
|
+
require 'json'
|
|
9
|
+
require 'securerandom'
|
|
10
|
+
|
|
11
|
+
module Aspera
|
|
12
|
+
module Plugins
|
|
13
|
+
module Xfer
|
|
14
|
+
# Persist the state of asynchronous transfers on the local file system.
|
|
15
|
+
#
|
|
16
|
+
# Each entry is a JSON document identified by a `job_id` (UUID generated by ascli).
|
|
17
|
+
# The underlying storage uses PersistencyFolder with the category prefix
|
|
18
|
+
# `CATEGORY` so all async-transfer files are grouped together and can be
|
|
19
|
+
# garbage-collected independently.
|
|
20
|
+
#
|
|
21
|
+
# Schema of a stored entry:
|
|
22
|
+
# job_id [String] UUID generated by ascli (= the store key)
|
|
23
|
+
# agent_type [String] 'desktop' | 'node' | 'connect' | 'transferd' | 'direct'
|
|
24
|
+
# transfer_id [String] Opaque ID returned by the agent's start_transfer
|
|
25
|
+
# agent_params [Hash] Agent-specific connection parameters for re-querying
|
|
26
|
+
# status [String] 'running' | 'completed' | 'failed' | 'cancelled'
|
|
27
|
+
# bytes_transferred [Integer] Last known bytes transferred (0 if unknown)
|
|
28
|
+
# started_at [String] ISO-8601 timestamp
|
|
29
|
+
# ended_at [String, nil] ISO-8601 timestamp once finished
|
|
30
|
+
# error [String, nil] Error message when status == 'failed'
|
|
31
|
+
class AsyncTransferStore
|
|
32
|
+
CATEGORY = 'async_transfer_'
|
|
33
|
+
private_constant :CATEGORY
|
|
34
|
+
|
|
35
|
+
# Class-level registry of in-process agent references, keyed by job_id.
|
|
36
|
+
# Shared across all AsyncTransferStore instances within the same Ruby process,
|
|
37
|
+
# so that a reference registered in one Runner call is visible in the next
|
|
38
|
+
# (e.g. MCP server mode where each tool call creates a fresh Runner/Context).
|
|
39
|
+
# Never persisted to disk.
|
|
40
|
+
@agent_refs = {}
|
|
41
|
+
class << self
|
|
42
|
+
attr_reader :agent_refs
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @param persistency [PersistencyFolder]
|
|
46
|
+
def initialize(persistency)
|
|
47
|
+
@persistency = persistency
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Register an in-process agent reference for a job.
|
|
51
|
+
# Called by TransferAgent immediately after start_transfer (async mode).
|
|
52
|
+
# The reference is only available while the same Ruby process is alive.
|
|
53
|
+
# @param job_id [String] the ascli-generated UUID
|
|
54
|
+
# @param agent_ref [Object] live agent instance (responds to sessions_by_job)
|
|
55
|
+
def register_agent_ref(job_id, agent_ref)
|
|
56
|
+
self.class.agent_refs[job_id] = agent_ref
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Retrieve a previously registered in-process agent reference.
|
|
60
|
+
# @param job_id [String]
|
|
61
|
+
# @return [Object, nil] the live agent instance, or nil if not registered / process restarted
|
|
62
|
+
def agent_ref(job_id)
|
|
63
|
+
self.class.agent_refs[job_id]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Persist (create or update) an async transfer entry.
|
|
67
|
+
# Keys whose name starts with '_' are in-process references (e.g. '_agent_ref'), and secrets (e.g. agent `password`)
|
|
68
|
+
# are not written on disk: they are intentionally excluded from the JSON serialization — at every nesting level.
|
|
69
|
+
# @param job_id [String] the ascli-generated UUID
|
|
70
|
+
# @param data [Hash] fields to store (will be JSON-serialized)
|
|
71
|
+
def write(job_id, data)
|
|
72
|
+
Aspera.assert_type(job_id, String) { 'job_id' }
|
|
73
|
+
Aspera.assert_type(data, Hash) { 'data' }
|
|
74
|
+
@persistency.put(store_key(job_id), JSON.generate(persistable(data)))
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Read one entry.
|
|
79
|
+
# @param job_id [String]
|
|
80
|
+
# @return [Hash, nil] the stored data, or nil if not found
|
|
81
|
+
def read(job_id)
|
|
82
|
+
Aspera.assert_type(job_id, String) { 'job_id' }
|
|
83
|
+
raw = @persistency.get(store_key(job_id))
|
|
84
|
+
return if raw.nil?
|
|
85
|
+
JSON.parse(raw)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# List all async transfer entries.
|
|
89
|
+
# @return [Array<Hash>] each entry includes the `job_id` field
|
|
90
|
+
def list
|
|
91
|
+
@persistency.current_items(CATEGORY).map do |key, raw|
|
|
92
|
+
data = JSON.parse(raw)
|
|
93
|
+
data['job_id'] ||= key.sub(CATEGORY, '')
|
|
94
|
+
data
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Delete one entry.
|
|
99
|
+
# @param job_id [String]
|
|
100
|
+
def delete(job_id)
|
|
101
|
+
Aspera.assert_type(job_id, String) { 'job_id' }
|
|
102
|
+
@persistency.delete(store_key(job_id))
|
|
103
|
+
nil
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
private
|
|
107
|
+
|
|
108
|
+
# Map a job_id to the PersistencyFolder key (includes category prefix).
|
|
109
|
+
def store_key(job_id)
|
|
110
|
+
"#{CATEGORY}#{job_id}"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Recursively remove from a Hash the keys that must never reach the file system:
|
|
114
|
+
# - keys whose name starts with '_': in-process Ruby object references (e.g. '_agent_ref') that cannot be serialized to JSON
|
|
115
|
+
# - secrets (e.g. 'password'): taken from current options when the transfer is queried
|
|
116
|
+
def persistable(value)
|
|
117
|
+
case value
|
|
118
|
+
when Hash
|
|
119
|
+
value.each_with_object({}) do |(k, v), h|
|
|
120
|
+
h[k] = persistable(v) unless k.to_s.start_with?('_') || Secret::Hider.instance.secret?(k, v)
|
|
121
|
+
end
|
|
122
|
+
when Array
|
|
123
|
+
value.map { |v| persistable(v) }
|
|
124
|
+
else
|
|
125
|
+
value
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
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 '../../ascp/installation'
|
|
8
|
+
require_relative '../../log'
|
|
9
|
+
require_relative '../../schema/documentation'
|
|
10
|
+
require_relative '../../sync/operations'
|
|
11
|
+
require_relative '../../transfer/command_line_builder'
|
|
12
|
+
require_relative '../../transfer/spec'
|
|
13
|
+
require_relative '../../cli/deprecation'
|
|
14
|
+
require_relative '../../cli/plugins/factory'
|
|
15
|
+
require_relative '../../cli/result'
|
|
16
|
+
require_relative '../../cli/terminal_formatter'
|
|
17
|
+
|
|
18
|
+
module Aspera
|
|
19
|
+
module Plugins
|
|
20
|
+
module Xfer
|
|
21
|
+
# Mounted on plugin config (manifest `mounts`), after the modules that give the actions and the DSL methods `ascp_logs_commands` and `sync_admin_commands`:
|
|
22
|
+
# command trees `sync`, `ascp`, `agents` and the deprecated `transfer`.
|
|
23
|
+
# `sync` is placed before `gem`, the other trees where config includes the mounts: the command tree of config is the same as before the bundle.
|
|
24
|
+
module ConfigCommands
|
|
25
|
+
class << self
|
|
26
|
+
# Declare the command trees in the plugin class that includes the module
|
|
27
|
+
# @param base [Class] Plugin class (config)
|
|
28
|
+
def included(base)
|
|
29
|
+
base.class_exec do
|
|
30
|
+
command :sync, description: 'Manage Aspera Sync operations', before: :gem
|
|
31
|
+
|
|
32
|
+
# ascp sub-commands
|
|
33
|
+
command :ascp, description: 'Manage FASP/ascp transfer engine'
|
|
34
|
+
commands_under :ascp do
|
|
35
|
+
command :show, description: 'Show ascp binary path', action: ->(**) { Cli::Result::Text.new(Ascp::Installation.instance.path(:ascp)) }
|
|
36
|
+
command :info, description: 'Show ascp and transfer spec information'
|
|
37
|
+
command :install, description: "Install the transfer SDK (#{Cli::Deprecation.new(last: Cli::Plugins::Config::DEPRECATED_LAST, message: 'use transferd install')})",
|
|
38
|
+
arguments: [{name: :version, mandatory: false, default: nil}],
|
|
39
|
+
action: ->(version: nil, **) { transferd_plugin(command: 'config ascp install', replacement: 'transferd install').action_install(version: version) }
|
|
40
|
+
command(
|
|
41
|
+
:spec, description: 'Show the transfer spec schema',
|
|
42
|
+
arguments: [{name: :agent_name, allowed: -> { Aspera::Agent::Factory::ALL.keys + [Aspera::Transfer::Spec::DOC_OVERVIEW] }, mandatory: false, default: nil}],
|
|
43
|
+
action: lambda do |agent_name: nil, **|
|
|
44
|
+
builder = Schema::Documentation.new(Cli::TerminalFormatter, Aspera::Transfer::Spec::SCHEMA, **Aspera::Transfer::Spec.doc_options(agent_name)).build
|
|
45
|
+
Cli::Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
46
|
+
end
|
|
47
|
+
)
|
|
48
|
+
command :schema, description: 'Show the transfer spec JSON schema',
|
|
49
|
+
arguments: [{name: :agent_name, allowed: -> { Aspera::Agent::Factory::ALL.keys }, mandatory: false, default: nil}]
|
|
50
|
+
command :errors, description: 'Show FASP error codes: of the management port (default), or of sessions (errcode in logs)',
|
|
51
|
+
arguments: [{name: :kind, allowed: %i[management session], mandatory: false, default: :management}]
|
|
52
|
+
ascp_logs_commands :logs
|
|
53
|
+
commands_under :logs do
|
|
54
|
+
command :find, description: 'Find the ascp log files of this system: of installed products, and default locations', action: :action_ascp_logs_find
|
|
55
|
+
end
|
|
56
|
+
command :products, description: 'Manage installed Aspera products'
|
|
57
|
+
commands_under :products do
|
|
58
|
+
command :list, description: 'List installed Aspera products',
|
|
59
|
+
action: ->(**) { Cli::Result::ObjectList.new(Ascp::Installation.instance.installed_products, fields: %w[name app_root]) }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# agents sub-commands
|
|
64
|
+
command :agents, description: 'Manage transfer agents'
|
|
65
|
+
commands_under :agents do
|
|
66
|
+
command :list, description: 'List all transfer agents'
|
|
67
|
+
command :show, description: 'Show details for a transfer agent',
|
|
68
|
+
arguments: [{name: :agent_name, allowed: -> { Aspera::Agent::Factory::ALL.keys }}]
|
|
69
|
+
command :parameters, description: 'Show configurable parameters for a transfer agent',
|
|
70
|
+
arguments: [{name: :agent_name, allowed: -> { Aspera::Agent::Factory::ALL.keys }}]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# async transfer jobs: moved to `agents jobs`, `transfer` is kept as deprecated alias
|
|
74
|
+
commands_under %i[agents jobs], description: 'Manage asynchronous transfer jobs' do
|
|
75
|
+
command :list, description: 'List all async transfer jobs'
|
|
76
|
+
command :status, description: 'Show status of an async transfer job',
|
|
77
|
+
arguments: [{name: :job_id, complete: :transfer_job}]
|
|
78
|
+
command :cleanup, description: 'Remove completed/failed/cancelled transfer entries'
|
|
79
|
+
end
|
|
80
|
+
command :transfer, description: "Manage asynchronous transfers (#{Cli::Deprecation.new(last: Cli::Plugins::Config::DEPRECATED_LAST, message: 'use agents jobs')})",
|
|
81
|
+
setup: :deprecated_transfer_setup, mount: {plugin: self, at: %i[agents jobs], instance: :itself}
|
|
82
|
+
|
|
83
|
+
# sync sub-commands
|
|
84
|
+
commands_under :sync do
|
|
85
|
+
command(
|
|
86
|
+
:spec, description: 'Show the sync configuration schema',
|
|
87
|
+
action: lambda do |**|
|
|
88
|
+
builder = Schema::Documentation.new(Cli::TerminalFormatter, Sync::Operations::CONF_SCHEMA, annotate: Aspera::Transfer::CommandLineBuilder.method(:doc_lines)).build
|
|
89
|
+
Cli::Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
90
|
+
end
|
|
91
|
+
)
|
|
92
|
+
sync_admin_commands :admin
|
|
93
|
+
sync_logs_command :logs
|
|
94
|
+
command :translate, description: 'Translate async-style arguments to sync config format',
|
|
95
|
+
arguments: [{name: :async_arguments, multiple: true}],
|
|
96
|
+
action: ->(async_arguments:, **) { Cli::Result::SingleObject.new(Sync::Operations.args_to_conf(async_arguments)) }
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Setup of the deprecated `config transfer` (alias of `config agents jobs`, same plugin)
|
|
103
|
+
def deprecated_transfer_setup(**)
|
|
104
|
+
Log.log.warn { "Command config transfer is #{Cli::Deprecation.new(last: Cli::Plugins::Config::DEPRECATED_LAST, message: 'use config agents jobs')}" }
|
|
105
|
+
{}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Instance of plugin `transferd`, found by name, for the deprecated command `config ascp install`
|
|
109
|
+
# @param command [String] Deprecated command
|
|
110
|
+
# @param replacement [String] Command to use instead
|
|
111
|
+
# @return [Cli::Plugins::Base] Plugin instance
|
|
112
|
+
def transferd_plugin(command:, replacement:)
|
|
113
|
+
Log.log.warn { "Command #{command} is #{Cli::Deprecation.new(last: Cli::Plugins::Config::DEPRECATED_LAST, message: "use #{replacement}")}" }
|
|
114
|
+
Cli::Plugins::Factory.instance.plugin_class(:transferd).new(context: context)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
module Aspera
|
|
7
|
+
module Plugins
|
|
8
|
+
module Xfer
|
|
9
|
+
# Included by the commands of the bundles that transfer files (manifest: `depends: - xfer`):
|
|
10
|
+
# the transfer agent is the service `transfer` of this bundle.
|
|
11
|
+
# Single-file plugins use `Cli::Plugins::Base#transfer`.
|
|
12
|
+
module Helper
|
|
13
|
+
# @return [TransferAgent] Service `transfer` of the context of the plugin: created once, on first use
|
|
14
|
+
# @raise [Cli::Error] If the bundle `xfer` is unavailable
|
|
15
|
+
def transfer = context.service(:transfer)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: xfer
|
|
2
|
+
title: Aspera transfer agents, ascp and async
|
|
3
|
+
schemas:
|
|
4
|
+
- key: transfer_opts
|
|
5
|
+
file: schemas/options.yaml
|
|
6
|
+
owned: true
|
|
7
|
+
extension_points:
|
|
8
|
+
- name: agent
|
|
9
|
+
schema: schemas/agent_extension.schema.yaml
|
|
10
|
+
services:
|
|
11
|
+
- name: transfer
|
|
12
|
+
file: transfer_agent.rb
|
|
13
|
+
class: TransferAgent
|
|
14
|
+
# Included in this order: options `sql`, `ascp_logs` and the DSL methods of the action modules are used by ConfigCommands
|
|
15
|
+
mounts:
|
|
16
|
+
- target: config
|
|
17
|
+
file: sync_actions.rb
|
|
18
|
+
module: SyncActions
|
|
19
|
+
- target: config
|
|
20
|
+
file: ascp_logs_actions.rb
|
|
21
|
+
module: AscpLogsActions
|
|
22
|
+
- target: config
|
|
23
|
+
file: ascp_actions.rb
|
|
24
|
+
module: AscpActions
|
|
25
|
+
- target: config
|
|
26
|
+
file: transfer_actions.rb
|
|
27
|
+
module: TransferActions
|
|
28
|
+
- target: config
|
|
29
|
+
file: config_commands.rb
|
|
30
|
+
module: ConfigCommands
|
|
31
|
+
# Section of the instructions of the MCP server
|
|
32
|
+
mcp: |-
|
|
33
|
+
TRANSFERS
|
|
34
|
+
Pass verbatim any flag the user requests (--transfer.agent=<agent>, --to-folder, …).
|
|
35
|
+
Agents (default: direct): %{agent}.
|
|
36
|
+
At security level high (the default of this server), a transfer uses an agent on a host the user controls:
|
|
37
|
+
set --transfer.agent=node, or --transfer.agent=transferd with --transfer.url=<remote daemon>.
|
|
38
|
+
An agent that runs on this host (direct, connect, desktop, httpgw, a local transferd daemon) is refused.
|
|
39
|
+
Transfers are asynchronous: the command returns a job_id immediately — never retry it.
|
|
40
|
+
monitor → ["config", "transfer", "status", "<job_id>"]
|
|
41
|
+
list → ["config", "transfer", "list"]
|
|
42
|
+
cleanup → ["config", "transfer", "cleanup"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://github.com/IBM/aspera-cli/tree/main/lib/aspera/plugins/xfer/schemas/agent_extension.schema.yaml
|
|
3
|
+
title: Transfer agent of a bundle
|
|
4
|
+
description: >-
|
|
5
|
+
Entry of the extension point `agent` of bundle `xfer` (manifest `extensions.agent` of a bundle), besides `file` and `class` of its code.
|
|
6
|
+
type: object
|
|
7
|
+
additionalProperties: false
|
|
8
|
+
required:
|
|
9
|
+
- name
|
|
10
|
+
- short
|
|
11
|
+
- options_schema
|
|
12
|
+
properties:
|
|
13
|
+
name:
|
|
14
|
+
description: Name of the agent, value of option `transfer`, unique.
|
|
15
|
+
type: string
|
|
16
|
+
pattern: '^[a-z][a-z0-9_]*$'
|
|
17
|
+
short:
|
|
18
|
+
description: Letter of the agent, unique.
|
|
19
|
+
type: string
|
|
20
|
+
pattern: '^[a-z]$'
|
|
21
|
+
options_schema:
|
|
22
|
+
description: >-
|
|
23
|
+
Schema file of the parameters of the agent (component `<Name>AgentOptions` of `TransferAgentOptions`), relative to the folder of the bundle:
|
|
24
|
+
no segment starts with a dot (no `..`, no hidden file).
|
|
25
|
+
type: string
|
|
26
|
+
pattern: '^[^./\\][^/\\]*(/[^./\\][^/\\]*)*$'
|