Skip to content

Commit 05a4cb0

Browse files
authored
Merge pull request #51 from medianetlab/develop
Develop
2 parents cb25ef6 + a674f56 commit 05a4cb0

24 files changed

+503
-614
lines changed

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
# Changelog
22

3+
## v1.6.0
4+
5+
***Summary:***
6+
7+
> - *This version focuses on specific enchancements for both AsSessionWithQoS and Monitoring Event APIs*
8+
> - *AsSessionWithQoS API*:
9+
> - *Provision of periodic reports, (NetApp indicates the reporting period in sec)*
10+
> - *MonitoringEvent API*:
11+
> - *Addition of LOSS_OF_CONNECTIVITY event, Network detects that the UE is no longer reachable for either signalling or user plane communication. The NetApp may provide a Maximum Detection Time, which indicates the maximum period of time without any communication with the UE (after the UE is considered to be unreachable by the network)*
12+
> - *Addition of UE_REACHABILITY event, which indicates when the UE becomes reachable (for sending downlink data to the UE)*
13+
14+
15+
## UI changes
16+
17+
- 👉 replace common html blocks with reusable Jinja2 templates (header, sidebar, footer)
18+
19+
20+
## Backend
21+
22+
23+
- ➕ Addition of two events on `MonitoringEvent API``/api/v1/3gpp-monitoring-event/v1/{scsAsId}/subscriptions` 👇
24+
- `LOSS_OF_CONNECTIVITY` event
25+
- `UE_REACHABILITY` event
26+
- ➕ Addition of periodic reports for `AsSessionWithQoS API``/api/v1/3gpp-as-session-with-qos/v1/{scsAsId}/subscriptions`
27+
28+
29+
30+
## Database
31+
32+
- Optimization on MongoDB 👇
33+
- MongoClient instance from pymongo module is created once in `backend/app/app/db/session.py`
34+
35+
36+
37+
## Other
38+
39+
-`make logs-backend` : display the logs only in the backend service
40+
-`make logs-mongo` : display the logs only for mongo service
41+
42+
43+
<br><br>
44+
45+
346
## v1.5.0
447

548
***Summary:***

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ build-no-cache:
3838
logs:
3939
docker-compose logs -f
4040

41+
logs-backend:
42+
docker-compose logs -f backend
43+
44+
logs-mongo:
45+
docker-compose logs -f mongo
46+
4147
ps:
4248
docker ps -a
4349

backend/app/app/api/api_v1/endpoints/monitoringevent.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from app.crud import crud_mongo, user, ue
99
from app.api import deps
1010
from app import tools
11+
from app.db.session import client
1112
from app.api.api_v1.endpoints.utils import add_notifications
1213
from .ue_movement import retrieve_ue_state, retrieve_ue
1314

@@ -18,13 +19,14 @@
1819
def read_active_subscriptions(
1920
*,
2021
scsAsId: str = Path(..., title="The ID of the Netapp that read all the subscriptions", example="myNetapp"),
21-
db_mongo: Database = Depends(deps.get_mongo_db),
2222
current_user: models.User = Depends(deps.get_current_active_user),
2323
http_request: Request
2424
) -> Any:
2525
"""
2626
Read all active subscriptions
2727
"""
28+
db_mongo = client.fastapi
29+
2830
retrieved_docs = crud_mongo.read_all(db_mongo, db_collection, current_user.id)
2931
temp_json_subs = retrieved_docs.copy() #Create copy of the list (json_subs) -> you cannot remove items from a list while you iterating the list.
3032

