Moving all files to root directory
[appc.git] / appc-dg / appc-dg-shared / appc-dg-ssh / src / main / java / org / openecomp / appc / dg / ssh / SshService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.dg.ssh;
23
24 import java.util.Map;
25
26 import org.openecomp.appc.exceptions.APPCException;
27 import org.openecomp.sdnc.sli.SvcLogicContext;
28 import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
29
30 /**
31  * Set of common methods that can be called from DG.
32  */
33 public interface SshService extends SvcLogicJavaPlugin {
34
35         /**
36          * Input parameter for SHH connection details
37          */
38         String PARAM_IN_connection_details = "connection_details";
39
40         /**
41          * Input parameter for SSH command to be executed.
42          */
43         String PARAM_IN_command = "command";
44
45         /*
46         String PARAM_IN_host = "host";
47         String PARAM_IN_port = "port";
48         String PARAM_IN_username = "username";
49         String PARAM_IN_password = "password";
50         */
51
52         /**
53          * Input parameter for SSH command timeout
54          */
55         String PARAM_IN_timeout = "timeout";
56
57         /**
58          * Output parameter - SSH command execution status.
59          */
60         String PARAM_OUT_status = "status";
61
62         /**
63          * Output parameter - content of SSH command stdout.
64          */
65         String PARAM_OUT_stdout = "stdout";
66
67         /**
68          * Output parameter - content of SSH command stderr.
69          */
70         String PARAM_OUT_stderr = "stderr";
71
72         /**
73          * Default SSH connection port.
74          */
75         int DEF_port = 22;
76
77         /**
78          * Default SSH command timeout
79          */
80         long DEF_timeout = 120000;
81
82         /**
83          * Default success status.
84          */
85         int DEF_SUCCESS_STATUS = 0;
86
87         /**
88          * Execute remote command over SSH.
89          *
90          * @param params contains list of input parameters required for the implementation
91          * @param ctx SLI service logic context
92          * @throws APPCException
93          */
94         void exec(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
95
96         /**
97          * Execute remote command over SSH and check return status assuming that success status is 0.
98          * If non-zero status is returned - fail the execution by throwing exception with content written
99          * by command to stderr.
100          *
101          * @param params contains list of input parameters required for the implementation
102          * @param ctx SLI service logic context
103          * @throws APPCException
104          */
105         void execWithStatusCheck(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
106 }