Commit Graph

236 Commits

Author SHA1 Message Date
661c7fc16c Implement pruning in config as well
After pruning elements from the VPP configuration, also remove them
from the configuration. The purpose of this is to leave a reasonable
representation of the VPP state in the configuration, so that subsequent
creates and syncs do not have to query the VPP API repeatedly.

The goal of this change is to be able to plan a complete path from
prune, create and sync, with only reading the initial VPP configuration
once, not multiple times.
2022-03-25 23:04:28 +00:00
1d7fd268e0 Add ability to delete sub-ints on BVI + Loopback
- Add a get_sub_interfaces() call to fetch all DPDK / Bond sub-ints
- In prune_bvis(), prune_loopbacks() and prune_sub_interfaces(),
  use sub_number_of_tags to go out-to-in (qinx, dot1x, untagged)
2022-03-25 18:43:46 +00:00
9aeb60ad98 Also bring down BVIs and Loopbacks if they do not exist in the config 2022-03-25 14:15:40 +00:00
152fa12099 Update to ordering
- Prune bridgedomains before pruning BVIs. The reason for this is that
  prune_bridgedomains() will set the BVI to L3 mode, and if the BVI is
  removed before the bridge is pruned, this is an error.
- When pruning bridge members, use the VPP configuration as the member
  may not exist in the config, upon which the call to interface.is_sub()
  will return False even if it is actually a VPP sub-int.

Update README.md, also take into account the previous change which calls
prune_addresses() before object deletion.
2022-03-25 13:56:04 +00:00
a068f25f19 Re-order the Pruning flow
1. sub-ints have to be removed before their parent, particularly
   bondethernets, because destroying BondEthernet0 will cascade
   destruction of all of its sub-ints. So:
   - first prune_sub_interfaces()
   - then prune_bondethernets()
   - finally prune_phys()
2. for any interface (loop, bvi, sub, phy, bond), prune_addresses()
   before destroying the interface

Update the README with this new flow.
2022-03-25 13:35:14 +00:00
0a31a22e7e Add docstrings, reorder functions. Rename prune_addresses_set_interface_down() to merely prune_interfaces_down(), and make distinction on setting down and pruning addresses, so we don't do it twice. 2022-03-25 11:55:30 +00:00
864c78ddfe Only change link and MTU if they differ from the vpp_iface 2022-03-25 00:29:57 +00:00
250aae5210 Prune step 8: Remove qinx, dot1ad/dot1q, and set phys to default if they are not in the config 2022-03-25 00:15:41 +00:00
33aedd585f Prune Step 7: Remove VXLAN tunnels that either aren't in the config, or have a mismatched src/dst/vni 2022-03-24 23:42:46 +00:00
c381c7cbaa Prune Step 6: Remove BondEthernets and their member interfaces that are not in the config 2022-03-24 23:17:56 +00:00
731f7ecbb4 Implement Prune Step 5: Remove L2XC that are not in the config 2022-03-24 22:50:22 +00:00
721ac690cd Implement Prune Step 4: Remove members from bridgedomains, and remove bridgedomains not in the config 2022-03-24 22:25:37 +00:00
cd4d44a2b1 Implement Prune Step 3 -- remove BVI and Loopback interfaces and IPs that are not in the config 2022-03-24 22:02:31 +00:00
4666ba1611 Ensure bridgedomains exist in the YAML config before trying to look up BVIs in them 2022-03-24 21:57:39 +00:00
3a74a07ee6 Add get_by_bvi_name() and add a few hints on the difference between 'bridgename' (bd*) and 'bvi interfacename' (bvi*) 2022-03-24 21:38:13 +00:00
13f70758da merge conflict 2022-03-24 21:00:08 +00:00
15c54d5e1d Implement Prune Step 2: Remove any mismatched LCP, in correct order 2022-03-24 20:59:28 +00:00
d6e2e9765b Implement Prune Step 2: Remove any mismatched LCP, in correct order 2022-03-24 20:55:28 +00:00
82bcb24d5e Add get_by_lcp_name() + tests 2022-03-24 20:38:28 +00:00
de9ed1730d Add get_by_lcp_name() plus tests. Correct behavior of sub-ints without explicit encap: they are exact-match 2022-03-24 20:14:06 +00:00
95c08bbb29 Print an error if the number of errors is unexpected 2022-03-24 20:12:36 +00:00
fe2e63ac0e Prune Step1: remove addresses and set down, any interface not in the YAML config 2022-03-24 17:16:29 +00:00
29a8bae899 Add get_bondethernets() 2022-03-24 16:34:45 +00:00
de95e522ab Move VPPApi into a Reconciler class, add (empty) prune() create() and sync() methods. Add --force flag to enable making progress after warnings are issued 2022-03-24 15:57:12 +00:00
2e2f63e1dd Fix reporting of YAML tests; send retval based on the bitflags of tests passing/failing 2022-03-24 15:15:26 +00:00
cfcbec239c Cosmetic rename instance of config/validator class 2022-03-24 15:05:15 +00:00
672dd65f11 Rename validator/ to config/ 2022-03-24 13:56:04 +00:00
e8e41098be Assert that all PHYs in the config also exist in VPP 2022-03-24 12:29:16 +00:00
8129235031 Clean up logging a little bit 2022-03-24 12:14:26 +00:00
b43d7903fd Add a few additional useful functions
- is_*() returns True if the interface name is of a certain type
  is_bondethernet() is_loopback() is_bvi() is_bridgedomain()
  is_vxlan_tunnel() is_phy()