@@ -58,14 +60,15 @@ def create_subscription(
5860
*,
5961
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
6062
db: Session = Depends(deps.get_db),
61-
db_mongo: Database = Depends(deps.get_mongo_db),
6263
item_in: schemas.MonitoringEventSubscriptionCreate,
6364
current_user: models.User = Depends(deps.get_current_active_user),
6465
http_request: Request
6566
) -> Any:
6667
"""
6768
Create new subscription.
6869
"""
70+
db_mongo = client.fastapi
71+
6972
UE = ue.get_externalId(db=db, externalId=str(item_in.externalId), owner_id=current_user.id)
7073
if not UE:
7174
raise HTTPException(status_code=409, detail="UE with this external identifier doesn't exist")
@@ -122,7 +125,7 @@ def create_subscription(
122125
add_notifications(http_request, http_response, False)
123126

124127
return http_response
125-
elif item_in.monitoringType == "LOSS_OF_CONNECTIVITY" and item_in.maximumNumberOfReports == 1:
128+
elif (item_in.monitoringType == "LOSS_OF_CONNECTIVITY" or item_in.monitoringType == "UE_REACHABILITY") and item_in.maximumNumberOfReports == 1:
126129
return JSONResponse(content=jsonable_encoder(
127130
{
128131
"title" : "The requested parameters are out of range",
@@ -132,7 +135,7 @@ def create_subscription(
132135
}
133136
}
134137
), status_code=403)
135-
elif item_in.monitoringType == "LOSS_OF_CONNECTIVITY" and item_in.maximumNumberOfReports > 1:
138+
elif (item_in.monitoringType == "LOSS_OF_CONNECTIVITY" or item_in.monitoringType == "UE_REACHABILITY") and item_in.maximumNumberOfReports > 1:
136139
#Check if subscription with externalid && monitoringType exists
137140
if crud_mongo.read_by_multiple_pairs(db_mongo, db_collection, externalId = item_in.externalId, monitoringType = item_in.monitoringType):
138141
raise HTTPException(status_code=409, detail=f"There is already an active subscription for UE with external id {item_in.externalId} - Monitoring Type = {item_in.monitoringType}")
@@ -165,14 +168,15 @@ def update_subscription(
165168
*,
166169
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
167170
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
168-
db_mongo: Database = Depends(deps.get_mongo_db),
169171
item_in: schemas.MonitoringEventSubscriptionCreate,
170172
current_user: models.User = Depends(deps.get_current_active_user),
171173
http_request: Request
172174
) -> Any:
173175
"""
174176
Update/Replace an existing subscription resource
175177
"""
178+
db_mongo = client.fastapi
179+
176180
try:
177181
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
178182
except Exception as ex:
@@ -209,13 +213,14 @@ def read_subscription(
209213
*,
210214
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
211215
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
212-
db_mongo: Database = Depends(deps.get_mongo_db),
213216
current_user: models.User = Depends(deps.get_current_active_user),
214217
http_request: Request
215218
) -> Any:
216219
"""
217220
Get subscription by id
218221
"""
222+
db_mongo = client.fastapi
223+
219224
try:
220225
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
221226
except Exception as ex:
@@ -245,13 +250,14 @@ def delete_subscription(
245250
*,
246251
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
247252
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
248-
db_mongo: Database = Depends(deps.get_mongo_db),
249253
current_user: models.User = Depends(deps.get_current_active_user),
250254
http_request: Request
251255
) -> Any:
252256
"""
253257
Delete a subscription
254258
"""
259+
db_mongo = client.fastapi
260+
255261
try:
256262
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
257263
except Exception as ex:

backend/app/app/api/api_v1/endpoints/qosInformation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi.responses import JSONResponse
44
from pymongo.database import Database
55
from sqlalchemy.orm.session import Session
6-
6+
from app.db.session import client
77
from app import models
88
from app.api import deps
99
from app.core.config import qosSettings
@@ -53,12 +53,13 @@ def read_qos_active_profiles(
5353
gNB_id: str = Path(..., title="The ID of the gNB", example="AAAAA1"),
5454
current_user: models.User = Depends(deps.get_current_active_user),
5555
http_request: Request,
56-
db_mongo: Database = Depends(deps.get_mongo_db),
5756
db: Session = Depends(deps.get_db)
5857
) -> Any:
5958
"""
6059
Get the available QoS Characteristics
6160
"""
61+
db_mongo = client.fastapi
62+
6263
gNB = gnb.get_gNB_id(db=db, id=gNB_id)
6364
if not gNB:
6465
raise HTTPException(status_code=404, detail="gNB not found")

backend/app/app/api/api_v1/endpoints/qosMonitoring.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from app import models, schemas
99
from app.api import deps
1010
from app.crud import crud_mongo, user, ue
11+
from app.db.session import client
1112
from .utils import add_notifications
1213
from .qosInformation import qos_reference_match
1314

@@ -18,13 +19,13 @@
1819
def read_active_subscriptions(
1920
*,
2021
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
21-
db_mongo: Database = Depends(deps.get_mongo_db),
2222
current_user: models.User = Depends(deps.get_current_active_user),
2323
http_request: Request
2424
) -> Any:
2525
"""
2626
Get subscription by id
2727
"""
28+
db_mongo = client.fastapi
2829
retrieved_docs = crud_mongo.read_all(db_mongo, db_collection, current_user.id)
2930

3031
#Check if there are any active subscriptions
@@ -47,22 +48,25 @@ def monitoring_notification(body: schemas.UserPlaneNotificationData):
4748
def create_subscription(
4849
*,
4950
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
50-
db_mongo: Database = Depends(deps.get_mongo_db),
5151
db: Session = Depends(deps.get_db),
5252
item_in: schemas.AsSessionWithQoSSubscriptionCreate,
5353
current_user: models.User = Depends(deps.get_current_active_user),
5454
http_request: Request
5555
) -> Any:
5656

57+
db_mongo = client.fastapi
58+
5759
json_request = jsonable_encoder(item_in)
5860
#Currently only EVENT_TRIGGERED is supported
5961
fiveG_qi = qos_reference_match(item_in.qosReference)
6062
if fiveG_qi.get('type') == 'GBR' or fiveG_qi.get('type') == 'DC-GBR':
6163
if (json_request['qosMonInfo'] == None) or (json_request['qosMonInfo']['repFreqs'] == None):
6264
raise HTTPException(status_code=400, detail="Please enter a value in repFreqs field")
63-
else:
64-
if 'EVENT_TRIGGERED' not in json_request['qosMonInfo']['repFreqs']:
65-
raise HTTPException(status_code=400, detail="Only 'EVENT_TRIGGERED' reporting frequency is supported at the current version. Please enter 'EVENT_TRIGGERED' in repFreqs field")
65+
66+
print(f'------------------------------------Curl from script {item_in.ipv4Addr}')
67+
# else:
68+
# if 'EVENT_TRIGGERED' not in json_request['qosMonInfo']['repFreqs']:
69+
# raise HTTPException(status_code=400, detail="Only 'EVENT_TRIGGERED' reporting frequency is supported at the current version. Please enter 'EVENT_TRIGGERED' in repFreqs field")
6670

6771

6872
#Ensure that the user sends only one of the ipv4, ipv6, macAddr fields
@@ -134,13 +138,13 @@ def read_subscription(
134138
*,
135139
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
136140
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
137-
db_mongo: Database = Depends(deps.get_mongo_db),
138141
current_user: models.User = Depends(deps.get_current_active_user),
139142
http_request: Request
140143
) -> Any:
141144
"""
142145
Get subscription by id
143146
"""
147+
db_mongo = client.fastapi
144148

145149
try:
146150
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
@@ -165,13 +169,13 @@ def update_subscription(
165169
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
166170
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
167171
item_in: schemas.AsSessionWithQoSSubscriptionCreate,
168-
db_mongo: Database = Depends(deps.get_mongo_db),
169172
current_user: models.User = Depends(deps.get_current_active_user),
170173
http_request: Request
171174
) -> Any:
172175
"""
173176
Update subscription by id
174177
"""
178+
db_mongo = client.fastapi
175179

176180
try:
177181
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
@@ -201,13 +205,14 @@ def delete_subscription(
201205
*,
202206
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
203207
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
204-
db_mongo: Database = Depends(deps.get_mongo_db),
205208
current_user: models.User = Depends(deps.get_current_active_user),
206209
http_request: Request
207210
) -> Any:
208211
"""
209212
Delete a subscription
210213
"""
214+
db_mongo = client.fastapi
215+
211216
try:
212217
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
213218
except Exception as ex:

0 commit comments

Comments
 (0)