Giter Club home page Giter Club logo

tng-sdk-package's Issues

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

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.

Flag/parameter --offline

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

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'

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!!!)

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.

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

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

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.

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"
}

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

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.

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.

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

Service mode

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

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.

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)

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

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.