Using Reference BooksΒΆ

Reference book allows users to create groups of information that can be used in Batfish queries. They can contain:

Name

Description

Type

name

Name of the reference book

str

addressGroup

A list of addressGroups

List of addressGroup

interfaceGroup

A list of interfaceGroups

List of interfaceGroup

Example usage

Create a reference book for information about border routers and add an InterfaceGroup for the as2 border interfaces

[4]:
interfacegroup = [InterfaceGroup('as2-border',
                                 interfaces = [Interface('as2border1','GigabitEthernet2/0'),
                                               Interface('as2border2', 'GigabitEthernet2/0')])]
refbook = ReferenceBook(name='border', interfaceGroups= interfacegroup)

bf_put_reference_book(refbook)

Example usage

Add an AddressGroup for the IP addresses of all as2 border interfaces to the ReferenceBook('border')

[5]:
refbook = bf_get_reference_book('border')
addressGroup = [
    AddressGroup(name='as2-border', addresses = ['2.12.21.1', '2.12.12.1'])
]
[6]:
refbook.addressGroups.extend(addressGroup)
bf_put_reference_book(refbook)
[7]:
bf_get_reference_book('border')
[7]:
ReferenceBook(name='border', addressGroups=[AddressGroup(name='as2-border', addresses=['2.12.12.1', '2.12.21.1'], childGroupNames=[])], interfaceGroups=[InterfaceGroup(name='as2-border', interfaces=[Interface(hostname='as2border1', interface='GigabitEthernet2/0'), Interface(hostname='as2border2', interface='GigabitEthernet2/0')])])