Giter Club home page Giter Club logo

tng-sdk-package's Introduction

Join the chat at https://gitter.im/sonata-nfv/Lobby Build Status

tng-sdk-package

This repository contains the tng-sdk-package component that is part of the European H2020 project 5GTANGO NFV SDK. This component is responsible to create and unpack 5GTANGO service, VNF, and test packages. The seed code of this component is based on the son-cli toolbox that was developed as part of the European H2020 project SONATA.

To simplify the creation and extraction of 5GTANGO packages, we develop this packager tool as part of 5GTANGO's SDK. This tool is a complete rewrite of the SONATA packaging tool. The reason for this rewrite is that the 5GANGO packaging tool does not only support and simplifies the package creation but can also be used to unpack packages. For this, the packaging tool can be deployed as a micro service and used, e.g., by the service platform to unpack packages. The clear benefit of this design, compared to the SONATA design in which we used different tools for this, is that only one common codebase needs to be maintained that deals with packages. Thus, code changes, which may be a result of a change in the package format, need only be done in a single component of 5GTANGO. The architecture and design of the packaging tools is described in 5GTANGO D4.1 First open-source release of the SDK toolset in more detail.

Documentation

Besides this README file, more documentation is available in the wiki belonging to this repository. Additional information are available in the project's deliverables:

Installation and Dependencies

This component is implemented in Python3. Its requirements are specified here.

Automated:

The automated installation requires pip (more specifically pip3).

# install official release from PyPi
$ pip install tngsdk.package
# install latest version from GitHub master
$ pip install git+https://github.com/sonata-nfv/tng-sdk-package

Manual:

$ git clone [email protected]:sonata-nfv/tng-sdk-package.git
$ cd tng-sdk-package
$ python setup.py install

Hint:

It is a good practice to first create a new virtual environment in which all 5GTANGO SDK tools can be installed. You can do this as follows:

# get the path to your Python3 installation
which python3

# create a new virtualenv
virtualenv -p <path/to/python3> venv

# activate the virtualenv
source venv/bin/activate

Usage

The packager can either be used as command line tool (CLI mode) or deployed as a micro service which offers a REST API.

CLI mode

Runs the packager locally from the command line. Details about all possible parameters can be shown using:

tng-pkg -h

Packaging

# package a 5GTANGO SDK project
tng-pkg -p misc/5gtango_ns_project_example1

Unpackaging

# unpack a 5GTANGO package to a local 5GTANGO SDK project
tng-pkg -u misc/5gtango-ns-package-example.tgo

Service mode

Runs the packager as a micro service that exposes a REST API.

  • Note: Currently only unpackaging is supported in this mode.

Run tng-sdk-package as a service:

Bare metal
tng-pkg -s
Docker-based
# build Docker container
pipeline/build/build.sh

# run Docker container
docker run --rm -d -p 5099:5099 --name tng-sdk-package registry.sonata-nfv.eu:5000/tng-sdk-package

Unpackaging

# terminal 1 (run tng-sdk-package service)
tng-pkg -s

# terminal 2 (client that sends a package to be unpacked using REST API)
curl -X POST -v -H "Content-Type: multipart/form-data" \
    -F package="@misc/5gtango-ns-package-example.tgo" \
    http://127.0.0.1:5099/api/v1/packages
    
# get status of all known packageing processes
curl -X GET http://127.0.0.1:5099/api/v1/packages/status

Development

To contribute to the development of this 5GTANGO component, you may use the very same development workflow as for any other 5GTANGO Github project. That is, you have to fork the repository and create pull requests.

Setup development environment

$ python setup.py develop

CI Integration

All pull requests are automatically tested by Jenkins and will only be accepted if no test is broken.

Run tests manually

You can also run the test manually on your local machine. To do so, you need to do:

$ pytest -v

Execute full CI pipeline locally:

$ ./pipeline_local.sh

License

This 5GTANGO component is published under Apache 2.0 license. Please see the LICENSE file for more details.


Lead Developers

The following lead developers are responsible for this repository and have admin rights. They can, for example, merge pull requests.

Feedback-Chanel

  • Please use the GitHub issues to report bugs.
  • You may use the mailing list [email protected]

tng-sdk-package's People

Contributors

felipevicens avatar rafaelsche avatar tsoenen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tng-sdk-package's Issues

Upload a package file to the REST API

give transaction UUID as response since the unpackaing should be async

  • implement REST endpint
  • document REST endpoint
  • synchronous vs. asynchronous request handling
  • add a callback mock
  • perform callback after unpackaging
  • improve unittests (for all modules!!!)

