From 7e83d0876ddb84a45e130eeba28bc40ef53c074b Mon Sep 17 00:00:00 2001 From: Yaron Yogev Date: Thu, 27 Jul 2017 09:02:54 +0300 Subject: Calipso initial release for OPNFV Change-Id: I7210c244b0c10fa80bfa8c77cb86c9d6ddf8bc88 Signed-off-by: Yaron Yogev --- app/test/fetch/cli_fetch/__init__.py | 9 + app/test/fetch/cli_fetch/test_cli_access.py | 159 ++++++ .../fetch/cli_fetch/test_cli_fetch_host_pnics.py | 135 +++++ .../cli_fetch/test_cli_fetch_host_pnics_vpp.py | 34 ++ .../cli_fetch/test_cli_fetch_host_vservices.py | 132 +++++ .../cli_fetch/test_cli_fetch_instance_vnics.py | 111 ++++ .../cli_fetch/test_cli_fetch_instance_vnics_ovs.py | 36 ++ .../cli_fetch/test_cli_fetch_instance_vnics_vpp.py | 23 + .../fetch/cli_fetch/test_cli_fetch_vconnectors.py | 66 +++ .../cli_fetch/test_cli_fetch_vconnectors_ovs.py | 38 ++ .../cli_fetch/test_cli_fetch_vconnectors_vpp.py | 50 ++ .../cli_fetch/test_cli_fetch_vservice_vnics.py | 124 +++++ app/test/fetch/cli_fetch/test_data/__init__.py | 9 + app/test/fetch/cli_fetch/test_data/cli_access.py | 58 ++ .../cli_fetch/test_data/cli_fetch_host_pnics.py | 147 +++++ .../test_data/cli_fetch_host_pnics_vpp.py | 204 +++++++ .../test_data/cli_fetch_host_verservices.py | 276 +++++++++ .../test_data/cli_fetch_instance_vnics.py | 288 ++++++++++ .../cli_fetch/test_data/cli_fetch_vconnectors.py | 103 ++++ .../test_data/cli_fetch_vconnectors_ovs.py | 234 ++++++++ .../test_data/cli_fetch_vconnectors_vpp.py | 137 +++++ .../test_data/cli_fetch_vservice_vnics.py | 616 +++++++++++++++++++++ 22 files changed, 2989 insertions(+) create mode 100644 app/test/fetch/cli_fetch/__init__.py create mode 100644 app/test/fetch/cli_fetch/test_cli_access.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_host_pnics_vpp.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_host_vservices.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_ovs.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_vpp.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_vconnectors.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_ovs.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_vpp.py create mode 100644 app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py create mode 100644 app/test/fetch/cli_fetch/test_data/__init__.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_access.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics_vpp.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_host_verservices.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_instance_vnics.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_vconnectors.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_vconnectors_ovs.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_vconnectors_vpp.py create mode 100644 app/test/fetch/cli_fetch/test_data/cli_fetch_vservice_vnics.py (limited to 'app/test/fetch/cli_fetch') diff --git a/app/test/fetch/cli_fetch/__init__.py b/app/test/fetch/cli_fetch/__init__.py new file mode 100644 index 0000000..b0637e9 --- /dev/null +++ b/app/test/fetch/cli_fetch/__init__.py @@ -0,0 +1,9 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### diff --git a/app/test/fetch/cli_fetch/test_cli_access.py b/app/test/fetch/cli_fetch/test_cli_access.py new file mode 100644 index 0000000..f393538 --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_access.py @@ -0,0 +1,159 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +import time + +from discover.fetchers.cli.cli_access import CliAccess +from test.fetch.cli_fetch.test_data.cli_access import * +from test.fetch.test_fetch import TestFetch +from unittest.mock import MagicMock, patch +from utils.ssh_conn import SshConn + + +class TestCliAccess(TestFetch): + + def setUp(self): + self.configure_environment() + self.cli_access = CliAccess() + + @patch("utils.ssh_conn.SshConn.exec") + def check_run_result(self, is_gateway_host, + enable_cache, + cached_command_result, exec_result, + expected_result, err_msg, + ssh_con_exec): + # mock cached commands + if not is_gateway_host: + self.cli_access.cached_commands = { + NON_GATEWAY_CACHED_COMMAND: cached_command_result + } + else: + self.cli_access.cached_commands = { + GATEWAY_CACHED_COMMAND: cached_command_result + } + original_is_gateway_host = SshConn.is_gateway_host + SshConn.is_gateway_host = MagicMock(return_value=is_gateway_host) + ssh_con_exec.return_value = exec_result + result = self.cli_access.run(COMMAND, COMPUTE_HOST_ID, + on_gateway=False, enable_cache=enable_cache) + self.assertEqual(result, expected_result, err_msg) + + # reset the cached commands after testing + self.cli_access.cached_commands = {} + # reset method + SshConn.is_gateway_host = original_is_gateway_host + + def test_run(self): + curr_time = time.time() + test_cases = [ + { + "is_gateway_host": True, + "enable_cache": False, + "cached_command_result": None, + "exec_result": RUN_RESULT, + "expected_result": RUN_RESULT, + "err_msg": "Can't get the " + + "result of the command" + }, + { + "is_gateway_host": True, + "enable_cache": True, + "cached_command_result": { + "timestamp": curr_time, + "result": CACHED_COMMAND_RESULT + }, + "exec_result": None, + "expected_result": CACHED_COMMAND_RESULT, + "err_msg": "Can't get the cached " + + "result of the command " + + "when the host is a gateway host" + }, + { + "is_gateway_host": False, + "enable_cache": True, + "cached_command_result": { + "timestamp": curr_time, + "result": CACHED_COMMAND_RESULT + }, + "exec_result": None, + "expected_result": CACHED_COMMAND_RESULT, + "err_msg": "Can't get the cached " + + "result of the command " + + "when the host is not a gateway host" + }, + { + "is_gateway_host": True, + "enable_cache": True, + "cached_command_result": { + "timestamp": curr_time - self.cli_access.cache_lifetime, + "result": CACHED_COMMAND_RESULT + }, + "exec_result": RUN_RESULT, + "expected_result": RUN_RESULT, + "err_msg": "Can't get the result " + + "of the command when the cached result expired " + + "and the host is a gateway host" + }, + { + "is_gateway_host": False, + "enable_cache": True, + "cached_command_result": { + "timestamp": curr_time - self.cli_access.cache_lifetime, + "result": CACHED_COMMAND_RESULT + }, + "exec_result": RUN_RESULT, + "expected_result": RUN_RESULT, + "err_msg": "Can't get the result " + + "of the command when the cached result expired " + + "and the host is a not gateway host" + } + ] + + for test_case in test_cases: + self.check_run_result(test_case["is_gateway_host"], + test_case["enable_cache"], + test_case["cached_command_result"], + test_case["exec_result"], + test_case["expected_result"], + test_case["err_msg"]) + + def test_run_fetch_lines(self): + original_run = self.cli_access.run + self.cli_access.run = MagicMock(return_value=RUN_RESULT) + + result = self.cli_access.run_fetch_lines(COMMAND, COMPUTE_HOST_ID) + + self.assertEqual(result, FETCH_LINES_RESULT, + "Can't get correct result of the command line") + self.cli_access.run = original_run + + def test_run_fetch_lines_with_empty_command_result(self): + original_run = self.cli_access.run + self.cli_access.run = MagicMock(return_value="") + + result = self.cli_access.run_fetch_lines(COMMAND, COMPUTE_HOST_ID) + self.assertEqual(result, [], "Can't get [] when the command " + + "result is empty") + self.cli_access.run = original_run + + def test_merge_ws_spillover_lines(self): + fixed_lines = self.cli_access.merge_ws_spillover_lines(LINES_FOR_FIX) + self.assertEqual(fixed_lines, FIXED_LINES, "Can't merge the " + + "ws-separated spillover lines") + + def test_parse_line_with_ws(self): + parse_line = self.cli_access.parse_line_with_ws(LINE_FOR_PARSE, HEADERS) + self.assertEqual(parse_line, PARSED_LINE, "Can't parse the line with ws") + + def test_parse_cmd_result_with_whitespace(self): + result = self.cli_access.parse_cmd_result_with_whitespace(FIXED_LINES, + HEADERS, + remove_first=False) + self.assertEqual(result, PARSED_CMD_RESULT, + "Can't parse the cmd result with whitespace") diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py b/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py new file mode 100644 index 0000000..f5f327e --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py @@ -0,0 +1,135 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_host_pnics import CliFetchHostPnics +from test.fetch.cli_fetch.test_data.cli_fetch_host_pnics import * +from test.fetch.test_fetch import TestFetch +from unittest.mock import MagicMock +from unittest.mock import call + + +class TestCliFetchHostPnics(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchHostPnics() + self.fetcher.set_env(self.env) + + def check_get_result(self, host, + interface_lines, interface_names, + interface_details, expected_result, + err_msg): + original_get_by_id = self.fetcher.inv.get_by_id + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_find_interface_details = self.fetcher.find_interface_details + + self.fetcher.inv.get_by_id = MagicMock(return_value=host) + self.fetcher.run_fetch_lines = MagicMock(return_value=interface_lines) + self.fetcher.find_interface_details = MagicMock(side_effect= + interface_details) + result = self.fetcher.get(PNICS_FOLDER_ID) + self.assertEqual(result, expected_result, err_msg) + + if interface_names: + interface_calls = [call(HOST_ID, interface_name) for + interface_name in interface_names] + self.fetcher.find_interface_details.assert_has_calls(interface_calls, + any_order=True) + # reset the methods + self.fetcher.inv.get_by_id = original_get_by_id + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.find_interface_details = original_find_interface_details + + def test_get(self): + test_cases = [ + { + "host": NETWORK_NODE, + "interface_lines": INTERFACE_LINES, + "interface_names": INTERFACE_NAMES, + "interface_details": [INTERFACE, None], + "expected_results": INTERFACES_GET_RESULTS, + "err_msg": "Can't get interfaces" + }, + { + "host": [], + "interface_lines": None, + "interface_names": None, + "interface_details": None, + "expected_results": [], + "err_msg": "Can't get [] when the host " + + "doesn't exist in the database" + }, + { + "host": WRONG_NODE, + "interface_lines": None, + "interface_names": None, + "interface_details": None, + "expected_results": [], + "err_msg": "Can't get [] when the host doesn't " + + "have required host type" + }, + { + "host": NETWORK_NODE, + "interface_lines": [], + "interface_names": None, + "interface_details":None, + "expected_results": [], + "err_msg": "Can't get [] when " + + "the interface lines is []" + } + ] + for test_case in test_cases: + self.check_get_result(test_case["host"], + test_case["interface_lines"], + test_case["interface_names"], + test_case["interface_details"], + test_case["expected_results"], + test_case["err_msg"]) + + def test_find_interface_details(self): + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_handle_line = self.fetcher.handle_line + original_set_interface_data = self.fetcher.set_interface_data + + self.fetcher.run_fetch_lines = MagicMock(return_value=IFCONFIG_CM_RESULT) + self.fetcher.handle_line = MagicMock() + self.fetcher.set_interface_data = MagicMock() + + result = self.fetcher.find_interface_details(HOST_ID, INTERFACE_NAME) + + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.handle_line = original_handle_line + self.fetcher.set_interface_data = original_set_interface_data + + self.assertEqual(result, INTERFACE_DETAILS, "Can't get interface details") + + def test_handle_mac_address_line(self): + self.fetcher.handle_line(RAW_INTERFACE, MAC_ADDRESS_LINE) + self.assertEqual(RAW_INTERFACE["mac_address"], MAC_ADDRESS, + "Can't get the correct mac address") + + # Test failed, defect, result: addr: expected result: fe80::f816:3eff:fea1:eb73/64 + def test_handle_ipv6_address_line(self): + self.fetcher.handle_line(RAW_INTERFACE, IPV6_ADDRESS_LINE) + self.assertEqual(RAW_INTERFACE['IPv6 Address'], IPV6_ADDRESS, + "Can' get the correct ipv6 address") + + def test_handle_ipv4_address_line(self): + self.fetcher.handle_line(RAW_INTERFACE, IPV4_ADDRESS_LINE) + self.assertEqual(RAW_INTERFACE['IP Address'], IPV4_ADDRESS, + "Can't get the correct ipv4 address") + + def test_set_interface_data(self): + original_run_fetch_lines = self.fetcher.run_fetch_lines + self.fetcher.run_fetch_lines = MagicMock(return_value=ETHTOOL_RESULT) + self.fetcher.set_interface_data(INTERFACE_FOR_SET) + self.assertEqual(INTERFACE_FOR_SET, INTERFACE_AFTER_SET, "Can't get the attributes of the " + "interface from the CMD result") + + self.fetcher.run_fetch_lines = original_run_fetch_lines diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics_vpp.py b/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics_vpp.py new file mode 100644 index 0000000..805e36d --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics_vpp.py @@ -0,0 +1,34 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_host_pnics_vpp import CliFetchHostPnicsVpp +from test.fetch.test_fetch import TestFetch +from unittest.mock import MagicMock +from test.fetch.cli_fetch.test_data.cli_fetch_host_pnics_vpp import * + + +class TestCliFetchHostPnicsVpp(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchHostPnicsVpp() + self.fetcher.set_env(self.env) + + def test_get(self): + # store original method + original_find_items = self.fetcher.inv.find_items + + # mock the method + self.fetcher.inv.find_items = MagicMock(return_value=VEDGES) + + result = self.fetcher.get(ID) + # reset the method + self.fetcher.inv.find_items = original_find_items + + self.assertNotEqual(result, [], "Can't get the pnics info") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_host_vservices.py b/app/test/fetch/cli_fetch/test_cli_fetch_host_vservices.py new file mode 100644 index 0000000..c33faca --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_host_vservices.py @@ -0,0 +1,132 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_host_vservices import CliFetchHostVservices +from test.fetch.test_fetch import TestFetch +from test.fetch.cli_fetch.test_data.cli_fetch_host_verservices import * +from unittest.mock import MagicMock + + +class TestCliFetchHostVservices(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchHostVservices() + self.fetcher.set_env(self.env) + + def test_get(self): + # store original get_single method + original_get_single = self.fetcher.inv.get_single + # mock the host data + self.fetcher.inv.get_single = MagicMock(return_value=NETWORK_HOST) + # store original run_fetch_lines method + original_run_fetch_lines = self.fetcher.run_fetch_lines + # mock command line results + self.fetcher.run_fetch_lines = MagicMock(return_value=NAMESPACES) + + # only test the logic on get method, mock the set_details method + original_set_details = self.fetcher.set_details + self.fetcher.set_details = MagicMock() + + result = self.fetcher.get(NETWORK_HOST['id']) + # reset methods + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.set_details = original_set_details + self.fetcher.inv.get_single = original_get_single + + self.assertNotEqual(result, [], "Can't get verservices") + + def test_get_with_wrong_host_type(self): + # store original get_single method + original_get_single = self.fetcher.inv.get_single + # mock the host data + self.fetcher.inv.get_single = MagicMock(return_value=COMPUTE_HOST) + result = self.fetcher.get(COMPUTE_HOST['id']) + + self.fetcher.inv.get_single = original_get_single + + self.assertEqual(result, [], "Can't get empty array when the host_type doesn't contain Network") + + def test_set_details(self): + # store orginal methods + original_get_router_name = self.fetcher.get_router_name + original_get_network_name = self.fetcher.get_network_name + original_get_type = self.fetcher.agents_list.get_type + + # mock methods + self.fetcher.get_network_name = MagicMock(return_value=ROUTER[0]['name']) + self.fetcher.get_router_name = MagicMock(return_value=ROUTER[0]['name']) + self.fetcher.agents_list.get_type = MagicMock(return_value=AGENT) + + self.fetcher.set_details(NETWORK_HOST['id'], LOCAL_SERVICES_IDS[0]) + + # reset methods + self.fetcher.get_network_name = original_get_network_name + self.fetcher.get_router_name = original_get_router_name + self.fetcher.agents_list.get_type = original_get_type + + self.assertIn("name", LOCAL_SERVICES_IDS[0], "Can't add name") + self.assertIn("parent_id", LOCAL_SERVICES_IDS[0], "Can't add parent id") + + def test_get_network_name(self): + # store original method + original_get_objects_list_for_id = self.fetcher.get_objects_list_for_id + # mock the result + self.fetcher.get_objects_list_for_id = MagicMock(return_value=ROUTER) + + name = self.fetcher.get_network_name(ID_CLEAN) + + self.fetcher.get_objects_list_for_id = original_get_objects_list_for_id + self.assertEqual(name, ROUTER[0]['name'], "Can't get network name") + + def test_get_network_without_router(self): + # store original method + original_get_objects_list_for_id = self.fetcher.get_objects_list_for_id + # mock the result + self.fetcher.get_objects_list_for_id = MagicMock(return_value=[]) + + name = self.fetcher.get_network_name(ID_CLEAN) + + self.fetcher.get_objects_list_for_id = original_get_objects_list_for_id + self.assertEqual(name, ID_CLEAN, "Can't use the id as the name when network info from database is empty") + + def test_get_router_name(self): + # store original method + original_get_objects_list_for_id = self.fetcher.get_objects_list_for_id + # mock the result + self.fetcher.get_objects_list_for_id = MagicMock(return_value=ROUTER) + + name = self.fetcher.get_router_name(LOCAL_SERVICES_IDS[0], ID_CLEAN) + + self.fetcher.get_objects_list_for_id = original_get_objects_list_for_id + + self.assertIn("name", LOCAL_SERVICES_IDS[0], "Can't get network name") + self.assertEqual(name, ROUTER[0]['name'], "Can't get router name") + + def test_set_agent_type(self): + # store original get_type method + original_get_type = self.fetcher.agents_list.get_type + self.fetcher.agents_list.get_type = MagicMock(return_value=AGENT) + + self.fetcher.set_agent_type(VSERVICE) + # reset method + self.fetcher.set_agent_type = original_get_type + self.assertIn("parent_id", VSERVICE, "Can't add parent id to vservice document") + + def test_set_agent_type_without_agent(self): + # store original get_type method + original_get_type = self.fetcher.agents_list.get_type + self.fetcher.agents_list.get_type = MagicMock(return_value={}) + + self.fetcher.set_agent_type(VSERVICE) + # reset method + self.fetcher.set_agent_type = original_get_type + self.assertIn("parent_id", VSERVICE, "Can't add parent id to vservice document") + self.assertEqual(VSERVICE['parent_type'], "vservice_miscellenaous_folder", + "Can't add document to miscellenaous folder when it doesn't have agent") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics.py b/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics.py new file mode 100644 index 0000000..5a57b9c --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics.py @@ -0,0 +1,111 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_instance_vnics import CliFetchInstanceVnics +from test.fetch.test_fetch import TestFetch +from test.fetch.cli_fetch.test_data.cli_fetch_instance_vnics import * +from unittest.mock import MagicMock + + +class TestCliFetchInstanceVnics(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchInstanceVnics() + self.fetcher.set_env(self.env) + + def test_get(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_get_vnics_from_dumpxml = self.fetcher.get_vnics_from_dumpxml + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(side_effect=[INSATNCE, COMPUTE_HOST]) + self.fetcher.run_fetch_lines = MagicMock(return_value=INSTANCES_LIST) + self.fetcher.get_vnics_from_dumpxml = MagicMock(return_value=VNICS_FROM_DUMP_XML) + + result = self.fetcher.get(VNICS_FOLDER['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.get_vnics_from_dumpxml = original_get_vnics_from_dumpxml + + self.assertNotEqual(result, [], "Can't get vnics with VNICS folder id") + + def test_get_without_instance(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=[]) + + result = self.fetcher.get(VNICS_FOLDER['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + + self.assertEqual(result, [], "Can't get empty array when the instance can't be found") + + def test_get_without_host(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(side_effect=[[], NETWORK_HOST]) + + result = self.fetcher.get(VNICS_FOLDER['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + + self.assertEqual(result, [], "Can't get empty array when the host doesn't contain network host type") + + def test_get_vnics_from_dumpxml(self): + # store original functions + original_run = self.fetcher.run + original_set_vnic_properties = self.fetcher.set_vnic_properties + + # mock the functions + self.fetcher.run = MagicMock(return_value=DUMPXML) + self.fetcher.set_vnic_properties = MagicMock() + + vnics = self.fetcher.get_vnics_from_dumpxml(ID, INSATNCE) + # reset functions + self.fetcher.run = original_run + self.fetcher.set_vnic_properties = original_set_vnic_properties + + self.assertNotEqual(vnics, [], "Can't get vnics") + + def test_get_vnics_from_dumpxml_with_empty_command_result(self): + # store original functions + original_run = self.fetcher.run + + # mock the functions + self.fetcher.run = MagicMock(return_value=" ") + + vnics = self.fetcher.get_vnics_from_dumpxml(ID, INSATNCE) + # reset functions + self.fetcher.run = original_run + + self.assertEqual(vnics, [], "Can't get empty array when the dumpxml is empty") + + def test_get_vnics_from_dumpxml_with_wrong_instance(self): + # store original functions + original_run = self.fetcher.run + + # mock the functions + self.fetcher.run = MagicMock(return_value=WRONG_DUMPXML) + + vnics = self.fetcher.get_vnics_from_dumpxml(ID, INSATNCE) + # reset functions + self.fetcher.run = original_run + + self.assertEqual(vnics, [], "Can't get empty array when the instance is wrong") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_ovs.py b/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_ovs.py new file mode 100644 index 0000000..24a1b5d --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_ovs.py @@ -0,0 +1,36 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.cli_fetch_instance_vnics_ovs import CliFetchInstanceVnicsOvs +from test.fetch.test_fetch import TestFetch +from test.fetch.cli_fetch.test_data.cli_fetch_instance_vnics import * +from unittest.mock import MagicMock + + +class TestCliFetchInstanceVnicsOvs(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchInstanceVnicsOvs() + self.fetcher.set_env(self.env) + + def test_set_vnic_properties(self): + # store original method + original_set = self.fetcher.inv.set + self.fetcher.inv.set = MagicMock() + + self.fetcher.set_vnic_properties(VNIC, INSATNCE) + # reset method + self.fetcher.inv.set = original_set + + self.assertIn("source_bridge", VNIC, "Can't set source_bridge for ovs vnic") + + def test_get_vnic_name(self): + name = self.fetcher.get_vnic_name(VNIC, INSATNCE) + self.assertNotEqual(name, None, "Can't get vnic name") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_vpp.py b/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_vpp.py new file mode 100644 index 0000000..46c25fb --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_instance_vnics_vpp.py @@ -0,0 +1,23 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.cli_fetch_instance_vnics_vpp import CliFetchInstanceVnicsVpp +from test.fetch.cli_fetch.test_data.cli_fetch_instance_vnics import * +from test.fetch.test_fetch import TestFetch + + +class TestCliFetchInstanceVnicsVpp(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchInstanceVnicsVpp() + + def test_get_name(self): + name = self.fetcher.get_vnic_name(VNIC, INSATNCE) + self.assertNotEqual(name, None, "Can't get vnic name") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors.py b/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors.py new file mode 100644 index 0000000..23e0a99 --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors.py @@ -0,0 +1,66 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_vconnectors import CliFetchVconnectors +from test.fetch.test_fetch import TestFetch +from test.fetch.cli_fetch.test_data.cli_fetch_vconnectors import * +from unittest.mock import MagicMock + + +class TestCliFetchVconnectors(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchVconnectors() + self.fetcher.set_env(self.env) + + def test_get(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + original_get_vconnectors = self.fetcher.get_vconnectors + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=HOST) + self.fetcher.get_vconnectors = MagicMock(return_value=VCONNECTORS) + + result = self.fetcher.get(VCONNECTORS_FOLDER['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + self.fetcher.get_vconnectors = original_get_vconnectors + + self.assertEqual(result, VCONNECTORS, "Can't get the vconnectors") + + def test_get_without_host(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=[]) + + result = self.fetcher.get(VCONNECTORS_FOLDER['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + + self.assertEqual(result, [], "Can't get empty array when the host doesn't exist") + + def test_get_with_wrong_host(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=WRONG_HOST) + + result = self.fetcher.get(VCONNECTORS_FOLDER['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + + self.assertEqual(result, [], "Can't get empty array when the host doesn't contain host type") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_ovs.py b/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_ovs.py new file mode 100644 index 0000000..cc882a1 --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_ovs.py @@ -0,0 +1,38 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_vconnectors_ovs import CliFetchVconnectorsOvs +from test.fetch.test_fetch import TestFetch +from test.fetch.cli_fetch.test_data.cli_fetch_vconnectors_ovs import * +from unittest.mock import MagicMock + + +class TestCliFetchVconnectorsOvs(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchVconnectorsOvs() + self.fetcher.set_env(self.env) + + def test_get_vconnectors(self): + # store the original methods + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_find_items = self.fetcher.inv.find_items + + # mock the methods + self.fetcher.run_fetch_lines = MagicMock(return_value=BRIDGE_RESULT) + self.fetcher.inv.find_items = MagicMock(return_value=[]) + + result = self.fetcher.get_vconnectors(NETWORK_NODE) + + # reset methods + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.inv.find_items = original_find_items + + self.assertNotEqual(result, [], "Can't get vconnectors with the host id") diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_vpp.py b/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_vpp.py new file mode 100644 index 0000000..f729c2c --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_vconnectors_vpp.py @@ -0,0 +1,50 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_vconnectors_vpp import CliFetchVconnectorsVpp +from test.fetch.test_fetch import TestFetch +from unittest.mock import MagicMock +from test.fetch.cli_fetch.test_data.cli_fetch_vconnectors_vpp import * + + +class TestCliFetchVconnectorsVpp(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchVconnectorsVpp() + self.fetcher.set_env(self.env) + + def test_get_vconnectors(self): + # store original method + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_get_interface_details = self.fetcher.get_interface_details + + # mock methods + self.fetcher.run_fetch_lines = MagicMock(return_value=MODE_RESULT) + self.fetcher.get_interface_details = MagicMock(return_value=None) + + result = self.fetcher.get_vconnectors(HOST) + + # reset methods + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.get_interface_details = original_get_interface_details + + self.assertNotEqual(result, {}, "Can't get vconnectors info") + + def test_set_interface_details(self): + # store original methods + original_run_fetch_lines = self.fetcher.run_fetch_lines + + # mock method + self.fetcher.run_fetch_lines = MagicMock(return_value=INTERFACE_LINES) + + result = self.fetcher.get_interface_details(HOST, INTERFACE_NAME) + # restore method + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.assertNotEqual(result, None, "Can't get the interface details") \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py b/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py new file mode 100644 index 0000000..b77f41e --- /dev/null +++ b/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py @@ -0,0 +1,124 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from discover.fetchers.cli.cli_fetch_vservice_vnics import CliFetchVserviceVnics +from test.fetch.test_fetch import TestFetch +from test.fetch.cli_fetch.test_data.cli_fetch_vservice_vnics import * +from unittest.mock import MagicMock + + +class TestCliFetchVserviceVnics(TestFetch): + + def setUp(self): + self.configure_environment() + self.fetcher = CliFetchVserviceVnics() + self.fetcher.set_env(self.env) + + def test_get(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_handle_service = self.fetcher.handle_service + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=NETWORK_NODE) + self.fetcher.run_fetch_lines = MagicMock(return_value=NAME_SPACES) + self.fetcher.handle_service = MagicMock(return_value=SERVICES) + + result = self.fetcher.get(NETWORK_NODE['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.handle_service = original_handle_service + + self.assertNotEqual(result, [], "Can't get vnics") + + def test_get_with_error_host(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=ERROR_NODE) + + result = self.fetcher.get(NETWORK_NODE['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + + self.assertEqual(result, [], "Can't get empty array when the host doesn't contain host_type") + + def test_get_with_compute_host(self): + # store original methods + original_get_by_id = self.fetcher.inv.get_by_id + + # mock methods + self.fetcher.inv.get_by_id = MagicMock(return_value=COMPUTE_NODE) + + result = self.fetcher.get(NETWORK_NODE['id']) + + # reset methods + self.fetcher.inv.get_by_id = original_get_by_id + + self.assertEqual(result, [], "Can't get empty array when the host type doesn't contain network") + + def test_handle_service(self): + # store original method + original_run_fetch_lines = self.fetcher.run_fetch_lines + original_set_interface_data = self.fetcher.set_interface_data + # mock the method + self.fetcher.run_fetch_lines = MagicMock(return_value=IFCONFIG_RESULT) + self.fetcher.set_interface_data = MagicMock() + result = self.fetcher.handle_service(NETWORK_NODE['id'], SERVICE_ID) + # reset method + self.fetcher.run_fetch_lines = original_run_fetch_lines + self.fetcher.set_interface_data = original_set_interface_data + + self.assertNotEqual(result, [], "Can't get interfaces data") + + def test_set_interface_data(self): + # store original methods + original_get_by_field = self.fetcher.inv.get_by_field + original_get_by_id = self.fetcher.inv.get_by_id + original_set = self.fetcher.inv.set + + # mock the methods + self.fetcher.inv.get_by_field = MagicMock(return_value=NETWORK) + self.fetcher.inv.get_by_id = MagicMock(return_value=VSERVICE) + self.fetcher.inv.set = MagicMock() + + self.fetcher.set_interface_data(VNIC) + + # reset methods + self.fetcher.inv.get_by_field = original_get_by_field + self.fetcher.inv.get_by_id = original_get_by_id + self.fetcher.inv.set = original_set + + self.assertIn("data", VNIC, "Can't set data") + self.assertIn("cidr", VNIC, "Can't set cidr") + self.assertIn("network", VNIC, "Can't set network") + + def test_handle_mac_address_line(self): + self.fetcher.handle_line(RAW_VNIC, MAC_ADDRESS_LINE) + self.assertEqual(RAW_VNIC['mac_address'], MAC_ADDRESS, "Can't get the correct mac address from the line") + + def test_handle_ipv4_address_line(self): + self.fetcher.handle_line(RAW_VNIC, IPV4_ADDRESS_LINE) + self.assertEqual(RAW_VNIC['IP Address'], IPV4_ADDRESS, "Can't get the correct ipv4 address from the line") + + def test_handle_ipv6_address_line(self): + self.fetcher.handle_line(RAW_VNIC, IPV6_ADDRESS_LINE) + self.assertEqual(RAW_VNIC['IPv6 Address'], IPV6_ADDRESS, "Can't get the correct ipv6 address from the line") + + def test_get_net_size(self): + size = self.fetcher.get_net_size(NET_MASK_ARRAY) + self.assertEqual(size, SIZE, "Can't get the size of network by netmask") + + def test_get_cidr_for_vnic(self): + cidr = self.fetcher.get_cidr_for_vnic(VNIC) + self.assertEqual(cidr, CIDR, "the cidr info is wrong") diff --git a/app/test/fetch/cli_fetch/test_data/__init__.py b/app/test/fetch/cli_fetch/test_data/__init__.py new file mode 100644 index 0000000..b0637e9 --- /dev/null +++ b/app/test/fetch/cli_fetch/test_data/__init__.py @@ -0,0 +1,9 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### diff --git a/app/test/fetch/cli_fetch/test_data/cli_access.py b/app/test/fetch/cli_fetch/test_data/cli_access.py new file mode 100644 index 0000000..b151dc6 --- /dev/null +++ b/app/test/fetch/cli_fetch/test_data/cli_access.py @@ -0,0 +1,58 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +COMPUTE_HOST_ID = "node-5.cisco.com" +COMMAND = "virsh list" +NON_GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "ssh -o StrictHostKeyChecking=no " + \ + COMPUTE_HOST_ID + " sudo " + COMMAND +GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "sudo " + COMMAND +CACHED_COMMAND_RESULT = " Id Name State\n---\n 2 instance-00000003 running" +RUN_RESULT = " Id Name State\n---\n 2 instance-00000002 running" +FETCH_LINES_RESULT = [ + " Id Name State", + "---", + " 2 instance-00000002 running" +] + +LINES_FOR_FIX = [ + "br-ex\t\t8000.005056acc9a2\tno\t\teno33554952", + "\t\t\t\t\t\t\tp_ff798dba-0", + "\t\t\t\t\t\t\tv_public", + "\t\t\t\t\t\t\tv_vrouter_pub", + "br-fw-admin\t\t8000.005056ace897\tno\t\teno16777728" +] + +FIXED_LINES = [ + "br-ex\t\t8000.005056acc9a2\tno\t\teno33554952,p_ff798dba-0,v_public,v_vrouter_pub", + "br-fw-admin\t\t8000.005056ace897\tno\t\teno16777728" +] + +PARSED_CMD_RESULT = [ + { + "bridge_id": "8000.005056acc9a2", + "bridge_name": "br-ex", + "interfaces": "eno33554952,p_ff798dba-0,v_public,v_vrouter_pub", + "stp_enabled": "no" + }, + { + "bridge_id": "8000.005056ace897", + "bridge_name": "br-fw-admin", + "interfaces": "eno16777728", + "stp_enabled": "no" + } +] + +LINE_FOR_PARSE = "br-ex\t\t8000.005056acc9a2\tno\t\teno33554952,p_ff798dba-0,v_public,v_vrouter_pub" +PARSED_LINE = { + "bridge_id": "8000.005056acc9a2", + "bridge_name": "br-ex", + "interfaces": "eno33554952,p_ff798dba-0,v_public,v_vrouter_pub", + "stp_enabled": "no" +} +HEADERS = ["bridge_name", "bridge_id", "stp_enabled", "interfaces"] diff --git a/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py new file mode 100644 index 0000000..316c68a --- /dev/null +++ b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py @@ -0,0 +1,147 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +PNICS_FOLDER_ID = "node-6.cisco.com-pnics" +HOST_ID = "node-6.cisco.com" + +NETWORK_NODE = { + "host_type": [ + "Controller", + "Network" + ], + "id": "node-6.cisco.com" +} + +WRONG_NODE = { + "host_type": [ + "Controller" + ] +} + +INTERFACE_LINES = [ + "lrwxrwxrwx 1 root 0 Jul 5 17:17 eno16777728 -> ../../devices/0000:02:00.0/net/eno16777728", + "lrwxrwxrwx 1 root 0 Jul 5 17:17 eno33554952 -> ../../devices/0000:02:01.0/net/eno33554952" +] + +INTERFACE_NAMES = ["eno16777728", "eno33554952"] + +INTERFACE_NAME = INTERFACE_NAMES[0] +IFCONFIG_CM_RESULT = [ + "eno16777728 Link encap:Ethernet HWaddr 00:50:56:ac:e8:97 ", + " UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1", + " RX packets:409056348 errors:0 dropped:0 overruns:0 frame:0", + " TX packets:293898173 errors:0 dropped:0 overruns:0 carrier:0", + " collisions:0 txqueuelen:1000 ", + " RX bytes:103719003730 (103.7 GB) TX bytes:165090993470 (165.0 GB)", + "" +] + +INTERFACE_DETAILS = { + "host": "node-6.cisco.com", + "id": "eno16777728-unknown_mac", + "lines": [], + "local_name": "eno16777728", + "name": "eno16777728", + "state": "UP" +} + +MAC_ADDRESS_LINE = "eno16777728 Link encap:Ethernet HWaddr 00:50:56:ac:e8:97 " +MAC_ADDRESS = "00:50:56:ac:e8:97" +RAW_INTERFACE = { + "host": "node-6.cisco.com", + "lines": [], + "local_name": "eno16777728", + "name": "eno16777728" +} + +INTERFACE_AFTER_LINE_HANDLE = { + "host": "node-6.cisco.com", + "lines": [MAC_ADDRESS_LINE.strip()], + "local_name": "eno16777728", + "name": "eno16777728", + "id": "eno16777728-" + MAC_ADDRESS, + "mac_address": MAC_ADDRESS +} + +INTERFACE_FOR_SET = { + "host": "node-6.cisco.com", + "lines": [ + "Link encap:Ethernet HWaddr 00:50:56:ac:e8:97", + "UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1" + ], + "local_name": "eno16777728", + "mac_address": "00:50:56:ac:e8:97" +} + +INTERFACE_AFTER_SET = { + "host": "node-6.cisco.com", + "data": "Link encap:Ethernet HWaddr 00:50:56:ac:e8:97" + + "\nUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1", + "local_name": "eno16777728", + "mac_address": "00:50:56:ac:e8:97", + "Supported ports": "[ TP ]", + "Supported link modes": ["10baseT/Half 10baseT/Full", + "100baseT/Half 100baseT/Full", + "1000baseT/Full"], + "Supported pause frame use": "No" +} + +INTERFACE = { + "Advertised auto-negotiation": "Yes", + "Advertised link modes": [ + "10baseT/Half 10baseT/Full", + "100baseT/Half 100baseT/Full", + "1000baseT/Full" + ], + "Advertised pause frame use": "No", + "Auto-negotiation": "on", + "Current message level": [ + "0x00000007 (7)", + "drv probe link" + ], + "Duplex": "Full", + "Link detected": "yes", + "MDI-X": "off (auto)", + "PHYAD": "0", + "Port": "Twisted Pair", + "Speed": "1000Mb/s", + "Supported link modes": [ + "10baseT/Half 10baseT/Full", + "100baseT/Half 100baseT/Full", + "1000baseT/Full" + ], + "Supported pause frame use": "No", + "Supported ports": "[ TP ]", + "Supports Wake-on": "d", + "Supports auto-negotiation": "Yes", + "Transceiver": "internal", + "Wake-on": "d", + "data": "Link encap:Ethernet HWaddr 00:50:56:ac:e8:97\nUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\nRX packets:408989052 errors:0 dropped:0 overruns:0 frame:0\nTX packets:293849880 errors:0 dropped:0 overruns:0 carrier:0\ncollisions:0 txqueuelen:1000\nRX bytes:103702814216 (103.7 GB) TX bytes:165063440009 (165.0 GB)\n", + "host": "node-6.cisco.com", + "id": "eno16777728-00:50:56:ac:e8:97", + "local_name": "eno16777728", + "mac_address": "00:50:56:ac:e8:97", + "name": "eno16777728" +} + +INTERFACES_GET_RESULTS = [INTERFACE] + +IPV6_ADDRESS_LINE = " inet6 addr: fe80::f816:3eff:fea1:eb73/64 Scope:Link" +IPV6_ADDRESS = "fe80::f816:3eff:fea1:eb73/64" +IPV4_ADDRESS_LINE = " inet addr:172.16.13.2 Bcast:172.16.13.255 Mask:255.255.255.0" +IPV4_ADDRESS = "172.16.13.2" + +ETHTOOL_RESULT = [ + "Settings for eno16777728:", + "\tSupported ports: [ TP ]", + "\tSupported link modes: 10baseT/Half 10baseT/Full ", + "\t 100baseT/Half 100baseT/Full ", + "\t 1000baseT/Full ", + "\tSupported pause frame use: No", +] diff --git a/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics_vpp.py b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics_vpp.py new file mode 100644 index 0000000..99bd4cd --- /dev/null +++ b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics_vpp.py @@ -0,0 +1,204 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +ID = "node-4.cisco.com-VPP-folders" +VEDGES = [ + { + "agent_type": "Open vSwitch agent", + "binary": "neutron-openvswitch-agent", + "configurations" : { + "tunneling_ip": "192.168.2.3", + "arp_responder_enabled" : True, + "extensions" : [ + + ], + "l2_population" : True, + "enable_distributed_routing" : False, + "bridge_mappings" : { + "physnet1": "br-floating" + }, + "log_agent_heartbeats" : False, + "tunnel_types" : [ + "vxlan" + ], + "in_distributed_mode" : False + }, + "description" : None, + "environment": "Mirantis-Liberty-Xiaocong", + "host": "node-6.cisco.com", + "id": "1764430c-c09e-4717-86fa-c04350b1fcbb", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/internal/node-6.cisco.com/node-6.cisco.com-vedges/1764430c-c09e-4717-86fa-c04350b1fcbb", + "name": "node-6.cisco.com-OVS", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/internal/node-6.cisco.com/vEdges/node-6.cisco.com-OVS", + "object_name": "node-6.cisco.com-OVS", + "parent_id": "node-6.cisco.com-vedges", + "parent_type": "vedges_folder", + "ports" : { + "TenGigabitEthernet-g-63489f34-af" : { + "id": "8", + "name": "qg-63489f34-af", + "internal" : True, + "tag": "2", + "host": "node-4.cisco.com", + "state": "up" + }, + "qr-3ff411a2-54" : { + "id": "7", + "name": "qr-3ff411a2-54", + "internal" : True, + "tag": "5" + }, + "tap31c19fbe-5d" : { + "id": "19", + "name": "tap31c19fbe-5d", + "internal" : True, + "tag": "117" + }, + "br-int" : { + "id": "3", + "name": "br-int", + "internal" : True + }, + "qr-18f029db-77" : { + "id": "17", + "name": "qr-18f029db-77", + "internal" : True, + "tag": "105" + }, + "br-tun" : { + "id": "13", + "name": "br-tun", + "internal" : True + }, + "tap82d4992f-4d" : { + "id": "9", + "name": "tap82d4992f-4d", + "internal" : True, + "tag": "5" + }, + "tap16620a58-c4" : { + "id": "16", + "name": "tap16620a58-c4", + "internal" : True, + "tag": "6" + }, + "p_ff798dba-0" : { + "id": "15", + "name": "p_ff798dba-0", + "internal" : True + }, + "tapee8e5dbb-03" : { + "id": "6", + "name": "tapee8e5dbb-03", + "internal" : True, + "tag": "1" + }, + "tap702e9683-0c" : { + "id": "20", + "name": "tap702e9683-0c", + "internal" : True, + "tag": "118" + }, + "tapaf69959f-ef" : { + "id": "18", + "name": "tapaf69959f-ef", + "internal" : True, + "tag": "105" + }, + "tap5f22f397-d8" : { + "id": "11", + "name": "tap5f22f397-d8", + "internal" : True, + "tag": "3" + }, + "qr-bb9b8340-72" : { + "id": "1", + "name": "qr-bb9b8340-72", + "internal" : True, + "tag": "3" + }, + "qr-8733cc5d-b3" : { + "id": "2", + "name": "qr-8733cc5d-b3", + "internal" : True, + "tag": "4" + }, + "ovs-system" : { + "id": "0", + "name": "ovs-system", + "internal" : True + }, + "br-floating" : { + "id": "14", + "name": "br-floating", + "internal" : True + }, + "qg-57e65d34-3d" : { + "id": "10", + "name": "qg-57e65d34-3d", + "internal" : True, + "tag": "2" + }, + "qr-f7b44150-99" : { + "id": "4", + "name": "qr-f7b44150-99", + "internal" : True, + "tag": "1" + }, + "tapbf16c3ab-56" : { + "id": "5", + "name": "tapbf16c3ab-56", + "internal" : True, + "tag": "4" + } + }, + "show_in_tree" : True, + "topic": "N/A", + "tunnel_ports" : { + "br-tun" : { + "name": "br-tun", + "interface": "br-tun", + "type": "internal" + }, + "vxlan-c0a80201" : { + "name": "vxlan-c0a80201", + "options" : { + "local_ip": "192.168.2.3", + "out_key": "flow", + "in_key": "flow", + "df_default": "True", + "remote_ip": "192.168.2.1" + }, + "interface": "vxlan-c0a80201", + "type": "vxlan" + }, + "vxlan-c0a80202" : { + "name": "vxlan-c0a80202", + "options" : { + "local_ip": "192.168.2.3", + "out_key": "flow", + "in_key": "flow", + "df_default": "True", + "remote_ip": "192.168.2.2" + }, + "interface": "vxlan-c0a80202", + "type": "vxlan" + }, + "patch-int" : { + "name": "patch-int", + "options" : { + "peer": "patch-tun" + }, + "interface": "patch-int", + "type": "patch" + } + }, + "type": "vedge" +} + ] \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_data/cli_fetch_host_verservices.py b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_verservices.py new file mode 100644 index 0000000..94ee38c --- /dev/null +++ b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_verservices.py @@ -0,0 +1,276 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +NETWORK_HOST = { + "config": { + "interfaces": 4, + "log_agent_heartbeats": False, + "gateway_external_network_id": "", + "router_id": "", + "interface_driver": "neutron.agent.linux.interface.OVSInterfaceDriver", + "ex_gw_ports": 2, + "routers": 2, + "handle_internal_only_routers": True, + "floating_ips": 1, + "external_network_bridge": "", + "use_namespaces": True, + "agent_mode": "legacy" + }, + "environment": "Mirantis-Liberty-Xiaocong", + "host": "node-6.cisco.com", + "host_type": [ + "Controller", + "Network" + ], + "id": "node-6.cisco.com", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/internal/node-6.cisco.com", + "name": "node-6.cisco.com", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/internal/node-6.cisco.com", + "object_name": "node-6.cisco.com", + "parent_id": "internal", + "parent_type": "availability_zone", + "services": { + "nova-scheduler": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:10.000000" + }, + "nova-consoleauth": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:54.000000" + }, + "nova-conductor": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:45.000000" + }, + "nova-cert": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:56.000000" + } + }, + "show_in_tree": True, + "type" : "host", + "zone" : "internal" +} + +COMPUTE_HOST = { + "environment": "Mirantis-Liberty-Xiaocong", + "host": "node-5.cisco.com", + "host_type": [ + "Compute" + ], + "id": "node-5.cisco.com", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/osdna-zone/node-5.cisco.com", + "ip_address": "192.168.0.4", + "name": "node-5.cisco.com", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/osdna-zone/node-5.cisco.com", + "object_name": "node-5.cisco.com", + "os_id": "1", + "parent_id": "osdna-zone", + "parent_type": "availability_zone", + "services": { + "nova-compute": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:42.000000" + } + }, + "show_in_tree": True, + "type": "host", + "zone": "osdna-zone" +} + +NAMESPACES = [ + 'qdhcp-413de095-01ed-49dc-aa50-4479f43d390e', + 'qdhcp-2e3b85f4-756c-49d9-b34c-f3db13212dbc', + 'qdhcp-b6fd5175-4b22-4256-9b1a-9fc4b9dce1fe', + 'qdhcp-eb276a62-15a9-4616-a192-11466fdd147f', + 'qdhcp-7e59b726-d6f4-451a-a574-c67a920ff627', + 'qdhcp-a55ff1e8-3821-4e5f-bcfd-07df93720a4f', + 'qdhcp-6504fcf7-41d7-40bb-aeb1-6a7658c105fc', + 'qrouter-9ec3d703-0725-47e3-8f48-02b16236caf9', + 'qrouter-49ac7716-06da-49ed-b388-f8ba60e8a0e6', + 'haproxy', + 'vrouter' +] + +LOCAL_SERVICES_IDS = [ + { + "local_service_id": "qdhcp-413de095-01ed-49dc-aa50-4479f43d390e" + }, + { + "local_service_id": "qdhcp-2e3b85f4-756c-49d9-b34c-f3db13212dbc" + }, + { + "local_service_id": "qdhcp-b6fd5175-4b22-4256-9b1a-9fc4b9dce1fe" + }, + { + "local_service_id": "qdhcp-eb276a62-15a9-4616-a192-11466fdd147f" + }, + { + "local_service_id": "qdhcp-7e59b726-d6f4-451a-a574-c67a920ff627" + }, + { + "local_service_id": "qdhcp-a55ff1e8-3821-4e5f-bcfd-07df93720a4f" + }, + { + "local_service_id": "qdhcp-6504fcf7-41d7-40bb-aeb1-6a7658c105fc" + }, + { + "local_service_id": "qrouter-9ec3d703-0725-47e3-8f48-02b16236caf9" + }, + { + "local_service_id": "qrouter-49ac7716-06da-49ed-b388-f8ba60e8a0e6" + } +] + +VSERVICE = { + "host": "node-6.cisco.com", + "id": "qdhcp-b6fd5175-4b22-4256-9b1a-9fc4b9dce1fe", + "local_service_id": "qdhcp-b6fd5175-4b22-4256-9b1a-9fc4b9dce1fe", + "name": "dhcp-osdna-met4", + "service_type": "dhcp" + } + +AGENT = { + "description": "DHCP agent", + "folder_text": "DHCP servers", + "type": "dhcp" +} + +ROUTER = [ + {"name": "123456"} +] + +ID_CLEAN = "413de095-01ed-49dc-aa50-4479f43d390e" +# functional test +INPUT = "node-6.cisco.com" +OUTPUT = [ + { + "host": "node-6.cisco.com", + "id": "qdhcp-413de095-01ed-49dc-aa50-4479f43d390e", + "local_service_id": "qdhcp-413de095-01ed-49dc-aa50-4479f43d390e", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-aiya", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "host": "node-6.cisco.com", + "id": "qdhcp-2e3b85f4-756c-49d9-b34c-f3db13212dbc", + "local_service_id": "qdhcp-2e3b85f4-756c-49d9-b34c-f3db13212dbc", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-123456", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "host": "node-6.cisco.com", + "id": "qdhcp-b6fd5175-4b22-4256-9b1a-9fc4b9dce1fe", + "local_service_id": "qdhcp-b6fd5175-4b22-4256-9b1a-9fc4b9dce1fe", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-osdna-met4", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "host": "node-6.cisco.com", + "id": "qdhcp-eb276a62-15a9-4616-a192-11466fdd147f", + "local_service_id": "qdhcp-eb276a62-15a9-4616-a192-11466fdd147f", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-osdna-net3", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "host": "node-6.cisco.com", + "id": "qdhcp-7e59b726-d6f4-451a-a574-c67a920ff627", + "local_service_id": "qdhcp-7e59b726-d6f4-451a-a574-c67a920ff627", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-osdna-net1", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "host": "node-6.cisco.com", + "id": "qdhcp-a55ff1e8-3821-4e5f-bcfd-07df93720a4f", + "local_service_id": "qdhcp-a55ff1e8-3821-4e5f-bcfd-07df93720a4f", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-osdna-net2", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "host": "node-6.cisco.com", + "id": "qdhcp-6504fcf7-41d7-40bb-aeb1-6a7658c105fc", + "local_service_id": "qdhcp-6504fcf7-41d7-40bb-aeb1-6a7658c105fc", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "dhcp-admin_internal_net", + "parent_id": "node-6.cisco.com-vservices-dhcps", + "parent_text": "DHCP servers", + "parent_type": "vservice_dhcps_folder", + "service_type": "dhcp" + }, + { + "admin_state_up": 1, + "enable_snat": 1, + "gw_port_id": "63489f34-af99-44f4-81de-9a2eb1c1941f", + "host": "node-6.cisco.com", + "id": "qrouter-9ec3d703-0725-47e3-8f48-02b16236caf9", + "local_service_id": "qrouter-9ec3d703-0725-47e3-8f48-02b16236caf9", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "router-osdna-router", + "parent_id": "node-6.cisco.com-vservices-routers", + "parent_text": "Gateways", + "parent_type": "vservice_routers_folder", + "service_type": "router", + "status": "ACTIVE", + "tenant_id": "75c0eb79ff4a42b0ae4973c8375ddf40" + }, + { + "admin_state_up": 1, + "enable_snat": 1, + "gw_port_id": "57e65d34-3d87-4751-8e95-fc78847a3070", + "host": "node-6.cisco.com", + "id": "qrouter-49ac7716-06da-49ed-b388-f8ba60e8a0e6", + "local_service_id": "qrouter-49ac7716-06da-49ed-b388-f8ba60e8a0e6", + "master_parent_id": "node-6.cisco.com-vservices", + "master_parent_type": "vservices_folder", + "name": "router-router04", + "parent_id": "node-6.cisco.com-vservices-routers", + "parent_text": "Gateways", + "parent_type": "vservice_routers_folder", + "service_type": "router", + "status": "ACTIVE", + "tenant_id": "8c1751e0ce714736a63fee3c776164da" + } +] \ No newline at end of file diff --git a/app/test/fetch/cli_fetch/test_data/cli_fetch_instance_vnics.py b/app/test/fetch/cli_fetch/test_data/cli_fetch_instance_vnics.py new file mode 100644 index 0000000..a43b5c2 --- /dev/null +++ b/app/test/fetch/cli_fetch/test_data/cli_fetch_instance_vnics.py @@ -0,0 +1,288 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +VNICS_FOLDER = { + "create_object": True, + "environment": "Mirantis-Liberty-Xiaocong", + "id": "bf0cb914-b316-486c-a4ce-f22deb453c52-vnics", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/osdna-zone/node-5.cisco.com/node-5.cisco.com-instances/bf0cb914-b316-486c-a4ce-f22deb453c52/bf0cb914-b316-486c-a4ce-f22deb453c52-vnics", + "name": "vNICs", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/osdna-zone/node-5.cisco.com/Instances/test/vNICs", + "object_name": "vNICs", + "parent_id": "bf0cb914-b316-486c-a4ce-f22deb453c52", + "parent_type": "instance", + "show_in_tree": True, + "text": "vNICs", + "type": "vnics_folder" +} + +INSATNCE = { + "_id": "5806817e4a0a8a3fbe3bee8b", + "children_url": "/osdna_dev/discover.py?type=tree&id=bf0cb914-b316-486c-a4ce-f22deb453c52", + "environment": "Mirantis-Liberty-Xiaocong", + "host": "node-5.cisco.com", + "id": "bf0cb914-b316-486c-a4ce-f22deb453c52", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/osdna-zone/node-5.cisco.com/node-5.cisco.com-instances/bf0cb914-b316-486c-a4ce-f22deb453c52", + "ip_address": "192.168.0.4", + "local_name": "instance-00000026", + "mac_address": "fa:16:3e:e8:7f:04", + "name": "test", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/osdna-zone/node-5.cisco.com/Instances/test", + "network": [ + "2e3b85f4-756c-49d9-b34c-f3db13212dbc" + ], + "network_info": [ + { + "devname": "tap1f72bd15-8a", + "id": "1f72bd15-8ab2-43cb-94d7-e823dd845255", + "profile": { + + }, + "vnic_type": "normal", + "type": "ovs", + "address": "fa:16:3e:e8:7f:04", + "qbg_params": None, + "network": { + "bridge": "br-int", + "label": "123456", + "subnets": [ + { + "cidr": "172.16.13.0/24", + "version": 4, + "gateway": { + "version": 4, + "meta": { + + }, + "address": "172.16.13.1", + "type": "gateway" + }, + "routes": [ + + ], + "dns": [ + + ], + "ips": [ + { + "meta": { + + }, + "version": 4, + "type": "fixed", + "address": "172.16.13.4", + "floating_ips": [ + + ] + } + ], + "meta": { + "dhcp_server": "172.16.13.2" + } + } + ], + "meta": { + "tenant_id": "75c0eb79ff4a42b0ae4973c8375ddf40", + "injected": False + }, + "id": "2e3b85f4-756c-49d9-b34c-f3db13212dbc" + }, + "active": True, + "meta": { + + }, + "details": { + "port_filter": True, + "ovs_hybrid_plug": True + }, + "preserve_on_delete": False, + "qbh_params": None, + "ovs_interfaceid": "1f72bd15-8ab2-43cb-94d7-e823dd845255" + } + ], + "object_name": "test", + "parent_id": "node-5.cisco.com-instances", + "parent_type": "instances_folder", + "project_id": "75c0eb79ff4a42b0ae4973c8375ddf40", + "projects": [ + "OSDNA-project" + ], + "show_in_tree": True, + "type": "instance", + "uuid": "bf0cb914-b316-486c-a4ce-f22deb453c52" +} + + +COMPUTE_HOST = { + "environment": "Mirantis-Liberty-Xiaocong", + "host": "node-5.cisco.com", + "host_type": [ + "Compute" + ], + "id": "node-5.cisco.com", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/osdna-zone/node-5.cisco.com", + "ip_address": "192.168.0.4", + "name": "node-5.cisco.com", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/osdna-zone/node-5.cisco.com", + "object_name": "node-5.cisco.com", + "os_id": "1", + "parent_id": "osdna-zone", + "parent_type": "availability_zone", + "services": { + "nova-compute": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:42.000000" + } + }, + "show_in_tree": True, + "type": "host", + "zone": "osdna-zone" +} + +NETWORK_HOST = { + "config": { + "interfaces": 4, + "log_agent_heartbeats": False, + "gateway_external_network_id": "", + "router_id": "", + "interface_driver": "neutron.agent.linux.interface.OVSInterfaceDriver", + "ex_gw_ports": 2, + "routers": 2, + "handle_internal_only_routers": True, + "floating_ips": 1, + "external_network_bridge": "", + "use_namespaces": True, + "agent_mode": "legacy" + }, + "environment": "Mirantis-Liberty-Xiaocong", + "host": "node-6.cisco.com", + "host_type": [ + "Controller", + "Network" + ], + "id": "node-6.cisco.com", + "id_path": "/Mirantis-Liberty-Xiaocong/Mirantis-Liberty-Xiaocong-regions/RegionOne/RegionOne-availability_zones/internal/node-6.cisco.com", + "name": "node-6.cisco.com", + "name_path": "/Mirantis-Liberty-Xiaocong/Regions/RegionOne/Availability Zones/internal/node-6.cisco.com", + "object_name": "node-6.cisco.com", + "parent_id": "internal", + "parent_type": "availability_zone", + "services": { + "nova-scheduler": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:10.000000" + }, + "nova-consoleauth": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:54.000000" + }, + "nova-conductor": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:45.000000" + }, + "nova-cert": { + "active": True, + "available": True, + "updated_at": "2016-10-21T18:01:56.000000" + } + }, + "show_in_tree": True, + "type": "host", + "zone": "internal" +} + +DUMPXML = "\n instance-00000026\n bf0cb914-b316-486c-a4ce-f22deb453c52\n \n \n \n test\n 2016-10-17 22:37:43\n \n 64\n 0\n 0\n 0\n 1\n \n \n admin\n OSDNA-project\n \n \n \n \n 65536\n 65536\n 1\n \n 1024\n \n \n \n OpenStack Foundation\n OpenStack Nova\n 12.0.0\n 9cf57bfd-7477-4671-b2d3-3dfeebfefb1d\n bf0cb914-b316-486c-a4ce-f22deb453c52\n Virtual Machine\n \n \n \n hvm\n \n \n \n \n \n \n \n \n \n \n \n destroy\n restart\n destroy\n \n /usr/bin/qemu-system-x86_64\n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n