MitchellGulledge / Meraki-vWAN

5 stars 4 forks source link

Does not work with MX HA scenario with unique public IP addresses #4

Closed yujiterada closed 4 years ago

yujiterada commented 4 years ago

Currently, the script does not work with all scenarios with a MX HA setup.

If the MX in active and standby have a same public IP address for their WAN port, the script will succeed. This is a scenario in which there is a router in the upstream which NATs the private IP address of the MX WAN IP to a single public IP.

If the MX in active and standby have a different public IP address for their WAN port, the script will fail.

Expected Behavior

Should handle all scenarios for MX HA.

Current Behavior

Finds the first MX returned in getNetworkDevices, and this MX can be the active or standby. The script can provision the tunnel for the standby MX. If it provisions a tunnel for the active MX, the tunnel will fail after failover.

# get device info
devices = mdashboard.devices.getNetworkDevices(network_info)
xdevices = get_mx_from_network_devices(devices)

Possible Solution

Change get_mx_from_network_devices to return a list and not a dictionary.

def get_mx_from_network_devices(network_devices: list):
    '''
    Returns only the MX information obtained from
    mdashboard.devices.getNetworkDevices(). If it does not exist,
    return an empty list.
    @param network_devices: mdashboard.devices.getNetworkDevices().
    @rtype:   list
    @return:  list of information of MX.
    '''
    result = []
    for network_device in network_devices:
        if network_device['model'][0:2] == 'MX':
            result.append(network_device)
    return result

if len < 1, then exit as MX does not exist in network if len == 1, then a single MX exists in the network and apply current logic if len > 1, then MX is in HA in the network, and therefore gather public IPs for both MXs for creating a VPN site for both the active and standby MX

Steps to Reproduce

  1. Create a network in Meraki Dashboard
  2. Configure MX with HA
  3. The active and standby MX should have a unique public IP for its WAN port.
yujiterada commented 4 years ago

@JackStromberg or @MitchellGulledge, please create a new branch specifically for this fix so I can create a pull request with the possible solution.

JackStromberg commented 4 years ago

@yujiterada new branch created. Check out https://github.com/MitchellGulledge/Meraki-vWAN/tree/MX-HA-Support

JackStromberg commented 4 years ago

Fixed in PR #12