diff --git a/api/patch_request.py b/api/patch_request.py index 6c6ad789130736524442ea3e7f9626cfbb4c29df..c33e0af277c17e2a27a9b8a60f9e017385889225 100644 --- a/api/patch_request.py +++ b/api/patch_request.py @@ -161,6 +161,14 @@ def validate_patch_request_actions(conn, user, actions: list[APIPatchRequestActi {'idx': 'vlan_list', 'name': 'nd.vlan.list', 'inner_join_ref': {'bcd_list': 'default'}}, ], user=user.login_name) internal_action.bcd = Port(**bcd_result['bcd_list'][0]) + + if action.bcd_tagged or action.use_lacp: + if action.comment is None or len(action.comment) == 0: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail='Comment must be provided for tagged or lacp!' + ) + if len(bcd_result['vlan_list']) > 0: internal_action.vlan_ids = list( map(lambda v: '{compound}: {id}'.format(compound=v.get('net_instnc', 'UNKNOWN?'), id=v['id']), @@ -343,6 +351,7 @@ def validate_patch_request_actions(conn, user, actions: list[APIPatchRequestActi internal_action.site = Site(**r['site_list'][0]) internal_action.action = action.action internal_action.bcd_tagged = action.bcd_tagged + internal_action.use_lacp = action.use_lacp internal_action.comment = action.comment internal_actions.append(internal_action) diff --git a/model/patch_request.py b/model/patch_request.py index 16d1f64e5ffeca9c6c0a8862e19e43fe08d9bf9e..85aaabc02c1b135ce8d7506767ea9023a9c43173 100644 --- a/model/patch_request.py +++ b/model/patch_request.py @@ -22,6 +22,7 @@ class APIPatchRequestAction(BaseModel): action: PatchActionType = Field() bcd_name: Optional[str] = Field(default=None) bcd_tagged: Optional[bool] = Field(default=False) + use_lacp: Optional[bool] = Field(default=False) building_gpk: str = Field() comment: str = Field() module_gpk: str = Field() @@ -35,6 +36,7 @@ class PatchRequestAction(BaseModel): action: Optional[PatchActionType] = Field(default=None) bcd: Optional[BCD] = Field(default=None) bcd_tagged: Optional[bool] = Field(default=False) + use_lacp: Optional[bool] = Field(default=False) building: Optional[Bldg] = Field(default=None) comment: str = Field(default='') module: Optional[Module] = Field(default=None) diff --git a/templates/patch_request_confirm_template.j2 b/templates/patch_request_confirm_template.j2 index d3cd4632269af6d903c5a7a644f3da0d1ab1e260..d985481c4cec7df654deffd0057ff1f9d029062a 100644 --- a/templates/patch_request_confirm_template.j2 +++ b/templates/patch_request_confirm_template.j2 @@ -18,6 +18,9 @@ {% if action['bcd'] is defined and action['bcd']['name'] is defined %} <b>Broadcast domain:</b> {{ action['bcd']['name'] }} ({% if action['bcd_tagged'] %}add tagged{%else%}untagged{%endif%})<br> {% endif %} + {% if action['use_lacp'] %} + <b>LACP:</b> True <br> + {% endif %} {% if action['new_insert_type'] %} <b>New insert:</b> {{ action['new_insert_type'] }}<br> {% endif %} diff --git a/templates/patch_request_template.j2 b/templates/patch_request_template.j2 index 7ecb09e1e2459abef7168e8378d7796881c26e5a..0bb25143a23e52f5b50caa0bdcd4c719c36e8093 100644 --- a/templates/patch_request_template.j2 +++ b/templates/patch_request_template.j2 @@ -38,10 +38,16 @@ <td style="border: 1px solid black; border-collapse: collapse;">{{ action['p_port']['name'] }}</td> </tr> {% endif %} + {% if action['use_lacp'] %} + <tr> + <th style="border: 1px solid black; border-collapse: collapse; font-weight: bold;">LACP</th> + <td style="border: 1px solid black; border-collapse: collapse;">True (see comment!)</td> + </tr> + {% endif %} {% if action['bcd'] is defined and action['bcd']['name'] is defined %} <tr> <th style="border: 1px solid black; border-collapse: collapse;">Broadcast Domain</th> - <td style="border: 1px solid black; border-collapse: collapse;">{{ action['bcd']['name'] }} ({% if action['bcd_tagged'] %}add tagged{% else %}untagged{% endif %}) + <td style="border: 1px solid black; border-collapse: collapse;">{{ action['bcd']['name'] }} ({% if action['bcd_tagged'] %}add tagged (see comment){% else %}untagged{% endif %}) <ul> {% for v in action['vlan_ids'] %} <li>{{ v }}</li>