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
df8de42a
Commit
df8de42a
authored
6 months ago
by
Mohamad Rahhal
Browse files
Options
Downloads
Patches
Plain Diff
intermediate backup
parent
23ebe4eb
No related branches found
No related tags found
No related merge requests found
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py
+18
-12
18 additions, 12 deletions
...i/service/rest_server/nbi_plugins/camara_qod/Resources.py
src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py
+2
-2
2 additions, 2 deletions
src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py
with
20 additions
and
14 deletions
src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py
+
18
−
12
View file @
df8de42a
...
@@ -94,6 +94,15 @@ class ProfileDetail(_Resource):
...
@@ -94,6 +94,15 @@ class ProfileDetail(_Resource):
except
Exception
as
e
:
except
Exception
as
e
:
LOGGER
.
error
(
f
"
Error while fetching QoSProfile:
{
e
}
"
)
LOGGER
.
error
(
f
"
Error while fetching QoSProfile:
{
e
}
"
)
return
{
"
error
"
:
"
Internal Server Error
"
},
500
return
{
"
error
"
:
"
Internal Server Error
"
},
500
def
get
(
self
,
QoDConstraintsRequest
):
qos_profiles
=
self
.
qos_profile_client
.
GetConstraintListFromQoSProfile
(
QoDConstraintsRequest
)
qos_profile_list
=
[]
#since it iterates over QoSProfile , create a list to store all QOS profiles
for
qos_profile
in
qos_profiles
:
qos_profile_data
=
grpc_message_to_qos_table_data
(
qos_profile
)
#transform to json
qos_profile_list
.
append
(
qos_profile_data
)
# append to the list
return
jsonify
(
qos_profile_list
)
def
put
(
self
,
qos_profile_id
):
def
put
(
self
,
qos_profile_id
):
try
:
try
:
...
@@ -155,12 +164,14 @@ class qodinfo(_Resource):
...
@@ -155,12 +164,14 @@ class qodinfo(_Resource):
def
post
(
self
):
def
post
(
self
):
if
not
request
.
is_json
:
if
not
request
.
is_json
:
return
(
jsonify
({
'
error
'
:
'
Unsupported Media Type
'
,
'
message
'
:
'
JSON payload is required
'
}),
415
)
return
(
jsonify
({
'
error
'
:
'
Unsupported Media Type
'
,
'
message
'
:
'
JSON payload is required
'
}),
415
)
request_data
:
Dict
=
request
.
get_json
()
request_data
:
Dict
=
request
.
get_json
()
qos_profile_id
=
request_data
.
get
(
'
qos_profile_id
'
)
qos_profile_id
=
request_data
.
get
(
'
qos_profile_id
'
)
qos_session_id
=
request_data
.
get
(
'
qos_session_id
'
)
LOGGER
.
info
(
f
'
qos_profile_id:
{
qos_profile_id
}
'
)
LOGGER
.
info
(
f
'
qos_profile_id:
{
qos_profile_id
}
'
)
if
not
qos_profile_id
:
if
not
qos_profile_id
:
return
jsonify
({
'
error
'
:
'
qos_profile_id is required
'
}),
400
return
jsonify
({
'
error
'
:
'
qos_profile_id is required
'
}),
400
if
qos_session_id
:
return
jsonify
({
'
error
'
:
'
qos_session_id is not allowed in creation
'
}),
400
service
=
QOD_2_service
(
self
.
client
,
request_data
,
qos_profile_id
)
service
=
QOD_2_service
(
self
.
client
,
request_data
,
qos_profile_id
)
stripped_service
=
copy
.
deepcopy
(
service
)
stripped_service
=
copy
.
deepcopy
(
service
)
stripped_service
.
ClearField
(
'
service_endpoint_ids
'
)
stripped_service
.
ClearField
(
'
service_endpoint_ids
'
)
...
@@ -180,11 +191,7 @@ class qodinfo(_Resource):
...
@@ -180,11 +191,7 @@ class qodinfo(_Resource):
qod_info
=
[
service_2_qod
(
service
)
for
service
in
service_list
.
services
]
qod_info
=
[
service_2_qod
(
service
)
for
service
in
service_list
.
services
]
LOGGER
.
info
(
f
"
error related to qod_info:
{
qod_info
}
"
)
LOGGER
.
info
(
f
"
error related to qod_info:
{
qod_info
}
"
)
return
qod_info
return
qod_info
class
qodinfoId
(
_Resource
):
class
qodinfoId
(
_Resource
):
def
get
(
self
,
sessionId
:
str
):
def
get
(
self
,
sessionId
:
str
):
...
@@ -199,21 +206,21 @@ class qodinfoId(_Resource):
...
@@ -199,21 +206,21 @@ class qodinfoId(_Resource):
def
put
(
self
,
sessionId
:
str
):
def
put
(
self
,
sessionId
:
str
):
try
:
try
:
request_data
:
Dict
=
request
.
get_json
()
request_data
:
Dict
=
request
.
get_json
()
session
Id
=
request_data
.
get
(
'
session_id
'
)
session
_id
=
request_data
.
get
(
'
session_id
'
)
if
not
session
I
d
:
if
not
session
_i
d
:
return
jsonify
({
'
error
'
:
'
sessionId is required
'
}),
400
return
jsonify
({
'
error
'
:
'
sessionId is required
'
}),
400
qos_profile_id
=
request_data
.
get
(
'
qos_profile_id
'
)
qos_profile_id
=
request_data
.
get
(
'
qos_profile_id
'
)
if
not
qos_profile_id
:
if
not
qos_profile_id
:
return
jsonify
({
'
error
'
:
'
qos_profile_id is required
'
}),
400
return
jsonify
({
'
error
'
:
'
qos_profile_id is required
'
}),
400
service
=
QOD_2_service
(
self
.
client
,
request_data
,
qos_profile_i
d
)
service
=
self
.
client
.
GetService
(
grpc_service_id
(
DEFAULT_CONTEXT_NAME
,
sessionI
d
)
)
updated_service
=
self
.
service_client
.
UpdateService
(
service
)
updated_service
=
self
.
service_client
.
UpdateService
(
service
)
qod_response
=
service_2_qod
(
updated_service
)
qod_response
=
service_2_qod
(
updated_service
)
return
qod_response
,
200
return
qod_response
,
200
except
KeyError
as
e
:
except
KeyError
as
e
:
LOGGER
.
error
(
f
"
Missing required key:
{
e
}
"
)
LOGGER
.
error
(
f
"
Missing required key:
{
e
}
"
)
return
{
"
error
"
:
f
"
Missing required key:
{
str
(
e
)
}
"
},
400
return
{
"
error
"
:
f
"
Missing required key:
{
str
(
e
)
}
"
},
400
except
grpc
.
_channel
.
_InactiveRpcError
as
exc
:
except
grpc
.
_channel
.
_InactiveRpcError
as
exc
:
if
exc
.
code
()
==
grpc
.
StatusCode
.
NOT_FOUND
:
if
exc
.
code
()
==
grpc
.
StatusCode
.
NOT_FOUND
:
LOGGER
.
warning
(
f
"
Qod Session not found:
{
sessionId
}
"
)
LOGGER
.
warning
(
f
"
Qod Session not found:
{
sessionId
}
"
)
...
@@ -223,7 +230,6 @@ class qodinfoId(_Resource):
...
@@ -223,7 +230,6 @@ class qodinfoId(_Resource):
except
Exception
as
e
:
except
Exception
as
e
:
LOGGER
.
error
(
f
"
Error in PUT /sessions/
{
sessionId
}
:
{
e
}
"
)
LOGGER
.
error
(
f
"
Error in PUT /sessions/
{
sessionId
}
:
{
e
}
"
)
return
{
"
error
"
:
"
Internal Server Error
"
},
500
return
{
"
error
"
:
"
Internal Server Error
"
},
500
def
delete
(
self
,
sessionId
:
str
):
def
delete
(
self
,
sessionId
:
str
):
self
.
service_client
.
DeleteService
(
grpc_service_id
(
DEFAULT_CONTEXT_NAME
,
sessionId
))
self
.
service_client
.
DeleteService
(
grpc_service_id
(
DEFAULT_CONTEXT_NAME
,
sessionId
))
...
...
This diff is collapsed.
Click to expand it.
src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py
+
2
−
2
View file @
df8de42a
...
@@ -27,8 +27,8 @@ from common.tools.object_factory.Service import json_service_id
...
@@ -27,8 +27,8 @@ from common.tools.object_factory.Service import json_service_id
from
uuid
import
uuid4
from
uuid
import
uuid4
from
nbi.service.rest_server.nbi_plugins.ietf_network.bindings.networks
import
network
from
nbi.service.rest_server.nbi_plugins.ietf_network.bindings.networks
import
network
from
qos_profile.client.QoSProfileClient
import
QoSProfileClient
from
qos_profile.client.QoSProfileClient
import
QoSProfileClient
from
context.service.database.QoSProfile
import
grpc_message_to_qos_table_data
#
from context.service.database.QoSProfile import grpc_message_to_qos_table_data
from
common.proto.context_pb2
import
QoSProfile
,
QoSProfileId
,
Uuid
,
QoSProfileValueUnitPair
,
Empty
from
common.proto.context_pb2
import
QoSProfile
,
QoSProfileId
,
Uuid
,
QoSProfileValueUnitPair
,
Empty
,
ServiceId
import
logging
import
logging
import
grpc
import
grpc
from
netaddr
import
IPAddress
,
IPNetwork
from
netaddr
import
IPAddress
,
IPNetwork
...
...
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