Skip to main content

Network Config Backup from IP Fabric to Git

Project description

Network Config Backup from IP Fabric to Github

As a User of the IP Fabric product, I want to copy the network device configuration from IP Fabric into a Git repository.

This tool takes inspiration from the netcfgbu project that backs up network configuration using a direct SSH-to-device approach.

Quick Start

Once you've configured your ipfnetcfgbu.toml configuration file, you can run the following command to backup all devices, using "start of today" as the timestamp basis:

ipf-netcfgbu backup --force

To backup only those devices whose configurations have actually changed since "start of today":

ipf-netcfgbu backup

To save these configurations into your remote git repository:

ipf-netcfgbu vcs save

Installation

This package is not yet in PyPi. To install:

pip install ipf-netcfgbu@git+https://github.com/jeremyschulman/ipf-netcfgbu.git

Usage

Usage: ipf-netcfgbu [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  backup  Backup network configurations.
  vcs     Version Control System subcommands.

Backup Command

The backup command provides the following options:

Usage: ipf-netcfgbu backup [OPTIONS]

  Backup network configurations.

Options:
  -C, --config FILENAME
  --start-date <DATE-TIME>  Identifies the starting timestamp date/time
  --end-date <DATE-TIME>    Identifies the ending timestamp date/time
  --force                   Force backup of all configs, not just those that
                            changed

  --dry-run                 Use to see device list that would be backed up
  --filters TEXT            Override the `filters` option in the config file
  --help                    Show this message and exit.

The start-date and end-date syntax follows values allowed by the Maya package. For example you can use expressions like "2 days ago" or explicit dates like "2020-sep-16". You can also provide a time with the date, for example "yesterday noon" or "2020-sep-16 2:30 pm"

The filters enables any IP Fabric allowable API filter; the expression syntax is defined in the aio-ipfabric filters module. Here are some examples:

# Hostname starts with "abc"

--filters 'hostname =~ "abc.*"'

# Site is "atl" or Hostname contains the substring "sw2"

--filters "or(site = atl, hostname has sw2)"

# Either:
#  (a) Site is "atl" and Hostname contains subscript "core"
#  (b) Site is "chc" and Hostname ends in "club-switch21" or "club-switch22"

--filters 'or(and(site = atl, hostname has core), and(site = chc, hostname =~ ".*club-switch2[12]"))'

More docs on that comming soon. Ask for help via github issue if you need.

Configuration File

The ipf-netcfgbu looks for a TOML based configuration file in one of the following places

  1. As specified by the -C option
  2. As specified by the IPFNETCFGBU_CONFIGFILE enviornment variable
  3. $PWD/ipfnetcfgbu.toml

See Example: ipfnetcfgbu.toml

The configuration file has the following sections:

defaults

  • config_dir - The local filesystem directory where the network configuration files will be stored after they are retrieved from IP Fabric.

ipfabric

  • credentials.username - The IP Fabric login user-name
  • credentials.password - The IP Fabric login password
  • credentials.token - The IP Fabric authentication token

NOTE: Either the token or the (username, password) options must be provided.

  • server_url - The HTTPS URL to the IP Fabric system
  • filters - A string representing an IP Fabric filter expression used to limit the device records retrieved from IP Fabric that are used as the inventory for backup purposes. If no filters is provided, then all devices will be scoped for backup.
  • strip_hostname_domains - A list of string values that are domain-name suffix values you want to remove from the IP Fabric device stored hostname value. In some device cases, NX-OS for example, the IP Fabric system stores the device FQDN.

git

This is the same configuration structure as netcfgbu.
See docs for details.

loggers

This is the same configuration structure as netcfgbu.
See example ipfnetcfgbu.toml file for details.

Environment Variables

  • IPFNETCFGBU_CONFIGFILE - filepath to your configuration file

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

ipf-netcfgbu-0.3.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipf_netcfgbu-0.3.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file ipf-netcfgbu-0.3.1.tar.gz.

File metadata

  • Download URL: ipf-netcfgbu-0.3.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for ipf-netcfgbu-0.3.1.tar.gz
Algorithm Hash digest
SHA256 dbdf1fb13ad0ff7f190cad6adc946711635cfe9d60c81d502dfe4af92678ea72
MD5 2da3cc056e3f8dee49f0e0dec6588f19
BLAKE2b-256 b55ca47b44d644e8a44aeabca2f93fb7337eaa0e56a32e049e635ea689159f87

See more details on using hashes here.

File details

Details for the file ipf_netcfgbu-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ipf_netcfgbu-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for ipf_netcfgbu-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7756d995dad5be2236ff63dd3cdd35d531b51a328603f0cbbbe92d40af13674
MD5 b917fcbd19946918dc750fa6703c1632
BLAKE2b-256 ba8939d1bfcb11e5e59013dcc60dd4fc9c1b5d736b007a7240d2a8ed510c7399

See more details on using hashes here.

Supported by

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