Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netvs-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scc-net
netvs
netvs-middleware
Commits
f76527bf
Commit
f76527bf
authored
1 year ago
by
!! Julian Keck (old Account; do not use) !!
Browse files
Options
Downloads
Patches
Plain Diff
UPD prepare for bcd assignment for changed insert
parent
776aedde
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/patch_request.py
+22
-2
22 additions, 2 deletions
api/patch_request.py
model/patch_request.py
+10
-0
10 additions, 0 deletions
model/patch_request.py
templates/patch_request_template.j2
+11
-0
11 additions, 0 deletions
templates/patch_request_template.j2
with
43 additions
and
2 deletions
api/patch_request.py
+
22
−
2
View file @
f76527bf
...
...
@@ -94,7 +94,7 @@ async def get_insert_types(token: APIToken = Depends(check_auth), conn=Depends(g
for
i
in
suffix_list
if
len
(
suffix_list
)
>
0
else
[
''
]:
cmp_ports
.
append
({
**
tmp_port
,
'
port_name_suffix
'
:
i
'
port_name_suffix
'
:
i
+
'
::
'
})
tmp_ports
=
cmp_ports
...
...
@@ -108,7 +108,7 @@ async def get_insert_types(token: APIToken = Depends(check_auth), conn=Depends(g
for
i
in
prefix_list
if
len
(
prefix_list
)
>
0
else
[
''
]:
cmp_ports
.
append
({
**
tmp_port
,
'
port_name_prefix
'
:
i
'
port_name_prefix
'
:
'
::
'
+
i
})
tmp_ports
=
cmp_ports
...
...
@@ -227,6 +227,26 @@ def validate_patch_request_actions(conn, user, actions: list[APIPatchRequestActi
detail
=
'
BCD is required for patch action
'
)
if
action
.
action
!=
PatchActionType
.
CHANGE_INSERT
and
len
(
action
.
new_insert_assignment
)
>
0
:
raise
HTTPException
(
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
detail
=
'
New insert assignments are only allowed for change_insert actions
'
)
for
insert_assignment
in
action
.
new_insert_assignment
:
if
not
user
.
has_bcd
(
conn
,
insert_assignment
.
bcd_name
):
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
f
'
You do not have permission to request patch for BCD
{
insert_assignment
[
"
bcd_name
"
]
}
'
)
bcd_result
=
execute_wapi_function
(
conn
,
[
{
'
idx
'
:
'
bcd_list
'
,
'
name
'
:
'
nd.bcd.list
'
,
'
old
'
:
{
'
name
'
:
insert_assignment
.
bcd_name
}},
],
user
=
user
.
login_name
)
insert_assignment
.
bcd
=
Port
(
**
bcd_result
[
'
bcd_list
'
][
0
])
internal_action
.
new_insert_assignment
=
action
.
new_insert_assignment
internal_action
.
new_insert_type
=
action
.
new_insert_type
r
=
execute_wapi_function
(
conn
,
[
{
'
idx
'
:
'
bldg_list
'
,
'
name
'
:
'
nd.bldg.list
'
,
'
old
'
:
{
'
gpk
'
:
action
.
building_gpk
}},
{
'
idx
'
:
'
site_list
'
,
'
name
'
:
'
nd.site.list
'
,
'
inner_join_ref
'
:
{
'
bldg_list
'
:
'
default
'
}},
...
...
This diff is collapsed.
Click to expand it.
model/patch_request.py
+
10
−
0
View file @
f76527bf
...
...
@@ -12,6 +12,12 @@ class PatchActionType(Enum):
CHANGE_INSERT
=
'
change_insert
'
class
APIInsertBCDAssignment
(
BaseModel
):
bcd_name
:
str
=
Field
()
bcd_tagged
:
bool
=
Field
(
default
=
False
)
port_name
:
str
=
Field
()
class
APIPatchRequestAction
(
BaseModel
):
action
:
PatchActionType
=
Field
()
bcd_name
:
Optional
[
str
]
=
Field
(
default
=
None
)
...
...
@@ -21,6 +27,8 @@ class APIPatchRequestAction(BaseModel):
module_gpk
:
str
=
Field
()
room_gpk
:
str
=
Field
()
p_port_gpk
:
str
=
Field
()
new_insert_type
:
Optional
[
str
]
=
Field
(
default
=
None
)
new_insert_assignment
:
list
[
APIInsertBCDAssignment
]
=
Field
(
default
=
[])
class
PatchRequestAction
(
BaseModel
):
...
...
@@ -35,6 +43,8 @@ class PatchRequestAction(BaseModel):
site
:
Optional
[
Site
]
=
Field
(
default
=
None
)
path_link
:
Optional
[
str
]
=
Field
(
default
=
None
)
ports_summary
:
Optional
[
str
]
=
Field
(
default
=
None
)
new_insert_type
:
Optional
[
str
]
=
Field
(
default
=
None
)
new_insert_assignment
:
list
[
APIInsertBCDAssignment
]
=
Field
(
default
=
[])
class
PatchRequestFormRequest
(
BaseModel
):
...
...
This diff is collapsed.
Click to expand it.
templates/patch_request_template.j2
+
11
−
0
View file @
f76527bf
...
...
@@ -16,6 +16,17 @@
{% if action['bcd'] is defined %}
<b>Broadcast domain:</b> {{ action['bcd']['name'] }} ({% if action['bcd_tagged'] %}add tagged{%else%}untagged{%endif%})<br>
{% endif %}
{% if action['new_insert_type'] %}
<b>New insert:</b> {{ action['new_insert_type'] }}<br>
{% endif %}
{% if action['new_insert_assignment'] is defined %}
<b>BCD-assignment:</b> the following BCDs should be assigned to the new insert. Port names are only estimated, you might need to adjust them:<br>
<ul>
{% for assignment in action['new_insert_assignment'] %}
<li>{{ assignment['port_name'] }}: {{ assignment['bcd_name'] }} ({{ assignment['bcd_tagged'] }})</li>
{% endfor %}
</ul>
{% endif %}
<b>Comment:</b> {{ action['comment'] }}<br>
{% if (action['path_link'] | default(none)) is not none %}
<b>Link to path:</b> <a href="{{ action['path_link'] }}">{{ action['path_link'] }}</a><br>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment