diff --git a/automated-pytest-suite/keywords/dc_helper.py b/automated-pytest-suite/keywords/dc_helper.py index 7e0fcf5..48d2ff9 100644 --- a/automated-pytest-suite/keywords/dc_helper.py +++ b/automated-pytest-suite/keywords/dc_helper.py @@ -396,60 +396,6 @@ def wait_for_subcloud_dns_config(subcloud=None, subcloud_ssh=None, expected_dns= check_interval=check_interval, **func_kwargs) -def wait_for_subcloud_snmp_comms(subcloud=None, subcloud_ssh=None, expected_comms=None, - fail_ok=False, timeout=DCTimeout.SYNC, check_interval=30): - """ - Wait for dns configuration to reach expected value - Args: - subcloud (str|None): - subcloud_ssh (None|SSHClient): - expected_comms (None|str|list): - fail_ok (bool): - timeout (int): - check_interval (int): - - Returns (tuple): - (0, ) # same as expected - (1, ) # did not update within timeout - (2, ) # updated to unexpected value - - """ - func = system_helper.get_snmp_comms - func_kwargs = {'con_ssh': subcloud_ssh} if subcloud_ssh else {} - return wait_for_subcloud_config(subcloud=subcloud, func=func, - config_name='SNMP Community strings', - expected_value=expected_comms, fail_ok=fail_ok, - timeout=timeout, check_interval=check_interval, - strict_order=False, **func_kwargs) - - -def wait_for_subcloud_snmp_trapdests(subcloud=None, subcloud_ssh=None, expected_trapdests=None, - fail_ok=False, timeout=DCTimeout.SYNC, check_interval=30): - """ - Wait for dns configuration to reach expected value - Args: - subcloud (str|None): - subcloud_ssh (None|SSHClient): - expected_trapdests (None|str|list): - fail_ok (bool): - timeout (int): - check_interval (int): - - Returns (tuple): - (0, ) # same as expected - (1, ) # did not update within timeout - (2, ) # updated to unexpected value - - """ - func = system_helper.get_snmp_trapdests - func_kwargs = {'con_ssh': subcloud_ssh} if subcloud_ssh else {} - return wait_for_subcloud_config(subcloud=subcloud, func=func, - config_name='SNMP Community strings', - expected_value=expected_trapdests, fail_ok=fail_ok, - timeout=timeout, check_interval=check_interval, - strict_order=False, **func_kwargs) - - def wait_for_subcloud_ntp_config(subcloud=None, subcloud_ssh=None, expected_ntp=None, clear_alarm=True, fail_ok=False, timeout=DCTimeout.SYNC, check_interval=30): diff --git a/automated-pytest-suite/keywords/system_helper.py b/automated-pytest-suite/keywords/system_helper.py index 7f20158..c6fc639 100644 --- a/automated-pytest-suite/keywords/system_helper.py +++ b/automated-pytest-suite/keywords/system_helper.py @@ -2169,181 +2169,6 @@ def get_servicegroups(fields='uuid', uuid=None, service_group_name=None, regex=regex, **kwargs) -def create_snmp_comm(comm_string, field='uuid', fail_ok=False, con_ssh=None, - auth_info=Tenant.get('admin_platform')): - """ - Create a new SNMP community string - Args: - comm_string (str): Community string to create - field (str): property to return - fail_ok (bool) - con_ssh (SSHClient): - auth_info (dict): - - Returns (tuple): - - """ - args = '-c "{}"'.format(comm_string) - code, out = cli.system('snmp-comm-add', args, ssh_client=con_ssh, - fail_ok=fail_ok, auth_info=auth_info) - - if code > 0: - return 1, out - - val = table_parser.get_value_two_col_table(table_parser.table(out), - field=field) - - return 0, val - - -def create_snmp_trapdest(comm_string, ip_addr, field='uuid', fail_ok=False, - con_ssh=None, - auth_info=Tenant.get('admin_platform')): - """ - Create a new SNMP trap destination - Args: - comm_string (str): SNMP community string - ip_addr (str): IP address of the trap destination - field (str): property to return - fail_ok (bool) - con_ssh (SSHClient): - auth_info (dict): - - Returns (tuple): - - """ - args = '-c "{}" -i "{}"'.format(comm_string, ip_addr) - code, out = cli.system('snmp-trapdest-add', args, ssh_client=con_ssh, - fail_ok=fail_ok, auth_info=auth_info) - - if code > 0: - return 1, out - - val = table_parser.get_value_two_col_table(table_parser.table(out), - field=field) - - return 0, val - - -def get_snmp_comms(field='SNMP community', con_ssh=None, - auth_info=Tenant.get('admin_platform')): - """ - Get SNMP community strings - Args: - field (str|list|tuple) - con_ssh (SSHClient): - auth_info (dict): - - Returns (list): - - """ - table_ = table_parser.table( - cli.system('snmp-comm-list', ssh_client=con_ssh, auth_info=auth_info)[ - 1]) - - return table_parser.get_multi_values(table_, field) - - -def get_snmp_trapdests(field='IP Address', con_ssh=None, - auth_info=Tenant.get('admin_platform'), - exclude_system=True, - **kwargs): - """ - Get SNMP trap destination ips - Args: - field (str|tuple|list): - con_ssh (SSHClient): - auth_info (dict): - exclude_system - kwargs - - Returns (list): - - """ - table_ = table_parser.table( - cli.system('snmp-trapdest-list', ssh_client=con_ssh, - auth_info=auth_info)[1]) - if exclude_system: - table_ = table_parser.filter_table(table_, exclude=True, **{ - 'SNMP Community': 'dcorchAlarmAggregator'}) - - return table_parser.get_multi_values(table_, field, **kwargs) - - -def delete_snmp_comm(comms, check_first=True, fail_ok=False, con_ssh=None, - auth_info=Tenant.get('admin_platform')): - """ - Delete snmp community string - Args: - comms (str): Community string or uuid to delete - check_first (bool) - fail_ok (bool) - con_ssh (SSHClient): - auth_info (dict): - - Returns (tuple): - - """ - if isinstance(comms, str): - comms = comms.split(sep=' ') - else: - comms = list(comms) - - if check_first: - current_comms = get_snmp_comms(con_ssh=con_ssh, auth_info=auth_info) - comms = [comm for comm in comms if comm in current_comms] - if not comms: - msg = '"{}" SNMP community string does not exist. Do ' \ - 'nothing.'.format(comms) - LOG.info(msg) - return -1, msg - - LOG.info('Deleting SNMP community strings: {}'.format(comms)) - comms = ' '.join(['"{}"'.format(comm) for comm in comms]) - code, out = cli.system('snmp-comm-delete', comms, ssh_client=con_ssh, - fail_ok=fail_ok, auth_info=auth_info) - - post_comms = get_snmp_comms(con_ssh=con_ssh, auth_info=auth_info) - undeleted_comms = [comm for comm in comms if comm in post_comms] - if undeleted_comms: - raise exceptions.SysinvError( - "Community string still exist after deletion: {}".format( - undeleted_comms)) - - if code == 0: - msg = 'SNMP community string "{}" is deleted successfully'.format(comms) - else: - msg = 'SNMP community string "{}" failed to delete'.format(comms) - - LOG.info(msg) - return code, out - - -def delete_snmp_trapdest(ip_addrs, fail_ok=False, con_ssh=None, - auth_info=Tenant.get('admin_platform')): - """ - Delete SNMP trap destination - Args: - ip_addrs (str|list): SNMP trap destination IP address(es) - fail_ok (bool) - con_ssh (SSHClient): - auth_info (dict): - - Returns (dict): - - """ - if isinstance(ip_addrs, str): - ip_addrs = ip_addrs.split(sep=' ') - - arg = '' - for ip_addr in ip_addrs: - arg += '"{}" '.format(ip_addr) - code, out = cli.system('snmp-trapdest-delete', arg, ssh_client=con_ssh, - fail_ok=fail_ok, auth_info=auth_info) - - return code, out - - def get_oam_values(fields=None, con_ssh=None, auth_info=Tenant.get('admin_platform'), rtn_dict=True): """ diff --git a/automated-pytest-suite/testcases/functional/dc/test_shared_config_snmp.py b/automated-pytest-suite/testcases/functional/dc/test_shared_config_snmp.py deleted file mode 100644 index f8147b7..0000000 --- a/automated-pytest-suite/testcases/functional/dc/test_shared_config_snmp.py +++ /dev/null @@ -1,153 +0,0 @@ -# -# Copyright (c) 2020 Wind River Systems, Inc. -# -# SPDX-License-Identifier: Apache-2.0 -# - -from pytest import fixture - -from utils.tis_log import LOG -from utils.clients.ssh import ControllerClient -from consts.proj_vars import ProjVar -from consts.auth import Tenant, TestFileServer -from keywords import dc_helper, system_helper - -SNMP_COMM = 'cgcsauto_dc_snmp_comm' -SNMP_COMM_LOCAL = 'cgcsauto_comm_local' -SNMP_TRAPDEST = ('cgcsauto_dc_snmp_trapdest', TestFileServer.SERVER) -SNMP_TRAPDEST_LOCAL = ('cgcsauto_trapdest_local', '8.8.8.8') - - -@fixture(scope='module') -def snmp_precheck(request): - LOG.info("Gather SNMP config and subcloud management info") - central_auth = Tenant.get('admin_platform', dc_region='RegionOne') - central_comms = system_helper.get_snmp_comms(auth_info=central_auth) - central_trapdests = system_helper.get_snmp_trapdests(auth_info=central_auth) - - primary_subcloud = ProjVar.get_var('PRIMARY_SUBCLOUD') - managed_subclouds = dc_helper.get_subclouds(mgmt='managed', avail='online') - if primary_subcloud in managed_subclouds: - managed_subclouds.remove(primary_subcloud) - else: - dc_helper.manage_subcloud(primary_subcloud) - - ssh_map = ControllerClient.get_active_controllers_map() - managed_subclouds = [subcloud for subcloud in managed_subclouds if subcloud in ssh_map] - - LOG.fixture_step("Ensure SNMP community strings are synced on {}".format(primary_subcloud)) - subcloud_auth = Tenant.get('admin_platform', dc_region=primary_subcloud) - subcloud_comms = system_helper.get_snmp_comms(auth_info=subcloud_auth) - - if sorted(subcloud_comms) != sorted(central_comms): - dc_helper.wait_for_subcloud_snmp_comms(primary_subcloud, expected_comms=central_comms) - - LOG.fixture_step("Ensure SNMP trapdests are synced on {}".format(primary_subcloud)) - subcloud_trapdests = system_helper.get_snmp_trapdests(auth_info=subcloud_auth) - if sorted(subcloud_trapdests) != sorted(central_trapdests): - dc_helper.wait_for_subcloud_snmp_trapdests(primary_subcloud, - expected_trapdests=central_trapdests) - - def revert(): - LOG.fixture_step("Manage {} if unmanaged".format(primary_subcloud)) - dc_helper.manage_subcloud(primary_subcloud) - - LOG.fixture_step("Delete new SNMP community string and trapdest on central region") - system_helper.delete_snmp_comm(comms=SNMP_COMM, auth_info=central_auth) - - LOG.fixture_step("Delete new SNMP community string and trapdest on subcloud") - system_helper.delete_snmp_comm(comms=SNMP_COMM_LOCAL, auth_info=subcloud_auth) - system_helper.delete_snmp_trapdest(ip_addrs=SNMP_TRAPDEST_LOCAL[1], - auth_info=subcloud_auth) - - LOG.fixture_step( - "Wait for sync audit on {} and SNMP community strings and trapdests to sync over" - .format(primary_subcloud)) - dc_helper.wait_for_sync_audit(subclouds=primary_subcloud, fail_ok=True) - dc_helper.wait_for_subcloud_snmp_comms(primary_subcloud, expected_comms=central_comms, - timeout=60, check_interval=10) - dc_helper.wait_for_subcloud_snmp_trapdests(primary_subcloud, - expected_trapdests=central_trapdests, - timeout=60, check_interval=10) - - request.addfinalizer(revert) - - return primary_subcloud, managed_subclouds, central_comms, central_trapdests - - -def test_dc_snmp(snmp_precheck): - """ - - Update DNS servers on central region and check it is propagated to subclouds - Args: - snmp_precheck: test fixture for setup/teardown - - Setups: - - Ensure primary subcloud is managed and SNMP config is synced - - Test Steps: - - Un-manage primary subcloud - - Add a SNMP community string and a trapdest on unmanaged subcloud locally - - Add a different SNMP community string and trapdest on central region - - Wait for new SNMP configs to sync over to managed online subclouds - - Ensure central SNMP configs are not updated on unmanaged primary subcloud - - Re-manage primary subcloud and ensure DNS config syncs over - - Verify nslookup works in Central Region and primary subcloud - - Teardown: - - Delete DNS servers to original value (module) - - """ - primary_subcloud, managed_subclouds, central_comms, central_trapdests = snmp_precheck - central_auth = Tenant.get('admin_platform', dc_region='RegionOne') - sub_auth = Tenant.get('admin_platform', dc_region=primary_subcloud) - - LOG.tc_step("Unmanage {}".format(primary_subcloud)) - dc_helper.unmanage_subcloud(subcloud=primary_subcloud, check_first=False) - - LOG.tc_step( - 'Add SNMP community string and trapdest to unmanaged subcloud - {}' - .format(primary_subcloud)) - system_helper.create_snmp_comm(comm_string=SNMP_COMM_LOCAL, auth_info=sub_auth) - system_helper.create_snmp_trapdest(comm_string=SNMP_TRAPDEST_LOCAL[0], - ip_addr=SNMP_TRAPDEST_LOCAL[1], - auth_info=sub_auth) - - LOG.tc_step('Add SNMP community string and trapdest to central region') - system_helper.create_snmp_comm(comm_string=SNMP_COMM, auth_info=central_auth) - - LOG.tc_step( - "Wait for new SNMP config to sync over to managed subclouds: {}".format(managed_subclouds)) - expt_comms = central_comms + [SNMP_COMM] - expt_trapdests = central_trapdests - dc_helper.wait_for_sync_audit(subclouds=managed_subclouds, fail_ok=True, timeout=660) - for managed_sub in managed_subclouds: - dc_helper.wait_for_subcloud_snmp_comms(subcloud=managed_sub, expected_comms=expt_comms, - timeout=30, check_interval=10) - dc_helper.wait_for_subcloud_snmp_trapdests(subcloud=managed_sub, - expected_trapdests=expt_trapdests, - timeout=30, check_interval=10) - - LOG.tc_step("Ensure central SNMP config is not synced to unmanaged subcloud: {}".format( - primary_subcloud)) - code_comm = dc_helper.wait_for_subcloud_snmp_comms(subcloud=primary_subcloud, - expected_comms=expt_comms, - timeout=15, check_interval=5, - fail_ok=True)[0] - code_trapdest = dc_helper.wait_for_subcloud_snmp_trapdests(subcloud=primary_subcloud, - expected_trapdests=expt_trapdests, - timeout=15, check_interval=5, - fail_ok=True)[0] - assert code_comm == 1, \ - "SNMP comm is updated unexpectedly on unmanaged subcloud {}".format(primary_subcloud) - assert code_trapdest == 1, \ - "SNMP trapdest is updated unexpectedly on unmanaged subcloud {}".format(primary_subcloud) - - LOG.tc_step('Re-manage {} and ensure DNS config syncs over'.format(primary_subcloud)) - dc_helper.manage_subcloud(subcloud=primary_subcloud, check_first=False) - all_comms = expt_comms + [SNMP_COMM_LOCAL] - all_trapdests = expt_trapdests + [SNMP_TRAPDEST_LOCAL[1]] - dc_helper.wait_for_subcloud_snmp_comms(subcloud=primary_subcloud, expected_comms=all_comms) - dc_helper.wait_for_subcloud_snmp_trapdests(subcloud=primary_subcloud, - expected_trapdests=all_trapdests, - timeout=30, check_interval=10) diff --git a/automated-pytest-suite/testcases/rest/test_GET_good_authentication.py b/automated-pytest-suite/testcases/rest/test_GET_good_authentication.py index 44138d6..629fdb3 100755 --- a/automated-pytest-suite/testcases/rest/test_GET_good_authentication.py +++ b/automated-pytest-suite/testcases/rest/test_GET_good_authentication.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2019 Wind River Systems, Inc. +# Copyright (c) 2019-2020 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -30,7 +30,6 @@ def sysinv_rest(): ('GET', '/health'), ('GET', '/health/upgrade'), ('GET', '/ialarms'), - ('GET', '/icommunity'), ('GET', '/idns'), ('GET', '/iextoam'), ('GET', '/ihosts'), @@ -41,7 +40,6 @@ def sysinv_rest(): ('GET', '/iprofiles'), ('GET', '/istorconfig'), ('GET', '/isystems'), - ('GET', '/itrapdest'), ('GET', '/lldp_agents'), ('GET', '/lldp_neighbors'), ('GET', '/loads'), diff --git a/automated-pytest-suite/testcases/rest/test_bad_authentication.py b/automated-pytest-suite/testcases/rest/test_bad_authentication.py index 541a817..b10d634 100755 --- a/automated-pytest-suite/testcases/rest/test_bad_authentication.py +++ b/automated-pytest-suite/testcases/rest/test_bad_authentication.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2019 Wind River Systems, Inc. +# Copyright (c) 2019-2020 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -176,7 +176,6 @@ def put(sysinv_rest, resource): 'operation,resource', [ ('DELETE', '/addrpools/__pool_id__'), ('DELETE', '/ialarms/__alarm_uuid__'), - ('DELETE', '/icommunity/__community_id__'), ('DELETE', '/ihosts/__host_id__/addresses/__address_id__'), ('DELETE', '/ihosts/__host_id__'), ('DELETE', '/ihosts/__host_id__/routes/__route_id__'), @@ -185,7 +184,6 @@ def put(sysinv_rest, resource): ('DELETE', '/iprofiles/__profile_id__'), ('DELETE', '/ipvs/__physicalvolume_id__'), ('DELETE', '/istors/__stor_id__'), - ('DELETE', '/itrapdest/__trapdest_id__'), ('DELETE', '/loads/__load_id__'), ('DELETE', '/sdn_controller/__controller_id__'), ('DELETE', '/service_parameter/__parameter_id__'), @@ -207,8 +205,6 @@ def put(sysinv_rest, resource): ('GET', '/health/upgrade'), ('GET', '/ialarms/__alarm_uuid__'), ('GET', '/ialarms'), - ('GET', '/icommunity'), - ('GET', '/icommunity/__community_id__'), ('GET', '/icpus/__cpu_id__'), ('GET', '/idisks/__disk_id__'), ('GET', '/idns'), @@ -245,8 +241,6 @@ def put(sysinv_rest, resource): ('GET', '/istorconfig'), ('GET', '/istors/__stor_id__'), ('GET', '/isystems'), - ('GET', '/itrapdest'), - ('GET', '/itrapdest/__trapdest_id__'), ('GET', '/lldp_agents'), ('GET', '/lldp_agents/__lldp_agent_id__'), ('GET', '/lldp_neighbors'), @@ -279,7 +273,6 @@ def put(sysinv_rest, resource): ('PATCH', '/devices/__device_id__'), ('PATCH', '/drbdconfig/__drbdconfig_id__'), ('PATCH', '/event_suppression/__event_suppression_uuid__'), - ('PATCH', '/icommunity/__community_id__'), ('PATCH', '/idns/__dns_id__'), ('PATCH', '/iextoam/__extoam_id__'), ('PATCH', '/ihosts/__host_id__'), @@ -294,7 +287,6 @@ def put(sysinv_rest, resource): ('PATCH', '/isensors/__sensor_id__'), ('PATCH', '/istors/__stor_id__'), ('PATCH', '/isystems'), - ('PATCH', '/itrapdest/__trapdest_id__'), ('PATCH', '/remotelogging/__remotelogging_id__'), ('PATCH', '/sdn_controller/__controller_id__'), ('PATCH', '/service_parameter/__parameter_id__'), @@ -305,7 +297,6 @@ def put(sysinv_rest, resource): ('PATCH', '/upgrade'), ('POST', '/addrpools'), ('POST', '/firewallrules/import_firewall_rules'), - ('POST', '/icommunity'), ('POST', '/ihosts'), ('POST', '/ihosts/bulk_add'), ('POST', '/ihosts/__host_id__/addresses'), @@ -318,7 +309,6 @@ def put(sysinv_rest, resource): ('POST', '/ilvgs'), ('POST', '/iprofiles'), ('POST', '/ipvs'), - ('POST', '/itrapdest'), ('POST', '/loads/import_load'), ('POST', '/sdn_controller'), ('POST', '/service_parameter/apply'),