Skip to content

community.routeros.api_modify: add versioned_field "default-route-tables" for "ip dhcp-client" #407

@YannSK

Description

@YannSK
SUMMARY

Trying to use a new "ip dhcp-client" field "default-route-tables" added in routeros 7.18 (2025-Feb-24 10:47) :
*) dhcpv4-client - allow selecting to which routing tables add default route;

It results in :
fatal: [ROUTER]: FAILED! => {"changed": false, "msg": "Unknown key \"default-route-tables\" for interface=\"ether1\"."}

Field is documented here : https://help.mikrotik.com/docs/spaces/ROS/pages/24805500/DHCP#DHCP-DHCPClient

ISSUE TYPE
  • Feature Idea
ADDITIONAL INFORMATION

I've added it like this as a versioned_field in plugins/module_utils/_api_data.py :

    ('ip', 'dhcp-client'): APIData(
        unversioned=VersionedAPIData(
            fully_understood=True,
            primary_keys=('interface', ),
            versioned_fields=[
                ([('7.18', '>=')], 'default-route-tables', KeyInfo(default=False)),
            ],
            fields={
                'add-default-route': KeyInfo(default=True),
                'comment': KeyInfo(can_disable=True, remove_value=''),
                'default-route-distance': KeyInfo(default=1),
                'dhcp-options': KeyInfo(default='hostname,clientid', can_disable=True, remove_value=''),
                'disabled': KeyInfo(default=False),
                'interface': KeyInfo(),
                'script': KeyInfo(can_disable=True),
                'use-peer-dns': KeyInfo(default=True),
                'use-peer-ntp': KeyInfo(default=True)
            },
        ),
    ),

Works for me but really not confident enough to make a formal PR. If someone could review that and add this field for some future version it would be nice.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions