Commit Graph

256 Commits

Author SHA1 Message Date
5a30d9d995 Add proper exception classes (pylint) 2022-04-22 19:40:04 +00:00
bc0310e088 Study and respond to PyLint
Add a reasonably tolerant .pylintrc and fix most pylint errors and
warnings.

------------------------------------------------------------------
Your code has been rated at 9.78/10
2022-04-22 19:32:38 +00:00
f8a6c3eba7 Add a note about black code formatting 2022-04-22 13:13:42 +00:00
b7ff5479ac Fix lint errors with black 2022-04-22 13:10:16 +00:00
1b49059ffb Add the --diff flag to black to show what should change 2022-04-22 13:09:09 +00:00
9ee9a32693 Test github push action 2022-04-22 13:07:04 +00:00
d9e46b4041 Add a black (code formatting) github action on PR and push 2022-04-22 13:06:21 +00:00
baaaaa67b5 Initial formatting run with Black. Integration tests and unit tests pass before and after this change. 2022-04-22 13:05:55 +00:00
b375ddb433 Final f-string conversions that flynt did not catch. Tested: integration test before and after are clean 2022-04-22 11:48:08 +00:00
e13694a566 Move to f-strings
Used:
$ flynt -a -tc . vppcfg

Execution time:                            0.216s
Files checked:                             24
Files modified:                            13
Character count reduction:                 632 (0.36%)

Per expression type:
Old style (`%`) expressions attempted:     209/211 (99.1%)
No `.format(...)` calls attempted.
No concatenations attempted.
F-string expressions created:              205

Ran an integration test before and after. No diffs.
2022-04-22 10:58:41 +00:00
13cdba1e1d Remove commented out 'print' debug lines 2022-04-22 09:33:27 +00:00
d8c0dd4ab4 Skip TAPs that are an LCP 2022-04-21 19:17:52 +00:00
e6f271181b bugfix - only print MAC on PHYs, not sub-interfaces 2022-04-15 10:46:36 +00:00
58cf9e6b0c A few cosmetic refactors
- add __vxlan_tunnel_has_diff() to align with the other _has_diff()
  methods
- factor out a few repetitive occurences of l2xc creations
- strictly make "cli=" the pattern instead of "cli = ", to help grepping :)
2022-04-14 12:15:06 +00:00
eee718c77c Refactor and clean up some repetitive code 2022-04-12 11:04:13 +00:00
594e21afa4 Remove redundant code - remove_interface() already removes TAP cache entries 2022-04-12 10:47:45 +00:00
2b1287f4ef Remove spurious logging 2022-04-12 09:11:56 +00:00
6637820021 Add TAP support
- based on previously submitted schema and validation, can add a TAP
  with host netns, bridge and MTU.
- detect diffs in __tap_has_diff(), used to prune TAPs that must change
- add prune_taps() and create_taps() in the reconciler
- add Dumper() logic to emit YAML config for TAPs
- Move tap_is_lcp() into the VPPApi() class, so it can be reused