Unpack a 5GTANGO package using REST

  • call unpacking using CLI
  • call unpacking using REST
  • unpackaging procedure (TODO more details)
    • create wiki page to document TangoPackager and EtsiPackager
    • extract package file to temp dir.
    • collect all infos about package (define a clear order in which manifests are checked, document it)
      • read TOSCA.meta, ETSI MF, NAPD.yaml
      • validate NAPD against its schema
      • unify metadata from different files (fill empty NAPD skeleton if no NAPD is there)
      • assert that a minimum set of meta data is available or abort packaging process (generic function that should work on all package spec. levels)
    • validate checksums
      • compute and compare checksums
      • error handling CLI mode
      • error handling REST mode
      • --ignore flag
    • add example commands from comments to README.md
    • call storage backend for each extracted artifact
    • generate and return result (w. links if service)
    • REST: send full callback payload (id, metadata, ...) -> return record as result of _do_unpack...
  • ~~~store to local file backend (replaces catalogue for first version)~~~
  • failure management: produce logs in service mode, but do not stop service if something fails
  • IMPORTANT implement specific unittests for 5GTANGO packager (use example package)

Additional features

We might create independent issues for these.

  • CLI mode: nicer output and result overview (cli.py dispatch method)
  • helper to guess mime types (e.g. packager: _etsi_to_napd_package_content)

We skip label and reference support in v0.

Integrate with tng-sdk-validate

If validator is installed, use it.

  • install validator in Docker image (have it always there in service mode)
  • have a command line flag to manually skip validation
  • implement validation as such
    • validate during packaging
      • good case tng-pkg -p misc/5gtango_ns_project_example1/
      • bad case tng-pkg -p misc/5gtango_ns_project_example1_bad/
        • nice error handling
      • add unittest
    • validate during unpackaging (inside Docker!!!!) (problem: we do not always unpackage to a tng-project! solution: run a second project sotrage backend always that unpacks to tmp and validates there)
      • good case tng-pkg -u misc/5gtango-ns-package-example.tgo -o /tmp
      • bad case tng-pkg -u misc/5gtango-ns-package-example-bad.tgo -o /tmp
      • add unittest
  • check that old validation is not called anymore (or keep it as fallback)

Implement/wrap in validation.py

REST: Support packaging of 5GTANGO projects using REST

POST to /project

Input: ZIP file with project structure/files

Processing: Extract ZIP to local FS (temp), run packaging process on it.

Return: Link to *.tgo file for download.

Document: Endpoint documentation using Swagger and Wiki


2019-05-13:

Also have a GET /project that lists all created packages (JSON list with package names, uuids, links)

Pack 5GTANGO packages using CLI

Goal of this issue is to capture the developments needed to enable basic package creation using the 5GTANGO SDK.

Scenario: A NS/VNF/test developer has created a local project using the tng-sdk-project tool and has added files/descriptors to it:

tng-workspace
tng-project -p test_project1

Now she wants to use tng-sdk-package to package this project:

# minimal
tng-pkg -p misc/5gtango_ns_project_example1
# w. more options
tng-pkg -p 5gtango_ns_project_example1 \
    --workspace path/to/workspace \
    --format eu.5gtango
    --output my_package.tgo

The resulting package can be uploaded to the SP/V&V.

Steps to be performed by the packager:

  • find project.yml or project.yaml in path given by -p
  • open, read, validate project.yaml
  • setup unittest
  • create NAPD data structure (use existing NAPDR structure) based on project.yml
  • re-write file paths: descriptors are always put to Definitions (TOSCA)
  • update timestamps
  • compute checksums
  • create a temp. working directory (WD) to build package in
  • (--- from here things depend on output format ---)
  • create empty package skeleton in WD
  • copy all files from project to WD
  • write NAPD (and clean it if needed)
    • add package type (MIME depending on output format)
  • gen. and write ETSI MF (ETSI compatibility)
  • gen. and write TOSCA.meta (TOSCA compatibility)
  • zip WD and write to --output or vender.name.version.tgo in PWD
  • evolve existing unittest
  • add a packager ent-to-end untittest (first package then unpackage)
  • examples to README.md

Refactor `packager.py`

File gets huge. Split it into multiple files. Move helper functions to packager.__init__.py

Have different modules for different package types etc.

packager.tango.py
packager.osm.py

Maybe: packager.commons.py etc.

Support 5GTANGO catalogues as storage backend

  • configure catalogue endpoint with ENV variables using the service's docker file (use localhost as fallback, e.g., local dev env)
  • upload NAPD.yaml (Attention: ETS-only packages would not work with this backend!)
  • upload VNFDs
  • upload NSDs
  • upload TESTDs
  • upload original package file
  • upload other arbitrary files to catalogue (e.g. test binaries)
  • upload additional catalogue support mapping (endpoint in catalog?, implement in _build_catalog_metadata)
    • fix integration bug (400) File with {name => upb_logo.png, uuid => 2dd10810-d608-45cb-8712-4491df20fbca} not found in the Catalogue
  • return package UUID and send it in callback
  • unified upload error handling
  • unit tests for storage.py (currently skip_store=True in test_unit_rest.py, re-enable!)
  • expose skip_store as CLI and ENV config
  • test with all three example packages from tng-schema and misc/

