def get_nc_connection(module): global _DEVICE_NC_CONNECTION if not _DEVICE_NC_CONNECTION: load_params(module) conn = NetconfConnection(module._socket_path) _DEVICE_NC_CONNECTION = conn return _DEVICE_NC_CONNECTION
def get_connection(module): if hasattr(module, '_netconf_connection'): return module._netconf_connection capabilities = get_capabilities(module) network_api = capabilities.get('network_api') if network_api == 'netconf': module._netconf_connection = NetconfConnection(module._socket_path) else: module.fail_json(msg='Invalid connection type %s' % network_api) return module._netconf_connection
def get_connection(module): if hasattr(module, "_netconf_connection"): return module._netconf_connection capabilities = get_capabilities(module) network_api = capabilities.get("network_api") if network_api == "netconf": module._netconf_connection = NetconfConnection(module._socket_path) else: module.fail_json(msg="Invalid connection type %s" % network_api) return module._netconf_connection
def get_connection(module): if hasattr(module, "connection"): return module.connection capabilities = get_capabilities(module) network_api = capabilities.get("network_api") if network_api == "cliconf": module.connection = Connection(module._socket_path) elif network_api == "netconf": module.connection = NetconfConnection(module._socket_path) else: module.fail_json( msg="Invalid connection type {0!s}".format(network_api)) return module.connection
def get_connection(module): if hasattr(module, 'connection'): return module.connection capabilities = get_capabilities(module) network_api = capabilities.get('network_api') if network_api == 'cliconf': module.connection = Connection(module._socket_path) elif network_api == 'netconf': module.connection = NetconfConnection(module._socket_path) else: module.fail_json( msg='Invalid connection type {0!s}'.format(network_api)) return module.connection
def get_resource_connection(module): if hasattr(module, "_connection"): return module._connection capabilities = get_capabilities(module) network_api = capabilities.get("network_api") if network_api == "netconf": module._connection = NetconfConnection(module._socket_path) elif network_api == "local": # This isn't supported, but we shouldn't fail here. # Set the connection to a fake connection so it fails sensibly. module._connection = LocalResourceConnection(module) else: module._connection = Connection(module._socket_path) return module._connection
def get_resource_connection(module): if hasattr(module, "_connection"): return module._connection capabilities = get_capabilities(module) network_api = capabilities.get("network_api") if network_api in ("cliconf", "nxapi", "eapi", "exosapi"): module._connection = Connection(module._socket_path) elif network_api == "netconf": module._connection = NetconfConnection(module._socket_path) elif network_api == "local": # This isn't supported, but we shouldn't fail here. # Set the connection to a fake connection so it fails sensibly. module._connection = LocalResourceConnection(module) else: module.fail_json( msg="Invalid connection type {0!s}".format(network_api)) return module._connection