AnnetDefine network rules in Python

Annet takes device data and rules written in Python. It then builds configuration for each device, compares it with the current state, and prepares commands to apply the changes.

  1. Annet passes device data to the generator. The device is not contacted yet.

Data source

Use a custom Storage adapter for other inventory systems.
Device dataadapter: netbox
leaf-1bdcim.device
vendor
Huawei VRP
role
leaf
interface
10GE1/0/1
↳ peer
spine-1a · Ethernet3

Ready-made adapters: NetBox and a YAML file.

annet

leaf-1b
Python generatorgenerators/interfaces.py
class InterfaceDescription(PartialGenerator):    def run_VENDOR(self, device):        for interface in device.interfaces:            peer = interface.connected_endpoints[0]            with self.block(f"interface {interface.name}"):                yield f"description {peer.device.hostname}@{peer.name}"

Intended configuration

Filling in device data…
leaf-1bCE6857
0102030405060708

10GE1/0/1 · No description

ssh leaf-1bVRP
<leaf-1b>

How Annet works

Annet

Generators

Partial · Entire · JSONFragment

Generators split configuration into manageable parts. An ACL defines the lines owned by PartialGenerator and the keys owned by JSONFragment. Entire generates a whole file without an ACL.

class Hostname(PartialGenerator):
    TAGS = ["hostname"]

    def acl_huawei(self, device):
        return """
        sysname
        header
        """

    def run_huawei(self, device):
        yield "sysname", device.hostname
        yield 'header login information "%s"' % device.hostname

The device type determines which generator describes its configuration.

How to get started with Annet