From d6a56cd8f71cc196083c6ab16e86d24c7c89f9ef Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Thu, 19 Jul 2018 11:17:06 +0900 Subject: SSHApiCallNode API definition Issue-ID: CCSDK-384 Change-Id: I558bb774081074fbd1c541512d767a9ca5d1f866 Signed-off-by: Ganesh Chandrasekaran --- .../sli/plugins/sshapicall/SshApiCallNode.java | 84 +++++ .../sli/plugins/sshapicall/impl/AuthType.java | 19 + .../ccsdk/sli/plugins/sshapicall/impl/Format.java | 39 +++ .../sli/plugins/sshapicall/impl/Parameters.java | 42 +++ .../sshapicall/impl/SshapiCallNodeImpl.java | 43 +++ .../sli/plugins/sshapicall/model/JsonParser.java | 96 +++++ .../plugins/sshapicall/model/RetryException.java | 32 ++ .../sli/plugins/sshapicall/model/RetryPolicy.java | 62 ++++ .../plugins/sshapicall/model/RetryPolicyStore.java | 56 +++ .../sli/plugins/sshapicall/model/XmlJsonUtil.java | 389 +++++++++++++++++++++ .../sli/plugins/sshapicall/model/XmlParser.java | 174 +++++++++ .../META-INF/spring/sshapi-call-node-context.xml | 51 +++ .../spring/sshapi-call-node-osgi-context.xml | 34 ++ .../blueprint/sshapi-call-node-blueprint.xml | 16 + 14 files changed, 1137 insertions(+) create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java create mode 100644 sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml create mode 100644 sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml create mode 100755 sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java new file mode 100644 index 000000000..4efddec80 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import java.io.OutputStream; +import java.util.Map; + +public interface SshApiCallNode extends SvcLogicJavaPlugin { + + /** + * Allows Directed Graphs the ability to interact with SSH APIs. + * @param paramMap HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
+ * Exec remote command over SSH. Return command execution status. + * Command output is written to out or err stream. + * + * @param ctx Reference to context memory + */ + void execCommand(Map paramMap, SvcLogicContext ctx) throws SvcLogicException; + + /** + * Allows Directed Graphs the ability to interact with SSH APIs. + * @param paramMap HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
+ * Exec remote command over SSH with pseudo-tty. Return command execution status. + * Command output is written to out stream only as pseudo-tty writes to one stream only. + * + * @param ctx Reference to context memory + */ + void execCommandWithPty(Map paramMap, SvcLogicContext ctx) throws SvcLogicException ; + +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java new file mode 100644 index 000000000..308162271 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java @@ -0,0 +1,19 @@ +package org.onap.ccsdk.sli.plugins.sshapicall.impl; + +public enum AuthType { + NONE, BASIC, DIGEST, OAUTH, Unspecified; + + public static AuthType fromString(String s) { + if ("basic".equalsIgnoreCase(s)) + return BASIC; + if ("digest".equalsIgnoreCase(s)) + return DIGEST; + if ("oauth".equalsIgnoreCase(s)) + return OAUTH; + if ("none".equalsIgnoreCase(s)) + return NONE; + if ("unspecified".equalsIgnoreCase(s)) + return Unspecified; + throw new IllegalArgumentException("Invalid value for format: " + s); + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java new file mode 100644 index 000000000..75604de66 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.impl; + +public enum Format { + JSON, XML, NONE; + + public static Format fromString(String s) { + if ("json".equalsIgnoreCase(s)) + return JSON; + if ("xml".equalsIgnoreCase(s)) + return XML; + if ("none".equalsIgnoreCase(s)) + return NONE; + throw new IllegalArgumentException("Invalid value for format: " + s); + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java new file mode 100644 index 000000000..a392cc73c --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.impl; + +import java.util.Set; + +public class Parameters { + public String templateFileName; + public String sshapiUrl; + public String sshapiUser; + public String sshapiPassword; + public Format sshKey; + public String cmd; + public String responsePrefix; + public Set listNameList; + public boolean convertResponse; + public Boolean dumpHeaders; + public String requestBody; + public AuthType authtype; + public Boolean returnRequestPayload; +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java new file mode 100644 index 000000000..9283b8b5f --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.impl; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode; + +import java.io.OutputStream; +import java.util.Map; + +public class SshapiCallNodeImpl implements SshApiCallNode { + @Override + public void execCommand(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + //TODO: Implementation + } + + @Override + public void execCommandWithPty(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + //TODO: Implementation + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java new file mode 100644 index 000000000..e840053f8 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.codehaus.jettison.json.JSONArray; +import org.codehaus.jettison.json.JSONException; +import org.codehaus.jettison.json.JSONObject; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class JsonParser { + + private static final Logger log = LoggerFactory.getLogger(JsonParser.class); + + private JsonParser() { + // Preventing instantiation of the same. + } + + @SuppressWarnings("unchecked") + public static Map convertToProperties(String s) + throws SvcLogicException { + + checkNotNull(s, "Input should not be null."); + + try { + JSONObject json = new JSONObject(s); + Map wm = new HashMap<>(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } + + Map mm = new HashMap<>(); + + while (!wm.isEmpty()) + for (String key : new ArrayList<>(wm.keySet())) { + Object o = wm.get(key); + wm.remove(key); + + if (o instanceof Boolean || o instanceof Number || o instanceof String) { + mm.put(key, o.toString()); + + log.info("Added property: {} : {}", key, o.toString()); + } else if (o instanceof JSONObject) { + JSONObject jo = (JSONObject) o; + Iterator i = jo.keys(); + while (i.hasNext()) { + String key1 = i.next(); + wm.put(key + "." + key1, jo.get(key1)); + } + } else if (o instanceof JSONArray) { + JSONArray ja = (JSONArray) o; + mm.put(key + "_length", String.valueOf(ja.length())); + + log.info("Added property: {}_length: {}", key, String.valueOf(ja.length())); + + for (int i = 0; i < ja.length(); i++) + wm.put(key + '[' + i + ']', ja.get(i)); + } + } + return mm; + } catch (JSONException e) { + throw new SvcLogicException("Unable to convert JSON to properties" + e.getLocalizedMessage(), e); + } + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java new file mode 100644 index 000000000..9a1d3a312 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +public class RetryException extends Exception { + + public RetryException(String message) { + super(message); + } + +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java new file mode 100644 index 000000000..fef0f81af --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +public class RetryPolicy { + private String[] hostnames; + private Integer maximumRetries; + + public Integer getMaximumRetries() { + return maximumRetries; + } + + public String getNextHostName(String uri) throws RetryException { + Integer position = null; + + for (int i = 0; i < hostnames.length; i++) { + if (uri.contains(hostnames[i])) { + position = i; + break; + } + } + + if(position == null){ + throw new RetryException("No match found for the provided uri[" + uri + "] " + + "so the next host name could not be retreived"); + } + position++; + + if (position > hostnames.length - 1) { + position = 0; + } + return hostnames[position]; + } + + public RetryPolicy(String[] hostnames, Integer maximumRetries){ + this.hostnames = hostnames; + this.maximumRetries = maximumRetries; + } + + +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java new file mode 100644 index 000000000..65575b8ce --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +import java.util.HashMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RetryPolicyStore { + private static final Logger log = LoggerFactory.getLogger(RetryPolicyStore.class); + + HashMap retryPolicies; + public String proxyServers; + + public String getProxyServers() { + return proxyServers; + } + + public void setProxyServers(String admServers) { + this.proxyServers = admServers; + String[] adminServersArray = admServers.split(","); + RetryPolicy adminPortalRetry = new RetryPolicy(adminServersArray, adminServersArray.length); + retryPolicies.put("dme2proxy", adminPortalRetry); + } + + public RetryPolicyStore() { + retryPolicies = new HashMap<>(); + } + + public RetryPolicy getRetryPolicy(String policyName) { + return (this.retryPolicies.get(policyName)); + } + +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java new file mode 100644 index 000000000..e7fc60edb --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java @@ -0,0 +1,389 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class XmlJsonUtil { + + private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class); + + private XmlJsonUtil() { + // Preventing instantiation of the same. + } + + public static String getXml(Map varmap, String var) { + boolean escape = true; + if (var.startsWith("'")) { + var = var.substring(1); + escape = false; + } + + Object o = createStructure(varmap, var); + return generateXml(o, 0, escape); + } + + public static String getJson(Map varmap, String var) { + boolean escape = true; + if (var.startsWith("'")) { + var = var.substring(1); + escape = false; + } + + boolean quotes = true; + if (var.startsWith("\"")) { + var = var.substring(1); + quotes = false; + } + + Object o = createStructure(varmap, var); + return generateJson(o, escape, quotes); + } + + private static Object createStructure(Map flatmap, String var) { + if (flatmap.containsKey(var)) { + if (var.endsWith("_length") || var.endsWith("].key")) + return null; + return flatmap.get(var); + } + + Map mm = new HashMap<>(); + for (String k : flatmap.keySet()) + if (k.startsWith(var + ".")) { + int i1 = k.indexOf('.', var.length() + 1); + int i2 = k.indexOf('[', var.length() + 1); + int i3 = k.length(); + if (i1 > 0 && i1 < i3) + i3 = i1; + if (i2 > 0 && i2 < i3) + i3 = i2; + String k1 = k.substring(var.length() + 1, i3); + String var1 = k.substring(0, i3); + if (!mm.containsKey(k1)) { + Object str = createStructure(flatmap, var1); + if (str != null && (!(str instanceof String) || ((String) str).trim().length() > 0)) + mm.put(k1, str); + } + } + if (!mm.isEmpty()) + return mm; + + boolean arrayFound = false; + for (String k : flatmap.keySet()) + if (k.startsWith(var + "[")) { + arrayFound = true; + break; + } + + if (arrayFound) { + List ll = new ArrayList<>(); + + int length = Integer.MAX_VALUE; + String lengthStr = flatmap.get(var + "_length"); + if (lengthStr != null) { + try { + length = Integer.parseInt(lengthStr); + } catch (Exception e) { + log.warn("Invalid number for {}_length:{}", var, lengthStr, e); + } + } + + for (int i = 0; i < length; i++) { + Object v = createStructure(flatmap, var + '[' + i + ']'); + if (v == null) + break; + ll.add(v); + } + + if (!ll.isEmpty()) + return ll; + } + + return null; + } + + @SuppressWarnings("unchecked") + private static String generateXml(Object o, int indent, boolean escape) { + if (o == null) + return null; + + if (o instanceof String) + return escape ? escapeXml((String) o) : (String) o;; + + if (o instanceof Map) { + StringBuilder ss = new StringBuilder(); + Map mm = (Map) o; + for (Map.Entry entry: mm.entrySet()) { + Object v = entry.getValue(); + String key = entry.getKey(); + if (v instanceof String) { + String s = escape ? escapeXml((String) v) : (String) v; + ss.append(pad(indent)).append('<').append(key).append('>'); + ss.append(s); + ss.append("').append('\n'); + } else if (v instanceof Map) { + ss.append(pad(indent)).append('<').append(key).append('>').append('\n'); + ss.append(generateXml(v, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } else if (v instanceof List) { + List ll = (List) v; + for (Object o1 : ll) { + ss.append(pad(indent)).append('<').append(key).append('>').append('\n'); + ss.append(generateXml(o1, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } + } + } + return ss.toString(); + } + + return null; + } + + private static String generateJson(Object o, boolean escape, boolean quotes) { + if (o == null) + return null; + + StringBuilder ss = new StringBuilder(); + generateJson(ss, o, 0, false, escape, quotes); + return ss.toString(); + } + + @SuppressWarnings("unchecked") + private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape, boolean quotes) { + if (o instanceof String) { + String s = escape ? escapeJson((String) o) : (String) o; + if (padFirst) + ss.append(pad(indent)); + if (quotes) { + ss.append('"').append(s).append('"'); + } else { + ss.append(s); + } + return; + } + + if (o instanceof Map) { + Map mm = (Map) o; + + if (padFirst) + ss.append(pad(indent)); + ss.append("{\n"); + + boolean first = true; + for (Map.Entry entry : mm.entrySet()) { + if (!first) + ss.append(",\n"); + first = false; + Object v = entry.getValue(); + String key = entry.getKey(); + ss.append(pad(indent + 1)).append('"').append(key).append("\": "); + generateJson(ss, v, indent + 1, false, escape, true); + } + + ss.append("\n"); + ss.append(pad(indent)).append('}'); + + return; + } + + if (o instanceof List) { + List ll = (List) o; + + if (padFirst) + ss.append(pad(indent)); + ss.append("[\n"); + + boolean first = true; + for (Object o1 : ll) { + if (!first) + ss.append(",\n"); + first = false; + + generateJson(ss, o1, indent + 1, true, escape, quotes); + } + + ss.append("\n"); + ss.append(pad(indent)).append(']'); + } + } + + public static String removeLastCommaJson(String s) { + StringBuilder sb = new StringBuilder(); + int k = 0; + int start = 0; + while (k < s.length()) { + int i11 = s.indexOf('}', k); + int i12 = s.indexOf(']', k); + int i1 = -1; + if (i11 < 0) + i1 = i12; + else if (i12 < 0) + i1 = i11; + else + i1 = i11 < i12 ? i11 : i12; + if (i1 < 0) + break; + + int i2 = s.lastIndexOf(',', i1); + if (i2 < 0) { + k = i1 + 1; + continue; + } + + String between = s.substring(i2 + 1, i1); + if (between.trim().length() > 0) { + k = i1 + 1; + continue; + } + + sb.append(s.substring(start, i2)); + start = i2 + 1; + k = i1 + 1; + } + + sb.append(s.substring(start, s.length())); + + return sb.toString(); + } + + public static String removeEmptyStructJson(String s) { + int k = 0; + while (k < s.length()) { + boolean curly = true; + int i11 = s.indexOf('{', k); + int i12 = s.indexOf('[', k); + int i1 = -1; + if (i11 < 0) { + i1 = i12; + curly = false; + } else if (i12 < 0) + i1 = i11; + else + if (i11 < i12) + i1 = i11; + else { + i1 = i12; + curly = false; + } + + if (i1 >= 0) { + int i2 = curly ? s.indexOf('}', i1) : s.indexOf(']', i1); + if (i2 > 0) { + String value = s.substring(i1 + 1, i2); + if (value.trim().length() == 0) { + int i4 = s.lastIndexOf('\n', i1); + if (i4 < 0) + i4 = 0; + int i5 = s.indexOf('\n', i2); + if (i5 < 0) + i5 = s.length(); + + s = s.substring(0, i4) + s.substring(i5); + k = 0; + } else + k = i1 + 1; + } else + break; + } else + break; + } + + return s; + } + + public static String removeEmptyStructXml(String s) { + int k = 0; + while (k < s.length()) { + int i1 = s.indexOf('<', k); + if (i1 < 0 || i1 == s.length() - 1) + break; + + char c1 = s.charAt(i1 + 1); + if (c1 == '?' || c1 == '!') { + k = i1 + 2; + continue; + } + + int i2 = s.indexOf('>', i1); + if (i2 < 0) { + k = i1 + 1; + continue; + } + + String closingTag = " 0) { + k = i2 + 1; + continue; + } + + int i4 = s.lastIndexOf('\n', i1); + if (i4 < 0) + i4 = 0; + int i5 = s.indexOf('\n', i3); + if (i5 < 0) + i5 = s.length(); + + s = s.substring(0, i4) + s.substring(i5); + k = 0; + } + + return s; + } + + private static String escapeXml(String v) { + String s = v.replaceAll("&", "&"); + s = s.replaceAll("<", "<"); + s = s.replaceAll("'", "'"); + s = s.replaceAll("\"", """); + s = s.replaceAll(">", ">"); + return s; + } + + private static String escapeJson(String v) { + String s = v.replaceAll("\\\\", "\\\\\\\\"); + s = s.replaceAll("\"", "\\\\\""); + return s; + } + + private static String pad(int n) { + StringBuilder s = new StringBuilder(); + for (int i = 0; i < n; i++) + s.append(Character.toString('\t')); + return s.toString(); + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java new file mode 100644 index 000000000..c23aca6cf --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +public final class XmlParser { + + private static final Logger log = LoggerFactory.getLogger(XmlParser.class); + + private XmlParser() { + // Preventing instantiation of the same. + } + + public static Map convertToProperties(String s, Set listNameList) + throws SvcLogicException { + + checkNotNull(s, "Input should not be null."); + + Handler handler = new Handler(listNameList); + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser saxParser = factory.newSAXParser(); + InputStream in = new ByteArrayInputStream(s.getBytes()); + saxParser.parse(in, handler); + } catch (ParserConfigurationException | IOException | SAXException | NumberFormatException e) { + throw new SvcLogicException("Unable to convert XML to properties" + e.getLocalizedMessage(), e); + } + return handler.getProperties(); + } + + private static class Handler extends DefaultHandler { + + private Set listNameList; + + private Map properties = new HashMap<>(); + + public Map getProperties() { + return properties; + } + + public Handler(Set listNameList) { + super(); + this.listNameList = listNameList; + if (this.listNameList == null) + this.listNameList = new HashSet<>(); + } + + StringBuilder currentName = new StringBuilder(); + StringBuilder currentValue = new StringBuilder(); + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) + throws SAXException { + super.startElement(uri, localName, qName, attributes); + + String name = localName; + if (name == null || name.trim().length() == 0) + name = qName; + int i2 = name.indexOf(':'); + if (i2 >= 0) + name = name.substring(i2 + 1); + + if (currentName.length() > 0) + currentName.append(Character.toString('.')); + currentName.append(name); + + String listName = removeIndexes(currentName.toString()); + + if (listNameList.contains(listName)) { + String n = currentName.toString() + "_length"; + int len = getInt(properties, n); + properties.put(n, String.valueOf(len + 1)); + currentName.append("[").append(len).append("]"); + } + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + super.endElement(uri, localName, qName); + + String name = localName; + if (name == null || name.trim().length() == 0) + name = qName; + int i2 = name.indexOf(':'); + if (i2 >= 0) + name = name.substring(i2 + 1); + + String s = currentValue.toString().trim(); + if (s.length() > 0) { + properties.put(currentName.toString(), s); + + log.info("Added property: {} : {}", currentName, s); + currentValue = new StringBuilder(); + } + + int i1 = currentName.lastIndexOf("." + name); + if (i1 <= 0) + currentName = new StringBuilder(); + else + currentName = new StringBuilder(currentName.substring(0, i1)); + } + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + super.characters(ch, start, length); + + String value = new String(ch, start, length); + currentValue.append(value); + } + + private static int getInt(Map mm, String name) { + String s = mm.get(name); + if (s == null) + return 0; + return Integer.parseInt(s); + } + + private String removeIndexes(String currentName) { + StringBuilder b = new StringBuilder(); + boolean add = true; + for (int i = 0; i < currentName.length(); i++) { + char c = currentName.charAt(i); + if (c == '[') + add = false; + else if (c == ']') + add = true; + else if (add) + b.append(Character.toString(c)); + } + return b.toString(); + } + } +} diff --git a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml new file mode 100644 index 000000000..4cce6ffad --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml @@ -0,0 +1,51 @@ + + + + + + + + + file:${SDNC_CONFIG_DIR}/ueb.properties + file:${SDNC_CONFIG_DIR}/dme2.properties + + + + + + + + + + + + + + + + + diff --git a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml new file mode 100644 index 000000000..c8e9a99e3 --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml new file mode 100755 index 000000000..b24aaf1ee --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode + + + + \ No newline at end of file -- cgit 1.2.3-korg From 8b39ca99c8a49197b05f8fea7de9a1606c810e63 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Tue, 24 Jul 2018 16:40:14 +0900 Subject: SSHApiCallNode sshExec API Impl Issue-ID: CCSDK-385 Change-Id: I430f9075ced10edb49062fc12091774e91611b32 Signed-off-by: Ganesh Chandrasekaran --- .../sli/plugins/restapicall/RestapiCallNode.java | 2 +- .../features/ccsdk-sshapi-call-node/pom.xml | 3 +- sshapi-call-node/provider/pom.xml | 10 + .../sli/plugins/sshapicall/SshApiCallNode.java | 226 ++++++++++++++--- .../sli/plugins/sshapicall/impl/AuthType.java | 19 -- .../ccsdk/sli/plugins/sshapicall/impl/Format.java | 39 --- .../sli/plugins/sshapicall/impl/Parameters.java | 42 ---- .../sshapicall/impl/SshapiCallNodeImpl.java | 43 ---- .../sli/plugins/sshapicall/model/AuthType.java | 41 +++ .../ccsdk/sli/plugins/sshapicall/model/Format.java | 39 +++ .../sli/plugins/sshapicall/model/JsonParser.java | 6 +- .../sli/plugins/sshapicall/model/Parameters.java | 45 ++++ .../sli/plugins/sshapicall/model/ParseParam.java | 274 +++++++++++++++++++++ .../plugins/sshapicall/model/RetryException.java | 32 --- .../sli/plugins/sshapicall/model/RetryPolicy.java | 62 ----- .../plugins/sshapicall/model/RetryPolicyStore.java | 56 ----- .../META-INF/spring/sshapi-call-node-context.xml | 6 +- .../spring/sshapi-call-node-osgi-context.xml | 2 +- .../blueprint/sshapi-call-node-blueprint.xml | 2 +- .../sli/plugins/sshapicall/TestJsonParser.java | 16 +- 20 files changed, 623 insertions(+), 342 deletions(-) delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java (limited to 'sshapi-call-node/provider/src/main') diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 5168b3ec1..42462f0e6 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -90,7 +90,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { /** * Allows Directed Graphs the ability to interact with REST APIs. - * @param parameters HashMap of parameters passed by the DG to this function + * @param paramMap HashMap of parameters passed by the DG to this function * * * diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 12ec06867..7b74d6de9 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -36,7 +36,7 @@ - + diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 165003ff1..e380d7c25 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -39,6 +39,16 @@ org.onap.ccsdk.sli.coresli-provider + + org.onap.appc + appc-ssh-adapter-api + 1.3.0 + provided + + + org.json + json + org.slf4j slf4j-api diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java index 4efddec80..e4b082cda 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java @@ -1,10 +1,11 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : APPC * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= * 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 @@ -16,36 +17,89 @@ * 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========================================================= */ package org.onap.ccsdk.sli.plugins.sshapicall; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +//import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.ByteArrayOutputStream; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Strings; +import org.json.JSONObject; +import org.onap.appc.adapter.ssh.SshAdapter; +import org.onap.appc.adapter.ssh.SshConnection; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import java.io.OutputStream; -import java.util.Map; +import org.onap.ccsdk.sli.plugins.sshapicall.model.AuthType; +import org.onap.ccsdk.sli.plugins.sshapicall.model.Parameters; +import org.onap.ccsdk.sli.plugins.sshapicall.model.ParseParam; + + +public class SshApiCallNode implements SvcLogicJavaPlugin { + + private static final EELFLogger logger = EELFManager.getInstance().getApplicationLogger(); + + /** + * Output parameter - SSH command execution status. + */ + String PARAM_OUT_status = "status"; + + /** + * Output parameter - content of SSH command stdout. + */ + String PARAM_OUT_stdout = "stdout"; + + /** + * Output parameter - content of SSH command stderr. + */ + String PARAM_OUT_stderr = "stderr"; + + /** + * Default success status. + */ + int DEF_SUCCESS_STATUS = 0; + + private SshAdapter sshAdapter; -public interface SshApiCallNode extends SvcLogicJavaPlugin { + public void setSshAdapter(SshAdapter sshAdapter) { + this.sshAdapter = sshAdapter; + } /** * Allows Directed Graphs the ability to interact with SSH APIs. - * @param paramMap HashMap of parameters passed by the DG to this function + * @param params HashMap of parameters passed by the DG to this function *
parameterMandatory/Optionaldescriptionexample values
* * * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * * vpn-information.vrf-details - * - * - * + * + * + * + * * *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
PasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
SshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
EnvParametersOptionalA JSON dictionary which should list key value pairs to be passed to the command execution. + * These values would correspond to instance specific parameters that a command may need to execute an action.
FileParametersOptionalA JSON dictionary where keys are filenames and values are contents of files. + * The SSH Server will utilize this feature to generate files with keys as filenames and values as content. + * This attribute can be used to generate files that a command may require as part of execution.
* Exec remote command over SSH. Return command execution status. @@ -53,32 +107,140 @@ public interface SshApiCallNode extends SvcLogicJavaPlugin { * * @param ctx Reference to context memory */ - void execCommand(Map paramMap, SvcLogicContext ctx) throws SvcLogicException; + + public void execCommand(Map params, SvcLogicContext ctx) throws SvcLogicException { + ParseParam parser = new ParseParam(); + Parameters p = parser.getParameters(params); + logger.debug("=> Connecting to SSH server..."); + SshConnection sshConnection = getSshConnection(p); + sshConnection.connect(); + try { + logger.debug("=> Connected to SSH server..."); + logger.debug("=> Running SSH command..."); + sshConnection.setExecTimeout(p.sshExecTimeout); + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + ByteArrayOutputStream stderr = new ByteArrayOutputStream(); + int status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); + String stdoutRes = stdout.toString(); + String stderrRes = stderr.toString(); + logger.debug("=> executed SSH command"); + + if(status == DEF_SUCCESS_STATUS) { + parser.parseOutput(ctx, stdoutRes); + } + ctx.setAttribute(PARAM_OUT_status, String.format("%01d", status)); + ctx.setAttribute(PARAM_OUT_stdout, stdoutRes); + ctx.setAttribute(PARAM_OUT_stderr, stderrRes); + } finally { + sshConnection.disconnect(); + } + } + + private SshConnection getSshConnection(Parameters p) throws SvcLogicException{ + if (p.authtype == AuthType.BASIC) + return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); + // This is not supported yet in the API, patch has already been added to APPC + else if (p.authtype == AuthType.KEY){ + //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); + throw new SvcLogicException("SSH Key based Auth method not supported"); + } + else if (p.authtype == AuthType.NONE){ + //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); + throw new SvcLogicException("SSH Auth type required, BASIC auth in support"); + } + else if (p.authtype == AuthType.UNSPECIFIED){ + if (p.sshapiUser != null && p.sshapiPassword != null) + return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); + else if (p.sshKey != null) + throw new SvcLogicException("SSH Key based Auth method not supported"); + } + throw new SvcLogicException("SSH Auth type required, BASIC auth in support"); + } + /** * Allows Directed Graphs the ability to interact with SSH APIs. - * @param paramMap HashMap of parameters passed by the DG to this function + * @param params HashMap of parameters passed by the DG to this function * * * * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * * vpn-information.vrf-details - * - * - * + * + * + * + * * *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
PasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
SshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
EnvParametersOptionalA JSON dictionary which should list key value pairs to be passed to the command execution. + * These values would correspond to instance specific parameters that a command may need to execute an action.
FileParametersOptionalA JSON dictionary where keys are filenames and values are contents of files. + * The SSH Server will utilize this feature to generate files with keys as filenames and values as content. + * This attribute can be used to generate files that a command may require as part of execution.
- * Exec remote command over SSH with pseudo-tty. Return command execution status. - * Command output is written to out stream only as pseudo-tty writes to one stream only. + * Exec remote command over SSH. Return command execution status. + * Command output is written to out or err stream. * - * @param ctx Reference to context memory + * @param ctx Reference to context memory + */ + + public void execWithStatusCheck(Map params, SvcLogicContext ctx) throws SvcLogicException { + execCommand(params, ctx); + int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status)); + if(status != DEF_SUCCESS_STATUS) { + StringBuilder errmsg = new StringBuilder(); + errmsg.append("SSH command returned error status [").append(status).append(']'); + String stderrRes = ctx.getAttribute(PARAM_OUT_stderr); + String stdoutRes = ctx.getAttribute(PARAM_OUT_stdout); + if((stderrRes != null) && !stderrRes.isEmpty()) { + errmsg.append(". Error: [").append(stderrRes).append(']'); + } else if ((stdoutRes != null) && !stdoutRes.isEmpty()) { + errmsg.append(". Error: [").append(stdoutRes).append(']'); + } + throw new SvcLogicException(errmsg.toString()); + } + } + + /** + * Allows Directed Graphs the ability to interact with SSH APIs. + * @param params HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
PasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
SshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
EnvParametersOptionalA JSON dictionary which should list key value pairs to be passed to the command execution. + * These values would correspond to instance specific parameters that a command may need to execute an action.
FileParametersOptionalA JSON dictionary where keys are filenames and values are contents of files. + * The SSH Server will utilize this feature to generate files with keys as filenames and values as content. + * This attribute can be used to generate files that a command may require as part of execution.
+ * Exec remote command over SSH. Return command execution status. + * Command output is written to out or err stream. + * + * @param ctx Reference to context memory */ - void execCommandWithPty(Map paramMap, SvcLogicContext ctx) throws SvcLogicException ; + public void execCommandWithPty(Map params, SvcLogicContext ctx) throws SvcLogicException { + } } diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java deleted file mode 100644 index 308162271..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.onap.ccsdk.sli.plugins.sshapicall.impl; - -public enum AuthType { - NONE, BASIC, DIGEST, OAUTH, Unspecified; - - public static AuthType fromString(String s) { - if ("basic".equalsIgnoreCase(s)) - return BASIC; - if ("digest".equalsIgnoreCase(s)) - return DIGEST; - if ("oauth".equalsIgnoreCase(s)) - return OAUTH; - if ("none".equalsIgnoreCase(s)) - return NONE; - if ("unspecified".equalsIgnoreCase(s)) - return Unspecified; - throw new IllegalArgumentException("Invalid value for format: " + s); - } -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java deleted file mode 100644 index 75604de66..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * - * 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========================================================= - */ - -package org.onap.ccsdk.sli.plugins.sshapicall.impl; - -public enum Format { - JSON, XML, NONE; - - public static Format fromString(String s) { - if ("json".equalsIgnoreCase(s)) - return JSON; - if ("xml".equalsIgnoreCase(s)) - return XML; - if ("none".equalsIgnoreCase(s)) - return NONE; - throw new IllegalArgumentException("Invalid value for format: " + s); - } -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java deleted file mode 100644 index a392cc73c..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * 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========================================================= - */ - -package org.onap.ccsdk.sli.plugins.sshapicall.impl; - -import java.util.Set; - -public class Parameters { - public String templateFileName; - public String sshapiUrl; - public String sshapiUser; - public String sshapiPassword; - public Format sshKey; - public String cmd; - public String responsePrefix; - public Set listNameList; - public boolean convertResponse; - public Boolean dumpHeaders; - public String requestBody; - public AuthType authtype; - public Boolean returnRequestPayload; -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java deleted file mode 100644 index 9283b8b5f..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * 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========================================================= - */ - -package org.onap.ccsdk.sli.plugins.sshapicall.impl; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode; - -import java.io.OutputStream; -import java.util.Map; - -public class SshapiCallNodeImpl implements SshApiCallNode { - @Override - public void execCommand(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - //TODO: Implementation - } - - @Override - public void execCommandWithPty(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - //TODO: Implementation - } -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java new file mode 100644 index 000000000..2ec48c70c --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +public enum AuthType { + NONE, BASIC, KEY, UNSPECIFIED; + + public static AuthType fromString(String s) { + if ("basic".equalsIgnoreCase(s)) + return BASIC; + if ("key".equalsIgnoreCase(s)) + return KEY; + if ("unspecified".equalsIgnoreCase(s)) + return UNSPECIFIED; + if ("none".equalsIgnoreCase(s)) + return NONE; + throw new IllegalArgumentException("Invalid value for format: " + s); + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java new file mode 100644 index 000000000..e50a96c6c --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +public enum Format { + JSON, XML, NONE; + + public static Format fromString(String s) { + if ("json".equalsIgnoreCase(s)) + return JSON; + if ("xml".equalsIgnoreCase(s)) + return XML; + if ("none".equalsIgnoreCase(s)) + return NONE; + throw new IllegalArgumentException("Invalid value for format: " + s); + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java index e840053f8..f40f1ad71 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java @@ -47,11 +47,10 @@ public final class JsonParser { @SuppressWarnings("unchecked") public static Map convertToProperties(String s) - throws SvcLogicException { + throws JSONException { checkNotNull(s, "Input should not be null."); - try { JSONObject json = new JSONObject(s); Map wm = new HashMap<>(); Iterator ii = json.keys(); @@ -89,8 +88,5 @@ public final class JsonParser { } } return mm; - } catch (JSONException e) { - throw new SvcLogicException("Unable to convert JSON to properties" + e.getLocalizedMessage(), e); - } } } diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java new file mode 100644 index 000000000..a22da5bcb --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +import java.util.Set; + +public class Parameters { + public String sshapiUrl; + public int sshapiPort; + public String sshapiUser; + public String sshapiPassword; + public String sshKey; + public long sshExecTimeout; + public String sshFileParameters; + public String sshEnvParameters; + public boolean sshWithRetry; + public String cmd; + public String responsePrefix; + public Format responseType; + + public Set listNameList; + public boolean convertResponse; + public AuthType authtype; +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java new file mode 100644 index 000000000..caf49ef91 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java @@ -0,0 +1,274 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * * Copyright (C) 2017 AT&T Intellectual Property. + * ================================================================================ + * Copyright (C) 2018 Samsung Electronics. All rights + * reserved. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.ccsdk.sli.plugins.sshapicall.model; + +import com.google.common.base.Strings; +import org.json.JSONException; +import org.json.JSONObject; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +public class ParseParam { + private static final Logger log = LoggerFactory.getLogger(ParseParam.class); + /** + * Default SSH command timeout + */ + private long dEF_timeout = 12000; + /** + * Default SSH connection port. + */ + private int dEF_port = 22; + /** + * Default SSH command timeout + */ + private final String FILE_PARAMETERS_OPT_KEY = "FileParameters"; + /** + * Default SSH connection port. + */ + private final String ENV_PARAMETERS_OPT_KEY = "EnvParameters"; + private Parameters p = new Parameters(); + + public Parameters getParameters(Map paramMap) throws SvcLogicException { + p.sshapiUrl = parseParam(paramMap, "Url", true, null); + p.sshapiPort = Integer.parseInt(parseParam(paramMap, "Port", true, Integer.toString(dEF_port))); + p.sshapiUser = parseParam(paramMap, "User", false, null); + p.sshapiPassword = parseParam(paramMap, "Password", false, null); + p.sshKey = parseParam(paramMap, "SshKey", false, null); + p.sshExecTimeout = Long.parseLong(parseParam(paramMap, "ExecTimeout", false, Long.toString(dEF_timeout))); + p.sshWithRetry = Boolean.valueOf(parseParam(paramMap, "Retry", false, "false")); + p.cmd = parseParam(paramMap, "Cmd", true, null); + p.responsePrefix = parseParam(paramMap, "ResponsePrefix", false, null); + p.responseType = Format.fromString(parseParam(paramMap, "ResponseType", false, "none")); + p.listNameList = getListNameList(paramMap); + p.convertResponse = Boolean.valueOf(parseParam(paramMap, "ConvertResponse", false, "true")); + p.authtype = AuthType.fromString(parseParam(paramMap, "AuthType", false, "unspecified")); + + return p; + } + + public void parseOutput (SvcLogicContext ctx, String outMessage) throws SvcLogicException { + if (p.convertResponse) { + if (p.responseType == Format.NONE) { + classifyOutput(ctx, outMessage); + } else if (p.responseType == Format.JSON) { + classifyOutput(ctx, outMessage); + } else if (p.responseType == Format.XML) { + classifyOutput(ctx, outMessage, p.listNameList); + } + } + } + + private void classifyOutput(SvcLogicContext ctx, String outMessage, Set listNameList) throws SvcLogicException { + Map mm = XmlParser.convertToProperties(outMessage, p.listNameList); + toCtx (ctx, mm); + } + + private void toCtx (SvcLogicContext ctx, Map mm) { + if (mm != null) { + for (Map.Entry entry : mm.entrySet()) { + if (p.responsePrefix != null) { + ctx.setAttribute(p.responsePrefix + "." + entry.getKey(), entry.getValue()); + log.info("+++ " + p.responsePrefix + "." + entry.getKey() + ": [" + entry.getValue() + "]"); + } else { + ctx.setAttribute(entry.getKey(), entry.getValue()); + log.info("+++ " + entry.getKey() + ": [" + entry.getValue() + "]"); + } + } + } + } + + private void classifyOutput(SvcLogicContext ctx, String outMessage) throws SvcLogicException { + try { + Map mm = JsonParser.convertToProperties(outMessage); + toCtx (ctx, mm); + } catch (org.codehaus.jettison.json.JSONException e) { + log.info("Output not in JSON format"); + putToProperties(ctx, p.responsePrefix); + } catch (Exception e) { + throw new SvcLogicException("error parsing response file"); + } + } + + private void putToProperties(SvcLogicContext ctx, String outMessage) throws SvcLogicException { + + try { + Properties prop = new Properties(); + prop.load(new ByteArrayInputStream(outMessage.getBytes(StandardCharsets.UTF_8))); + for (Object key : prop.keySet()) { + String name = (String) key; + String value = prop.getProperty(name); + if (value != null && value.trim().length() > 0) { + if (p.responsePrefix != null) { + ctx.setAttribute(p.responsePrefix + "." + name, value.trim()); + log.info("+++ " + p.responsePrefix + "." + name + ": [" + value + "]"); + } else { + ctx.setAttribute(name, value.trim()); + log.info("+++ " + name + ": [" + value + "]"); + } + } + } + } catch (Exception e) { + throw new SvcLogicException( "Error parsing response file."); + } + } + + public String makeCommand (Map params) { + JSONObject jsonPayload = new JSONObject(); + final String[] optionalTestParams = {ENV_PARAMETERS_OPT_KEY, FILE_PARAMETERS_OPT_KEY}; + parseParam(params, optionalTestParams, jsonPayload); + JSONObject envParams = (JSONObject) jsonPayload.remove(ENV_PARAMETERS_OPT_KEY); + JSONObject fileParams = (JSONObject) jsonPayload.remove(FILE_PARAMETERS_OPT_KEY); + + StringBuilder constructedCommand = new StringBuilder(); + constructedCommand.append(parseFileParam(fileParams)).append(p.cmd).append(" ").append(parseEnvParam(envParams)); + + return constructedCommand.toString(); + } + + private String parseEnvParam(JSONObject envParams) { + StringBuilder envParamBuilder = new StringBuilder(); + if (envParams != null) { + for (Object key : envParams.keySet()) { + if (envParamBuilder.length() > 0) { + envParamBuilder.append(", "); + } + envParamBuilder.append(key + "=" + envParams.get((String) key)); + } + } + return envParamBuilder.toString(); + } + + private String parseFileParam(JSONObject fileParams) { + StringBuilder fileParamBuilder = new StringBuilder(); + if (fileParams != null) { + for (Object key : fileParams.keySet()) { + fileParamBuilder.append("echo -e \"" + fileParams.get((String) key) + "\" > /srv/salt/" + key).append("; "); + } + } + return fileParamBuilder.toString(); + } + + private void parseParam(Map params, String[] optionalTestParams, JSONObject jsonPayload) + throws JSONException { + + Set optionalParamsSet = new HashSet<>(); + Collections.addAll(optionalParamsSet, optionalTestParams); + + //@formatter:off + params.entrySet() + .stream() + .filter(entry -> optionalParamsSet.contains(entry.getKey())) + .filter(entry -> !Strings.isNullOrEmpty(entry.getValue())) + .forEach(entry -> parseParam(entry, jsonPayload)); + //@formatter:on + } + + private void parseParam(Map.Entry params, JSONObject jsonPayload) + throws JSONException { + String key = params.getKey(); + String payload = params.getValue(); + + switch (key) { + case ENV_PARAMETERS_OPT_KEY: + JSONObject paramsJson = new JSONObject(payload); + jsonPayload.put(key, paramsJson); + break; + + case FILE_PARAMETERS_OPT_KEY: + jsonPayload.put(key, getFilePayload(payload)); + break; + + default: + break; + } + } + + /** + * Return payload with escaped newlines + */ + private JSONObject getFilePayload(String payload) { + String formattedPayload = payload.replace("\n", "\\n").replace("\r", "\\r"); + return new JSONObject(formattedPayload); + } + + private Set getListNameList(Map paramMap) { + Set ll = new HashSet<>(); + for (Map.Entry entry : paramMap.entrySet()) + if (entry.getKey().startsWith("listName")) + ll.add(entry.getValue()); + return ll; + } + + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in sshapiCallNode"); + } + + s = s.trim(); + StringBuilder value = new StringBuilder(); + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + break; + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = "%" + varName + "%"; + + value.append(s.substring(i, i1)); + value.append(varValue); + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value.append(s.substring(i)); + + log.info("Parameter {}: [{}]", name, value); + return value.toString(); + } +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java deleted file mode 100644 index 9a1d3a312..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * 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========================================================= - */ - -package org.onap.ccsdk.sli.plugins.sshapicall.model; - -public class RetryException extends Exception { - - public RetryException(String message) { - super(message); - } - -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java deleted file mode 100644 index fef0f81af..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * 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========================================================= - */ - -package org.onap.ccsdk.sli.plugins.sshapicall.model; - -public class RetryPolicy { - private String[] hostnames; - private Integer maximumRetries; - - public Integer getMaximumRetries() { - return maximumRetries; - } - - public String getNextHostName(String uri) throws RetryException { - Integer position = null; - - for (int i = 0; i < hostnames.length; i++) { - if (uri.contains(hostnames[i])) { - position = i; - break; - } - } - - if(position == null){ - throw new RetryException("No match found for the provided uri[" + uri + "] " + - "so the next host name could not be retreived"); - } - position++; - - if (position > hostnames.length - 1) { - position = 0; - } - return hostnames[position]; - } - - public RetryPolicy(String[] hostnames, Integer maximumRetries){ - this.hostnames = hostnames; - this.maximumRetries = maximumRetries; - } - - -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java deleted file mode 100644 index 65575b8ce..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * 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========================================================= - */ - -package org.onap.ccsdk.sli.plugins.sshapicall.model; - -import java.util.HashMap; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RetryPolicyStore { - private static final Logger log = LoggerFactory.getLogger(RetryPolicyStore.class); - - HashMap retryPolicies; - public String proxyServers; - - public String getProxyServers() { - return proxyServers; - } - - public void setProxyServers(String admServers) { - this.proxyServers = admServers; - String[] adminServersArray = admServers.split(","); - RetryPolicy adminPortalRetry = new RetryPolicy(adminServersArray, adminServersArray.length); - retryPolicies.put("dme2proxy", adminPortalRetry); - } - - public RetryPolicyStore() { - retryPolicies = new HashMap<>(); - } - - public RetryPolicy getRetryPolicy(String policyName) { - return (this.retryPolicies.get(policyName)); - } - -} diff --git a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml index 4cce6ffad..50c9b2aa3 100644 --- a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml +++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml @@ -40,12 +40,8 @@ - + - - - - diff --git a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml index c8e9a99e3..25631d6af 100644 --- a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml +++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml @@ -29,6 +29,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml index b24aaf1ee..7a5424329 100755 --- a/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml +++ b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java index 9df790ae3..66be73001 100644 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java @@ -31,6 +31,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import org.codehaus.jettison.json.JSONException; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.sshapicall.model.JsonParser; @@ -50,8 +51,12 @@ public class TestJsonParser { String line; while ((line = in.readLine()) != null) b.append(line).append('\n'); - - Map mm = JsonParser.convertToProperties(b.toString()); + Map mm = null; + try { + mm = JsonParser.convertToProperties(b.toString()); + } catch (JSONException e){ + throw new SvcLogicException(e.getMessage()); + } logProperties(mm); @@ -60,7 +65,12 @@ public class TestJsonParser { @Test(expected = NullPointerException.class) public void testNullString() throws SvcLogicException { - JsonParser.convertToProperties(null); + Map mm = null; + try { + mm = JsonParser.convertToProperties(null); + } catch (JSONException e){ + throw new SvcLogicException(e.getMessage()); + } } private void logProperties(Map mm) { -- cgit 1.2.3-korg From 1476ff884265181b5934d71a7a0e59b705ee1aac Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Thu, 2 Aug 2018 15:06:36 +0900 Subject: dependancy and tests cases added Issue-ID: CCSDK-407 Change-Id: I0450875b0a29cc4612e0979e3d6e97b6c4b398f0 Signed-off-by: Ganesh Chandrasekaran --- features/ccsdk-sli-plugins-all/pom.xml | 7 + .../features/src/main/resources/features.xml | 6 +- .../features/src/main/resources/features.xml | 14 +- sshapi-call-node/provider/ReadMe.md | 32 +++ sshapi-call-node/provider/pom.xml | 31 --- .../sli/plugins/sshapicall/SshApiCallNode.java | 69 ++++--- .../sli/plugins/sshapicall/model/AuthType.java | 2 +- .../ccsdk/sli/plugins/sshapicall/model/Format.java | 2 +- .../sli/plugins/sshapicall/model/JsonParser.java | 2 +- .../sli/plugins/sshapicall/model/Parameters.java | 2 +- .../sli/plugins/sshapicall/model/ParseParam.java | 9 +- .../sli/plugins/sshapicall/model/XmlJsonUtil.java | 2 +- .../sli/plugins/sshapicall/model/XmlParser.java | 2 +- .../sli/plugins/sshapicall/TestJsonParser.java | 2 +- .../sli/plugins/sshapicall/TestSshApiCallNode.java | 228 +++++++++++++++++++++ .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 2 +- .../sli/plugins/sshapicall/TestXmlParser.java | 2 +- 17 files changed, 332 insertions(+), 82 deletions(-) create mode 100644 sshapi-call-node/provider/ReadMe.md create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java (limited to 'sshapi-call-node/provider/src/main') diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index d41b48022..051f3a463 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -51,6 +51,13 @@ xml features + + ${project.groupId} + ccsdk-sshapi-call-node + ${project.version} + xml + features + ${project.groupId} ccsdk-restconf-client diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml index a764aa477..3734a951a 100644 --- a/restapi-call-node/features/src/main/resources/features.xml +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -32,9 +32,9 @@ sdnc-sli spring spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} + mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} mvn:org.codehaus.jettison/jettison/${jettison.version} mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-provider/${project.version} diff --git a/sshapi-call-node/features/src/main/resources/features.xml b/sshapi-call-node/features/src/main/resources/features.xml index 573f5cb05..fd7caf535 100644 --- a/sshapi-call-node/features/src/main/resources/features.xml +++ b/sshapi-call-node/features/src/main/resources/features.xml @@ -35,17 +35,11 @@ sdnc-sli spring spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} - - - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} - mvn:org.codehaus.jettison/jettison/${jettison.version} - - mvn:org.onap.ccsdk.sli.plugins/sshapi-call-node-provider/${project.version} - + mvn:org.onap.ccsdk.sli.core/sli-common/${project.version} + mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} + mvn:org.onap.appc/appc-ssh-adapter-api/1.3.0 + mvn:org.onap.ccsdk.sli.plugins/sshapi-call-node-provider/${project.version} diff --git a/sshapi-call-node/provider/ReadMe.md b/sshapi-call-node/provider/ReadMe.md new file mode 100644 index 000000000..6c31ae0c2 --- /dev/null +++ b/sshapi-call-node/provider/ReadMe.md @@ -0,0 +1,32 @@ +SSHApi-Call-Node Plugin: + +Parameters List that managed in from Directed Graphs: + +Input: +Url -> Mandatory -> url to make the SSH connection request to. +Port -> Mandatory -> port to make the SSH connection request to. +AuthType -> Optional -> Type of authentiation to be used BASIC or sshKey based -> true or false +User -> Optional -> user name to use for ssh basic authentication -> sdnc_ws +Password -> Optional -> unencrypted password to use for ssh basic authentication -> plain_password +SshKey -> Optional -> Consumer SSH key to use for ssh authentication -> plain_key +ExecTimeout -> Optional -> SSH command execution timeout -> plain_key +Retry -> Optional -> Make ssh connection with default retry policy -> plain_key +Cmd -> Mandatory -> ssh command to be executed on the server. -> get post put delete patch +EnvParameters -> Optional -> A JSON dictionary which should list key value pairs to be passed to the command execution. These values would correspond to instance specific parameters that a command may need to execute an action. +FileParameters -> Optional -> A JSON dictionary where keys are filenames and values are contents of files. The SSH Server will utilize this feature to generate files with keys as filenames and values as content. This attribute can be used to generate files that a command may require as part of execution. +ConvertResponse -> Optional -> whether the response should be converted to properties -> true or false +ResponseType -> Optional -> If we know the response is to be in a specific format (supported are JSON, XML and NONE) +ResponsePrefix -> Optional -> location the response will be written to in context memory +listName[i] -> Optional -> Used for processing XML responses with repeating elements.vpn-information.vrf-details + +Output: +"'ResponsePrefix'.sshApi.call.node.status" -> SSH Exit status code is set in here. +"'ResponsePrefix'.sshApi.call.node.stdout" -> SSH command execution result is put in here. +"'ResponsePrefix'.sshApi.call.node.stderr" -> SSH execution failure message is put in here. + + + +API methods that are exposed: +1) execCommand +2) execWithStatusCheck: Throws exception if the exit status is not successful. +3) execCommandWithPty \ No newline at end of file diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index e380d7c25..5434e60fe 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -26,11 +26,6 @@ junit test - - org.springframework - spring-test - test - org.onap.ccsdk.sli.core sli-common @@ -49,32 +44,6 @@ org.json json - - org.slf4j - slf4j-api - - - org.springframework - spring-beans - - - org.springframework - spring-context - - - com.sun.jersey - jersey-client - - - com.sun.jersey.contribs.jersey-oauth - oauth-signature - ${jersey.version} - - - com.sun.jersey.contribs.jersey-oauth - oauth-client - ${jersey.version} - org.codehaus.jettison jettison diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java index e4b082cda..10635be71 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java @@ -3,9 +3,10 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs * ============================================================================= + * Copyright (C) 2018 Samsung Electronics. All rights + reserved. +* * ================================================================================ * 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 @@ -52,22 +53,22 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { /** * Output parameter - SSH command execution status. */ - String PARAM_OUT_status = "status"; + private String PARAM_OUT_status = "sshApi.call.node.status"; /** * Output parameter - content of SSH command stdout. */ - String PARAM_OUT_stdout = "stdout"; + private String PARAM_OUT_stdout = "sshApi.call.node.stdout"; /** * Output parameter - content of SSH command stderr. */ - String PARAM_OUT_stderr = "stderr"; + private String PARAM_OUT_stderr = "sshApi.call.node.stderr"; /** * Default success status. */ - int DEF_SUCCESS_STATUS = 0; + private int DEF_SUCCESS_STATUS = 0; private SshAdapter sshAdapter; @@ -81,7 +82,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * * * * @@ -90,8 +90,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * - * + * + * * vpn-information.vrf-details * * @@ -109,18 +109,29 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { */ public void execCommand(Map params, SvcLogicContext ctx) throws SvcLogicException { + execSshCommand(params, ctx, false); + } + + private void execSshCommand(Map params, SvcLogicContext ctx, boolean withPty) throws SvcLogicException { ParseParam parser = new ParseParam(); Parameters p = parser.getParameters(params); logger.debug("=> Connecting to SSH server..."); - SshConnection sshConnection = getSshConnection(p); - sshConnection.connect(); + SshConnection sshConnection = null; try { + sshConnection = getSshConnection(p); + sshConnection.connect(); logger.debug("=> Connected to SSH server..."); logger.debug("=> Running SSH command..."); sshConnection.setExecTimeout(p.sshExecTimeout); ByteArrayOutputStream stdout = new ByteArrayOutputStream(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - int status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); + int status; + if (withPty) { + status = sshConnection.execCommandWithPty(parser.makeCommand(params), stdout); + stderr = stdout; + } + else + status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); String stdoutRes = stdout.toString(); String stderrRes = stderr.toString(); logger.debug("=> executed SSH command"); @@ -131,12 +142,15 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(PARAM_OUT_status, String.format("%01d", status)); ctx.setAttribute(PARAM_OUT_stdout, stdoutRes); ctx.setAttribute(PARAM_OUT_stderr, stderrRes); + } catch (Exception e){ + throw new SvcLogicException("Exception in SSH adaptor : " + e.getMessage()); } finally { - sshConnection.disconnect(); + if (sshConnection != null) + sshConnection.disconnect(); } } - private SshConnection getSshConnection(Parameters p) throws SvcLogicException{ + private SshConnection getSshConnection(Parameters p) throws SvcLogicException { if (p.authtype == AuthType.BASIC) return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); // This is not supported yet in the API, patch has already been added to APPC @@ -164,7 +178,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
ResponsePrefixOptionallocation the response will be written to in context memory
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE)
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
* * - * * * * @@ -173,8 +186,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * - * + * + * * vpn-information.vrf-details * * @@ -193,16 +206,19 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { public void execWithStatusCheck(Map params, SvcLogicContext ctx) throws SvcLogicException { execCommand(params, ctx); + ParseParam parser = new ParseParam(); + String responsePrefix = parser.getStringParameters(params, parser.SSH_ResponsePrefix); + parseResponse(ctx, responsePrefix); + } + + private void parseResponse (SvcLogicContext ctx, String responsePrefix) throws SvcLogicException { int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status)); if(status != DEF_SUCCESS_STATUS) { StringBuilder errmsg = new StringBuilder(); errmsg.append("SSH command returned error status [").append(status).append(']'); - String stderrRes = ctx.getAttribute(PARAM_OUT_stderr); - String stdoutRes = ctx.getAttribute(PARAM_OUT_stdout); - if((stderrRes != null) && !stderrRes.isEmpty()) { - errmsg.append(". Error: [").append(stderrRes).append(']'); - } else if ((stdoutRes != null) && !stdoutRes.isEmpty()) { - errmsg.append(". Error: [").append(stdoutRes).append(']'); + String stderr = ctx.getAttribute(PARAM_OUT_stderr); + if((stderr != null) && !stderr.isEmpty()) { + errmsg.append(". Error: [").append(stderr).append(']'); } throw new SvcLogicException(errmsg.toString()); } @@ -214,7 +230,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
ResponsePrefixOptionallocation the response will be written to in context memory
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE)
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
* * - * * * * @@ -223,8 +238,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * - * + * + * * vpn-information.vrf-details * * @@ -241,6 +256,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * @param ctx Reference to context memory */ public void execCommandWithPty(Map params, SvcLogicContext ctx) throws SvcLogicException { - + execSshCommand(params, ctx, true); } } diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java index 2ec48c70c..806c80890 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java index e50a96c6c..43c3c38d6 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java index f40f1ad71..296192a5b 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java index a22da5bcb..fa2371e88 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java index caf49ef91..a72bc7bbe 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. @@ -59,6 +59,7 @@ public class ParseParam { * Default SSH command timeout */ private final String FILE_PARAMETERS_OPT_KEY = "FileParameters"; + public final String SSH_ResponsePrefix = "ResponsePrefix"; /** * Default SSH connection port. */ @@ -74,7 +75,7 @@ public class ParseParam { p.sshExecTimeout = Long.parseLong(parseParam(paramMap, "ExecTimeout", false, Long.toString(dEF_timeout))); p.sshWithRetry = Boolean.valueOf(parseParam(paramMap, "Retry", false, "false")); p.cmd = parseParam(paramMap, "Cmd", true, null); - p.responsePrefix = parseParam(paramMap, "ResponsePrefix", false, null); + p.responsePrefix = parseParam(paramMap, SSH_ResponsePrefix, false, null); p.responseType = Format.fromString(parseParam(paramMap, "ResponseType", false, "none")); p.listNameList = getListNameList(paramMap); p.convertResponse = Boolean.valueOf(parseParam(paramMap, "ConvertResponse", false, "true")); @@ -83,6 +84,10 @@ public class ParseParam { return p; } + public String getStringParameters(Map paramMap, String paramName) throws SvcLogicException { + return parseParam(paramMap, SSH_ResponsePrefix, false, null); + } + public void parseOutput (SvcLogicContext ctx, String outMessage) throws SvcLogicException { if (p.convertResponse) { if (p.responseType == Format.NONE) { diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java index e7fc60edb..d68fbc6ac 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java index c23aca6cf..e31754bcd 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java index 66be73001..4a5b765a8 100644 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java new file mode 100644 index 000000000..3992dffe1 --- /dev/null +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java @@ -0,0 +1,228 @@ +package jtest.org.onap.ccsdk.sli.plugins.sshapicall; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode; +import org.onap.ccsdk.sli.plugins.sshapicall.model.XmlParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + +public class TestSshApiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestSshApiCallNode.class); + + private SshApiCallNode adapter; + private String TestId; + private boolean testMode = true; + private Map params; + private SvcLogicContext svcContext; + + + @Before + public void setup() throws IllegalArgumentException { + testMode = true; + svcContext = new SvcLogicContext(); + adapter = new SshApiCallNode(); + + params = new HashMap<>(); + params.put("AgentUrl", "https://192.168.1.1"); + params.put("User", "test"); + params.put("Password", "test"); + } + + @After + public void tearDown() { + testMode = false; + adapter = null; + params = null; + svcContext = null; + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHBasicFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "basic"); + params.put("Cmd", "test"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHKeyFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "key"); + params.put("Cmd", "test"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHNoneFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "none"); + params.put("Cmd", "test"); + params.put("ResponseType", "xml"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "json"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = IllegalArgumentException.class) + public void testExecCommandResponse_noSSHInvalidParam() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "txt"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = IllegalArgumentException.class) + public void testExecCommandResponse_noSSHInvalidAuthParam() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "spring"); + params.put("ResponseType", "json"); + adapter.execWithStatusCheck(params, svcContext); + } +} diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java index 599043e9c..218ad6a8d 100644 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java index d904721f8..3f8d37163 100644 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. -- cgit 1.2.3-korg From efd6f9e3d2f770f16a6cb93efc061fe502a56979 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 3 Aug 2018 18:06:37 +0900 Subject: mocked testcases added Issue-ID: CCSDK-433 Change-Id: I9961df9131b4672a99601b31ed2e9312d0840d6b Signed-off-by: Ganesh Chandrasekaran --- sshapi-call-node/provider/ReadMe.md | 6 +- .../sli/plugins/sshapicall/SshApiCallNode.java | 64 ++++++++---- .../sli/plugins/sshapicall/TestSshApiCallNode.java | 107 +++++++++++++++++++++ 3 files changed, 155 insertions(+), 22 deletions(-) (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/ReadMe.md b/sshapi-call-node/provider/ReadMe.md index 6c31ae0c2..beaadcda8 100644 --- a/sshapi-call-node/provider/ReadMe.md +++ b/sshapi-call-node/provider/ReadMe.md @@ -20,9 +20,9 @@ ResponsePrefix -> Optional -> location the response will be written listName[i] -> Optional -> Used for processing XML responses with repeating elements.vpn-information.vrf-details Output: -"'ResponsePrefix'.sshApi.call.node.status" -> SSH Exit status code is set in here. -"'ResponsePrefix'.sshApi.call.node.stdout" -> SSH command execution result is put in here. -"'ResponsePrefix'.sshApi.call.node.stderr" -> SSH execution failure message is put in here. +"sshApi.call.node.status" -> SSH Exit status code is set in here. +"sshApi.call.node.stdout" -> SSH command execution result is put in here. +"sshApi.call.node.stderr" -> SSH execution failure message is put in here. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java index 10635be71..452d94785 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java @@ -65,11 +65,29 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { */ private String PARAM_OUT_stderr = "sshApi.call.node.stderr"; + /** + * Testing parameter - content of mocked SSH. + */ + private boolean PARAM_TEST_MODE = false; + private String PARAM_OUT_MESSAGE = "TestOut"; + + /** * Default success status. */ private int DEF_SUCCESS_STATUS = 0; + /** + * Used for jUnit test and testing interface + */ + public SshApiCallNode(boolean mode) { + PARAM_TEST_MODE = mode; + } + + public SshApiCallNode() { + PARAM_TEST_MODE = false; + } + private SshAdapter sshAdapter; public void setSshAdapter(SshAdapter sshAdapter) { @@ -117,23 +135,33 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { Parameters p = parser.getParameters(params); logger.debug("=> Connecting to SSH server..."); SshConnection sshConnection = null; + int status = -1; + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + ByteArrayOutputStream stderr = new ByteArrayOutputStream(); + String stdoutRes = "", stderrRes = ""; try { - sshConnection = getSshConnection(p); - sshConnection.connect(); - logger.debug("=> Connected to SSH server..."); - logger.debug("=> Running SSH command..."); - sshConnection.setExecTimeout(p.sshExecTimeout); - ByteArrayOutputStream stdout = new ByteArrayOutputStream(); - ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - int status; - if (withPty) { - status = sshConnection.execCommandWithPty(parser.makeCommand(params), stdout); - stderr = stdout; + if (!PARAM_TEST_MODE) { + sshConnection = getSshConnection(p); + sshConnection.connect(); + logger.debug("=> Connected to SSH server..."); + logger.debug("=> Running SSH command..."); + sshConnection.setExecTimeout(p.sshExecTimeout); + if (withPty) { + status = sshConnection.execCommandWithPty(parser.makeCommand(params), stdout); + stderr = stdout; + } + else + status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); + stdoutRes = stdout.toString(); + stderrRes = stderr.toString(); + + } else { + if (params.get("TestFail").equalsIgnoreCase("true")) + status = 202; + else + status = DEF_SUCCESS_STATUS; + stdoutRes = params.get(PARAM_OUT_MESSAGE); } - else - status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); - String stdoutRes = stdout.toString(); - String stderrRes = stderr.toString(); logger.debug("=> executed SSH command"); if(status == DEF_SUCCESS_STATUS) { @@ -206,12 +234,10 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { public void execWithStatusCheck(Map params, SvcLogicContext ctx) throws SvcLogicException { execCommand(params, ctx); - ParseParam parser = new ParseParam(); - String responsePrefix = parser.getStringParameters(params, parser.SSH_ResponsePrefix); - parseResponse(ctx, responsePrefix); + parseResponse(ctx); } - private void parseResponse (SvcLogicContext ctx, String responsePrefix) throws SvcLogicException { + private void parseResponse (SvcLogicContext ctx) throws SvcLogicException { int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status)); if(status != DEF_SUCCESS_STATUS) { StringBuilder errmsg = new StringBuilder(); diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java index 3992dffe1..544057a6e 100644 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java @@ -225,4 +225,111 @@ public class TestSshApiCallNode { params.put("ResponseType", "json"); adapter.execWithStatusCheck(params, svcContext); } + + @Test + public void testExecCommandResponse_validJSON() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "json"); + params.put("TestOut", "{\"equipment-data\":\"boo\"}"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("boo", svcContext.getAttribute("equipment-data")); + } + + @Test + public void testExecCommandResponse_validXML() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("modelVersion")); + } + + @Test + public void testExecCommandResponse_validJSONPrefix() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "json"); + params.put("TestOut", "{\"equipment-data\":\"boo\"}"); + params.put("ResponsePrefix", "test"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("boo", svcContext.getAttribute("test.equipment-data")); + } + + @Test + public void testExecCommandResponse_validXMLPrefix() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("ResponsePrefix", "test"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_validXMLFail() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("TestFail", "true"); + params.put("ResponsePrefix", "test"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_validXMLPrefixKey() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + params = new HashMap<>(); + params.put("Url", "test"); + params.put("Port", "10"); + params.put("SshKey", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("ResponsePrefix", "test"); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); + } } -- cgit 1.2.3-korg From f2cb0a21b9b7d4a48f25a34c9a57197cbec5dd79 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 8 Dec 2018 12:42:29 +0530 Subject: Sonar Fix: sshapi-call-node-provider-XmlParer.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-802 Change-Id: I5be30cd2270cda66108489456ac6566b1aa6dec7 Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java index e31754bcd..f386d401a 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java @@ -3,6 +3,8 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * + * Modifications Copyright © 2018 IBM. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. @@ -79,6 +81,9 @@ public final class XmlParser { return properties; } + StringBuilder currentName = new StringBuilder(); + StringBuilder currentValue = new StringBuilder(); + public Handler(Set listNameList) { super(); this.listNameList = listNameList; @@ -86,9 +91,6 @@ public final class XmlParser { this.listNameList = new HashSet<>(); } - StringBuilder currentName = new StringBuilder(); - StringBuilder currentValue = new StringBuilder(); - @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { -- cgit 1.2.3-korg From a6ded88f4df6f21c2452af2d6079e5150a321a40 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 28 Dec 2018 23:49:12 +0530 Subject: Sonar fix: SshApiCallNode.java Fixed sonar issues/code-smells acros this file Issue-ID: CCSDK-881 Change-Id: Ie1a98a47cedd7781e1e965825b152a50b7912ab0 Signed-off-by: Arundathi Patil --- .../sli/plugins/sshapicall/SshApiCallNode.java | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java index 452d94785..146188fb9 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java @@ -6,7 +6,9 @@ * ============================================================================= * Copyright (C) 2018 Samsung Electronics. All rights reserved. -* * ================================================================================ + * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -24,16 +26,9 @@ package org.onap.ccsdk.sli.plugins.sshapicall; -//import com.fasterxml.jackson.databind.ObjectMapper; - import java.io.ByteArrayOutputStream; -import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; -import com.google.common.base.Strings; -import org.json.JSONObject; import org.onap.appc.adapter.ssh.SshAdapter; import org.onap.appc.adapter.ssh.SshConnection; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -77,6 +72,10 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { */ private int DEF_SUCCESS_STATUS = 0; + + + private SshAdapter sshAdapter; + /** * Used for jUnit test and testing interface */ @@ -88,8 +87,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { PARAM_TEST_MODE = false; } - private SshAdapter sshAdapter; - public void setSshAdapter(SshAdapter sshAdapter) { this.sshAdapter = sshAdapter; } @@ -138,7 +135,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { int status = -1; ByteArrayOutputStream stdout = new ByteArrayOutputStream(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - String stdoutRes = "", stderrRes = ""; + String stdoutRes = ""; + String stderrRes = ""; try { if (!PARAM_TEST_MODE) { sshConnection = getSshConnection(p); @@ -156,7 +154,7 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { stderrRes = stderr.toString(); } else { - if (params.get("TestFail").equalsIgnoreCase("true")) + if (("true").equalsIgnoreCase(params.get("TestFail"))) status = 202; else status = DEF_SUCCESS_STATUS; @@ -183,11 +181,9 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); // This is not supported yet in the API, patch has already been added to APPC else if (p.authtype == AuthType.KEY){ - //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); throw new SvcLogicException("SSH Key based Auth method not supported"); } else if (p.authtype == AuthType.NONE){ - //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); throw new SvcLogicException("SSH Auth type required, BASIC auth in support"); } else if (p.authtype == AuthType.UNSPECIFIED){ -- cgit 1.2.3-korg From 98a18cb948cad4e8490ae89a4ba6a5a4e0dcc99c Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 28 Dec 2018 23:58:07 +0530 Subject: Sonar fix: JsonParser.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-882 Change-Id: I9e3dbe8407553b83d6885579bad9dbe06e04ba72 Signed-off-by: Arundathi Patil --- .../java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java index 296192a5b..3d48a790f 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java @@ -7,6 +7,8 @@ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -33,7 +35,6 @@ import java.util.Map; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -- cgit 1.2.3-korg From 8674ebef24904d6a6acdb3918241fc0576fdea6e Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 29 Dec 2018 00:02:42 +0530 Subject: Sonar fix: ParseParam.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-883 Change-Id: I69b08b1b9bd94df2815f8957f2f50527ac8b67fc Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java index a72bc7bbe..35c1087d8 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java @@ -7,6 +7,8 @@ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -32,12 +34,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashSet; -- cgit 1.2.3-korg From f6503a043bd4fb848d28d2f5d4aa45224041e099 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 29 Dec 2018 00:08:23 +0530 Subject: Sonar fix: XmlParser.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-800 Change-Id: I8d00a6e07bedeee7d5f3afebed982453fe0a4c2d Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sshapi-call-node/provider/src/main') diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java index f386d401a..6ea770ad9 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java @@ -77,10 +77,6 @@ public final class XmlParser { private Map properties = new HashMap<>(); - public Map getProperties() { - return properties; - } - StringBuilder currentName = new StringBuilder(); StringBuilder currentValue = new StringBuilder(); @@ -91,6 +87,10 @@ public final class XmlParser { this.listNameList = new HashSet<>(); } + public Map getProperties() { + return properties; + } + @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { -- cgit 1.2.3-korg From 9e7f1417df26d634482f053be2cf39b920a22106 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 9 Jul 2019 13:41:32 -0400 Subject: Code changes for Neon Updated code via ccsdk/parent/tools/fluorine2neon.sh script. Change-Id: Ice154214e118ca6ad5043eb0fe337095fd2246d9 Issue-ID: CCSDK-1389 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 +- features/ccsdk-sli-plugins-all/pom.xml | 4 +- features/features-sli-plugins/pom.xml | 4 +- features/installer/pom.xml | 4 +- features/pom.xml | 4 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 +- grToolkit/features/features-gr-toolkit/pom.xml | 4 +- grToolkit/features/pom.xml | 4 +- grToolkit/installer/pom.xml | 4 +- grToolkit/model/pom.xml | 14 +++--- grToolkit/pom.xml | 4 +- grToolkit/provider/pom.xml | 4 +- .../resources/OSGI-INF/blueprint/GrToolkit.xml | 33 ++++++++++++++ pom.xml | 4 +- .../features/ccsdk-properties-node/pom.xml | 4 +- .../features/features-properties-node/pom.xml | 4 +- properties-node/features/pom.xml | 4 +- properties-node/installer/pom.xml | 4 +- properties-node/pom.xml | 4 +- properties-node/provider/pom.xml | 4 +- .../blueprint/properties-node-blueprint.xml | 16 +++++++ .../features/ccsdk-restapi-call-node/pom.xml | 4 +- .../features/features-restapi-call-node/pom.xml | 4 +- restapi-call-node/features/pom.xml | 4 +- restapi-call-node/installer/pom.xml | 4 +- restapi-call-node/pom.xml | 4 +- restapi-call-node/provider/pom.xml | 4 +- .../blueprint/restapi-call-node-blueprint.xml | 16 +++++++ .../features/ccsdk-restconf-client/pom.xml | 4 +- .../features/features-restconf-client/pom.xml | 4 +- restconf-client/features/pom.xml | 4 +- restconf-client/installer/pom.xml | 4 +- restconf-client/pom.xml | 4 +- restconf-client/provider/pom.xml | 4 +- .../blueprint/restconf-client-blueprint.xml | 51 ++++++++++++++++++++++ .../features/ccsdk-sshapi-call-node/pom.xml | 4 +- .../features/features-sshapi-call-node/pom.xml | 4 +- sshapi-call-node/features/pom.xml | 4 +- sshapi-call-node/installer/pom.xml | 4 +- sshapi-call-node/pom.xml | 4 +- sshapi-call-node/provider/pom.xml | 4 +- .../blueprint/sshapi-call-node-blueprint.xml | 16 +++++++ template-node/features/ccsdk-template-node/pom.xml | 4 +- .../features/features-template-node/pom.xml | 4 +- template-node/features/pom.xml | 4 +- template-node/installer/pom.xml | 4 +- template-node/pom.xml | 4 +- template-node/provider/pom.xml | 4 +- version.properties | 4 +- 49 files changed, 224 insertions(+), 94 deletions(-) create mode 100755 grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml create mode 100755 properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml create mode 100755 restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml create mode 100755 restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml create mode 100755 sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml (limited to 'sshapi-call-node/provider/src/main') diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 9bc3a9c9b..7e395c9f9 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 6b7bf94d6..bbcfb7570 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 436306765..1ace61b96 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 3d662e444..334748748 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 29a67a820..6e349ca4a 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 1f4aec3f8..3266f6604 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 65b1a5d57..511ba38a0 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index c7f8ffea7..34f706c8f 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 64e172cc2..8c7ec32b2 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index f400a04cc..8abf89a08 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,23 +4,21 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle - org.opendaylight.mdsal.model - ietf-inet-types-2013-07-15 - - - org.opendaylight.mdsal.model - ietf-yang-types-20130715 + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index c36c1a08d..916df4427 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 1d8149592..0267f2488 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml new file mode 100755 index 000000000..5a4492c56 --- /dev/null +++ b/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 32ce564cd..6ee7dea9d 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 45adc9364..4781ac382 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 16588adbd..58944cceb 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 96121c6bc..bd93644d7 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index cfc02dd3d..536e20478 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index aa5e75a52..09991f46f 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 1f9fd46e2..8ca58c45c 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml b/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml new file mode 100755 index 000000000..6e1d48efd --- /dev/null +++ b/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.prop.PropertiesNode + + + + \ No newline at end of file diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 6578de4e9..2697c4ea7 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index dd3af78a3..41a5d8a4b 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 48b91821e..981db516a 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index f63597c57..8b2d60ba6 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 10497fd36..d6fb0b49c 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 74f0a98be..7a03a38c3 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml b/restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml new file mode 100755 index 000000000..390bb0a35 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode + + + + \ No newline at end of file diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index af235f856..8faa16a00 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 17065acbe..790e5b128 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 455987fcb..4537098fb 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index e7d8b4af4..09d290044 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 296282a56..e8b0123c3 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 1a734cdd2..ab685bb8b 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml b/restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml new file mode 100755 index 000000000..45c335b13 --- /dev/null +++ b/restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode + + + + + + org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode + + + + \ No newline at end of file diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 3f6c97c1d..44c5540f3 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 8a496684f..893b68a76 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 4db5892e3..6e31170a7 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 5d4ef718d..1b248a3d6 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 90bb6d511..66e2af306 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 8af4faac5..cd920a875 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml b/sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml new file mode 100755 index 000000000..7a5424329 --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode + + + + \ No newline at end of file diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index a1b16a5ff..91658ae62 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index c220d4fb8..105a03245 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 143d9742f..391a6ce14 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 5de128457..2a5891dd4 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 519388292..0c811f714 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index d3dd79412..f9cd3ef2d 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index dc2c5ad2a..3fc281cbc 100644 --- a/version.properties +++ b/version.properties @@ -6,8 +6,8 @@ # Comment release_name=0 -sprint_number=5 -feature_revision=2 +sprint_number=6 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
ResponsePrefixOptionallocation the response will be written to in context memory
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE)
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false