From 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:14:21 -0800 Subject: Second part of onap rename This is the second commit of the rename. The folder structure is renamed for appc-adapters and appc-config in this commit. Change-Id: Iaa2b8c937ff1ca1b5d1178128961fb115ee65d9b Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../netconf/AppcNetconfAdapterActivator.java | 139 ++++++++++++ .../appc/adapter/netconf/ConnectionDetails.java | 67 ++++++ .../netconf/MockOperationalStateValidatorImpl.java | 48 +++++ .../onap/appc/adapter/netconf/NetconfClient.java | 64 ++++++ .../appc/adapter/netconf/NetconfClientFactory.java | 43 ++++ .../adapter/netconf/NetconfClientRestconf.java | 68 ++++++ .../appc/adapter/netconf/NetconfClientType.java | 31 +++ .../adapter/netconf/NetconfConnectionDetails.java | 95 +++++++++ .../adapter/netconf/NetconfDataAccessService.java | 85 ++++++++ .../adapter/netconf/OperationalStateValidator.java | 35 +++ .../netconf/OperationalStateValidatorFactory.java | 55 +++++ .../netconf/VNFOperationalStateValidatorImpl.java | 132 ++++++++++++ .../org/onap/appc/adapter/netconf/VnfType.java | 58 +++++ .../netconf/exception/DataAccessException.java | 47 ++++ .../netconf/exception/NetconfDAOException.java | 47 ++++ .../adapter/netconf/internal/NetconfAdapter.java | 132 ++++++++++++ .../adapter/netconf/internal/NetconfAdapter2.java | 105 +++++++++ .../netconf/internal/NetconfConstMessages.java | 56 +++++ .../internal/NetconfDataAccessServiceImpl.java | 147 +++++++++++++ .../adapter/netconf/internal/NetconfMessage.java | 97 +++++++++ .../onap/appc/adapter/netconf/jsch/JSchLogger.java | 63 ++++++ .../adapter/netconf/jsch/NetconfClientJsch.java | 170 +++++++++++++++ .../odlconnector/NetconfClientRestconfImpl.java | 236 +++++++++++++++++++++ .../onap/appc/adapter/netconf/util/Constants.java | 68 ++++++ .../netconf/AppcNetconfAdapterActivator.java | 139 ------------ .../appc/adapter/netconf/ConnectionDetails.java | 67 ------ .../netconf/MockOperationalStateValidatorImpl.java | 48 ----- .../appc/adapter/netconf/NetconfClient.java | 64 ------ .../appc/adapter/netconf/NetconfClientFactory.java | 43 ---- .../adapter/netconf/NetconfClientRestconf.java | 68 ------ .../appc/adapter/netconf/NetconfClientType.java | 31 --- .../adapter/netconf/NetconfConnectionDetails.java | 95 --------- .../adapter/netconf/NetconfDataAccessService.java | 85 -------- .../adapter/netconf/OperationalStateValidator.java | 35 --- .../netconf/OperationalStateValidatorFactory.java | 55 ----- .../netconf/VNFOperationalStateValidatorImpl.java | 132 ------------ .../openecomp/appc/adapter/netconf/VnfType.java | 58 ----- .../netconf/exception/DataAccessException.java | 47 ---- .../netconf/exception/NetconfDAOException.java | 47 ---- .../adapter/netconf/internal/NetconfAdapter.java | 132 ------------ .../adapter/netconf/internal/NetconfAdapter2.java | 105 --------- .../netconf/internal/NetconfConstMessages.java | 56 ----- .../internal/NetconfDataAccessServiceImpl.java | 147 ------------- .../adapter/netconf/internal/NetconfMessage.java | 97 --------- .../appc/adapter/netconf/jsch/JSchLogger.java | 63 ------ .../adapter/netconf/jsch/NetconfClientJsch.java | 170 --------------- .../odlconnector/NetconfClientRestconfImpl.java | 236 --------------------- .../appc/adapter/netconf/util/Constants.java | 68 ------ 48 files changed, 2088 insertions(+), 2088 deletions(-) create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/ConnectionDetails.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/MockOperationalStateValidatorImpl.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClient.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientFactory.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientRestconf.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientType.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfConnectionDetails.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfDataAccessService.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidator.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidatorFactory.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VnfType.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/DataAccessException.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/NetconfDAOException.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter2.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfConstMessages.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfMessage.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/JSchLogger.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/NetconfClientJsch.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/util/Constants.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java') diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java new file mode 100644 index 000000000..bae220d13 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.adapter.netconf.internal.NetconfDataAccessServiceImpl; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.appc.i18n.Msg; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +public class AppcNetconfAdapterActivator implements BundleActivator { + + /** + * The bundle registration + */ + private ServiceRegistration registration = null; + private ServiceRegistration reporterRegistration = null; + private ServiceRegistration factoryRegistration = null; + private ServiceRegistration dbRegistration = null; + + /** + * The reference to the actual implementation object that implements the services + */ + private NetconfClientFactory clientFactory; + private NetconfDataAccessService DAService; + + /** + * The logger to be used + */ + private static final EELFLogger logger = EELFManager.getInstance().getLogger(AppcNetconfAdapterActivator.class); + + /** + * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start + * this bundle. This method can be used to register services or to allocate any resources that this bundle needs. + *

+ * This method must complete and return to its caller in a timely manner. + *

+ * + * @param context + * The execution context of the bundle being started. + * @throws java.lang.Exception + * If this method throws an exception, this bundle is marked as stopped and the Framework will remove + * this bundle's listeners, unregister all services registered by this bundle, and release all services + * used by this bundle. + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + if (registration == null) { + clientFactory = new NetconfClientFactory(); + factoryRegistration = context.registerService(NetconfClientFactory.class, clientFactory, null); + + DAService = new NetconfDataAccessServiceImpl(); + //set dblib service + DbLibService dblibSvc = null; + ServiceReference sref = context.getServiceReference(DbLibService.class.getName()); + try{ + dblibSvc = (DbLibService)context.getService(sref); + }catch(Exception e){ + logger.error(e.getMessage()); + } + DAService.setDbLibService(dblibSvc); + /////////////////////////////////// + factoryRegistration = context.registerService(NetconfDataAccessService.class, DAService, null); + } + + logger.info(Msg.COMPONENT_INITIALIZED, "NETCONF adapter"); + } + + /** + * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop + * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There + * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not + * call any Framework objects. + *

+ * This method must complete and return to its caller in a timely manner. + *

+ * + * @param context + * The execution context of the bundle being stopped. + * @throws java.lang.Exception + * If this method throws an exception, the bundle is still marked as stopped, and the Framework will + * remove the bundle's listeners, unregister all services registered by the bundle, and release all + * services used by the bundle. * + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + if (registration != null) { + registration.unregister(); + registration = null; + } + if (reporterRegistration != null) { + reporterRegistration.unregister(); + reporterRegistration = null; + } + + if (null != factoryRegistration) { + factoryRegistration.unregister(); + factoryRegistration = null; + } + + if (dbRegistration != null) { + dbRegistration.unregister(); + dbRegistration = null; + } + } + + public String getName() { + return "APPC NETCONF adapter"; + } + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/ConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/ConnectionDetails.java new file mode 100644 index 000000000..7536f9655 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/ConnectionDetails.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + + +public class ConnectionDetails { + + private String host; + private int port; + private String username; + private String password; + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/MockOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/MockOperationalStateValidatorImpl.java new file mode 100644 index 000000000..079ae76a4 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/MockOperationalStateValidatorImpl.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.exceptions.APPCException; + + +public class MockOperationalStateValidatorImpl implements OperationalStateValidator { + @Override + public VnfType getVnfType() { + return VnfType.MOCK; + } + + @Override + public String getConfigurationFileName() { + String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX); + return configFileName; + } + + @Override + public void validateResponse(String response) throws APPCException { + if(response != null && response.toUpperCase().contains("INVALID")){ + throw new APPCException("INVALID"); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClient.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClient.java new file mode 100644 index 000000000..eaed60fc0 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClient.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.exceptions.APPCException; + + + +public interface NetconfClient { + + /** + * Open connection to netconf device. + * + * @param connectionDetails object providing details required for netconf connection + */ + void connect(NetconfConnectionDetails connectionDetails) throws APPCException; + + /** + * Send Netconf message to device and receive response. + * + * @param message input netconf xml message + * @return output netconf xml message + */ + String exchangeMessage(String message) throws APPCException; + + /** + * send configuration to Netconf server + * + * @param configuration - xml configuration payload + */ + void configure(String configuration) throws APPCException; + + /** + * returns running configuration of Netconf server + */ + String getConfiguration() throws APPCException; + + /** + * Disconnect from netconf device. + */ + void disconnect() throws APPCException; +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientFactory.java new file mode 100644 index 000000000..45c8fb0ed --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientFactory.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; +import org.onap.appc.adapter.netconf.odlconnector.NetconfClientRestconfImpl; + + +public class NetconfClientFactory { + + public NetconfClient GetNetconfClient(NetconfClientType type){ + + if(type==NetconfClientType.RESTCONF) { + return new NetconfClientRestconfImpl(); + }else if(type == NetconfClientType.SSH){ + return new NetconfClientJsch(); + } + + return null; + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientRestconf.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientRestconf.java new file mode 100644 index 000000000..a23a16797 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientRestconf.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.exceptions.APPCException; + + + +public interface NetconfClientRestconf { + + /* + mount device to controller + @param deviceMountPointName - the name of the mounting point in controller + @param payload - json data describing device info + */ + void connect(String deviceMountPointName, String payload) throws APPCException; + + /* + check connection to device + @param deviceMountPointName - the name of the mounting point in controller + */ + boolean checkConnection(String deviceMountPointName) throws APPCException; + + /* + send configuration to Netconf server + @param configuration - xml configuration payload + @param deviceMountPointName - the name of the mounting point in controller + @param moduleName - name of the yang model + @param nodeName - name of the node created in server + */ + void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException; + + /* + returns configuration of Netconf server + @param deviceMountPointName - the name of the mounting point in controller + @param moduleName - name of the yang model + @param nodeName - name of the node created in server + */ + String getConfiguration(String deviceName, String moduleName, String nodeName) throws APPCException; + + /* + unmount device + @param deviceMountPointName - the name of the mounting point in controller + */ + void disconnect(String deviceMountPointName) throws APPCException; +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientType.java new file mode 100644 index 000000000..bf7512456 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientType.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + + +public enum NetconfClientType { + RESTCONF, + SSH +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfConnectionDetails.java new file mode 100644 index 000000000..e7c0cc44d --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfConnectionDetails.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import java.util.List; +import java.util.Properties; + +/** + * Provides details required for connecting to netconf device. + */ +public class NetconfConnectionDetails { + + private String host; + private int port; + private String username; + private String password; + + public static int DEFAULT_PORT = 830; + private List capabilities; + private Properties additionalProperties; + + public NetconfConnectionDetails() { + super(); + setPort(DEFAULT_PORT); + } + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getCapabilities() { + return capabilities; + } + + public void setCapabilities(List capabilities) { + this.capabilities = capabilities; + } + + public Properties getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Properties additionalProperties) { + this.additionalProperties = additionalProperties; + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfDataAccessService.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfDataAccessService.java new file mode 100644 index 000000000..f831541da --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfDataAccessService.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.adapter.netconf.exception.DataAccessException; +import org.onap.ccsdk.sli.core.dblib.DbLibService; + + +@SuppressWarnings("JavaDoc") +public interface NetconfDataAccessService { + + /** + * + * @param schema + */ + void setSchema(String schema); + + /** + * + * @param dbLibService + */ + void setDbLibService(DbLibService dbLibService); + + /** + * + * @param xmlID + * @return + * @throws DataAccessException + */ + String retrieveConfigFileName(String xmlID) throws DataAccessException; + + /** + * + * @param vnfType + * @param connectionDetails + * @return + * @throws DataAccessException + */ + boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws DataAccessException; + + /** + * + * @param vnfType + * @param connectionDetails + * @return + * @throws DataAccessException + */ + boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws + DataAccessException; + + /** + * + * @param instanceId + * @param requestId + * @param creationDate + * @param logText + * @return + * @throws DataAccessException + */ + boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws + DataAccessException; + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidator.java new file mode 100644 index 000000000..ffa3862e8 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidator.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.onap.appc.exceptions.APPCException; + + +public interface OperationalStateValidator { + public VnfType getVnfType(); + public String getConfigurationFileName(); + public void validateResponse(String response) throws APPCException; + final public static String CONFIG_FILE_PROPERTY_SUFFIX = "-CONFIG_FILE"; +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidatorFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidatorFactory.java new file mode 100644 index 000000000..37e96917d --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidatorFactory.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.apache.commons.lang3.NotImplementedException; +import org.onap.appc.configuration.Configuration; +import org.onap.appc.configuration.ConfigurationFactory; + +public class OperationalStateValidatorFactory { + protected static final Configuration configuration = ConfigurationFactory.getConfiguration(); + + public static OperationalStateValidator getOperationalStateValidator(String vnfType) { + VnfType vnfTypeEnum = null; + try { + vnfTypeEnum = VnfType.getVnfType(vnfType); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Illegal value in vnfType. vnfType="+vnfType,e); + } + return getOperationalStateValidator(vnfTypeEnum); + } + + public static OperationalStateValidator getOperationalStateValidator(VnfType vnfType) { + switch (vnfType) { + case VNF: + case VNF_MOCK: + return new VNFOperationalStateValidatorImpl(); + case MOCK: + return new MockOperationalStateValidatorImpl(); + default: + throw new NotImplementedException("missing implementaion for the given vnfType:" + vnfType.name()); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java new file mode 100644 index 000000000..4bb5ab238 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +import org.apache.commons.lang3.StringUtils; +import org.onap.appc.exceptions.APPCException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.*; + +public class VNFOperationalStateValidatorImpl implements OperationalStateValidator { + private static final String OPERATIONAL_STATE_ELEMENT_NAME = "operationalState"; + @Override + public VnfType getVnfType() { + return VnfType.VNF; + } + + @Override + public String getConfigurationFileName() { + String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX); + configFileName = configFileName == null? "VnfGetOperationalStates" : configFileName; + return configFileName; + } + + @Override + public void validateResponse(String response) throws APPCException { + if(StringUtils.isEmpty(response)) { + throw new APPCException("empty response"); + } + + boolean isValid = false; + String errorMsg = "unexpected response"; + try { + List operationalStateList = getOperationalStateList(response); + if(operationalStateList != null && !operationalStateList.isEmpty()) { + for (Map.Entry stateEntry : operationalStateList) { + if(!((String)stateEntry.getValue()).equalsIgnoreCase("ENABLED")){ + errorMsg = "at least one "+OPERATIONAL_STATE_ELEMENT_NAME+" is not in valid satae. "+operationalStateList.toString(); + isValid = false; + break; + }else{ + isValid =true; + } + } + }else { + errorMsg = "response without any "+OPERATIONAL_STATE_ELEMENT_NAME+" element"; + } + } catch (Exception e ) { + isValid = false; + errorMsg = e.toString(); + } + if(!isValid) throw new APPCException(errorMsg); + } + + private static List getOperationalStateList(String xmlText) throws IOException, ParserConfigurationException, SAXException { + List entryList = null; + if(StringUtils.isNotEmpty(xmlText)) { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + + Document document = builder.parse(new ByteArrayInputStream(xmlText.getBytes("UTF-8"))); + if(document != null) { + Element rootElement = document.getDocumentElement(); + NodeList nodeList = rootElement.getElementsByTagName(OPERATIONAL_STATE_ELEMENT_NAME); + if (nodeList != null && nodeList.getLength() > 0) { + for (int i = 0; i < nodeList.getLength(); i++) { + Node node = nodeList.item(i); + String text = node.getTextContent(); + String id = getElementID(node); + entryList = (entryList == null) ? new ArrayList() : entryList; + Map.Entry entry = new AbstractMap.SimpleEntry(id, text); + entryList.add(entry); + } + } + } + } + return entryList; + } + + private static String getElementID(Node node) { + String id = null; + Node parentNode = node.getParentNode(); + if (parentNode != null) { + if (node.getNodeType() == Node.ELEMENT_NODE) { + NodeList nodeList = ((Element) parentNode).getElementsByTagName("id"); + if (nodeList != null && nodeList.getLength() > 0) { + Node idNode = nodeList.item(0); + id = idNode != null ? idNode.getTextContent() : null; + } + }else { + id = parentNode.getNodeValue()+"|"+parentNode.getTextContent(); + } + } + + id = StringUtils.isEmpty(id) ? null : StringUtils.normalizeSpace(id); + id = StringUtils.isBlank(id) ? null : id; + id = id != null ? id : "unknown-id"; + return id; + } + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VnfType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VnfType.java new file mode 100644 index 000000000..19edc2fd3 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VnfType.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf; + +public enum VnfType { + VNF("VNF"), + MOCK("MOCK"), + VNF_MOCK("MOCK"), + ; + + String familyType; + String upperCaseName; + VnfType(String familyType) { + this.familyType = familyType; + this.upperCaseName = name().toUpperCase(); + } + + public VnfType getFamilyType() { + return VnfType.valueOf(familyType); + } + + public String getUpperCaseName() { + return upperCaseName; + } + + public static VnfType getVnfType(String inSensitiveCaseName){ + String localUpperCaseName = inSensitiveCaseName.toUpperCase(); + for(VnfType vnfType : VnfType.values()){ + if(vnfType.getUpperCaseName().equals(localUpperCaseName)){ + return vnfType; + } + } + throw new IllegalArgumentException( + "No enum with upperCaseName for this input value:" + inSensitiveCaseName ); + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/DataAccessException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/DataAccessException.java new file mode 100644 index 000000000..0c4964da0 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/DataAccessException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.exception; + + +public class DataAccessException extends RuntimeException { + + private static final long serialVersionUID = -155423437162622414L; + + public DataAccessException(){ + } + + public DataAccessException(String message){ + super(message); + } + + public DataAccessException(Throwable cause){ + super(cause); + } + + public DataAccessException(String message , Throwable cause){ + super(message , cause); + } + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/NetconfDAOException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/NetconfDAOException.java new file mode 100644 index 000000000..5ff1a331e --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/NetconfDAOException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.exception; + +public class NetconfDAOException extends RuntimeException { + + private static final long serialVersionUID = -155423437162622414L; + + public NetconfDAOException(){ + } + + public NetconfDAOException(String message){ + super(message); + } + + public NetconfDAOException(Throwable cause){ + super(cause); + } + + public NetconfDAOException(String message , Throwable cause){ + super(message , cause); + } + + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter.java new file mode 100644 index 000000000..2d8c6f417 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.internal; + +import org.onap.appc.configuration.ConfigurationFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.concurrent.*; + +/** + * Provides basic methods for exchanging netconf messages. + */ +public class NetconfAdapter { + + private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter.class); + private static final long MAX_WAITING_TIME = 1800000; + private static ExecutorService executor = Executors.newFixedThreadPool(5); + + // device input stream + private InputStream in; + // device output stream + private OutputStream out; + private long maxWaitingTime = ConfigurationFactory.getConfiguration().getLongProperty("org.onap.appc.netconf.recv.timeout", MAX_WAITING_TIME); + + /** + * Constructor. + * + * @param in InputStream this instance will read netconf messages from + * @param out OutputStream this instance will write netconf messages to + * @throws IOException + */ + public NetconfAdapter(InputStream in, OutputStream out) throws IOException { + this.in = in; + this.out = out; + } + + /** + * Receives netconf message from InputStream and return it's text (without netconf frame characters). + * + * @return text of message received from netconf device + * @throws IOException + */ + public String receiveMessage() throws IOException { + + final NetconfMessage message = new NetconfMessage(); + final byte[] buf = new byte[1024]; + + //int readByte = 1; + // Read data with timeout + Callable readTask = new Callable() { + @Override + public Boolean call() throws Exception { + int c; + while ((c = in.read(buf)) > 0) { + if (c > 0) { + message.append(buf, 0, c); + if (message.isCompleted()) { + break; + } + } + } + + if (c < 0) { + return false; + } + return true; + } + }; + + Future future = executor.submit(readTask); + Boolean status; + try { + status = future.get(maxWaitingTime, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw new IOException(e); + } + + if (status == false) { + throw new IOException("Failed to read netconf message"); + } + + + String text = message.getText(); + if (text != null) { + text = text.trim(); + } + if (LOG.isDebugEnabled()) { + LOG.debug("Received message from netconf device:\n" + text); + } + return text; + } + + /** + * Sends netconf message with provided text (adds netconf frame characters and sends the message). + * + * @param text text of message to be sent to netconf device + * @throws IOException + */ + public void sendMessage(final String text) throws IOException { + if (LOG.isDebugEnabled()) { + LOG.debug("Sending message to netconf device:\n" + text); + } + out.write(new NetconfMessage(text).getFrame()); + out.flush(); + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter2.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter2.java new file mode 100644 index 000000000..928d77470 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter2.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.internal; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; + +/** + * Provides basic methods for exchanging netconf messages. + */ +public class NetconfAdapter2 { + + private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter2.class); + + // device input pipe + private final PipedOutputStream pipedOutIn = new PipedOutputStream(); + private PipedInputStream in; + // device output pipe + private final PipedInputStream pipedInOut = new PipedInputStream(); + private PipedOutputStream out; + + /** + * Constructor. + * + * @throws IOException + */ + public NetconfAdapter2() throws IOException { + in = new PipedInputStream(pipedOutIn); + out = new PipedOutputStream(pipedInOut); + } + + /** + * @return InputStream this instance will read netconf messages from. + */ + public InputStream getIn() { + return in; + } + + /** + * @return OutputStream this instance will write netconf messages to. + */ + public OutputStream getOut() { + return out; + } + + /** + * Receives netconf message from InputStream and return it's text (without netconf frame characters). + * + * @return text of message received from netconf device + * @throws IOException + */ + public String receiveMessage() throws IOException { + NetconfMessage message = new NetconfMessage(); + byte[] buf = new byte[1024]; + int c; + while((c = pipedInOut.read(buf)) > 0) { + message.append(buf, 0, c); + if (message.isCompleted()) { + break; + } + } + String text = message.getText(); + if(LOG.isDebugEnabled()) { + LOG.debug("Received message from netconf device:\n" + text); + } + return text; + } + + /** + * Sends netconf message with provided text (adds netconf frame characters and sends the message). + * + * @param text text of message to be sent to netconf device + * @throws IOException + */ + public void sendMessage(final String text) throws IOException { + if(LOG.isDebugEnabled()) { + LOG.debug("Sending message to netconf device:\n" + text); + } + pipedOutIn.write(new NetconfMessage(text).getFrame()); + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfConstMessages.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfConstMessages.java new file mode 100644 index 000000000..c7ad9bc50 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfConstMessages.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.internal; + +public class NetconfConstMessages { + + public static final String CAPABILITIES_START = + "\n" + + "\n" + + " \n"; + + public static final String CAPABILITIES_BASE = + " urn:ietf:params:netconf:base:1.0\n"; + + public static final String CAPABILITIES_END = + " \n" + + ""; + + public static final String GET_RUNNING_CONFIG = + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + public static final String CLOSE_SESSION = + "\n" + + "\n" + + " \n" + + ""; +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java new file mode 100644 index 000000000..f3cca8597 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.internal; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.appc.adapter.netconf.ConnectionDetails; +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.NetconfDataAccessService; +import org.onap.appc.adapter.netconf.exception.DataAccessException; +import org.onap.appc.adapter.netconf.util.Constants; +import org.onap.ccsdk.sli.core.dblib.DbLibService; + +import javax.sql.rowset.CachedRowSet; +import java.sql.SQLException; +import java.util.ArrayList; + +public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { + + private static EELFLogger logger = EELFManager.getInstance().getLogger(NetconfDataAccessServiceImpl.class); + + public void setSchema(String schema) { + this.schema = schema; + } + + private String schema; + + public void setDbLibService(DbLibService service) {dbLibService = service;} + + private DbLibService dbLibService; + + @Override + public String retrieveConfigFileName(String xmlID) throws DataAccessException { + String fileContent = ""; + + String queryString = "select " + Constants.FILE_CONTENT_TABLE_FIELD_NAME + " " + + "from " + Constants.CONFIGFILES_TABLE_NAME + " " + + "where " + Constants.FILE_NAME_TABLE_FIELD_NAME + " = ?"; + + ArrayList argList = new ArrayList<>(); + argList.add(xmlID); + + try { + final CachedRowSet data = dbLibService.getData(queryString, argList, schema); + if (data.first()) { + fileContent = data.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME); + } + } catch (Exception e) { + logger.error("Error Accessing Database " + e); + throw new DataAccessException(e); + } + + return fileContent; + } + + @Override + public boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws + DataAccessException { + boolean recordFound = false; + + String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + + Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " + + "from " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME + " " + + "where " + Constants.VNF_TYPE_TABLE_FIELD_NAME + " = ?"; + + ArrayList argList = new ArrayList<>(); + argList.add(vnfType); + + try { + final CachedRowSet data = dbLibService.getData(queryString, argList, schema); + if (data.first()) { + connectionDetails.setUsername(data.getString(Constants.USER_NAME_TABLE_FIELD_NAME)); + connectionDetails.setPassword(data.getString(Constants.PASSWORD_TABLE_FIELD_NAME)); + connectionDetails.setPort(data.getInt(Constants.PORT_NUMBER_TABLE_FIELD_NAME)); + recordFound = true; + } + } catch (SQLException e) { + logger.error("Error Accessing Database " + e); + throw new DataAccessException(e); + } + + return recordFound; + } + + @Override + public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) + throws DataAccessException { + ConnectionDetails connDetails = new ConnectionDetails(); + if(this.retrieveConnectionDetails(vnfType, connDetails)) + { + connectionDetails.setHost(connDetails.getHost()); + connectionDetails.setPort(connDetails.getPort()); + connectionDetails.setUsername(connDetails.getUsername()); + connectionDetails.setPassword(connDetails.getPassword()); + } + return true; + } + + @Override + public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) + throws DataAccessException { + String queryString = "INSERT INTO "+ Constants.DEVICE_INTERFACE_LOG_TABLE_NAME+"("+ + Constants.SERVICE_INSTANCE_ID_FIELD_NAME+","+ + Constants.REQUEST_ID_FIELD_NAME+","+ + Constants.CREATION_DATE_FIELD_NAME+","+ + Constants.LOG_FIELD_NAME+") "; + queryString += "values(?,?,?,?)"; + + ArrayList argList = new ArrayList<>(); + argList.add(instanceId); + argList.add(requestId); + argList.add(creationDate); + argList.add(logText); + + try { + dbLibService.writeData(queryString, argList, schema); + } catch (SQLException e) { + logger.error("Logging Device interaction failed - "+ queryString); + throw new DataAccessException(e); + } + + return true; + } + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfMessage.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfMessage.java new file mode 100644 index 000000000..700a51b9f --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfMessage.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.internal; + +import java.io.ByteArrayOutputStream; + +class NetconfMessage { + + private static final String EOM = "]]>]]>"; + + private String text; + private MessageBuffer buffer = new MessageBuffer(); + private int eomNotch; + + NetconfMessage() { + } + + NetconfMessage(String text) { + if(text == null) { + throw new NullPointerException("Netconf message payload is null"); + } + append(text.getBytes(), 0, text.length()); + if(this.text == null) { + this.text = text; + } + } + + void append(byte[] bytes, int start, int end) { + boolean eomFound = false; + for(int i = start; i < end; i++) { + if(bytes[i] == EOM.charAt(eomNotch)) { + // advance notch + eomNotch++; + } else { + // reset notch + eomNotch = 0; + } + if(eomNotch == EOM.length()) { + // end of message found + eomFound = true; + end = i + 1; + break; + } + } + buffer.write(bytes, start, end); + if(eomFound) { + text = new String(buffer.getBytes(), 0, buffer.size() - EOM.length()); + buffer.reset(); + } + } + + String getText() { + return text; + } + + boolean isCompleted() { + return (text != null); + } + + byte[] getFrame() { + StringBuilder sb = new StringBuilder(); + if(text != null) { + sb.append(text).append("\n"); + } + sb.append(EOM); + return sb.toString().getBytes(); + } + + private class MessageBuffer extends ByteArrayOutputStream { + + byte[] getBytes() { + return buf; + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/JSchLogger.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/JSchLogger.java new file mode 100644 index 000000000..37bb3b2f2 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/JSchLogger.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * JSch logger implementation delegating to logback. + */ +public class JSchLogger implements com.jcraft.jsch.Logger { + + private static final Logger LOG = LoggerFactory.getLogger(JSchLogger.class); + + @Override + public boolean isEnabled(int level) { + return true; + } + + @Override + public void log(int level, String message) { + switch(level) { + case com.jcraft.jsch.Logger.DEBUG: + LOG.debug(message); + break; + + case com.jcraft.jsch.Logger.INFO: + LOG.info(message); + break; + + case com.jcraft.jsch.Logger.WARN: + LOG.warn(message); + break; + + case com.jcraft.jsch.Logger.ERROR: + case com.jcraft.jsch.Logger.FATAL: + LOG.error(message); + break; + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/NetconfClientJsch.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/NetconfClientJsch.java new file mode 100644 index 000000000..7b9d7a4ae --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/NetconfClientJsch.java @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelSubsystem; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; + +import java.io.IOException; +import java.util.List; +import java.util.Properties; + +import org.onap.appc.adapter.netconf.NetconfClient; +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.internal.NetconfAdapter; +import org.onap.appc.adapter.netconf.internal.NetconfConstMessages; +import org.onap.appc.encryption.EncryptionTool; +import org.onap.appc.exceptions.APPCException; +import org.onap.appc.i18n.Msg; +import com.att.eelf.i18n.EELFResourceManager; + +/** + * Implementation of NetconfClient interface based on JCraft jsch library. + */ +public class NetconfClientJsch implements NetconfClient { + + private static final int SESSION_CONNECT_TIMEOUT = 30000; + private static final int CHANNEL_CONNECT_TIMEOUT = 10000; + + private Session session; + private Channel channel; + private NetconfAdapter netconfAdapter; + + + @Override + public void connect(NetconfConnectionDetails connectionDetails) throws APPCException { + String host = connectionDetails.getHost(); + int port = connectionDetails.getPort(); + String username = connectionDetails.getUsername(); + String password = connectionDetails.getPassword(); + try { + JSch.setLogger(new JSchLogger()); + JSch jsch = new JSch(); + session = jsch.getSession(EncryptionTool.getInstance().decrypt(username), host, port); + session.setPassword(EncryptionTool.getInstance().decrypt(password)); + session.setConfig("StrictHostKeyChecking", "no"); + + Properties additionalProps = connectionDetails.getAdditionalProperties(); + if((additionalProps != null) && !additionalProps.isEmpty()) { + session.setConfig(additionalProps); + } + + session.connect(SESSION_CONNECT_TIMEOUT); + session.setTimeout(10000); + try { +// session.setServerAliveCountMax(0); // If this is not set to '0', then socket timeout on all reads will not work!!!! + channel = session.openChannel("subsystem"); + ((ChannelSubsystem)channel).setSubsystem("netconf"); + netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream()); + channel.connect(CHANNEL_CONNECT_TIMEOUT); + hello(connectionDetails.getCapabilities()); + } catch(Exception e) { + disconnect(); + throw e; + } + } catch(Exception e) { + String message = EELFResourceManager.format(Msg.CANNOT_ESTABLISH_CONNECTION, host, String.valueOf(port), username); + throw new APPCException(message, e); + } + } + + @Override + public String exchangeMessage(String message) throws APPCException { + try { + netconfAdapter.sendMessage(message); + return netconfAdapter.receiveMessage(); + } catch(IOException e) { + throw new APPCException(e); + } + } + + @Override + public void configure(String configuration) throws APPCException { + try { + isOk(exchangeMessage(configuration)); + } catch(IOException e) { + throw new APPCException(e); + } + } + + @Override + public String getConfiguration() throws APPCException { + return exchangeMessage(NetconfConstMessages.GET_RUNNING_CONFIG); + } + + @Override + public void disconnect() { + try { + if((channel != null) && !channel.isClosed()) { + netconfAdapter.sendMessage(NetconfConstMessages.CLOSE_SESSION); + isOk(netconfAdapter.receiveMessage()); + } + } catch(IOException e) { + throw new RuntimeException("Error closing netconf device", e); + } finally { + netconfAdapter = null; + if(channel != null) { + channel.disconnect(); + channel = null; + } + if(session != null) { + session.disconnect(); + session = null; + } + } + } + + private void hello(List capabilities) throws IOException { + String helloIn = netconfAdapter.receiveMessage(); + if(helloIn == null) { + throw new IOException("Expected hello message, but nothing received error from netconf device"); + } + if(helloIn.contains("")) { + throw new IOException("Expected hello message, but received error from netconf device:\n" + helloIn); + } + StringBuilder sb = new StringBuilder(); + sb.append(NetconfConstMessages.CAPABILITIES_START); + sb.append(NetconfConstMessages.CAPABILITIES_BASE); + if(capabilities != null) { + for(String capability: capabilities) { + sb.append(" ").append(capability).append("\n"); + } + } + sb.append(NetconfConstMessages.CAPABILITIES_END); + String helloOut = sb.toString(); + netconfAdapter.sendMessage(helloOut); + } + + private void isOk(String response) throws IOException { + if(response == null) { + throw new IOException("No response from netconf device"); + } + if(!response.contains("")) { + throw new IOException("Error response from netconf device: \n" + response); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java new file mode 100644 index 000000000..bc89551a8 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java @@ -0,0 +1,236 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.odlconnector; + +import org.apache.http.HttpStatus; +import org.onap.appc.adapter.netconf.NetconfClient; +import org.onap.appc.adapter.netconf.NetconfClientRestconf; +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.util.Constants; +import org.onap.appc.exceptions.APPCException; +import org.onap.appc.util.httpClient; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.Properties; + +public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRestconf { + + private EELFLogger logger = EELFManager.getInstance().getLogger(NetconfClientRestconfImpl.class); + + private NetconfConnectionDetails connectionDetails; + + //constructor + public NetconfClientRestconfImpl(){ + } + + //restconf client impl + + @SuppressWarnings("deprecation") + @Override + public void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException { + + logger.info("Configuring device "+deviceMountPointName+" with configuration "+configuration); + + int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/json"); + + if (httpCode != HttpStatus.SC_OK) { + logger.error("Configuration request failed. throwing Exception !"); + throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); + } + } + + @Override + public void connect(String deviceMountPointName, String payload) throws APPCException{ + + logger.info("Connecting device "+deviceMountPointName); + + int httpCode = httpClient.postMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getConnectPath(),payload,"application/json"); + + if(httpCode != HttpStatus.SC_NO_CONTENT){ + logger.error("Connect request failed with code "+httpCode+". throwing Exception !"); + throw new APPCException("Error connecting device :" + deviceMountPointName); + } + } + + @Override + public boolean checkConnection(String deviceMountPointName) throws APPCException { + logger.info("Checking device "+deviceMountPointName+" connectivity"); + + String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getCheckConnectivityPath(deviceMountPointName),"application/json"); + + return result != null; + } + + @Override + public void disconnect(String deviceMountPointName) throws APPCException { + logger.info("Disconnecting "+deviceMountPointName); + + int httpCode = httpClient.deleteMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getDisconnectPath(deviceMountPointName),"application/json"); + + if(httpCode != HttpStatus.SC_OK){ + logger.error("Disconnection of device "+deviceMountPointName+" failed!"); + throw new APPCException("Disconnection of device "+deviceMountPointName+" failed!"); + } + } + + @Override + public String getConfiguration(String deviceMountPointName, String moduleName, String nodeName) throws APPCException{ + logger.info("Getting configuration of device "+deviceMountPointName); + + String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),"application/json"); + + if (result == null) { + logger.error("Configuration request failed. throwing Exception !"); + throw new APPCException("Error getting configuration of node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); + } + + return result; + } + + //netconf client impl + + @Override + public void connect(NetconfConnectionDetails connectionDetails) throws APPCException { + if(connectionDetails == null){ + throw new APPCException("Invalid connection details - null value"); + } + this.connectionDetails = connectionDetails; + this.connect(connectionDetails.getHost(),getPayload()); + } + + @Override + public String exchangeMessage(String message) throws APPCException { + // TODO implement + return null; + } + + @Override + public void configure(String configuration) throws APPCException { + if(connectionDetails == null){ + throw new APPCException("Invalid connection details - null value"); + } + + Properties props = connectionDetails.getAdditionalProperties(); + if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){ + throw new APPCException("Invalid properties!"); + } + + String moduleName = props.getProperty("module.name"); + String nodeName = props.getProperty("node.name"); + String deviceMountPointName = connectionDetails.getHost(); + + int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/xml"); + + if (httpCode != HttpStatus.SC_OK) { + logger.error("Configuration request failed. throwing Exception !"); + throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); + } + } + + @Override + public String getConfiguration() throws APPCException { + if(connectionDetails == null){ + throw new APPCException("Invalid connection details - null value"); + } + + Properties props = connectionDetails.getAdditionalProperties(); + if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){ + throw new APPCException("Invalid properties!"); + } + + return this.getConfiguration(connectionDetails.getHost(),props.getProperty("module.name"),props.getProperty("node.name")); + } + + @Override + public void disconnect() throws APPCException { + if(connectionDetails == null){ + throw new APPCException("Invalid connection details - null value"); + } + this.disconnect(connectionDetails.getHost()); + } + + //private methods + private String getModuleConfigurePath(String deviceMountPointName, String moduleName, String nodeName){ + + + String deviceSpecificPath = deviceMountPointName + "/yang-ext:mount/" + moduleName + ":" + nodeName; + + return Constants.CONFIGURE_PATH + deviceSpecificPath; + } + + private String getConnectPath(){ + + return Constants.CONNECT_PATH; + } + + private String getCheckConnectivityPath(String deviceMountPointName) { + return Constants.CHECK_CONNECTION_PATH + deviceMountPointName; + } + + private String getDisconnectPath(String deviceMountPointName) { + return Constants.DISCONNECT_PATH + deviceMountPointName; + } + + private String getPayload() { + return "{\n" + + " \"config:module\":\n" + + " {\n" + + " \"type\":\"odl-sal-netconf-connector-cfg:sal-netconf-connector\",\n" + + " \"netconf-northbound-ssh\\odl-sal-netconf-connector-cfg:name\":"+connectionDetails.getHost()+",\n" + + " \"odl-sal-netconf-connector-cfg:address\":"+connectionDetails.getHost()+",\n" + + " \"odl-sal-netconf-connector-cfg:port\":"+connectionDetails.getPort()+",\n" + + " \"odl-sal-netconf-connector-cfg:username\":"+connectionDetails.getUsername()+",\n" + + " \"odl-sal-netconf-connector-cfg:password\":"+connectionDetails.getPassword()+",\n" + + " \"tcp-only\":\"false\",\n" + + " \"odl-sal-netconf-connector-cfg:event-executor\":\n" + + " {\n" + + " \"type\":\"netty:netty-event-executor\",\n" + + " \"name\":\"global-event-executor\"\n" + + " },\n" + + " \"odl-sal-netconf-connector-cfg:binding-registry\":\n" + + " {\n" + + " \"type\":\"opendaylight-md-sal-binding:binding-broker-osgi-registry\",\n" + + " \"name\":\"binding-osgi-broker\"\n" + + " },\n" + + " \"odl-sal-netconf-connector-cfg:dom-registry\":\n" + + " {\n" + + " \"type\":\"opendaylight-md-sal-dom:dom-broker-osgi-registry\",\n" + + " \"name\":\"dom-broker\"\n" + + " },\n" + + " \"odl-sal-netconf-connector-cfg:client-dispatcher\":\n" + + " {\n" + + " \"type\":\"odl-netconf-cfg:netconf-client-dispatcher\",\n" + + " \"name\":\"global-netconf-dispatcher\"\n" + + " },\n" + + " \"odl-sal-netconf-connector-cfg:processing-executor\":\n" + + " {\n" + + " \"type\":\"threadpool:threadpool\",\n" + + " \"name\":\"global-netconf-processing-executor\"\n" + + " }\n" + + " }\n" + + "}"; + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/util/Constants.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/util/Constants.java new file mode 100644 index 000000000..e8b8e9378 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/util/Constants.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 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 + * + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.util; + +public class Constants { + + public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/"; + public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules"; + public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/"; + public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/"; + + public static final String CONTROLLER_IP = "127.0.0.1"; + public static final int CONTROLLER_PORT = 8181; + public static final String PROTOCOL = "http"; + + // tables and fields + public static final String NETCONF_SCHEMA = "sdnctl"; + public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION"; + public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES"; + public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG"; + public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT"; + public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME"; + public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME"; + public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD"; + public static final String VM_HOST_TABLE_FIELD_NAME = "VM_HOST"; + public static final String VM_NAME_TABLE_FIELD_NAME = "VM_NAME"; + public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER"; + public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE"; + public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID"; + public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID"; + public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE"; + public static final String LOG_FIELD_NAME = "LOG"; + + // input fields names + public static final String VNF_TYPE_FIELD_NAME = "org.onap.appc.vftype"; + public static final String TARGET_VNF_TYPE = "target-vnf-type"; + public static final String FILE_CONTENT_FIELD_NAME = "file-content"; + public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details"; + public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name"; + public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address"; + public static final String DG_ERROR_FIELD_NAME = "org.onap.appc.dg.error"; + public static final String RESOURCEKEY = "resourceKey"; + public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message"; + public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; + +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java deleted file mode 100644 index bae220d13..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.adapter.netconf.internal.NetconfDataAccessServiceImpl; -import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.onap.appc.i18n.Msg; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -public class AppcNetconfAdapterActivator implements BundleActivator { - - /** - * The bundle registration - */ - private ServiceRegistration registration = null; - private ServiceRegistration reporterRegistration = null; - private ServiceRegistration factoryRegistration = null; - private ServiceRegistration dbRegistration = null; - - /** - * The reference to the actual implementation object that implements the services - */ - private NetconfClientFactory clientFactory; - private NetconfDataAccessService DAService; - - /** - * The logger to be used - */ - private static final EELFLogger logger = EELFManager.getInstance().getLogger(AppcNetconfAdapterActivator.class); - - /** - * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start - * this bundle. This method can be used to register services or to allocate any resources that this bundle needs. - *

- * This method must complete and return to its caller in a timely manner. - *

- * - * @param context - * The execution context of the bundle being started. - * @throws java.lang.Exception - * If this method throws an exception, this bundle is marked as stopped and the Framework will remove - * this bundle's listeners, unregister all services registered by this bundle, and release all services - * used by this bundle. - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - if (registration == null) { - clientFactory = new NetconfClientFactory(); - factoryRegistration = context.registerService(NetconfClientFactory.class, clientFactory, null); - - DAService = new NetconfDataAccessServiceImpl(); - //set dblib service - DbLibService dblibSvc = null; - ServiceReference sref = context.getServiceReference(DbLibService.class.getName()); - try{ - dblibSvc = (DbLibService)context.getService(sref); - }catch(Exception e){ - logger.error(e.getMessage()); - } - DAService.setDbLibService(dblibSvc); - /////////////////////////////////// - factoryRegistration = context.registerService(NetconfDataAccessService.class, DAService, null); - } - - logger.info(Msg.COMPONENT_INITIALIZED, "NETCONF adapter"); - } - - /** - * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop - * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There - * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not - * call any Framework objects. - *

- * This method must complete and return to its caller in a timely manner. - *

- * - * @param context - * The execution context of the bundle being stopped. - * @throws java.lang.Exception - * If this method throws an exception, the bundle is still marked as stopped, and the Framework will - * remove the bundle's listeners, unregister all services registered by the bundle, and release all - * services used by the bundle. * - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - if (registration != null) { - registration.unregister(); - registration = null; - } - if (reporterRegistration != null) { - reporterRegistration.unregister(); - reporterRegistration = null; - } - - if (null != factoryRegistration) { - factoryRegistration.unregister(); - factoryRegistration = null; - } - - if (dbRegistration != null) { - dbRegistration.unregister(); - dbRegistration = null; - } - } - - public String getName() { - return "APPC NETCONF adapter"; - } - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java deleted file mode 100644 index 7536f9655..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - - -public class ConnectionDetails { - - private String host; - private int port; - private String username; - private String password; - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java deleted file mode 100644 index 079ae76a4..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.exceptions.APPCException; - - -public class MockOperationalStateValidatorImpl implements OperationalStateValidator { - @Override - public VnfType getVnfType() { - return VnfType.MOCK; - } - - @Override - public String getConfigurationFileName() { - String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX); - return configFileName; - } - - @Override - public void validateResponse(String response) throws APPCException { - if(response != null && response.toUpperCase().contains("INVALID")){ - throw new APPCException("INVALID"); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java deleted file mode 100644 index eaed60fc0..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.exceptions.APPCException; - - - -public interface NetconfClient { - - /** - * Open connection to netconf device. - * - * @param connectionDetails object providing details required for netconf connection - */ - void connect(NetconfConnectionDetails connectionDetails) throws APPCException; - - /** - * Send Netconf message to device and receive response. - * - * @param message input netconf xml message - * @return output netconf xml message - */ - String exchangeMessage(String message) throws APPCException; - - /** - * send configuration to Netconf server - * - * @param configuration - xml configuration payload - */ - void configure(String configuration) throws APPCException; - - /** - * returns running configuration of Netconf server - */ - String getConfiguration() throws APPCException; - - /** - * Disconnect from netconf device. - */ - void disconnect() throws APPCException; -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java deleted file mode 100644 index 45c8fb0ed..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; -import org.onap.appc.adapter.netconf.odlconnector.NetconfClientRestconfImpl; - - -public class NetconfClientFactory { - - public NetconfClient GetNetconfClient(NetconfClientType type){ - - if(type==NetconfClientType.RESTCONF) { - return new NetconfClientRestconfImpl(); - }else if(type == NetconfClientType.SSH){ - return new NetconfClientJsch(); - } - - return null; - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java deleted file mode 100644 index a23a16797..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.exceptions.APPCException; - - - -public interface NetconfClientRestconf { - - /* - mount device to controller - @param deviceMountPointName - the name of the mounting point in controller - @param payload - json data describing device info - */ - void connect(String deviceMountPointName, String payload) throws APPCException; - - /* - check connection to device - @param deviceMountPointName - the name of the mounting point in controller - */ - boolean checkConnection(String deviceMountPointName) throws APPCException; - - /* - send configuration to Netconf server - @param configuration - xml configuration payload - @param deviceMountPointName - the name of the mounting point in controller - @param moduleName - name of the yang model - @param nodeName - name of the node created in server - */ - void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException; - - /* - returns configuration of Netconf server - @param deviceMountPointName - the name of the mounting point in controller - @param moduleName - name of the yang model - @param nodeName - name of the node created in server - */ - String getConfiguration(String deviceName, String moduleName, String nodeName) throws APPCException; - - /* - unmount device - @param deviceMountPointName - the name of the mounting point in controller - */ - void disconnect(String deviceMountPointName) throws APPCException; -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java deleted file mode 100644 index bf7512456..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - - -public enum NetconfClientType { - RESTCONF, - SSH -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java deleted file mode 100644 index e7c0cc44d..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import java.util.List; -import java.util.Properties; - -/** - * Provides details required for connecting to netconf device. - */ -public class NetconfConnectionDetails { - - private String host; - private int port; - private String username; - private String password; - - public static int DEFAULT_PORT = 830; - private List capabilities; - private Properties additionalProperties; - - public NetconfConnectionDetails() { - super(); - setPort(DEFAULT_PORT); - } - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public List getCapabilities() { - return capabilities; - } - - public void setCapabilities(List capabilities) { - this.capabilities = capabilities; - } - - public Properties getAdditionalProperties() { - return additionalProperties; - } - - public void setAdditionalProperties(Properties additionalProperties) { - this.additionalProperties = additionalProperties; - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java deleted file mode 100644 index f831541da..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.adapter.netconf.exception.DataAccessException; -import org.onap.ccsdk.sli.core.dblib.DbLibService; - - -@SuppressWarnings("JavaDoc") -public interface NetconfDataAccessService { - - /** - * - * @param schema - */ - void setSchema(String schema); - - /** - * - * @param dbLibService - */ - void setDbLibService(DbLibService dbLibService); - - /** - * - * @param xmlID - * @return - * @throws DataAccessException - */ - String retrieveConfigFileName(String xmlID) throws DataAccessException; - - /** - * - * @param vnfType - * @param connectionDetails - * @return - * @throws DataAccessException - */ - boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws DataAccessException; - - /** - * - * @param vnfType - * @param connectionDetails - * @return - * @throws DataAccessException - */ - boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws - DataAccessException; - - /** - * - * @param instanceId - * @param requestId - * @param creationDate - * @param logText - * @return - * @throws DataAccessException - */ - boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws - DataAccessException; - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java deleted file mode 100644 index ffa3862e8..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.onap.appc.exceptions.APPCException; - - -public interface OperationalStateValidator { - public VnfType getVnfType(); - public String getConfigurationFileName(); - public void validateResponse(String response) throws APPCException; - final public static String CONFIG_FILE_PROPERTY_SUFFIX = "-CONFIG_FILE"; -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java deleted file mode 100644 index 37e96917d..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.apache.commons.lang3.NotImplementedException; -import org.onap.appc.configuration.Configuration; -import org.onap.appc.configuration.ConfigurationFactory; - -public class OperationalStateValidatorFactory { - protected static final Configuration configuration = ConfigurationFactory.getConfiguration(); - - public static OperationalStateValidator getOperationalStateValidator(String vnfType) { - VnfType vnfTypeEnum = null; - try { - vnfTypeEnum = VnfType.getVnfType(vnfType); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("Illegal value in vnfType. vnfType="+vnfType,e); - } - return getOperationalStateValidator(vnfTypeEnum); - } - - public static OperationalStateValidator getOperationalStateValidator(VnfType vnfType) { - switch (vnfType) { - case VNF: - case VNF_MOCK: - return new VNFOperationalStateValidatorImpl(); - case MOCK: - return new MockOperationalStateValidatorImpl(); - default: - throw new NotImplementedException("missing implementaion for the given vnfType:" + vnfType.name()); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java deleted file mode 100644 index 4bb5ab238..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -import org.apache.commons.lang3.StringUtils; -import org.onap.appc.exceptions.APPCException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.*; - -public class VNFOperationalStateValidatorImpl implements OperationalStateValidator { - private static final String OPERATIONAL_STATE_ELEMENT_NAME = "operationalState"; - @Override - public VnfType getVnfType() { - return VnfType.VNF; - } - - @Override - public String getConfigurationFileName() { - String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX); - configFileName = configFileName == null? "VnfGetOperationalStates" : configFileName; - return configFileName; - } - - @Override - public void validateResponse(String response) throws APPCException { - if(StringUtils.isEmpty(response)) { - throw new APPCException("empty response"); - } - - boolean isValid = false; - String errorMsg = "unexpected response"; - try { - List operationalStateList = getOperationalStateList(response); - if(operationalStateList != null && !operationalStateList.isEmpty()) { - for (Map.Entry stateEntry : operationalStateList) { - if(!((String)stateEntry.getValue()).equalsIgnoreCase("ENABLED")){ - errorMsg = "at least one "+OPERATIONAL_STATE_ELEMENT_NAME+" is not in valid satae. "+operationalStateList.toString(); - isValid = false; - break; - }else{ - isValid =true; - } - } - }else { - errorMsg = "response without any "+OPERATIONAL_STATE_ELEMENT_NAME+" element"; - } - } catch (Exception e ) { - isValid = false; - errorMsg = e.toString(); - } - if(!isValid) throw new APPCException(errorMsg); - } - - private static List getOperationalStateList(String xmlText) throws IOException, ParserConfigurationException, SAXException { - List entryList = null; - if(StringUtils.isNotEmpty(xmlText)) { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - - Document document = builder.parse(new ByteArrayInputStream(xmlText.getBytes("UTF-8"))); - if(document != null) { - Element rootElement = document.getDocumentElement(); - NodeList nodeList = rootElement.getElementsByTagName(OPERATIONAL_STATE_ELEMENT_NAME); - if (nodeList != null && nodeList.getLength() > 0) { - for (int i = 0; i < nodeList.getLength(); i++) { - Node node = nodeList.item(i); - String text = node.getTextContent(); - String id = getElementID(node); - entryList = (entryList == null) ? new ArrayList() : entryList; - Map.Entry entry = new AbstractMap.SimpleEntry(id, text); - entryList.add(entry); - } - } - } - } - return entryList; - } - - private static String getElementID(Node node) { - String id = null; - Node parentNode = node.getParentNode(); - if (parentNode != null) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - NodeList nodeList = ((Element) parentNode).getElementsByTagName("id"); - if (nodeList != null && nodeList.getLength() > 0) { - Node idNode = nodeList.item(0); - id = idNode != null ? idNode.getTextContent() : null; - } - }else { - id = parentNode.getNodeValue()+"|"+parentNode.getTextContent(); - } - } - - id = StringUtils.isEmpty(id) ? null : StringUtils.normalizeSpace(id); - id = StringUtils.isBlank(id) ? null : id; - id = id != null ? id : "unknown-id"; - return id; - } - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java deleted file mode 100644 index 19edc2fd3..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf; - -public enum VnfType { - VNF("VNF"), - MOCK("MOCK"), - VNF_MOCK("MOCK"), - ; - - String familyType; - String upperCaseName; - VnfType(String familyType) { - this.familyType = familyType; - this.upperCaseName = name().toUpperCase(); - } - - public VnfType getFamilyType() { - return VnfType.valueOf(familyType); - } - - public String getUpperCaseName() { - return upperCaseName; - } - - public static VnfType getVnfType(String inSensitiveCaseName){ - String localUpperCaseName = inSensitiveCaseName.toUpperCase(); - for(VnfType vnfType : VnfType.values()){ - if(vnfType.getUpperCaseName().equals(localUpperCaseName)){ - return vnfType; - } - } - throw new IllegalArgumentException( - "No enum with upperCaseName for this input value:" + inSensitiveCaseName ); - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java deleted file mode 100644 index 0c4964da0..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.exception; - - -public class DataAccessException extends RuntimeException { - - private static final long serialVersionUID = -155423437162622414L; - - public DataAccessException(){ - } - - public DataAccessException(String message){ - super(message); - } - - public DataAccessException(Throwable cause){ - super(cause); - } - - public DataAccessException(String message , Throwable cause){ - super(message , cause); - } - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java deleted file mode 100644 index 5ff1a331e..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.exception; - -public class NetconfDAOException extends RuntimeException { - - private static final long serialVersionUID = -155423437162622414L; - - public NetconfDAOException(){ - } - - public NetconfDAOException(String message){ - super(message); - } - - public NetconfDAOException(Throwable cause){ - super(cause); - } - - public NetconfDAOException(String message , Throwable cause){ - super(message , cause); - } - - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java deleted file mode 100644 index 2d8c6f417..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.internal; - -import org.onap.appc.configuration.ConfigurationFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.concurrent.*; - -/** - * Provides basic methods for exchanging netconf messages. - */ -public class NetconfAdapter { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter.class); - private static final long MAX_WAITING_TIME = 1800000; - private static ExecutorService executor = Executors.newFixedThreadPool(5); - - // device input stream - private InputStream in; - // device output stream - private OutputStream out; - private long maxWaitingTime = ConfigurationFactory.getConfiguration().getLongProperty("org.onap.appc.netconf.recv.timeout", MAX_WAITING_TIME); - - /** - * Constructor. - * - * @param in InputStream this instance will read netconf messages from - * @param out OutputStream this instance will write netconf messages to - * @throws IOException - */ - public NetconfAdapter(InputStream in, OutputStream out) throws IOException { - this.in = in; - this.out = out; - } - - /** - * Receives netconf message from InputStream and return it's text (without netconf frame characters). - * - * @return text of message received from netconf device - * @throws IOException - */ - public String receiveMessage() throws IOException { - - final NetconfMessage message = new NetconfMessage(); - final byte[] buf = new byte[1024]; - - //int readByte = 1; - // Read data with timeout - Callable readTask = new Callable() { - @Override - public Boolean call() throws Exception { - int c; - while ((c = in.read(buf)) > 0) { - if (c > 0) { - message.append(buf, 0, c); - if (message.isCompleted()) { - break; - } - } - } - - if (c < 0) { - return false; - } - return true; - } - }; - - Future future = executor.submit(readTask); - Boolean status; - try { - status = future.get(maxWaitingTime, TimeUnit.MILLISECONDS); - } catch (Exception e) { - throw new IOException(e); - } - - if (status == false) { - throw new IOException("Failed to read netconf message"); - } - - - String text = message.getText(); - if (text != null) { - text = text.trim(); - } - if (LOG.isDebugEnabled()) { - LOG.debug("Received message from netconf device:\n" + text); - } - return text; - } - - /** - * Sends netconf message with provided text (adds netconf frame characters and sends the message). - * - * @param text text of message to be sent to netconf device - * @throws IOException - */ - public void sendMessage(final String text) throws IOException { - if (LOG.isDebugEnabled()) { - LOG.debug("Sending message to netconf device:\n" + text); - } - out.write(new NetconfMessage(text).getFrame()); - out.flush(); - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java deleted file mode 100644 index 928d77470..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.internal; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; - -/** - * Provides basic methods for exchanging netconf messages. - */ -public class NetconfAdapter2 { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter2.class); - - // device input pipe - private final PipedOutputStream pipedOutIn = new PipedOutputStream(); - private PipedInputStream in; - // device output pipe - private final PipedInputStream pipedInOut = new PipedInputStream(); - private PipedOutputStream out; - - /** - * Constructor. - * - * @throws IOException - */ - public NetconfAdapter2() throws IOException { - in = new PipedInputStream(pipedOutIn); - out = new PipedOutputStream(pipedInOut); - } - - /** - * @return InputStream this instance will read netconf messages from. - */ - public InputStream getIn() { - return in; - } - - /** - * @return OutputStream this instance will write netconf messages to. - */ - public OutputStream getOut() { - return out; - } - - /** - * Receives netconf message from InputStream and return it's text (without netconf frame characters). - * - * @return text of message received from netconf device - * @throws IOException - */ - public String receiveMessage() throws IOException { - NetconfMessage message = new NetconfMessage(); - byte[] buf = new byte[1024]; - int c; - while((c = pipedInOut.read(buf)) > 0) { - message.append(buf, 0, c); - if (message.isCompleted()) { - break; - } - } - String text = message.getText(); - if(LOG.isDebugEnabled()) { - LOG.debug("Received message from netconf device:\n" + text); - } - return text; - } - - /** - * Sends netconf message with provided text (adds netconf frame characters and sends the message). - * - * @param text text of message to be sent to netconf device - * @throws IOException - */ - public void sendMessage(final String text) throws IOException { - if(LOG.isDebugEnabled()) { - LOG.debug("Sending message to netconf device:\n" + text); - } - pipedOutIn.write(new NetconfMessage(text).getFrame()); - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java deleted file mode 100644 index c7ad9bc50..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.internal; - -public class NetconfConstMessages { - - public static final String CAPABILITIES_START = - "\n" + - "\n" + - " \n"; - - public static final String CAPABILITIES_BASE = - " urn:ietf:params:netconf:base:1.0\n"; - - public static final String CAPABILITIES_END = - " \n" + - ""; - - public static final String GET_RUNNING_CONFIG = - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - public static final String CLOSE_SESSION = - "\n" + - "\n" + - " \n" + - ""; -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java deleted file mode 100644 index f3cca8597..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.internal; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.onap.appc.adapter.netconf.ConnectionDetails; -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.NetconfDataAccessService; -import org.onap.appc.adapter.netconf.exception.DataAccessException; -import org.onap.appc.adapter.netconf.util.Constants; -import org.onap.ccsdk.sli.core.dblib.DbLibService; - -import javax.sql.rowset.CachedRowSet; -import java.sql.SQLException; -import java.util.ArrayList; - -public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(NetconfDataAccessServiceImpl.class); - - public void setSchema(String schema) { - this.schema = schema; - } - - private String schema; - - public void setDbLibService(DbLibService service) {dbLibService = service;} - - private DbLibService dbLibService; - - @Override - public String retrieveConfigFileName(String xmlID) throws DataAccessException { - String fileContent = ""; - - String queryString = "select " + Constants.FILE_CONTENT_TABLE_FIELD_NAME + " " + - "from " + Constants.CONFIGFILES_TABLE_NAME + " " + - "where " + Constants.FILE_NAME_TABLE_FIELD_NAME + " = ?"; - - ArrayList argList = new ArrayList<>(); - argList.add(xmlID); - - try { - final CachedRowSet data = dbLibService.getData(queryString, argList, schema); - if (data.first()) { - fileContent = data.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME); - } - } catch (Exception e) { - logger.error("Error Accessing Database " + e); - throw new DataAccessException(e); - } - - return fileContent; - } - - @Override - public boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws - DataAccessException { - boolean recordFound = false; - - String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + - Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " + - "from " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME + " " + - "where " + Constants.VNF_TYPE_TABLE_FIELD_NAME + " = ?"; - - ArrayList argList = new ArrayList<>(); - argList.add(vnfType); - - try { - final CachedRowSet data = dbLibService.getData(queryString, argList, schema); - if (data.first()) { - connectionDetails.setUsername(data.getString(Constants.USER_NAME_TABLE_FIELD_NAME)); - connectionDetails.setPassword(data.getString(Constants.PASSWORD_TABLE_FIELD_NAME)); - connectionDetails.setPort(data.getInt(Constants.PORT_NUMBER_TABLE_FIELD_NAME)); - recordFound = true; - } - } catch (SQLException e) { - logger.error("Error Accessing Database " + e); - throw new DataAccessException(e); - } - - return recordFound; - } - - @Override - public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) - throws DataAccessException { - ConnectionDetails connDetails = new ConnectionDetails(); - if(this.retrieveConnectionDetails(vnfType, connDetails)) - { - connectionDetails.setHost(connDetails.getHost()); - connectionDetails.setPort(connDetails.getPort()); - connectionDetails.setUsername(connDetails.getUsername()); - connectionDetails.setPassword(connDetails.getPassword()); - } - return true; - } - - @Override - public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) - throws DataAccessException { - String queryString = "INSERT INTO "+ Constants.DEVICE_INTERFACE_LOG_TABLE_NAME+"("+ - Constants.SERVICE_INSTANCE_ID_FIELD_NAME+","+ - Constants.REQUEST_ID_FIELD_NAME+","+ - Constants.CREATION_DATE_FIELD_NAME+","+ - Constants.LOG_FIELD_NAME+") "; - queryString += "values(?,?,?,?)"; - - ArrayList argList = new ArrayList<>(); - argList.add(instanceId); - argList.add(requestId); - argList.add(creationDate); - argList.add(logText); - - try { - dbLibService.writeData(queryString, argList, schema); - } catch (SQLException e) { - logger.error("Logging Device interaction failed - "+ queryString); - throw new DataAccessException(e); - } - - return true; - } - -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java deleted file mode 100644 index 700a51b9f..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.internal; - -import java.io.ByteArrayOutputStream; - -class NetconfMessage { - - private static final String EOM = "]]>]]>"; - - private String text; - private MessageBuffer buffer = new MessageBuffer(); - private int eomNotch; - - NetconfMessage() { - } - - NetconfMessage(String text) { - if(text == null) { - throw new NullPointerException("Netconf message payload is null"); - } - append(text.getBytes(), 0, text.length()); - if(this.text == null) { - this.text = text; - } - } - - void append(byte[] bytes, int start, int end) { - boolean eomFound = false; - for(int i = start; i < end; i++) { - if(bytes[i] == EOM.charAt(eomNotch)) { - // advance notch - eomNotch++; - } else { - // reset notch - eomNotch = 0; - } - if(eomNotch == EOM.length()) { - // end of message found - eomFound = true; - end = i + 1; - break; - } - } - buffer.write(bytes, start, end); - if(eomFound) { - text = new String(buffer.getBytes(), 0, buffer.size() - EOM.length()); - buffer.reset(); - } - } - - String getText() { - return text; - } - - boolean isCompleted() { - return (text != null); - } - - byte[] getFrame() { - StringBuilder sb = new StringBuilder(); - if(text != null) { - sb.append(text).append("\n"); - } - sb.append(EOM); - return sb.toString().getBytes(); - } - - private class MessageBuffer extends ByteArrayOutputStream { - - byte[] getBytes() { - return buf; - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java deleted file mode 100644 index 37bb3b2f2..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * JSch logger implementation delegating to logback. - */ -public class JSchLogger implements com.jcraft.jsch.Logger { - - private static final Logger LOG = LoggerFactory.getLogger(JSchLogger.class); - - @Override - public boolean isEnabled(int level) { - return true; - } - - @Override - public void log(int level, String message) { - switch(level) { - case com.jcraft.jsch.Logger.DEBUG: - LOG.debug(message); - break; - - case com.jcraft.jsch.Logger.INFO: - LOG.info(message); - break; - - case com.jcraft.jsch.Logger.WARN: - LOG.warn(message); - break; - - case com.jcraft.jsch.Logger.ERROR: - case com.jcraft.jsch.Logger.FATAL: - LOG.error(message); - break; - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java deleted file mode 100644 index 7b9d7a4ae..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import com.jcraft.jsch.Channel; -import com.jcraft.jsch.ChannelSubsystem; -import com.jcraft.jsch.JSch; -import com.jcraft.jsch.Session; - -import java.io.IOException; -import java.util.List; -import java.util.Properties; - -import org.onap.appc.adapter.netconf.NetconfClient; -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.internal.NetconfAdapter; -import org.onap.appc.adapter.netconf.internal.NetconfConstMessages; -import org.onap.appc.encryption.EncryptionTool; -import org.onap.appc.exceptions.APPCException; -import org.onap.appc.i18n.Msg; -import com.att.eelf.i18n.EELFResourceManager; - -/** - * Implementation of NetconfClient interface based on JCraft jsch library. - */ -public class NetconfClientJsch implements NetconfClient { - - private static final int SESSION_CONNECT_TIMEOUT = 30000; - private static final int CHANNEL_CONNECT_TIMEOUT = 10000; - - private Session session; - private Channel channel; - private NetconfAdapter netconfAdapter; - - - @Override - public void connect(NetconfConnectionDetails connectionDetails) throws APPCException { - String host = connectionDetails.getHost(); - int port = connectionDetails.getPort(); - String username = connectionDetails.getUsername(); - String password = connectionDetails.getPassword(); - try { - JSch.setLogger(new JSchLogger()); - JSch jsch = new JSch(); - session = jsch.getSession(EncryptionTool.getInstance().decrypt(username), host, port); - session.setPassword(EncryptionTool.getInstance().decrypt(password)); - session.setConfig("StrictHostKeyChecking", "no"); - - Properties additionalProps = connectionDetails.getAdditionalProperties(); - if((additionalProps != null) && !additionalProps.isEmpty()) { - session.setConfig(additionalProps); - } - - session.connect(SESSION_CONNECT_TIMEOUT); - session.setTimeout(10000); - try { -// session.setServerAliveCountMax(0); // If this is not set to '0', then socket timeout on all reads will not work!!!! - channel = session.openChannel("subsystem"); - ((ChannelSubsystem)channel).setSubsystem("netconf"); - netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream()); - channel.connect(CHANNEL_CONNECT_TIMEOUT); - hello(connectionDetails.getCapabilities()); - } catch(Exception e) { - disconnect(); - throw e; - } - } catch(Exception e) { - String message = EELFResourceManager.format(Msg.CANNOT_ESTABLISH_CONNECTION, host, String.valueOf(port), username); - throw new APPCException(message, e); - } - } - - @Override - public String exchangeMessage(String message) throws APPCException { - try { - netconfAdapter.sendMessage(message); - return netconfAdapter.receiveMessage(); - } catch(IOException e) { - throw new APPCException(e); - } - } - - @Override - public void configure(String configuration) throws APPCException { - try { - isOk(exchangeMessage(configuration)); - } catch(IOException e) { - throw new APPCException(e); - } - } - - @Override - public String getConfiguration() throws APPCException { - return exchangeMessage(NetconfConstMessages.GET_RUNNING_CONFIG); - } - - @Override - public void disconnect() { - try { - if((channel != null) && !channel.isClosed()) { - netconfAdapter.sendMessage(NetconfConstMessages.CLOSE_SESSION); - isOk(netconfAdapter.receiveMessage()); - } - } catch(IOException e) { - throw new RuntimeException("Error closing netconf device", e); - } finally { - netconfAdapter = null; - if(channel != null) { - channel.disconnect(); - channel = null; - } - if(session != null) { - session.disconnect(); - session = null; - } - } - } - - private void hello(List capabilities) throws IOException { - String helloIn = netconfAdapter.receiveMessage(); - if(helloIn == null) { - throw new IOException("Expected hello message, but nothing received error from netconf device"); - } - if(helloIn.contains("")) { - throw new IOException("Expected hello message, but received error from netconf device:\n" + helloIn); - } - StringBuilder sb = new StringBuilder(); - sb.append(NetconfConstMessages.CAPABILITIES_START); - sb.append(NetconfConstMessages.CAPABILITIES_BASE); - if(capabilities != null) { - for(String capability: capabilities) { - sb.append(" ").append(capability).append("\n"); - } - } - sb.append(NetconfConstMessages.CAPABILITIES_END); - String helloOut = sb.toString(); - netconfAdapter.sendMessage(helloOut); - } - - private void isOk(String response) throws IOException { - if(response == null) { - throw new IOException("No response from netconf device"); - } - if(!response.contains("")) { - throw new IOException("Error response from netconf device: \n" + response); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java deleted file mode 100644 index bc89551a8..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java +++ /dev/null @@ -1,236 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.odlconnector; - -import org.apache.http.HttpStatus; -import org.onap.appc.adapter.netconf.NetconfClient; -import org.onap.appc.adapter.netconf.NetconfClientRestconf; -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.util.Constants; -import org.onap.appc.exceptions.APPCException; -import org.onap.appc.util.httpClient; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.Properties; - -public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRestconf { - - private EELFLogger logger = EELFManager.getInstance().getLogger(NetconfClientRestconfImpl.class); - - private NetconfConnectionDetails connectionDetails; - - //constructor - public NetconfClientRestconfImpl(){ - } - - //restconf client impl - - @SuppressWarnings("deprecation") - @Override - public void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException { - - logger.info("Configuring device "+deviceMountPointName+" with configuration "+configuration); - - int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/json"); - - if (httpCode != HttpStatus.SC_OK) { - logger.error("Configuration request failed. throwing Exception !"); - throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); - } - } - - @Override - public void connect(String deviceMountPointName, String payload) throws APPCException{ - - logger.info("Connecting device "+deviceMountPointName); - - int httpCode = httpClient.postMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getConnectPath(),payload,"application/json"); - - if(httpCode != HttpStatus.SC_NO_CONTENT){ - logger.error("Connect request failed with code "+httpCode+". throwing Exception !"); - throw new APPCException("Error connecting device :" + deviceMountPointName); - } - } - - @Override - public boolean checkConnection(String deviceMountPointName) throws APPCException { - logger.info("Checking device "+deviceMountPointName+" connectivity"); - - String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getCheckConnectivityPath(deviceMountPointName),"application/json"); - - return result != null; - } - - @Override - public void disconnect(String deviceMountPointName) throws APPCException { - logger.info("Disconnecting "+deviceMountPointName); - - int httpCode = httpClient.deleteMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getDisconnectPath(deviceMountPointName),"application/json"); - - if(httpCode != HttpStatus.SC_OK){ - logger.error("Disconnection of device "+deviceMountPointName+" failed!"); - throw new APPCException("Disconnection of device "+deviceMountPointName+" failed!"); - } - } - - @Override - public String getConfiguration(String deviceMountPointName, String moduleName, String nodeName) throws APPCException{ - logger.info("Getting configuration of device "+deviceMountPointName); - - String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),"application/json"); - - if (result == null) { - logger.error("Configuration request failed. throwing Exception !"); - throw new APPCException("Error getting configuration of node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); - } - - return result; - } - - //netconf client impl - - @Override - public void connect(NetconfConnectionDetails connectionDetails) throws APPCException { - if(connectionDetails == null){ - throw new APPCException("Invalid connection details - null value"); - } - this.connectionDetails = connectionDetails; - this.connect(connectionDetails.getHost(),getPayload()); - } - - @Override - public String exchangeMessage(String message) throws APPCException { - // TODO implement - return null; - } - - @Override - public void configure(String configuration) throws APPCException { - if(connectionDetails == null){ - throw new APPCException("Invalid connection details - null value"); - } - - Properties props = connectionDetails.getAdditionalProperties(); - if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){ - throw new APPCException("Invalid properties!"); - } - - String moduleName = props.getProperty("module.name"); - String nodeName = props.getProperty("node.name"); - String deviceMountPointName = connectionDetails.getHost(); - - int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/xml"); - - if (httpCode != HttpStatus.SC_OK) { - logger.error("Configuration request failed. throwing Exception !"); - throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); - } - } - - @Override - public String getConfiguration() throws APPCException { - if(connectionDetails == null){ - throw new APPCException("Invalid connection details - null value"); - } - - Properties props = connectionDetails.getAdditionalProperties(); - if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){ - throw new APPCException("Invalid properties!"); - } - - return this.getConfiguration(connectionDetails.getHost(),props.getProperty("module.name"),props.getProperty("node.name")); - } - - @Override - public void disconnect() throws APPCException { - if(connectionDetails == null){ - throw new APPCException("Invalid connection details - null value"); - } - this.disconnect(connectionDetails.getHost()); - } - - //private methods - private String getModuleConfigurePath(String deviceMountPointName, String moduleName, String nodeName){ - - - String deviceSpecificPath = deviceMountPointName + "/yang-ext:mount/" + moduleName + ":" + nodeName; - - return Constants.CONFIGURE_PATH + deviceSpecificPath; - } - - private String getConnectPath(){ - - return Constants.CONNECT_PATH; - } - - private String getCheckConnectivityPath(String deviceMountPointName) { - return Constants.CHECK_CONNECTION_PATH + deviceMountPointName; - } - - private String getDisconnectPath(String deviceMountPointName) { - return Constants.DISCONNECT_PATH + deviceMountPointName; - } - - private String getPayload() { - return "{\n" + - " \"config:module\":\n" + - " {\n" + - " \"type\":\"odl-sal-netconf-connector-cfg:sal-netconf-connector\",\n" + - " \"netconf-northbound-ssh\\odl-sal-netconf-connector-cfg:name\":"+connectionDetails.getHost()+",\n" + - " \"odl-sal-netconf-connector-cfg:address\":"+connectionDetails.getHost()+",\n" + - " \"odl-sal-netconf-connector-cfg:port\":"+connectionDetails.getPort()+",\n" + - " \"odl-sal-netconf-connector-cfg:username\":"+connectionDetails.getUsername()+",\n" + - " \"odl-sal-netconf-connector-cfg:password\":"+connectionDetails.getPassword()+",\n" + - " \"tcp-only\":\"false\",\n" + - " \"odl-sal-netconf-connector-cfg:event-executor\":\n" + - " {\n" + - " \"type\":\"netty:netty-event-executor\",\n" + - " \"name\":\"global-event-executor\"\n" + - " },\n" + - " \"odl-sal-netconf-connector-cfg:binding-registry\":\n" + - " {\n" + - " \"type\":\"opendaylight-md-sal-binding:binding-broker-osgi-registry\",\n" + - " \"name\":\"binding-osgi-broker\"\n" + - " },\n" + - " \"odl-sal-netconf-connector-cfg:dom-registry\":\n" + - " {\n" + - " \"type\":\"opendaylight-md-sal-dom:dom-broker-osgi-registry\",\n" + - " \"name\":\"dom-broker\"\n" + - " },\n" + - " \"odl-sal-netconf-connector-cfg:client-dispatcher\":\n" + - " {\n" + - " \"type\":\"odl-netconf-cfg:netconf-client-dispatcher\",\n" + - " \"name\":\"global-netconf-dispatcher\"\n" + - " },\n" + - " \"odl-sal-netconf-connector-cfg:processing-executor\":\n" + - " {\n" + - " \"type\":\"threadpool:threadpool\",\n" + - " \"name\":\"global-netconf-processing-executor\"\n" + - " }\n" + - " }\n" + - "}"; - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java deleted file mode 100644 index e8b8e9378..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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 - * - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.util; - -public class Constants { - - public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/"; - public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules"; - public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/"; - public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/"; - - public static final String CONTROLLER_IP = "127.0.0.1"; - public static final int CONTROLLER_PORT = 8181; - public static final String PROTOCOL = "http"; - - // tables and fields - public static final String NETCONF_SCHEMA = "sdnctl"; - public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION"; - public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES"; - public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG"; - public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT"; - public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME"; - public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME"; - public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD"; - public static final String VM_HOST_TABLE_FIELD_NAME = "VM_HOST"; - public static final String VM_NAME_TABLE_FIELD_NAME = "VM_NAME"; - public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER"; - public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE"; - public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID"; - public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID"; - public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE"; - public static final String LOG_FIELD_NAME = "LOG"; - - // input fields names - public static final String VNF_TYPE_FIELD_NAME = "org.onap.appc.vftype"; - public static final String TARGET_VNF_TYPE = "target-vnf-type"; - public static final String FILE_CONTENT_FIELD_NAME = "file-content"; - public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details"; - public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name"; - public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address"; - public static final String DG_ERROR_FIELD_NAME = "org.onap.appc.dg.error"; - public static final String RESOURCEKEY = "resourceKey"; - public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message"; - public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; - -} -- cgit 1.2.3-korg