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
Description
Currently
get_hconfig_view()inconstructors.pyuses a hardcodedisinstancechain to map drivers to views. Only 5 of 10 platforms have views; the rest raiseValueError. With #226 introducing driver registration, views should follow the same pattern.Proposed Change
Add a
view_classparameter toregister_driver()or a separateregister_view():Built-in views are registered at import time alongside their drivers.
get_hconfig_view()reads from the registry instead of using isinstance checks.Benefits
get_hconfig_view()returnsNone(or raises a clear error) for platforms without views instead of a generic ValueErrorRelated