Skip to main content

Syntropy Network As Code Python library and Command Line Interface

Project description

Tests PyPi

Syntropy NAC

Syntropy Network As Code library and command line utility.

More information can be found at https://docs.syntropystack.com/docs/network-as-code

Requirements.

Python 3.6+

Installation & Usage

pip install

The latest package can be installed from PyPi:

pip install syntropynac

Command line tool usage

In order to be able to export or configure networks using YAML/JSON configuration files you can use syntropynac utility. First you must set proper environment variables:

$ export SYNTROPY_API_SERVER={Syntropy Stack API URL}
$ export SYNTROPY_API_TOKEN={API authorization token}

In case you have a registered user on the platform you can retrieve the API token using this command(deprecated and requires syntropyctl to be installed using pip):

$ syntropyctl login {user name} {password}
{your API authorization token}

You can omit {password} on the command line, then the utility will ask you to type the password.

In case you are using SSO to login to the platform the API authorization token can be retrieved from the Platform itself.

Or you can set the SYNTROPY_API_TOKEN environment variable like this(Set SYNTROPY_API_SERVER to the server address and SYNTROPY_API_TOKEN to empty value before that):

export SYNTROPY_API_TOKEN=`syntropyctl login {user name} {password}`

You can learn about the types of actions this utility can perform by running:

$ syntropynac --help
Usage: syntropynac [OPTIONS] COMMAND [ARGS]...

  Syntropy Network As Code cli tool

Options:
  --help  Show this message and exit.

Commands:
  configure-networks  Configure networks using a configuration YAML/JSON...
  export-networks     Exports existing networks to configuration YAML/JSON...

Exporting and configuring networks

It is possible to export existing networks using syntropynac export-networks command which will output existing networks configuration to stdout in a YAML format. This configuration can be passed to syntropynac configure-networks {infrastructure.yaml} to create networks and connections.

Note, however, that export-networks command will export connections(if any) as well as endpoints. The exported endpoints represent the endpoints without connections along with their services and tags. Those endpoints are ignored by the configure-networks command.

Below you can find a sample configuration file for different types of networks:

---
# Create point-to-point connections
name: interconnect
# Network topology is mandaroty. Values: P2P, P2M, MESH
topology: p2p
# Network state is mandatory. Values: present, absent
state: present
# Connections to create
connections:
  # Endpoint can be refferred to by name and by id
  endpoint-1:
    # state is present by default
    state: present
    # type is endpoint by default. Values: endpoint, tag, id
    type: endpoint
    # services specifies what services to enable for given endpoint
    services: 
    - nginx
    # id has precedence before name when type is endpoint
    id: 123
    connect_to:
      endpoint-2:
        type: endpoint
        services: 
        - postgre
  3:
    connect_to:
      endpoint-4:
        type: endpoint
    state: present
    type: id
  endpoint-5:
    connect_to:
      6:
        type: id
    state: absent
    type: endpoint

---
# Connect mqtt server with iot devices 
name: iot-network
state: present
topology: p2m
connections:
  mqtt-server-name.com:
    type: endpoint
    connect_to:
      # Will connect mqtt server with all the endpoints tagged as "iot-devices"
      iot-devices:
        state: present
        type: tag

---
# Create DNS servers mesh network 
name: dns-mesh
state: present
topology: mesh
connections:
  # Will create a mesh network using endpoints tagged as "dns-servers"
  dns-servers:
    state: present
    type: tag

---
# Delete a network
name: old-iot-network
topology: mesh
state: absent

Project details


Download files

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

Source Distribution

syntropynac-0.2.1.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

syntropynac-0.2.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file syntropynac-0.2.1.tar.gz.

File metadata

  • Download URL: syntropynac-0.2.1.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.14

File hashes

Hashes for syntropynac-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6f0283c39dd26fb04c259da811fcf3b330cc2bce3b1dc65cb1cec493e8c700b9
MD5 7d3b4a394cd574ca55dc6a1ea2da036e
BLAKE2b-256 9bd890135756cff88129e0b84ec8b4bacc947f12ff796ebe1a9bb09a7343d372

See more details on using hashes here.

File details

Details for the file syntropynac-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: syntropynac-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.14

File hashes

Hashes for syntropynac-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 708000c1cc3adcabc9b0011ed3aa0cb86294ac11dc7c8434ee42ebb657466b06
MD5 9a2d49aa642f224b9529457fe5f0809e
BLAKE2b-256 aa06cab200fde3bf97fc432213d3497de75cf787be6ac5b3a98e1b5f7d95cd0e

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