Skip to content

v4: Tie view registration to driver registration #229

@jtdub

Description

@jtdub

Description

Currently get_hconfig_view() in constructors.py uses a hardcoded isinstance chain to map drivers to views. Only 5 of 10 platforms have views; the rest raise ValueError. With #226 introducing driver registration, views should follow the same pattern.

Proposed Change

Add a view_class parameter to register_driver() or a separate register_view():

# Option A: view_class on register_driver
register_driver("MY_NOS", MyNOSDriver, view_class=MyNOSView)

# Option B: separate register_view
register_view(Platform.CISCO_IOS, HConfigViewCiscoIOS)

Built-in views are registered at import time alongside their drivers. get_hconfig_view() reads from the registry instead of using isinstance checks.

Benefits

  • Users can provide views for custom platforms
  • Users can override built-in views
  • Eliminates the hardcoded isinstance chain in constructors.py
  • get_hconfig_view() returns None (or raises a clear error) for platforms without views instead of a generic ValueError

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    v4-enhancementEnhancement planned for hier_config v4.0.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions