Skip to content

Commit

Permalink
Merge pull request medianetlab#51 from medianetlab/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
JFrgs authored Aug 23, 2022
2 parents cb25ef6 + a674f56 commit 05a4cb0
Show file tree
Hide file tree
Showing 24 changed files with 503 additions and 614 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# Changelog

## v1.6.0

***Summary:***

> - *This version focuses on specific enchancements for both AsSessionWithQoS and Monitoring Event APIs*
> - *AsSessionWithQoS API*:
> - *Provision of periodic reports, (NetApp indicates the reporting period in sec)*
> - *MonitoringEvent API*:
> - *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)*
> - *Addition of UE_REACHABILITY event, which indicates when the UE becomes reachable (for sending downlink data to the UE)*

## UI changes

- 👉 replace common html blocks with reusable Jinja2 templates (header, sidebar, footer)


## Backend


- ➕ Addition of two events on `MonitoringEvent API``/api/v1/3gpp-monitoring-event/v1/{scsAsId}/subscriptions` 👇
- `LOSS_OF_CONNECTIVITY` event
- `UE_REACHABILITY` event
- ➕ Addition of periodic reports for `AsSessionWithQoS API``/api/v1/3gpp-as-session-with-qos/v1/{scsAsId}/subscriptions`



## Database

- Optimization on MongoDB 👇
- MongoClient instance from pymongo module is created once in `backend/app/app/db/session.py`



## Other

-`make logs-backend` : display the logs only in the backend service
-`make logs-mongo` : display the logs only for mongo service


<br><br>


## v1.5.0

***Summary:***
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ build-no-cache:
logs:
docker-compose logs -f

logs-backend:
docker-compose logs -f backend

logs-mongo:
docker-compose logs -f mongo

ps:
docker ps -a

Expand Down
20 changes: 13 additions & 7 deletions backend/app/app/api/api_v1/endpoints/monitoringevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from app.crud import crud_mongo, user, ue
from app.api import deps
from app import tools
from app.db.session import client
from app.api.api_v1.endpoints.utils import add_notifications
from .ue_movement import retrieve_ue_state, retrieve_ue