Skip all other files in the first prototype.


ENV variable naming:

 CATALOGUE_URL: http://tng-cat:4011/catalogues/api/v2

CLI: Support unpackaging of 5GTANGO packages using CLI

This one is required for tng-sdk-profile: sonata-nfv/tng-sdk-benchmark#6

The output format should be a TANGO project folder that can be packaged again.

We should implement this as a new storage backend: TangoProjectFileSystemBackend

Inputs: destination folder

  • implement as storage backend
    • translate NAPD to a valid project.yaml
    • create output project folder
    • create folder structure of packe in project folder
    • copy all files to new folders
    • write project.yaml
  • write tests
  • update readme

Build integration test for tng-sdk-package

Unpackaging of example packages from tng-schema repo and upload to tng-cat.

End-to-end test across:

  • tng-schema
  • tng-sdk-package
  • tng-cat

Start implementing this test once #14 is closed.

Flag/parameter: --ignore-fingerprints

If someone want's to unpackage a package without checking it's checksums he/she should be able to do it.

  • CLI --ignore-fingerprints
  • REST parameter: 'ignore-fingerprints'

Service mode

Start packager in service mode: Running in a Docker container, offering a REST API

Package OSM packages

We want to be able to create also native OSM packages from an 5GTANGO SDK project.

OSM packages are a bit different, e.g., there are single packages for NSD, and every single VNFD. Packages are simple tar.gz files.

tng-pkg -p myproject --format osm

Documentation:

Examples:


Testing:

OSM release 5.0 instance at: http://fgcn-osm1.cs.upb.de/


2019-06-03:

  • Checksums: MD5 algorithm
  • Tagging to control destination package

Change /package POST endpoint return

Unify data models of POST endpoint and status endpoint.

POST should also return the following structure

{
"error_msg": null,
"package_process_uuid": "e6eec600-2990-470a-87c0-dbd3d0dd11f4",
"status": "success"
}

Auto versioning of created packages

Automatically increase version numbers of a project when a new package is created. Makes use much more convenient (we noticed this during SONATA pilot integration).

However, feature is optional and can be disabledif needed e.g. --autoversion (remove the old --no-autoversion flag)

Attention: Versions come as strings "0.1" or floats 0.1 both needs to work.

We add/increment the third part of the version field.

Examples:

0.1 -> "0.1.1"
"0.1.1" -> "0.1.2" etc.

Dynamic ETSI manifest naming during packaging

The first version always uses a fixed name for the ETSI manifest when a package is created.

This is still aligned to the ETSI spec but requires Entry-Manifest: etsi_manifest.mf to be present in the TOSCA.meta (which is the case in the current implementation)

We can improve this by also dynamically naming the *.mf like the main descriptor to be even more aligned.

This is not super important.

tng-cat-backend: Annotated NAPD with artifact UUIDs from catalogue

Having the UUIDs of the uploaded artifacts in the package descriptor (NAPD) will make re-use in the rest of the system much easier, as discussed with @jbonnet

TODO in tng-sdk-package code

  • upload NAPDR instead of NAPD
  • remove ugly additional metadata from NAPDR
  • re-order uploads to upload NAPDR after uploading the other artifacts
  • annotate NAPDR with UUID received from catalogue when the other artifacts are uploaded

Guess MIME typed during unpackaging if not present

TOSCA and ETSI packages have no MIME types in their descriptors. We should have a module that tries to guess them based on file ending or descriptor content.

This will improve compatibility to legacy package formats.

Add basic command line interface

#Example:

tng-package -h
usage: tng-package [-h] [-p PACKAGE] [-u UNPACKAGE] [--format FORMAT] [-v]
                   [-s] [--address SERVICE_PORT] [--port SERVICE_PORT]

5GTANGO SDK packager

optional arguments:
  -h, --help            show this help message and exit
  -p PACKAGE, --package PACKAGE
                        Create package from given project.
  -u UNPACKAGE, --unpackage UNPACKAGE
                        Unpackage given package.
  --format FORMAT       Package format [5GTANGO|OSM]. Default: 5GTANGO
  -v, --verbose         Output debug messages.
  -s, --service         Run packager in service mode with REST API.
  --address SERVICE_PORT
                        Listen address of REST API when in service mode.
                        Default: 0.0.0.0
  --port SERVICE_PORT   TCP port of REST API when in service mode. Default:
                        5099

Flag/parameter --offline

Skips the validation against online schemas (e.g. NAPD.yaml).
Skips resolving of online resources.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.