Skip to content

Commit

Permalink
changes to add patch positions to interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephine.Rutten committed Dec 16, 2024
1 parent 40d8114 commit 4f49b40
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cnaas_nms/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def put(self, hostname):
json_data = request.get_json()
data = {}
errors = []
patch_positions = []
device_settings = None
with sqla_session() as session: # type: ignore
dev: Optional[Device] = session.query(Device).filter(Device.hostname == hostname).one_or_none()
Expand Down Expand Up @@ -276,7 +277,13 @@ def put(self, hostname):
)
if "patch_postion" in if_dict["data"]:
if isinstance(if_dict["data"]["patch_postion"], str):
intfdata["patch_postion"] = if_dict["data"]["patch_postion"]
if if_dict["data"]["patch_postion"] not in patch_positions:
intfdata["patch_postion"] = if_dict["data"]["patch_postion"]
patch_positions.append(if_dict["data"]["patch_postion"])
else:
errors.append(
"patch_postion must be unique: {}".format(if_dict["data"]["patch_postion"])
)
else:
errors.append(
"patch_postion must be a string, got: {}".format(if_dict["data"]["patch_postion"])
Expand Down

0 comments on commit 4f49b40

Please sign in to comment.