diff options
author | Edyta Krukowska <edyta.krukowska@nokia.com> | 2021-03-16 12:52:56 +0100 |
---|---|---|
committer | Edyta Krukowska <edyta.krukowska@nokia.com> | 2021-03-16 13:38:33 +0100 |
commit | 2fa21ae5c2245ec5a75a7677320e77d70aae443e (patch) | |
tree | 9be6539a16f93646adb1a197f0ec0fe26c91b9c5 | |
parent | c4a6e3114d3614e257350f967eeb58517afff06b (diff) |
Update simulator-cli pom and add pom.xml to parent project
Issue-ID: INT-1869
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: I908529a8eaa9eadd967c3696def0b3b2200d71be
-rw-r--r-- | pom.xml | 40 | ||||
-rw-r--r-- | simulator-cli/assembly.xml | 38 | ||||
-rw-r--r-- | simulator-cli/cli/netconf_server.py | 20 | ||||
-rw-r--r-- | simulator-cli/pom.xml | 69 | ||||
-rw-r--r-- | simulator-cli/tests/test_netconf_server.py | 46 |
5 files changed, 180 insertions, 33 deletions
@@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============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========================================================= + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + + <parent> + <groupId>org.onap.oparent</groupId> + <artifactId>oparent</artifactId> + <version>2.1.0</version> + </parent> + + <groupId>org.onap.integration.simulators.nf-simulator</groupId> + <artifactId>nf-simulator</artifactId> + <version>1.0.0</version> + <modules> + <module>simulator-cli</module> + </modules> +</project> diff --git a/simulator-cli/assembly.xml b/simulator-cli/assembly.xml new file mode 100644 index 0000000..976577a --- /dev/null +++ b/simulator-cli/assembly.xml @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2016-2017 GigaSpaces Technologies Ltd. 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. +--> +<assembly + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>vnfsdk</id> + <formats> + <format>zip</format> + </formats> + <fileSets> + <fileSet> + <includes> + <include>MANIFEST.in</include> + <include>tests/**</include> + <include>requirements.txt</include> + <include>setup.py</include> + </includes> + <excludes> + <exclude>**/*.pyc</exclude> + </excludes> + </fileSet> + </fileSets> + <baseDirectory>.</baseDirectory> +</assembly> diff --git a/simulator-cli/cli/netconf_server.py b/simulator-cli/cli/netconf_server.py index 57196fa..a808a13 100644 --- a/simulator-cli/cli/netconf_server.py +++ b/simulator-cli/cli/netconf_server.py @@ -41,7 +41,7 @@ DEFAULT_EXTERNAL_SIM_PORT = 8080 DEFAULT_INTERNAL_SIM_PORT = 9000 -class NetconfSimulatorClient(object): +class NetconfServerClient(object): def __init__(self, ip: str, protocol: str = 'http', port: int = DEFAULT_EXTERNAL_SIM_PORT, verbose: bool = False) -> None: self._ip = ip self._protocol = protocol @@ -182,39 +182,39 @@ def create_argument_parser(): def run_tailf(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose) + client = NetconfServerClient(args.address, verbose=args.verbose) client.tailf_like_func() def run_get_cm_history(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) + client = NetconfServerClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) client.get_cm_history() def run_less(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) + client = NetconfServerClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) client.less_like_func(args.limit) def run_load_model(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose, - port=DEFAULT_INTERNAL_SIM_PORT) + client = NetconfServerClient(args.address, verbose=args.verbose, + port=DEFAULT_INTERNAL_SIM_PORT) client.load_yang_model(args.module_name, args.yang_model, args.config) def run_delete_model(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose, - port=DEFAULT_INTERNAL_SIM_PORT) + client = NetconfServerClient(args.address, verbose=args.verbose, + port=DEFAULT_INTERNAL_SIM_PORT) client.delete_yang_model(args.model_name) def run_get_config(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) + client = NetconfServerClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) client.get_config(args.module_name, args.container) def run_edit_config(args): - client = NetconfSimulatorClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) + client = NetconfServerClient(args.address, verbose=args.verbose, port=DEFAULT_INTERNAL_SIM_PORT) client.edit_config(args.config) diff --git a/simulator-cli/pom.xml b/simulator-cli/pom.xml new file mode 100644 index 0000000..60721df --- /dev/null +++ b/simulator-cli/pom.xml @@ -0,0 +1,69 @@ +<?xml version="1.0"?> +<!-- +================================================================================ +Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved. +Copyright (c) 2020 Pantheon.tech. All rights reserved. +Copyright (c) 2020-2021 Nokia. All rights reserved. +Copyright (c) 2020 J. F. Lucas. 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========================================================= +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.integration.simulators.nf-simulator</groupId> + <artifactId>nf-simulator</artifactId> + <version>1.0.0</version> + </parent> + + <groupId>simulator-cli</groupId> + <artifactId>simulator-cli</artifactId> + <version>1.0.0-SNAPSHOT</version> + <name>simulator-cli</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <sonar.sources>.</sonar.sources> + <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> + <sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths> + <sonar.language>py</sonar.language> + <sonar.pluginName>Python</sonar.pluginName> + <sonar.inclusions>./*.py</sonar.inclusions> + <sonar.exclusions>tests/*,setup.py</sonar.exclusions> + </properties> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.2.1</version> + <executions> + <execution> + <configuration> + <executable>tox</executable> + <workingDirectory>.</workingDirectory> + </configuration> + <id>python-build</id> + <phase>prepare-package</phase> + <goals> + <goal>exec</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/simulator-cli/tests/test_netconf_server.py b/simulator-cli/tests/test_netconf_server.py index 8e39184..b22a31f 100644 --- a/simulator-cli/tests/test_netconf_server.py +++ b/simulator-cli/tests/test_netconf_server.py @@ -22,7 +22,7 @@ import unittest import os from mock import patch -from cli.netconf_server import create_argument_parser, NetconfSimulatorClient +from cli.netconf_server import create_argument_parser, NetconfServerClient class TestArgumentParser(unittest.TestCase): @@ -87,76 +87,76 @@ class TestNetconfSimulatorClient(unittest.TestCase): def tearDownClass(cls): os.remove("example") - @patch('cli.netconf_simulator.requests') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.requests') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_properly_get_config(self, logger, requests): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() client.get_config() requests.get.assert_called_with('http://localhost:8080/netconf/get') - @patch('cli.netconf_simulator.requests') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.requests') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_properly_get_config_for_given_module(self, logger, requests): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() client.get_config("module", "container") requests.get.assert_called_with('http://localhost:8080/netconf/get/module/container') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_raise_exception_when_module_is_present_and_container_is_absent(self, logger): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() with self.assertRaises(AttributeError) as context: # pylint: disable=W0612 client.get_config(module_name="test") - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_raise_exception_when_module_is_absent_and_container_is_present(self, logger): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() with self.assertRaises(AttributeError) as context: # pylint: disable=W0612 client.get_config(container="test") - @patch('cli.netconf_simulator.requests') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.requests') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_properly_load_yang_model(self, logger, requests): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() client.load_yang_model('sample_module_name', 'example', 'example') requests.post.assert_called() - @patch('cli.netconf_simulator.requests') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.requests') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_properly_delete_yang_model(self, logger, requests): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() client.delete_yang_model('sample_model_name') requests.delete.assert_called() - @patch('cli.netconf_simulator.requests') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.requests') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_properly_edit_config(self, logger, requests): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() client.edit_config('example') requests.post.assert_called() - @patch('cli.netconf_simulator.requests') - @patch('cli.netconf_simulator.NetconfSimulatorClient._configure_logger') + @patch('cli.netconf_server.requests') + @patch('cli.netconf_server.NetconfServerClient._configure_logger') def test_should_properly_run_less_like_mode(self, logger, requests): - client = NetconfSimulatorClient('localhost') + client = NetconfServerClient('localhost') client.logger = logging.getLogger() client.less_like_func(100) |