From 2fa21ae5c2245ec5a75a7677320e77d70aae443e Mon Sep 17 00:00:00 2001 From: Edyta Krukowska Date: Tue, 16 Mar 2021 12:52:56 +0100 Subject: Update simulator-cli pom and add pom.xml to parent project Issue-ID: INT-1869 Signed-off-by: Edyta Krukowska Change-Id: I908529a8eaa9eadd967c3696def0b3b2200d71be --- pom.xml | 40 +++++++++++++++++ simulator-cli/assembly.xml | 38 ++++++++++++++++ simulator-cli/cli/netconf_server.py | 20 ++++----- simulator-cli/pom.xml | 69 ++++++++++++++++++++++++++++++ simulator-cli/tests/test_netconf_server.py | 46 ++++++++++---------- 5 files changed, 180 insertions(+), 33 deletions(-) create mode 100644 pom.xml create mode 100644 simulator-cli/assembly.xml create mode 100644 simulator-cli/pom.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4001ab1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,40 @@ + + + + + 4.0.0 + pom + + + org.onap.oparent + oparent + 2.1.0 + + + org.onap.integration.simulators.nf-simulator + nf-simulator + 1.0.0 + + simulator-cli + + 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 @@ + + + vnfsdk + + zip + + + + + MANIFEST.in + tests/** + requirements.txt + setup.py + + + **/*.pyc + + + + . + 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 @@ + + + + 4.0.0 + + org.onap.integration.simulators.nf-simulator + nf-simulator + 1.0.0 + + + simulator-cli + simulator-cli + 1.0.0-SNAPSHOT + simulator-cli + + + UTF-8 + . + xunit-results.xml + coverage.xml + py + Python + ./*.py + tests/*,setup.py + + + + ${project.artifactId}-${project.version} + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + tox + . + + python-build + prepare-package + + exec + + + + + + + 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) -- cgit 1.2.3-korg