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