Skip to content

Commit 4110f13

Browse files
authored
[dev]: device variable update (#189)
* introduce additional properties to DeviceVariable * fix DeviceVariable equality
1 parent fad9156 commit 4110f13

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Copyright 2023 Cisco Systems, Inc. and its affiliates
22

3-
from pydantic import BaseModel
3+
from typing import Literal, Optional, Tuple
4+
5+
from pydantic import BaseModel, PrivateAttr
6+
7+
VariableObjectType = Literal["variable", "variableName"]
48

59

610
class DeviceVariable(BaseModel):
711
name: str
12+
_object_type: VariableObjectType = PrivateAttr(default="variableName")
13+
_template_path: Optional[Tuple[str, ...]] = PrivateAttr(default=None)
14+
15+
def __eq__(self, other):
16+
# do not compare private attributes for backward compatibility
17+
return self.__dict__ == other.__dict__

catalystwan/utils/feature_template/find_template_values.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def find_template_values(
5656
# {"dns-addr": DeviceVariable(name="vpn_dns_primary")}
5757
if var_name := template_definition.get("vipVariableName"):
5858
new_value = DeviceVariable(name=var_name)
59+
new_value._object_type = value
60+
new_value._template_path = tuple(path)
5961
current_nesting = get_nested_dict(templated_values, path[:-1])
6062
current_nesting[field_key] = new_value
6163
return templated_values

0 commit comments

Comments
 (0)