def test_mgmt_config_ruleset_order(web): web.set_ruleset( "management_board_config", { "ruleset": { "": [ # "" -> folder { 'condition': {}, 'options': {}, 'value': ("snmp", "RULESET1"), }, { 'condition': {}, 'options': {}, 'value': ("snmp", "RULESET2"), }, ], } }) web.add_folder("folder1") web.add_host("mgmt-host", folder="folder1", attributes={ "ipaddress": "127.0.0.1", "management_protocol": "snmp", }) config_cache = reload_config() host_config = config_cache.get_host_config("mgmt-host") assert host_config.has_management_board assert host_config.management_protocol == "snmp" assert host_config.management_address == "127.0.0.1" assert host_config.management_credentials == "RULESET1"
def test_mgmt_config_ruleset_overidden_by_explicit_setting(web, protocol, cred_attribute, folder_credentials, ruleset_credentials): web.set_ruleset( "management_board_config", { "ruleset": { "": [ # "" -> folder { 'condition': {}, 'options': {}, 'value': (protocol, ruleset_credentials), }, ], } }) web.add_folder("folder1", attributes={ cred_attribute: folder_credentials, }) web.add_host("mgmt-host", folder="folder1", attributes={ "ipaddress": "127.0.0.1", "management_protocol": protocol, }) config_cache = reload_config() host_config = config_cache.get_host_config("mgmt-host") assert host_config.has_management_board assert host_config.management_protocol == protocol assert host_config.management_address == "127.0.0.1" assert host_config.management_credentials == folder_credentials
def test_mgmt_config_ruleset(web, protocol, cred_attribute, credentials, ruleset_credentials): web.set_ruleset( "management_board_config", { "ruleset": { "": [ # "" -> folder { 'conditions': { 'host_specs': ['@all'], 'host_tags': [] }, 'options': {}, 'value': (protocol, ruleset_credentials), }, ], } }) web.add_folder("folder1") web.add_host( "mgmt-host", folder="folder1", attributes={ "ipaddress": "127.0.0.1", "management_protocol": protocol, }) config_cache = reload_config() host_config = config_cache.get_host_config("mgmt-host") assert host_config.has_management_board assert host_config.management_protocol == protocol assert host_config.management_address == "127.0.0.1" assert host_config.management_credentials == ruleset_credentials
def test_mgmt_inherit_protocol(web, protocol, cred_attribute, credentials, folder_credentials): web.add_folder("folder1", attributes={ "management_protocol": protocol, cred_attribute: folder_credentials, }) web.add_host("mgmt-host", folder="folder1", attributes={ "ipaddress": "127.0.0.1", }) config_cache = reload_config() host_config = config_cache.get_host_config("mgmt-host") assert host_config.has_management_board assert host_config.management_protocol == protocol assert host_config.management_address == "127.0.0.1" assert host_config.management_credentials == folder_credentials