meraki / dashboard-api-python

Official Dashboard API library (SDK) for Python
MIT License
289 stars 151 forks source link

Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface #185

Closed koladiya closed 2 years ago

koladiya commented 2 years ago

meraki==1.18.2 & 1.19.0

While updating network switch stack routing interface using the below function it is throwing an error. https://github.com/meraki/dashboard-api-python/blob/6e68466ae79f0c1296f4836af22449e164d4c8c0/meraki/api/switch.py#L1692

Error:

Meraki API error: switch, updateNetworkSwitchStackRoutingInterface - 400 Bad Request, {'errors': ["Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface."]} status code = 400 reason = Bad Request error = {'errors': ["Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface."]}

Reason:

Solution:

TKIPisalegacycipher commented 2 years ago

Thanks for reporting this @koladiya !

We do expect the error to be thrown when trying to add a default gateway to more than one interface--you can only have a default gateway on one interface. If one already has it, and that's the interface you're updating, then we do expect that update command to succeed.

Are you seeing this when trying to update the default gateway on the interface that already has one, or something else?

koladiya commented 2 years ago

@TKIPisalegacycipher

We do expect the error to be thrown when trying to add a default gateway to more than one interface. you can only have a default gateway on one interface --> that is clear, it is not allowed. but this is not the case here.

Are you seeing this when trying to update the default gateway on the interface that already has one? --> YES

Meraki API error: switch, updateNetworkSwitchStackRoutingInterface - 400 Bad Request, {'errors': ["Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface."]} status code = 400 reason = Bad Request error = {'errors': ["Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface."]}

TKIPisalegacycipher commented 2 years ago

@koladiya could you let me know if you are still having this issue?

koladiya commented 2 years ago

@TKIPisalegacycipher the issue still persists. (I don't see any changes on this code)

again tested with meraki==1.18.2, 1.19.0 & 1.20.0

e.g. I have an existing layer 3 routing interface for stack devices that has a default gateway configured. If I want to update that interface, it fails as follows:

import meraki

meraki_api = meraki.DashboardAPI(suppress_logging=True)

network_id = <network_id>
stack_id = <stack_id>
interface_id = <interface_id>

data = {
    "name": "vlan99",
    "subnet": "10.10.10.0/24",
    "interfaceIp": "10.10.10.10",
    "multicastRouting": "disabled",
    "vlanId": 99,
    "defaultGateway": "10.10.10.1",
}

try:

    response = meraki_api.switch.updateNetworkSwitchStackRoutingInterface(
        networkId=network_id, switchStackId=stack_id, interfaceId=interface_id, **data
    )
    print(response)
except meraki.APIError as e:
    print(f"    Meraki API error: {e}")
    print(f"    status code = {e.status}")
    print(f"    reason = {e.reason}")
    print(f"    error = {e.message}")

errors:

    Meraki API error: switch, updateNetworkSwitchStackRoutingInterface - 400 Bad Request, {'errors': ["Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface."]}
    status code = 400
    reason = Bad Request
    error = {'errors': ["Parameter 'defaultGateway' to be set once and is already configured with a different layer 3 interface."]}

If I simply removed "defaultGateway": "10.10.10.1", from data, it works fine.

TKIPisalegacycipher commented 2 years ago

Please open a ticket with Meraki support. This seems to be an API issue and not specific to the library.