Skip to main content

Automatic deployment on-prem from zip archives

Project description

Summary

Automatic deployment on-prem from zip archives.

Warning

This is an alpha release. Not ready for production.

Docs

Not available yet. Scheduled for beta release.

Installation

Open command line and and install using pip:

> pip install adop

Usage

adop is available as console script and library module

> adop -h
> python -m adop -h

Print general help

> adop -h

Help on serving rest api

> adop serve-api -h

Serve rest api on http://127.0.0.1:8000

> adop serve-api -b 127.0.0.1 -p 8000

Find the generated access token

  • Windows

    > type %USERPROFILE%\.adop\adop.ini | findstr token
  • Linux

    $ cat ~/.adop/adop.ini | grep token

Test rest api with curl

  • Windows

    > curl ^
      -H "Token: paste-token-here" ^
      http://127.0.0.1:8000/api/v1/test
  • Linux

    $ curl \
      -H "Token: paste-token-here" \
      http://127.0.0.1:8000/api/v1/test

Upload and deploy a zip-library:

$ curl \
  -H "Content-Type: application/zip" \
  -H "Root: mylib" \
  -H "Token: paste-token-here" \
  --data-binary @work/mylib.zip \
  http://127.0.0.1:8000/api/v1/deploy/zip

Zip file layout

Zip files with exactly one root directory are valid and can be distributed. The root directory name must be unique if many zip files are to be distributed.

Example of a valid zip file layout:

/mylib
    /README.rst
    /main.py
    /mypackage1
        /__init__.py
        /__main__.py
    /mypackage2
        /__init__.py
        /__main__.py

Following layout is not valid:

/README.rst
/mylib1
    /__init__.py
    /__main__.py
/mylib2
    /__init__.py
    /__main__.py

API

Endpoints

Description

Method

Endpoint

Check that the API is available.

GET

/api/v1/test

Sha sum for all deployed zip-files.

GET

/api/v1/state

Sha sum for given deployed root.

GET

/api/v1/state/<root>

Start auto-fetch routine if enabled.

GET

/api/v1/trigger/fetch

Download zip-file with given root.

GET

/api/v1/download/zip/<root>

Upload a zip-file without deploying it.

POST

/api/v1/upload/zip

Upload and deploy a zip-file.

POST

/api/v1/deploy/zip

Deploy a preloaded zip-file.

GET

/api/v1/deploy/zip

Zip-file unpacking progress.

GET

/api/v1/progress

Headers

Header

Description

Endpoint

Token

The authorization token for this API.

  • All

Root

Name of the root folder of the zip-file. Used to identify which file is deployed.

  • POST /api/v1/upload/zip

  • POST /api/v1/deploy/zip

  • GET /api/v1/deploy/zip

Zip-Sha256

content hash of the zip-file to deploy.

  • GET /api/v1/deploy/zip

Result

The result is encoded as a json object. Most endpoints will return an object with result and result_code as keywords.

$ curl \
  -H "Token: paste-token-here" \
  http://127.0.0.1:8000/api/v1/test
{
  "result": "It works",
  "result_code": 0
}

Endpoints that take a long time will stream a progress log until the result is returned.

$ curl \
  -H "Content-Type: application/zip" \
  -H "Root: mylib" \
  -H "Token: paste-token-here" \
  --data-binary @work/mylib.zip \
  http://127.0.0.1:8000/api/v1/deploy/zip
// root: mylib
// store data
// verify data
// verify root dir
// verify zip data
// zip root: 'mylib'
// unpack zip data
// remove untracked files
{"root": "mylib", "result": "Success", "result_code": 0}

The Json specification does not support comments, so the client must ignore lines prefixed with // before decoding.

$ curl \
  -H "Content-Type: application/zip" \
  -H "Root: mylib" \
  -H "Token: paste-token-here" \
  --data-binary @work/mylib.zip \
  http://127.0.0.1:8000/api/v1/deploy/zip | \
  grep -v // | \
  python -m json.tool
{
    "root": "mylib",
    "result": "Success",
    "result_code": 0
}

Status and result codes

HTTP status

result_code

Descripton

200

0

OK. Indicates that the request has succeeded.

200

1

Fail. The request has succeeded but result was unsuccessful.

200

2

In progress. The request as been interrupted and returned to early to give the final result code.

401

4

Unauthorized. Invalid token.

500

5

Internal Error

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

adop-0.0.1a5-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file adop-0.0.1a5-py3-none-any.whl.

File metadata

  • Download URL: adop-0.0.1a5-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for adop-0.0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 f1b92204b6a266d509c16d104c09f4a2ce48ca18117ba04afa18b49a9ed6f52c
MD5 68e8a1c6e54708d1252540e1d30bb1d2
BLAKE2b-256 e1c02b82247089dc93b5f85c6e7d00e9eede59bcf5de05847f5699becc61d638

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page