summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-ssh
diff options
context:
space:
mode:
authorDunietz, Irwin <id1681@att.com>2020-01-16 15:13:14 -0500
committerTakamune Cho <takamune.cho@att.com>2020-01-29 19:44:48 +0000
commitb5fe8a69e90b950c07dc11af481eab7e9bab52c6 (patch)
tree3da81ce60554e65b93776b9aea647f3c6d8679ab /appc-dg/appc-dg-shared/appc-dg-ssh
parent9b32cb60360a2a2973c621053510718de0072111 (diff)
Change code in appc dispatcher for new LCMs in R6
Also introduce some minor improvements to robustness, efficiency, & formatting. Issue-ID: APPC-1789 Signed-off-by: Dunietz, Irwin <id1681@att.com> Change-Id: I82d970c2f7cde6c8dab1222af86ea70ce93b7e50
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-ssh')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/onap/appc/dg/ssh/impl/SshServiceImpl.java22
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/onap/appc/dg/ssh/impl/SshDBPluginImplTest.java10
2 files changed, 19 insertions, 13 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/onap/appc/dg/ssh/impl/SshServiceImpl.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/onap/appc/dg/ssh/impl/SshServiceImpl.java
index e758f36a2..1c7cc1b95 100644
--- a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/onap/appc/dg/ssh/impl/SshServiceImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/onap/appc/dg/ssh/impl/SshServiceImpl.java
@@ -2,24 +2,21 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
- * ================================================================================
- * Modifications (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
* ============LICENSE_END=========================================================
*/
@@ -48,6 +45,11 @@ public class SshServiceImpl implements SshService {
private SshAdapter sshAdapter;
+ /**
+ * Set sshAdapter.
+ * <p>Used through blueprint.
+ * @param sshAdapter the SshAdapter
+ */
public void setSshAdapter(SshAdapter sshAdapter) {
this.sshAdapter = sshAdapter;
}
@@ -57,7 +59,9 @@ public class SshServiceImpl implements SshService {
SshConnectionDetails connectionDetails = resolveConnectionDetails(params.get(PARAM_IN_connection_details));
String command = params.get(PARAM_IN_command);
logger.debug("=> Connecting to SSH server...");
- SshConnection sshConnection = sshAdapter.getConnection(connectionDetails.getHost(), connectionDetails.getPort(), connectionDetails.getUsername(), connectionDetails.getPassword());
+ SshConnection sshConnection =
+ sshAdapter.getConnection(connectionDetails.getHost(), connectionDetails.getPort(),
+ connectionDetails.getUsername(), connectionDetails.getPassword());
sshConnection.connect();
try {
logger.debug("=> Connected to SSH server...");
@@ -97,11 +101,11 @@ public class SshServiceImpl implements SshService {
public void execWithStatusCheck(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
exec(params, ctx);
int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status));
- if(status != DEF_SUCCESS_STATUS) {
+ if (status != DEF_SUCCESS_STATUS) {
StringBuilder errmsg = new StringBuilder();
errmsg.append("SSH command returned error status [").append(status).append(']');
String stderr = ctx.getAttribute(PARAM_OUT_stderr);
- if((stderr != null) && !stderr.isEmpty()) {
+ if ((stderr != null) && !stderr.isEmpty()) {
errmsg.append(". Error: [").append(stderr).append(']');
}
throw new APPCException(errmsg.toString());
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/onap/appc/dg/ssh/impl/SshDBPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/onap/appc/dg/ssh/impl/SshDBPluginImplTest.java
index 20d602cbb..49c1a5044 100644
--- a/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/onap/appc/dg/ssh/impl/SshDBPluginImplTest.java
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/onap/appc/dg/ssh/impl/SshDBPluginImplTest.java
@@ -3,6 +3,8 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2019 Ericsson
+ * ================================================================================
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +46,8 @@ public class SshDBPluginImplTest {
public void testRetrieveConnectionDetails() throws APPCException {
SshDBPluginImpl impl = new SshDBPluginImpl();
SshDataAccessService dataAccessServiceMock = Mockito.mock(SshDataAccessService.class);
- Mockito.doReturn(true).when(dataAccessServiceMock).retrieveConnectionDetails(Mockito.anyString(),
- Mockito.any(SshConnectionDetails.class));
+ Mockito.doReturn(true).when(dataAccessServiceMock)
+ .retrieveConnectionDetails(Mockito.anyString(), Mockito.any(SshConnectionDetails.class));
impl.setDataAccessService(dataAccessServiceMock);
Map<String, String> params = new HashMap<>();
SvcLogicContext ctx = new SvcLogicContext();
@@ -68,8 +70,8 @@ public class SshDBPluginImplTest {
public void testRetrieveConnectionDetailsSshDataAccessException() throws APPCException {
SshDBPluginImpl impl = new SshDBPluginImpl();
SshDataAccessService dataAccessServiceMock = Mockito.mock(SshDataAccessService.class);
- Mockito.doThrow(new SshDataAccessException()).when(dataAccessServiceMock).retrieveConnectionDetails(Mockito.anyString(),
- Mockito.any(SshConnectionDetails.class));
+ Mockito.doThrow(new SshDataAccessException()).when(dataAccessServiceMock)
+ .retrieveConnectionDetails(Mockito.anyString(), Mockito.any(SshConnectionDetails.class));
impl.setDataAccessService(dataAccessServiceMock);
Map<String, String> params = new HashMap<>();
SvcLogicContext ctx = new SvcLogicContext();