From 641f1e1bddae622df0f86cc3963ed8704e4f1e61 Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Mon, 13 Sep 2021 02:38:08 -0700 Subject: [PATCH] Fix issue where `structured_output: true` on a device would cause it to be disabled --- hyperglass/models/config/devices.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hyperglass/models/config/devices.py b/hyperglass/models/config/devices.py index 1731f70..230a1d6 100644 --- a/hyperglass/models/config/devices.py +++ b/hyperglass/models/config/devices.py @@ -136,19 +136,19 @@ class Device(HyperglassModelWithId, extra="allow"): def validate_structured_output(cls, value: bool, values: Dict) -> bool: """Validate structured output is supported on the device & set a default.""" - if value is True and values["nos"] not in SUPPORTED_STRUCTURED_OUTPUT: - raise ConfigError( - "The 'structured_output' field is set to 'true' on device '{d}' with " - + "NOS '{n}', which does not support structured output", - d=values["name"], - n=values["nos"], - ) - + if value is True: + if values["nos"] not in SUPPORTED_STRUCTURED_OUTPUT: + raise ConfigError( + "The 'structured_output' field is set to 'true' on device '{d}' with " + + "NOS '{n}', which does not support structured output", + d=values["name"], + n=values["nos"], + ) + return value elif value is None and values["nos"] in SUPPORTED_STRUCTURED_OUTPUT: value = True else: value = False - return value @validator("ssl")