Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
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
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
TFS
controller
Commits
a08d0a28
Commit
a08d0a28
authored
1 year ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
NBI component - IETF L3VPN:
- Enabled creation of multiple services at once
parent
8f996309
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!235
Release TeraFlowSDN 3.0
,
!204
Resolve "(CTTC) Multiple Bugs related to F5G PoC CAMARA experiment"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/L3VPN_Services.py
+32
-5
32 additions, 5 deletions
...vice/rest_server/nbi_plugins/ietf_l3vpn/L3VPN_Services.py
with
32 additions
and
5 deletions
src/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/L3VPN_Services.py
+
32
−
5
View file @
a08d0a28
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
import
logging
from
typing
import
Dict
from
typing
import
Dict
,
List
from
flask
import
request
from
flask.json
import
jsonify
from
flask_restful
import
Resource
...
...
@@ -36,11 +36,40 @@ class L3VPN_Services(Resource):
request_data
:
Dict
=
request
.
json
LOGGER
.
debug
(
'
Request: {:s}
'
.
format
(
str
(
request_data
)))
errors
=
list
()
if
'
ietf-l3vpn-svc:l3vpn-services
'
in
request_data
:
# processing multiple L3VPN service requests formatted as:
#{
# "ietf-l3vpn-svc:l3vpn-services": {
# "l3vpn-svc": [
# {
# "service-id": "vpn1",
# "vpn-services": {
# "vpn-service": [
for
l3vpn_svc
in
request_data
[
'
ietf-l3vpn-svc:l3vpn-services
'
][
'
l3vpn-svc
'
]:
l3vpn_svc
.
pop
(
'
service-id
'
,
None
)
l3vpn_svc_request_data
=
{
'
ietf-l3vpn-svc:l3vpn-svc
'
:
l3vpn_svc
}
errors
.
extend
(
self
.
_process_l3vpn
(
l3vpn_svc_request_data
))
elif
'
ietf-l3vpn-svc:l3vpn-svc
'
in
request_data
:
# processing single (standard) L3VPN service request formatted as:
#{
# "ietf-l3vpn-svc:l3vpn-svc": {
# "vpn-services": {
# "vpn-service": [
errors
.
extend
(
self
.
_process_l3vpn
(
request_data
))
else
:
errors
.
append
(
'
unexpected request: {:s}
'
.
format
(
str
(
request_data
)))
response
=
jsonify
(
errors
)
response
.
status_code
=
HTTP_CREATED
if
len
(
errors
)
==
0
else
HTTP_SERVERERROR
return
response
def
_process_l3vpn
(
self
,
request_data
:
Dict
)
->
List
[
Dict
]:
yang_validator
=
YangValidator
(
'
ietf-l3vpn-svc
'
)
request_data
=
yang_validator
.
parse_to_dict
(
request_data
)
yang_validator
.
destroy
()
errors
=
[]
errors
=
list
()
for
vpn_service
in
request_data
[
'
l3vpn-svc
'
][
'
vpn-services
'
][
'
vpn-service
'
]:
process_vpn_service
(
vpn_service
,
errors
)
...
...
@@ -48,6 +77,4 @@ class L3VPN_Services(Resource):
for
site
in
request_data
[
'
l3vpn-svc
'
][
'
sites
'
][
'
site
'
]:
process_site
(
site
,
errors
)
response
=
jsonify
(
errors
)
response
.
status_code
=
HTTP_CREATED
if
len
(
errors
)
==
0
else
HTTP_SERVERERROR
return
response
return
errors
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