Skip to content

Commit 273a5e7

Browse files
authored
[FEATURE][Task Plugin]Add remote-shell task plugin (#13801)
1 parent ad7ce2d commit 273a5e7

54 files changed

Lines changed: 2187 additions & 7 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/configs/docsdev.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ export default {
221221
title: 'Apache Linkis',
222222
link: '/en-us/docs/dev/user_doc/guide/task/linkis.html',
223223
},
224+
{
225+
title: 'SSH',
226+
link: '/en-us/docs/dev/user_doc/guide/task/ssh.html',
227+
},
224228
],
225229
},
226230
{
@@ -319,6 +323,10 @@ export default {
319323
title: 'OceanBase',
320324
link: '/en-us/docs/dev/user_doc/guide/datasource/oceanbase.html',
321325
},
326+
{
327+
title: 'SSH',
328+
link: '/en-us/docs/dev/user_doc/guide/datasource/ssh.html',
329+
},
322330
],
323331
},
324332
{
@@ -906,6 +914,10 @@ export default {
906914
title: 'Apache Linkis',
907915
link: '/zh-cn/docs/dev/user_doc/guide/task/linkis.html',
908916
},
917+
{
918+
title: 'SSH',
919+
link: '/zh-cn/docs/dev/user_doc/guide/task/ssh.html',
920+
},
909921
],
910922
},
911923
{
@@ -988,6 +1000,10 @@ export default {
9881000
title: 'OceanBase',
9891001
link: '/zh-cn/docs/dev/user_doc/guide/datasource/oceanbase.html',
9901002
},
1003+
{
1004+
title: 'SSH',
1005+
link: '/zh-cn/docs/dev/user_doc/guide/datasource/ssh.html',
1006+
},
9911007
],
9921008
},
9931009
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SSH Data Source
2+
3+
This data source is used for RemoteShell component to execute commands remotely.
4+
5+
![sh](../../../../img/new_ui/dev/datasource/ssh.png)
6+
7+
- Data Source: SSH
8+
- Data Source Name: Enter the name of the data source
9+
- Description: Enter the description of the data source
10+
- IP Hostname: Enter the IP to connect to SSH
11+
- Port: Enter the port to connect to SSH
12+
- Username: Set the username to connect to SSH
13+
- Password: Set the password to connect to SSH
14+
- Public Key: Set the public key to connect to SSH
15+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# RemoteShell
2+
3+
## Overview
4+
5+
RemoteShell task type is used to execute commands on remote servers.
6+
7+
## Create Task
8+
9+
- Click Project Management-Project Name-Workflow Definition, click the "Create Workflow" button to enter the DAG editing page.
10+
11+
- Drag <img src="../../../../img/tasks/icons/remoteshell.png" width="15"/> from the toolbar to the canvas to complete the creation.
12+
13+
## Task Parameters
14+
15+
[//]: # (TODO: use the commented anchor below once our website template supports this syntax)
16+
[//]: # (- Please refer to [DolphinScheduler Task Parameters Appendix]&#40;appendix.md#default-task-parameters&#41; `Default Task Parameters` section for default parameters.)
17+
18+
- Please refer to [DolphinScheduler Task Parameters Appendix](appendix.md) `Default Task Parameters` section for default parameters.
19+
- SSH Data Source: Select SSH data source.
20+
21+
## Task Example
22+
23+
### View the path of the remote server (remote-server)
24+
25+
![remote-shell-demo](../../../../img/tasks/demo/remote-shell.png)
26+
27+
## Precautions
28+
29+
After the task connects to the server, it will not automatically source bashrc and other files. The required environment variables can be imported in the following ways
30+
- Create environment variables in the security center-Environment Management, and then import them through the environment option in the task definition
31+
- Enter the corresponding environment variables directly in the script
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SSH 数据源
2+
3+
该数据源用于RemoteShell组件,用于远程执行命令。
4+
5+
![sh](../../../../img/new_ui/dev/datasource/ssh.png)
6+
7+
- 数据源:选择 SSH
8+
- 数据源名称:输入数据源的名称
9+
- 描述:输入数据源的描述
10+
- IP 主机名:输入连接 SSH 的 IP
11+
- 端口:输入连接 SSH 的端口
12+
- 用户名:设置连接 SSH 的用户名
13+
- 密码:设置连接 SSH 的密码
14+
- 公钥:设置连接 SSH 的公钥
15+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# RemoteShell
2+
3+
## 综述
4+
5+
RemoteShell 任务类型,用于在远程服务器上执行命令。
6+
7+
## 创建任务
8+
9+
- 点击项目管理-项目名称-工作流定义,点击"创建工作流"按钮,进入 DAG 编辑页面。
10+
- 工具栏中拖动 <img src="../../../../img/tasks/icons/remoteshell.png" width="15"/> 到画板中,即可完成创建。
11+
12+
## 任务参数
13+
14+
[//]: # (TODO: use the commented anchor below once our website template supports this syntax)
15+
[//]: # (- 默认参数说明请参考[DolphinScheduler任务参数附录]&#40;appendix.md#默认任务参数&#41;`默认任务参数`一栏。)
16+
17+
- 默认参数说明请参考[DolphinScheduler任务参数附录](appendix.md)`默认任务参数`一栏。
18+
- SSH Data Source: 选择SSH 数据源。
19+
20+
## 任务样例
21+
22+
### 查看远程服务器(remote-server)的路径
23+
24+
![remote-shell-demo](../../../../img/tasks/demo/remote-shell.png)
25+
26+
## 注意事项
27+
28+
该任务连接服务器后,不会自动source bashrc等文件,所需的环境变量,可以通过以下方式导入
29+
- 在安全中心-环境管理中创建环境变量,然后通过任务定义中的环境选项引入
30+
- 在脚本中直接输入对应的环境变量
39.6 KB
Loading
76.5 KB
Loading
747 Bytes
Loading

‎dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper;
3636
import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper;
3737
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
38+
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.DataSourceProcessor;
3839
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider;
3940
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
4041
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
@@ -186,9 +187,10 @@ public Result<Object> updateDataSource(int id, User loginUser, BaseDataSourcePar
186187
return result;
187188
}
188189
// check password,if the password is not updated, set to the old password.
189-
BaseConnectionParam connectionParam =
190-
(BaseConnectionParam) DataSourceUtils.buildConnectionParams(dataSourceParam);
190+
ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(dataSourceParam);
191+
191192
String password = connectionParam.getPassword();
193+
192194
if (StringUtils.isBlank(password)) {
193195
String oldConnectionParams = dataSource.getConnectionParams();
194196
ObjectNode oldParams = JSONUtils.parseObject(oldConnectionParams);
@@ -383,6 +385,15 @@ public Result<Object> verifyDataSourceName(String name) {
383385
@Override
384386
public Result<Object> checkConnection(DbType type, ConnectionParam connectionParam) {
385387
Result<Object> result = new Result<>();
388+
if (type == DbType.SSH) {
389+
DataSourceProcessor sshDataSourceProcessor = DataSourceUtils.getDatasourceProcessor(type);
390+
if (sshDataSourceProcessor.testConnection(connectionParam)) {
391+
putMsg(result, Status.SUCCESS);
392+
} else {
393+
putMsg(result, Status.CONNECT_DATASOURCE_FAILURE);
394+
}
395+
return result;
396+
}
386397
try (Connection connection = DataSourceClientProvider.getInstance().getConnection(type, connectionParam)) {
387398
if (connection == null) {
388399
log.error("Connection test to {} datasource failed, connectionParam:{}.", type.getDescp(),

‎dolphinscheduler-api/src/main/resources/task-type-config.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ task:
2929
- 'DINKY'
3030
- 'FLINK_STREAM'
3131
- 'HIVECLI'
32+
- 'REMOTESHELL'
3233
cloud:
3334
- 'EMR'
3435
- 'K8S'

0 commit comments

Comments
 (0)