Skip to main content

Cisco DevNet SD-WAN vManage (Viptela) CLI/SDK

Project description

Cisco Viptela vManage Python SDK/CLI/Ansible

This repo contains a Python SDK for Cisco Viptela vManage as well as a CLI and Ansible modules that leverage the SDK. Stable releases are found in pypi. The master branch is under active development and may not offer a stable interface.

Requirements

  • Python 3.6+

Installation

Creating Python virtual environment

python3 -m venv env
. env/bin/activate

Installation from PyPI

pip install viptela

Installation from github

pip install git+https://github.com/CiscoDevNet/python-viptela.git@specific_branch

Installation from within repo

git clone https://github.com/CiscoDevNet/python-viptela.git
cd python-viptela
pip install -e .

Environment Variables

IP/DNS, port and credentials for the vManage server can be set for the SDK via environment variable

  • VMANAGE_HOST
  • VMANAGE_PORT
  • VMANAGE_USERNAME
  • VMANAGE_PASSWORD

vManage Command Line Interface

Usage: vmanage [OPTIONS] COMMAND [ARGS]...

Options:
  --host TEXT      vManage Host (env: VMANAGE_HOST)  [required]
  --port INTEGER   vManage Port (env: VMANAGE_PORT, default=443)
  --username TEXT  vManage Username (env: VMANAGE_USERNAME)  [required]
  --password TEXT  vManage Password (env: VMANAGE_PASSWORD)  [required]
  --help           Show this message and exit.

Commands:
  activate     Activate commands
  certificate  Certficate commands
  clean        Clean vManage
  deactivate   Deactivate commands
  export       Export commands
  import       Import commands
  set          vManage Settings set commands
  show         Show commands

vManage host and credentials can be also specified via command line options. The command line options override the environment variables. If no password is specified, the user will be prompted for one.

Importing and exporting of templates and policy

Data file format

All template information is exported to a single file with to lists: feature_templates and device_templates. Each list contains dictionaries as pulled from the vManage API with a few additions and modifications. First, a list of attached devices and a list of input variables is added to the device template. Then instance IDs are translated into name so that the templates can be imported into another vManage.

All policy template information is exported to a single file with four lists: policy_lists, policy_definitions, central_policies, local_policies. Each list contains dictionaries as pulled from the vManage API with the instance IDs converted to names so that policies can be imported into another vManage.

Import Options

  • --check: Just check. No changes. (default=False)
  • --update: Update if exists (default=False)
  • --diff: Show diffs (default=False)

The CLI/SDK will import templates and policy idempotently and as non-destructivly as possible. It will only add templates and policies that are not there. When a template or policy does exist but is different than what is in the import file, it will not he updates unless the --update option is given.

Export Templates

Export all templates to a file
vmanage export templates --file vmanage-templates.json
Export templates from a specific vManange
vmanage --host=192.133.178.54 export templates --file vmanage-templates.json
Export specific device templates
vmanage export templates --type=device --file vmanage-templates.json --name=isr4331 --name=ISR1111-8P
Export just feature templates
vmanage export templates --type=feature --file vmanage-templates.json

Import Templates

Import all templates
vmanage import templates --file vmanage-templates.json
Import feature templates
vmanage import templates --type=feature --file vmanage-templates.json
Import specific device templates
vmanage import templates --type=device --file vmanage-templates.json --name=isr4331 --name=ISR1111-8P

Export Policies

vmanage export policies --file vmanage-policies.json

Import Policies

vmanage import policies --file vmanage-policies.json
Diff two templates
vmanage show template g0/0/0-R1 --diff g0/0/0-R2
[ ( 'change',
    'templateDefinition.tunnel-interface.color.value.vipType',
    ('ignore', 'constant')),
  ( 'change',
    'templateDefinition.tunnel-interface.color.value.vipValue',
    ('default', 'custom2')),
  ( 'add',
    'templateDefinition.tunnel-interface.color.restrict',
    [('vipVariableName', 'vpn_if_tunnel_color_restrict')]),
  ( 'change',
    'templateId',
    ( '2a0481f4-a5b2-44bf-baad-59de4d3b4e99',
      '1dc123db-7a14-40f5-9653-1c87ccd5eaa2')),
  ('change', 'createdOn', (1569072320921, 1569072320260)),
  ('change', '@rid', (843, 839)),
  ( 'change',
    'templateDescription',
    ( 'G0/0/0 Interface for R1 router with TLOC extension, adds NAT',
      'G0/0/0 Interface for R2 router with TLOC extension, adds NAT, changes '
      'color to custom2')),
  ('change', 'lastUpdatedOn', (1569072320921, 1569072320260))]

License

GNU General Public License v3.0

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

viptela-0.3.10.tar.gz (82.4 kB view details)

Uploaded Source

Built Distribution

viptela-0.3.10-py3-none-any.whl (140.0 kB view details)

Uploaded Python 3

File details

Details for the file viptela-0.3.10.tar.gz.

File metadata

  • Download URL: viptela-0.3.10.tar.gz
  • Upload date:
  • Size: 82.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for viptela-0.3.10.tar.gz
Algorithm Hash digest
SHA256 62b1677a8f5aa018ac9ae728d0d1becbbf56b0e352af6a156380ffc288ed07dc
MD5 3e88709dc95fa892ddafeb52925cb987
BLAKE2b-256 e19aecd678a71e93facca3dedd7be21b088c028b35bf28e6ac11b7970823c43d

See more details on using hashes here.

File details

Details for the file viptela-0.3.10-py3-none-any.whl.

File metadata

  • Download URL: viptela-0.3.10-py3-none-any.whl
  • Upload date:
  • Size: 140.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for viptela-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d684a70da1adfd86dc390fef9e6777dd53f7fe7b637abb53f2751f092c9645df
MD5 73fff1c97ef83cdef2ef54e40faa482e
BLAKE2b-256 17812f8a631d6bb87acc4aebe978df3deac6643eaa318b1e9f17187566d5b6b7

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