Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GET operations for DeviceGroups and Network Slices #81

Merged
merged 16 commits into from Oct 18, 2023

Conversation

ghislainbourgeois
Copy link
Contributor

@ghislainbourgeois ghislainbourgeois commented Jun 9, 2023

This PR goal is to introduce GET operations to the API for DeviceGroups and Network Slices. To do so, the following changes were needed:

  1. Move the snapshots from in-memory maps to Mongo in new collections
  2. Add GET operations for DeviceGroups and Slices, looking up in those new Mongo collections
  3. Add some unit tests for the new code
  4. Add test target to the Makefile
  5. Add GitHub workflow to run the unit tests

The larger goal is to be able to create a simple web application to configure SD-Core without requiring a full Aether installation for simple use cases.

Previously, device groups and slices were stored only in memory and used
to detect devices added or removed. This was susceptible to cause issue
whenever the webconsole service restarted, losing some context.

This change will also allow the addition of GET operations for
DeviceGroups and NetworkSlices.
@onf-bot
Copy link
Contributor

onf-bot commented Jun 9, 2023

Can one of the admins verify this patch?

1 similar comment
@onf-bot
Copy link
Contributor

onf-bot commented Jun 9, 2023

Can one of the admins verify this patch?

@thakurajayL
Copy link
Contributor

add to whiltelist

@thakurajayL
Copy link
Contributor

ok to test

@ghislainbourgeois
Copy link
Contributor Author

@thakurajayL my org has now signed the CLA, this should be ready for review, sorry it took that long.

@thakurajayL
Copy link
Contributor

add to whitelist

@thakurajayL
Copy link
Contributor

ok to test

@@ -0,0 +1,21 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 Intel Corporation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add ONF copyright

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the copyright.

Dockerfile Outdated
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM golang:1.16.0-stretch AS builder
FROM golang:1.16.0-buster AS builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is buster different than stretch ? You can think of updating golang as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stretch is debian 9, which is an archived release under Extended LTS support. Buster is Debian 10, and it is under regular LTS support. The current stable release would be Bookworm, or Debian 12. I will test for further updates with golang updates that do not require extensive changes.

Debian releases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated to latest go version on latest debian version.

logger.WebUILog.Infoln("Get Device Group by name")

var deviceGroup configmodels.DeviceGroups
filter := bson.M{"DeviceGroupName": c.Param("group-name")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to query the presense of the param? and if present then only go to database.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group-name is a path parameter and is defined in the router. There is no way to get in this function if the param is not there.

logger.WebUILog.Infoln("Get Network Slice by name")

var networkSlice configmodels.Slice
filter := bson.M{"SliceName": c.Param("slice-name")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add check for query param presence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also a path parameter defined in the router.

if networkSlice.SliceName == "" {
c.JSON(http.StatusNotFound, nil)
} else {
c.JSON(http.StatusOK, networkSlice)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share curl command output how it looks like both success & failure case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, in the case that the slice does not exist, we get:

curl -v ${WEBUI_IP}:5000/config/v1/network-slice/default
*   Trying 10.1.213.205:5000...
* Connected to 10.1.213.205 (10.1.213.205) port 5000 (#0)
> GET /config/v1/network-slice/default HTTP/1.1
> Host: 10.1.213.205:5000
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With
< Access-Control-Allow-Methods: POST, OPTIONS, GET, PUT, PATCH, DELETE
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Date: Mon, 11 Sep 2023 20:57:59 GMT
< Content-Length: 4
<
* Connection #0 to host 10.1.213.205 left intact
null

In the case where it exists, we get this:

curl -v ${WEBUI_IP}:5000/config/v1/network-slice/default
*   Trying 10.1.213.205:5000...
* Connected to 10.1.213.205 (10.1.213.205) port 5000 (#0)
> GET /config/v1/network-slice/default HTTP/1.1
> Host: 10.1.213.205:5000
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With
< Access-Control-Allow-Methods: POST, OPTIONS, GET, PUT, PATCH, DELETE
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Date: Mon, 11 Sep 2023 20:59:34 GMT
< Content-Length: 238
<
* Connection #0 to host 10.1.213.205 left intact
{"SliceName":"default","slice-id":{"sst":"1","sd":"010203"},"site-device-group":["cows"],"site-info":{"site-name":"demo","plmn":{"mcc":"208","mnc":"93"},"gNodeBs":[{"name":"demo-gnb1","tac":1}],"upf":{"upf-name":"upf","upf-port":"8805"}}}

configmodels/model_device_groups.go Outdated Show resolved Hide resolved
@thakurajayL
Copy link
Contributor

add to whitelist

@thakurajayL
Copy link
Contributor

ok to test

@thakurajayL
Copy link
Contributor

retest this please

@onf-bot
Copy link
Contributor

onf-bot commented Oct 12, 2023

test this please

1 similar comment
@onf-bot
Copy link
Contributor

onf-bot commented Oct 12, 2023

test this please

@thakurajayL thakurajayL merged commit a21ec74 into omec-project:master Oct 18, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants