Commit 2bd48024 authored by Javier Velázquez's avatar Javier Velázquez Committed by Julien Satti
Browse files

Initial code upload

parent a19c8cfe
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+4 −0
Original line number Diff line number Diff line
__pycache__/
swagger/__pycache__/
src/__pycache__/
+63 −59
Original line number Diff line number Diff line
# NSC
# Network Slice Controller (NSC) Architecture

The Network Slice Controller (NSC) is a component defined by the IETF to orchestrate the request, realization, and lifecycle control of network slices. It consists of two main modules: the mapper and the realizer. 

## Overview

## Getting started
The NSC handles end-to-end network slice requests originating from 5G customers. These requests are managed by the 5G end-to-end orchestrator, which configures RAN and Core Network elements accordingly and passes the request to the NSC for processing. The NSC then interacts with relevant network controllers to implement the network slice into the transport network.

To make it easy for you to get started with GitLab, here's a list of recommended next steps.
## Main Modules

Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
### Mapper

## Add your files
The mapper processes client network slice requests and correlates them with existing slices. When a slice request arrives, the mapper translates it by converting the request expressed in 3GPP NRM terms into the IETF NBI data model. This involves identifying the service demarcation points (SDPs) that define the connectivity in the transport network. Once these parameters are identified and mapped into the data model, the next step is to check the feasibility of implementing the slice request.

- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
Realizing a slice requires an existing network resource partition (NRP) with the specified slice requirements, which may not be available at the time of the request. This information will be retrieved from an external module, which is beyond the scope of this definition. This module will provide a response regarding the feasibility of realizing the slice.

```
cd existing_repo
git remote add origin https://labs.etsi.org/rep/tfs/nsc.git
git branch -M main
git push -uf origin main
```

## Integrate with your tools
If there are no available NRPs for instantiating the slice, the mapper will request the realizer to create a new NRP. This involves interacting with the network controllers responsible for the transport network handled by the NSC. This process is iterative until the mapper determines that the slice realization is feasible. In the current version, it is assumed that there is only one available NRP corresponding to the entire network, and that it is always accessible to the user.

- [ ] [Set up project integrations](https://labs.etsi.org/rep/tfs/nsc/-/settings/integrations)
### Realizer

## Collaborate with your team
The realizer module determines the realization of each slice by interacting with specific network controllers. This version is currently working with Teraflow SDN controller. It receives requests from the mapper and decides on the technologies to be used to instantiate the slice based on the selected NRP associated with the slice. For example, Layer 2 VPN is the technology employed to realize network slices in this version. To achieve this, the realizer generates a request for the network controller to establish a Layer 2 VPN between two SDPs with the requirements specified in the slice request.

- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Workflow

## Test and Deploy
1. **Request Initiation**: Network slice request originates from a 5G customer and is managed by the 5G end-to-end orchestrator.

Use the built-in continuous integration in GitLab.
2. **Mapper Processing**: Converts the request into the IETF NBI data model, identifies SDPs, and checks feasibility.

- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
3. **Realizer Action**: Determines technology (e.g., Layer 2 VPN) and interacts with network controllers to instantiate the slice.

***
4. **Implementation**: Network controllers configure the transport network as per the slice requirements.

# Editing this README
## Arquitecture

When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
<img src="images/NSC_Architecture.png" alt="NSC Architecture">

## Suggestions for a good README
## Requirements
- Python3
- python3-pip
- python3-venv

Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Configuration Constants

## Name
Choose a self-explaining name for your project.
In the main configuration file, several constants can be adjusted to customize the Network Slice Controller (NSC) behavior:

## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
### Logging
- `DEFAULT_LOGGING_LEVEL`: Sets logging verbosity
  - Default: `logging.INFO`
  - Options: `logging.DEBUG`, `logging.INFO`, `logging.WARNING`, `logging.ERROR`

## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
### Server
- `NSC_PORT`: Server port
  - Default: `8081`

## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
### Paths
- `SRC_PATH`: Absolute path to source directory
- `TEMPLATES_PATH`: Path to templates directory

## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
### Teraflow Configuration
- `TFS_UPLOAD`: Enable/disable uploading slice service to Teraflow
  - Default: `False`
- `TFS_IP`: Teraflow SDN controller IP
  - Default: `"192.168.165.10"`
- `TFS_L2VPN_SUPPORT`: Enable additional L2VPN configuration support
  - Default: `False`

## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.

## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
To deploy and execute the NSC, follow these steps:

0. **Preparation**
    ```
    git clone https://github.com/Telefonica/network_slice_controller.git
    cd network_slice_controller
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    ```

1. **Start NSC Server**:
    ```
    python3 app.py
    ```

## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
2. **Generate Slice Requests**:

## Contributing
State if you are open to contributions and what your requirements are for accepting them.
    To send slice request, the NSC accepts POST request at the endpoint /slice. It is available in the swagger documentation panel at {ip}:{NSC_PORT}/nsc

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
<!-- ## Versioning and Assumptions

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
- The current version assumes a single available Network Resource Partition (NRP) for the entire network.
- It interacts with specific network controllers tailored to the technology required for slice instantiation (e.g., Teraflow SDN controller).

## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## External Modules

## License
For open source projects, say how it is licensed.
The planner module, which is out of the scope of this development, provides information on NRP availability and feasibility of slice realization. -->
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

app.py

0 → 100644
+37 −0
Original line number Diff line number Diff line
# Copyright 2025 Telefonica Innovación Digital S.L.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from flask import Flask
from flask_restx import Api
from flask_cors import CORS
from swagger.slice_namespace import slice_ns
from src.Constants import NSC_PORT

app = Flask(__name__)
CORS(app)

# Create API instance
api = Api(
    app,
    version="1.0",
    title="Network Slice Controller (NSC) API",
    description="API for orchestrating and realizing transport network slice requests",
    doc="/nsc"  # Swagger UI URL
)

# Register namespaces
api.add_namespace(slice_ns, path="/slice")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=NSC_PORT, debug=True)
+252 KiB
Loading image diff...

requirements.txt

0 → 100644
+5 −0
Original line number Diff line number Diff line
Flask
flask-cors
flask-restx
netmiko
requests
Loading