aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration')
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java60
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java50
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java57
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java76
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java32
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java37
-rw-r--r--test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java37
7 files changed, 0 insertions, 349 deletions
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java
deleted file mode 100644
index d90c60d58..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-class NetconfBeanConfiguration {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NetconfBeanConfiguration.class);
-
- @Value("${netconf.port}")
- private Integer netconfPort;
-
- @Value("${netconf.address}")
- private String netconfAddress;
-
- @Value("${netconf.user}")
- private String netconfUser;
-
- @Value("${netconf.password}")
- private String netconfPassword;
-
- @Bean
- NetconfConfigurationReader configurationReader() {
- NetconfConnectionParams params = new NetconfConnectionParams(netconfAddress, netconfPort, netconfUser, netconfPassword);
- LOGGER.info("Configuration params are : {}", params);
- return new NetconfConfigurationReader(params, new NetconfSessionHelper());
- }
-
- @Bean
- NetconfConfigurationEditor configurationEditor() {
- NetconfConnectionParams params =
- new NetconfConnectionParams(netconfAddress, netconfPort, netconfUser, netconfPassword);
- return new NetconfConfigurationEditor(params, new NetconfSessionHelper());
- }
-
-}
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java
deleted file mode 100644
index 992c88d5a..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import com.tailf.jnc.Element;
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.IOException;
-
-@Slf4j
-public class NetconfConfigurationEditor {
-
- private NetconfConnectionParams params;
- private NetconfSessionHelper netconfSessionHelper;
-
- public NetconfConfigurationEditor(NetconfConnectionParams params, NetconfSessionHelper netconfSessionHelper) {
- this.params = params;
- this.netconfSessionHelper = netconfSessionHelper;
- }
-
- void editConfig(Element configurationXmlElement) throws JNCException, IOException {
- log.debug("New configuration passed to simulator: {}", configurationXmlElement.toXMLString());
- NetconfSession session = netconfSessionHelper.createNetconfSession(params);
- session.editConfig(configurationXmlElement);
- session.closeSession();
-
- log.info("Successfully updated configuration");
- }
-
-}
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java
deleted file mode 100644
index 10fe40e2f..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import com.tailf.jnc.NodeSet;
-import java.io.IOException;
-import java.util.Objects;
-
-class NetconfConfigurationReader {
-
- private NetconfConnectionParams params;
- private NetconfSessionHelper netconfSessionHelper;
-
- NetconfConfigurationReader(NetconfConnectionParams params, NetconfSessionHelper netconfSessionHelper) {
- this.params = params;
- this.netconfSessionHelper = netconfSessionHelper;
- }
-
- String getRunningConfig() throws IOException, JNCException {
- NetconfSession session = netconfSessionHelper.createNetconfSession(params);
- String config = session.getConfig().toXMLString();
- session.closeSession();
- return config;
- }
-
- String getRunningConfig(String modelPath) throws IOException, JNCException {
- NetconfSession session = netconfSessionHelper.createNetconfSession(params);
- NodeSet config = session.getConfig(modelPath);
- if (Objects.isNull(config) || Objects.isNull(config.first())) {
- throw new JNCException(JNCException.ELEMENT_MISSING, modelPath);
- }
- session.closeSession();
- return config.first().toXMLString();
- }
-
-
-}
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java
deleted file mode 100644
index 248aec46a..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import com.tailf.jnc.Element;
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.XMLParser;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-import org.xml.sax.InputSource;
-
-@Service
-public class NetconfConfigurationService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NetconfConfigurationService.class);
- private static final String CONFIGURATION_HAS_BEEN_ACTIVATED = "New configuration has been activated";
-
- private final NetconfConfigurationReader netconfConfigurationReader;
- private NetconfConfigurationEditor configurationEditor;
- private XMLParser parser;
-
- @Autowired
- public NetconfConfigurationService(NetconfConfigurationReader netconfConfigurationReader,
- NetconfConfigurationEditor netconfConfigurationEditor) throws JNCException {
- this.netconfConfigurationReader = netconfConfigurationReader;
- this.configurationEditor = netconfConfigurationEditor;
- this.parser = new XMLParser();
- }
-
- public String getCurrentConfiguration() throws IOException, JNCException {
- return netconfConfigurationReader.getRunningConfig();
- }
-
- public String getCurrentConfiguration(String model, String container) throws IOException, JNCException {
- String path = String.format("/%s:%s", model, container);
- return netconfConfigurationReader.getRunningConfig(path);
- }
-
- public String editCurrentConfiguration(MultipartFile newConfiguration) throws IOException, JNCException {
- Element configurationElement = convertMultipartToXmlElement(newConfiguration);
- configurationEditor.editConfig(configurationElement);
-
- LOGGER.debug("Loading new configuration: \n{}", configurationElement.toXMLString());
- return CONFIGURATION_HAS_BEEN_ACTIVATED;
- }
-
- private Element convertMultipartToXmlElement(MultipartFile editConfig) throws IOException, JNCException {
- InputSource inputSourceUpdateConfig = new InputSource(new ByteArrayInputStream(editConfig.getBytes()));
- return parser.parse(inputSourceUpdateConfig);
- }
-}
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java
deleted file mode 100644
index e43ff690e..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-@Getter
-@AllArgsConstructor
-public class NetconfConfigurationTO {
-
- private String configuration;
-
-}
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java
deleted file mode 100644
index ace0ee04c..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.ToString;
-
-@AllArgsConstructor
-@ToString
-@Getter
-class NetconfConnectionParams {
-
- private final String address;
- private final int port;
- private final String user;
- private final String password;
-
-}
diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java
deleted file mode 100644
index 69fda7d63..000000000
--- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Simulator
- * ================================================================================
- * Copyright (C) 2019 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.netconfsimulator.netconfcore.configuration;
-
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import com.tailf.jnc.SSHConnection;
-import com.tailf.jnc.SSHSession;
-import java.io.IOException;
-
-class NetconfSessionHelper {
-
- NetconfSession createNetconfSession(NetconfConnectionParams params) throws IOException, JNCException {
- SSHConnection sshConnection = new SSHConnection(params.getAddress(), params.getPort());
- sshConnection.authenticateWithPassword(params.getUser(), params.getPassword());
- return new NetconfSession(new SSHSession(sshConnection));
- }
-
-}