Expand All @@ -18,13 +19,14 @@
def read_active_subscriptions(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that read all the subscriptions", example="myNetapp"),
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Read all active subscriptions
"""
db_mongo = client.fastapi

retrieved_docs = crud_mongo.read_all(db_mongo, db_collection, current_user.id)
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.

Expand Down Expand Up @@ -58,14 +60,15 @@ def create_subscription(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
db: Session = Depends(deps.get_db),
db_mongo: Database = Depends(deps.get_mongo_db),
item_in: schemas.MonitoringEventSubscriptionCreate,
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Create new subscription.
"""
db_mongo = client.fastapi

UE = ue.get_externalId(db=db, externalId=str(item_in.externalId), owner_id=current_user.id)
if not UE:
raise HTTPException(status_code=409, detail="UE with this external identifier doesn't exist")
Expand Down Expand Up @@ -122,7 +125,7 @@ def create_subscription(
add_notifications(http_request, http_response, False)

return http_response
elif item_in.monitoringType == "LOSS_OF_CONNECTIVITY" and item_in.maximumNumberOfReports == 1:
elif (item_in.monitoringType == "LOSS_OF_CONNECTIVITY" or item_in.monitoringType == "UE_REACHABILITY") and item_in.maximumNumberOfReports == 1:
return JSONResponse(content=jsonable_encoder(
{
"title" : "The requested parameters are out of range",
Expand All @@ -132,7 +135,7 @@ def create_subscription(
}
}
), status_code=403)
elif item_in.monitoringType == "LOSS_OF_CONNECTIVITY" and item_in.maximumNumberOfReports > 1:
elif (item_in.monitoringType == "LOSS_OF_CONNECTIVITY" or item_in.monitoringType == "UE_REACHABILITY") and item_in.maximumNumberOfReports > 1:
#Check if subscription with externalid && monitoringType exists
if crud_mongo.read_by_multiple_pairs(db_mongo, db_collection, externalId = item_in.externalId, monitoringType = item_in.monitoringType):
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}")
Expand Down Expand Up @@ -165,14 +168,15 @@ def update_subscription(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
db_mongo: Database = Depends(deps.get_mongo_db),
item_in: schemas.MonitoringEventSubscriptionCreate,
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Update/Replace an existing subscription resource
"""
db_mongo = client.fastapi

try:
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
except Exception as ex:
Expand Down Expand Up @@ -209,13 +213,14 @@ def read_subscription(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Get subscription by id
"""
db_mongo = client.fastapi

try:
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
except Exception as ex:
Expand Down Expand Up @@ -245,13 +250,14 @@ def delete_subscription(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Delete a subscription
"""
db_mongo = client.fastapi

try:
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
except Exception as ex:
Expand Down
5 changes: 3 additions & 2 deletions backend/app/app/api/api_v1/endpoints/qosInformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi.responses import JSONResponse
from pymongo.database import Database
from sqlalchemy.orm.session import Session

from app.db.session import client
from app import models
from app.api import deps
from app.core.config import qosSettings
Expand Down Expand Up @@ -53,12 +53,13 @@ def read_qos_active_profiles(
gNB_id: str = Path(..., title="The ID of the gNB", example="AAAAA1"),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request,
db_mongo: Database = Depends(deps.get_mongo_db),
db: Session = Depends(deps.get_db)
) -> Any:
"""
Get the available QoS Characteristics
"""
db_mongo = client.fastapi

gNB = gnb.get_gNB_id(db=db, id=gNB_id)
if not gNB:
raise HTTPException(status_code=404, detail="gNB not found")
Expand Down
21 changes: 13 additions & 8 deletions backend/app/app/api/api_v1/endpoints/qosMonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from app import models, schemas
from app.api import deps
from app.crud import crud_mongo, user, ue
from app.db.session import client
from .utils import add_notifications
from .qosInformation import qos_reference_match

Expand All @@ -18,13 +19,13 @@
def read_active_subscriptions(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Get subscription by id
"""
db_mongo = client.fastapi
retrieved_docs = crud_mongo.read_all(db_mongo, db_collection, current_user.id)

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

db_mongo = client.fastapi

json_request = jsonable_encoder(item_in)
#Currently only EVENT_TRIGGERED is supported
fiveG_qi = qos_reference_match(item_in.qosReference)
if fiveG_qi.get('type') == 'GBR' or fiveG_qi.get('type') == 'DC-GBR':
if (json_request['qosMonInfo'] == None) or (json_request['qosMonInfo']['repFreqs'] == None):
raise HTTPException(status_code=400, detail="Please enter a value in repFreqs field")
else:
if 'EVENT_TRIGGERED' not in json_request['qosMonInfo']['repFreqs']:
raise HTTPException(status_code=400, detail="Only 'EVENT_TRIGGERED' reporting frequency is supported at the current version. Please enter 'EVENT_TRIGGERED' in repFreqs field")

print(f'------------------------------------Curl from script {item_in.ipv4Addr}')
# else:
# if 'EVENT_TRIGGERED' not in json_request['qosMonInfo']['repFreqs']:
# raise HTTPException(status_code=400, detail="Only 'EVENT_TRIGGERED' reporting frequency is supported at the current version. Please enter 'EVENT_TRIGGERED' in repFreqs field")


#Ensure that the user sends only one of the ipv4, ipv6, macAddr fields
Expand Down Expand Up @@ -134,13 +138,13 @@ def read_subscription(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Get subscription by id
"""
db_mongo = client.fastapi

try:
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
Expand All @@ -165,13 +169,13 @@ def update_subscription(
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
item_in: schemas.AsSessionWithQoSSubscriptionCreate,
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Update subscription by id
"""
db_mongo = client.fastapi

try:
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
Expand Down Expand Up @@ -201,13 +205,14 @@ def delete_subscription(
*,
scsAsId: str = Path(..., title="The ID of the Netapp that creates a subscription", example="myNetapp"),
subscriptionId: str = Path(..., title="Identifier of the subscription resource"),
db_mongo: Database = Depends(deps.get_mongo_db),
current_user: models.User = Depends(deps.get_current_active_user),
http_request: Request
) -> Any:
"""
Delete a subscription
"""
db_mongo = client.fastapi

try:
retrieved_doc = crud_mongo.read_uuid(db_mongo, db_collection, subscriptionId)
except Exception as ex:
Expand Down
Loading

0 comments on commit 05a4cb0

Please sign in to comment.