Check for Netmiko arguments that were passed in as NAPALM optional arguments.

    Return a dictionary of these optional args that will be passed into the
    Netmiko ConnectHandler call.

    .. note::

        This is a port of the NAPALM helper for backwards compatibility with
        older versions of NAPALM, and stability across Salt features.
        If the netmiko helpers module is available however, it will prefer that
        implementation nevertheless.

def _get_netmiko_args(optional_args):
    '''
    Check for Netmiko arguments that were passed in as NAPALM optional arguments.

    Return a dictionary of these optional args that will be passed into the
    Netmiko ConnectHandler call.

    .. note::

        This is a port of the NAPALM helper for backwards compatibility with
        older versions of NAPALM, and stability across Salt features.
        If the netmiko helpers module is available however, it will prefer that
        implementation nevertheless.
    '''
    if HAS_NETMIKO_HELPERS:
        return napalm.base.netmiko_helpers.netmiko_args(optional_args)
    # Older version don't have the netmiko_helpers module, the following code is
    # simply a port from the NAPALM code base, for backwards compatibility:
    # https://github.com/napalm-automation/napalm/blob/develop/napalm/base/netmiko_helpers.py
    netmiko_args, _, _, netmiko_defaults = inspect.getargspec(BaseConnection.__init__)
    check_self = netmiko_args.pop(0)
    if check_self != 'self':
        raise ValueError('Error processing Netmiko arguments')
    netmiko_argument_map = dict(six.moves.zip(netmiko_args, netmiko_defaults))
    # Netmiko arguments that are integrated into NAPALM already
    netmiko_filter = ['ip', 'host', 'username', 'password', 'device_type', 'timeout']
    # Filter out all of the arguments that are integrated into NAPALM
    for k in netmiko_filter:
        netmiko_argument_map.pop(k)
    # Check if any of these arguments were passed in as NAPALM optional_args
    netmiko_optional_args = {}
    for k, v in six.iteritems(netmiko_argument_map):
        try:
            netmiko_optional_args[k] = optional_args[k]
        except KeyError:
            pass
    # Return these arguments for use with establishing Netmiko SSH connection
    return netmiko_optional_args