Fix issue where structured_output: true on a device would cause it to be disabled

This commit is contained in:
thatmattlove 2021-09-13 02:38:08 -07:00
parent 1adad7e46d
commit 641f1e1bdd

View file

@ -136,19 +136,19 @@ class Device(HyperglassModelWithId, extra="allow"):
def validate_structured_output(cls, value: bool, values: Dict) -> bool: def validate_structured_output(cls, value: bool, values: Dict) -> bool:
"""Validate structured output is supported on the device & set a default.""" """Validate structured output is supported on the device & set a default."""
if value is True and values["nos"] not in SUPPORTED_STRUCTURED_OUTPUT: if value is True:
raise ConfigError( if values["nos"] not in SUPPORTED_STRUCTURED_OUTPUT:
"The 'structured_output' field is set to 'true' on device '{d}' with " raise ConfigError(
+ "NOS '{n}', which does not support structured output", "The 'structured_output' field is set to 'true' on device '{d}' with "
d=values["name"], + "NOS '{n}', which does not support structured output",
n=values["nos"], d=values["name"],
) n=values["nos"],
)
return value
elif value is None and values["nos"] in SUPPORTED_STRUCTURED_OUTPUT: elif value is None and values["nos"] in SUPPORTED_STRUCTURED_OUTPUT:
value = True value = True
else: else:
value = False value = False
return value return value
@validator("ssl") @validator("ssl")