- get_phys() by process of elimination, returns all interface names
  that are supposed to be physical network interfaces.

Add unit tests for validator/vxlan_tunnel.py
 => Notable: while here, fix a bug in get_by_name()
Add unit tests for all the is_*() and get_phys() functions.
2022-03-24 10:55:33 +00:00
ac5b8fcc8f Simple VPPApi abstraction, which fetches the necessary info from VPP, and a few dumpers 2022-03-23 23:29:19 +00:00
8ac9b50d94 Add some clarification to the reconsiliation algorithm 2022-03-23 23:28:12 +00:00
f37b80c012 Break into three sections 2022-03-23 17:16:29 +00:00
bcc4c8ff05 Merge branch 'main' of github.com:pimvanpelt/vppcfg into main 2022-03-23 17:11:46 +00:00
7390322693 Add first stab approximation of the reconsiliation order 2022-03-23 17:11:34 +00:00
613b4a27c7 Update README.md 2022-03-22 23:03:22 +01:00
df1b1bbbef Update README.md 2022-03-22 22:58:38 +01:00
c37faecd3f Buffer output, print when errors occur. Introduce debug/quiet flags 2022-03-22 20:11:32 +00:00
4cb07cf2da Add -d and -q flags 2022-03-22 19:52:19 +00:00
0ab907f155 Add get_bridgedomains() 2022-03-22 18:57:45 +00:00
27ce2351c7 Cosmetic: use '.. LCP' consistently 2022-03-22 18:49:31 +00:00
97fef9bfd2 Assert get_by_name() with non-existent name returns a tuple of None,None 2022-03-22 18:31:03 +00:00
5ecd1ef22c Add unit tests for loopbacks; While here, fix a bug in get_by_name(), yaay 2022-03-22 18:03:38 +00:00
36fbbf9b35 Add a full set of get_*_by_name() tests 2022-03-22 17:53:40 +00:00
1e7227a52a Allow for bridgedomains without any member interfaces 2022-03-22 15:38:43 +00:00
7bf940be0a Become a bit stricter: do full-line pattern match, and update unit tests to capture the full error output 2022-03-22 15:10:40 +00:00
7303adb74a Assert is_l2() on sub-ints cannot have address or LCP 2022-03-22 15:02:38 +00:00
077d49cb88 Assert that is_l2() interfaces cannot have LCP or address; Fix consistency on 'be' vs 'have' an LCP. 2022-03-22 14:54:09 +00:00
6688c6b243 Add the case of the ifname being the source of an l2xc to the is_l2() logic1
This is more strict than VPP itself, which does allow a destination to
be L3 while the source is L2:

DBGvpp# show mode
l3 local0
l3 GigabitEthernet3/0/0
l3 GigabitEthernet3/0/1
l3 HundredGigabitEthernet12/0/0
l3 HundredGigabitEthernet12/0/1

DBGvpp# set interface l2 xconnect GigabitEthernet3/0/0 GigabitEthernet3/0/1

DBGvpp# show mode
l3 local0
l2 xconnect GigabitEthernet3/0/0 GigabitEthernet3/0/1
l3 GigabitEthernet3/0/1
l3 HundredGigabitEthernet12/0/0
l3 HundredGigabitEthernet12/0/1

But it seems undesirable to have Gi3/0/1 be in l3 mode even though it's
the target of a cross connect, so I'm going to leave the behavior
stricter than VPP.
2022-03-22 14:21:32 +00:00
5ebaf5e005 Add optional filtering of get_lcps() based on type of interface 2022-03-22 14:17:36 +00:00