Add lots of test cases in intest/*.yaml and example.yaml - full
regression and integration and unit/YAML tests pass on this change.
2022-04-12 08:57:05 +00:00
95f56bc865 bugfix: correct ordering of iface_mtu and host_mtu 2022-04-10 16:14:58 +00:00
06046cd51a Allow TAP instances to be interfaces
- Cannot have LCP, Address or Sub-Interface
- Cannot be PHY
- Cannot be Bond member
- Can be target of L2XC
- Can be member of Bridge
- interface.mtu must be the same as tap.host.mtu

Add YAML tests for common mistakes. This unblocks taps becoming members
of a bridgedomain, and allowing a very cool feature: slowpath networking!
2022-04-10 16:10:19 +00:00
5fc3b4c42b Correct the returnvalue of get_parent_by_name() if ifname==None, add tests for that 2022-04-10 15:48:34 +00:00
72668bdb18 Allow for the integration test to be run in -strict mode, exiting the execution in case errors were found 2022-04-10 15:06:56 +00:00
0116583463 Rename VPPApiDumper() class to Dumper() 2022-04-10 14:55:01 +00:00
da7765569f Refactor VPPApi
VPPApiDumper() is its own file, preparing for VPPApiApplier() in an
upcoming commit. VPPApi() itself remains read-only. No need for an empty
__init__.py file.

Update vppcfg to use the correct vpp/dumper.py import
2022-04-10 14:47:37 +00:00
9d60a01879 Add a running log of executed commands in intest.exec 2022-04-10 13:57:00 +00:00
929fa7b546 bugfix: sync max frame size before packet MTU 2022-04-10 10:57:17 +00:00
a7545ac5af Add ability to manipulate MACs
Special care is taken for bondethernet, where the MAC changes when
the first member is added to it. BondEthernet requires its MAC to
be set in the bondethernets section, disallowing the MAC of individual
members to be set.

Also write a dumper for MACs of all types. Update integration test
cases to stress the MAC changes on loops, bonds, and phys.
2022-04-10 09:54:51 +00:00
656f2ce883 Only signal bondethernet diff if mode/lb are actually set in the config 2022-04-09 22:08:32 +00:00
be36cc0ede Allow BondEthernet to set MAC, and disallow interfaces to set their MAC if they are a bond member 2022-04-09 21:18:26 +00:00
35edcff884 Allow mac to be set up loopbacks, iff not multicast 2022-04-09 20:47:23 +00:00
1e0b99bc0f Clarify that custom validators only get called iff yamale passes 2022-04-09 20:35:58 +00:00
1230e04c3e Refactor validators into a list, and add a custom validator function, which is passed the YAML as an argument, and will return (rv,msgs) to signal custom semantic validation results 2022-04-09 20:12:21 +00:00
d6e3496809 Add TAP syntax/semantic validator 2022-04-09 19:56:48 +00:00
92a20d0755 Add a few MAC checks
Notably mac.is_multicast() which is needed for TAPs / LCPs and
interfaces.

Add a test for interface MAC addresses being non-multicast.
2022-04-09 15:15:00 +00:00
1a00f14b53 Assert hardware APIs must be made available for testing 2022-04-07 21:39:41 +00:00
b7425a825d Fix the MTU of BVIs to be consistent with the bridge they're in 2022-04-07 21:19:38 +00:00
8854208b09 Add license for docs, add notes on AP2 for code, add requirement for origin certification 2022-04-07 21:18:05 +00:00
771d1ba62f Add contributing guide with a few baseline expectations 2022-04-07 20:57:51 +00:00
a8ced1b982 Assert that BVI loopback's mtu is the same as its bridge MTU 2022-04-05 17:54:23 +00:00
8971c325c0 Allow bondethernet members list to be empty, and omitted from the YAML config 2022-04-05 16:08:51 +00:00
41bce7131c Remove surperfluous YAML file 2022-04-05 15:54:09 +00:00
0a755a0745 Add bond/bridge YAML emitter
Add int_to_mode() and int_to_lb() in config/bondethernet.py to map back
the retrieved values from VPP into their config strings.

Implement bond and bridge settings dumper, dumping all settings even if
they are default. This helps the user understand the configurable
options.
2022-04-05 15:53:26 +00:00
2360d28d0a Add the ability to set any mode/lb on bonds
This requires a schema change, adding 'mode' and 'load-balance' fields,
a semantic invariant that 'load-balance' can only be set in the case of
LACP and XOR bonds, a mapper from the mode/lb strings, ie.
"round-robin" to their VPP numeric counterparts, a bunch of unit tests.

Then in the reconciler, changing bonds (__bond_has_diff()) will
invalidate any LCP or sub-interfaces built on them, so those will have
to be pruned. create_bondethernet() will now create (or re-create)
the bond with the correct flags.

Unit-tests, YAML tests and the integration test all pass.

Updated config-guide.
2022-04-05 15:05:03 +00:00
289138da94 Bundle Yamale schema
TIL! Using the existence of obscure member sys._MEIPASS, I can detect if
we're running from a bundled PyInstaller binary, versus running from Python
directly.

Add schema.yaml to the datas of the PyInstaller spec. Then, if the
-/--schema flag is given, use it, and if it's not given, default to the
built-in one if we're running from a bundled binary, or fall-through to
./schema.yaml in other cases.

This avoids the need for config/schema.py as a carbon-copy of the schema,
slick!
2022-04-05 12:40:05 +00:00
fdb732142a Add bridgedomain settings.
Bridges can be created with default settings, with specific settings,
and they can be sync'd at runtime with all of the settings in this
change.

Notably missing are two features:
- unknown unicast flooding into specific interfaces (as opposed to
  on/off on the bridge)
- learn-limit, which does not have an API getter, only a setter.
2022-04-05 12:01:13 +00:00
f53f7d5095 Remove linux-cp / lcpng specialcase, the API exposed by lcpng and linux-cp is now identical 2022-04-05 11:08:58 +00:00
b461ef49bb Add 'state' field to interfaces and sub-interfaces
Assert that children cannot be 'up' of their parent is 'down'. Add tests. Update user-guide.
2022-04-05 11:06:33 +00:00
65de792e35 Implement workaround for endianness issue in linux-cp 2022-04-03 22:24:59 +00:00
a4a91d1f5e Replace dumper with an actual YAML emitter 2022-04-03 21:37:48 +00:00
53a7935168 Copy the Yamale schema.yaml file into the source-code verbatim. This allows the tool to run without any external (file) dependencies, using the built-in yamale_schema if the -s/--schema flag is not specified 2022-04-03 15:53:00 +00:00