Commit Graph

63 Commits

Author SHA1 Message Date
8a7c690ee5 Add ability to filter get_network_list() by ipv4 or ipv6, and add tests 2023-01-16 12:15:41 +00:00
4e2354c3d8 Add acl.get_network_list() + tests; Update docs to reference the ability to use prefixlist as a source/destination 2023-01-16 12:03:34 +00:00
a274fdc2af Add prefixlist.get_network_list() + tests 2023-01-16 12:01:29 +00:00
597981e79b Add prefixlist (mixed IPv4 and IPv6, containing either IP addresses or prefixes + tests 2023-01-16 10:15:57 +00:00
f0da3abe6e Add an ACL yaml unit test, to cover get_acls() and get_by_name() 2023-01-16 09:42:22 +00:00
adf7c7eb24 formatting with black 2023-01-16 01:13:27 +00:00
7fd47c0854 acl: Add the aclname to error messages 2023-01-16 01:12:16 +00:00
56ffe52e20 acl: semantic validation 2023-01-16 01:09:23 +00:00
6990fb691d Allow src/dst to also be an IP address 2023-01-16 00:16:17 +00:00
b08e97107e Add first semantic check + unittest 2023-01-15 22:24:13 +00:00
da7609a685 acls: Syntax schema, example and docs
First stab at integrating the acl-plugin from VPP. Allow to craft ACLs
consisting of one-or-more ACEs (this is ensured by 'terms' being
required with min=1), and a rich language to be able to set any L3
and L4 (UDP, ICMP, TCP) matchers that the plugin provides.

Explain how the syntax will look like, although for now only YAMALE
syntax checking can be performed (semantic validation is next).

TESTED:
pim@hippo:~/src/vppcfg/vppcfg$ ./vppcfg.py check -c example.yaml
[INFO    ] root.main: Loading configfile example.yaml
[INFO    ] vppcfg.config.valid_config: Configuration validated successfully
[INFO    ] root.main: Configuration is valid
2023-01-15 21:41:58 +00:00
305a30b1a1 feature: stateless planning
Add a  feature to plan a configuration without reading from the VPP Dataplane.

In this mode, the configuration file is read and validated in the same way as `check` or `plan`,
but then instead of retrieving the running state from the VPP API, a state is re-created using
the physical interfaces specified in the YAML config.

Implement this by creating vppapi:mockconfig() which reads the 'interfaces' scope from the YAML
config file, and creates a VPPMessage() of type sw_interface_details for each interface that is a
PHY (for now, only supporting device-type 'dpdk').

If the flag --novpp is specified in the planner, call mockconfig() instead of readconfig().

Some further details:
- if the MAC is not set in the YAML config, it won't be set in the output exec file.
- for bondethernets, no MAC can be generated unless it's set in the first member.
- the MTU is always set, because it's mocked to 64b and the YAML file will always be higher.

TESTED:
- the unit tests and YAML tests all pass
- the integration tests all pass, but they do not call this new codepath

- Based on an empty VPP on Hippo, I compared the output of these two, side by side:
for i in intest/*yaml; do ./vppcfg.py plan -c $i -o /tmp/$i-vpp.exec; done
for i in intest/*yaml; do ./vppcfg.py plan --novpp -c $i -o /tmp/$i-novpp.exec; done

==> The only changes here are:
* if I cannot determine the bondether MAC in the --novpp case, it is not emitted
* if the MAC address is set in the YAML file, the --novpp case will always emit it
* if VPP has mtu 9000, the --novpp case will end up still emitting interface and packet MTU,
  because it mocks the interface MTU at 64.

In all cases, --novpp emits more configuration statements, and the statements that it emits are
redundant.
2022-12-03 16:03:38 +00:00
490c294014 feature: add device-type to the schema
This attribute of the 'interface' schema allows the user to prompt what
type of PHY they are expecting this interface to be. It will serve an
immediate and a future purpose.

Immediate: presence of the 'dpdk' device-type in a list of interfaces
will help an upcoming vppapy.mockconfig() to generate a cache without
having to talk to the API. This is useful to generate a pre-compute a
complete vpp.exec based off of an empty VPP dataplane

Future: addition of different PHY types, notably RDMA and
VirtualEthernet types

TESTED:
- Added a unit test to ensure that only is_phy() eligable interfaces
  receive the device-type attribute.
- All unit and YAML tests pass.
2022-12-03 13:48:37 +00:00
628dc62b15 fix: move socket check to connect
If there is no need to connect to a running VPP instance (for example,
if the configuration is going to mock the VPPMessage()s rather than read
them from the VPP dataplane), then there is no need to assert that a
socket exists.

Scan the JSON files in the constructor though, not at connect time, as
other methods may want to use the JSON files without having to connect
to the API.
2022-12-03 12:42:33 +00:00
1b0fa13f74 refactor: Simplify cache_clear()
Don't return the cache, simply set self.cache to empty dictionary. Call
it from readconfig()

TESTED:
- unit tests and yaml tests pass
2022-12-03 12:31:18 +00:00
a622b1d54e refactor: indirect interface_names to interfaces
Before, interface_names was a literal copy of the VPPMessage() from
sw_interface_details, so interfaces and interface_names kept the
messages twice. This change makes interface_names a pointer to the index
on interfaces.

- Update the cache creation to make the indirection from interface_names
  to interfaces
- Introduce get_interface_by_name()
- Update/fix all the call sites

Tested:
- All unit tests and yamltests pass before and after this change
- The hippo integration test passes before and after this change
2022-12-03 12:14:07 +00:00
806f4f4fc8 Merge branch 'main' of github.com:pimvanpelt/vppcfg into main 2022-12-03 09:55:37 +00:00
e6936e94e9 Remove workaround for gerrit.fd.io/r/c/vpp/+/35479 2022-12-03 09:55:24 +00:00
d4911a3c99 Update PCI bus enumeration for hippo's regression test. Hu12/* -> Hu13/* 2022-12-03 09:54:53 +00:00
60c4324f7e vppapi: Use VPPApiJSONFiles instead of reinventing the wheel. 2022-10-28 14:05:03 +02:00
849b51be67 pylint: move most implementation detail to private methods 2022-07-18 08:03:56 +00:00
8121eba598 pylint: Remove a few exception lint warnings 2022-07-18 07:46:12 +00:00
343a59b376 bugfix: remove addresses also when there is a diff, not only when the interface is not present; remove duplicate block of code 2022-07-18 07:37:00 +00:00
18260e3465 Call the correct new location of vppcfg.py 2022-07-18 07:36:14 +00:00
1abcc38bdd build: add empty __init__.py to satisfy build / pylint 2022-07-13 12:28:15 +00:00
fbe82a3057 lint: Address pylint warnings 2022-07-13 12:16:45 +00:00
9f2ef0e56a build: fix python load paths
Fixed python load paths so that vppcfg will work installed as python
library and standalone from the source directory, fixing load
pathes for resources such as yaml files along the way.

Added a make target for pylint called 'make check-style', fixed a
number of minor pylint issues along the way.

Signed-off-by: Ray Kinsella <mdr@ashroe.eu>
2022-07-12 15:38:14 +01:00
a644840453 bugfix: print sub-interface, not phy, in this error message 2022-07-10 14:12:23 +00:00
b15106b88c build: reworked with setuptools
Signed-off-by: Ray Kinsella <mdr@ashroe.eu>
2022-07-01 18:36:13 +01:00
02cba6e81f Fix optional vpp args handling
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2022-05-17 17:36:58 -04:00
a7aefee4de Black formatting 2022-05-01 17:51:04 +00:00
a69a49d6f6 Only copy over keyword args if they're set (fixes bug in 'check' which does not supply args.vpp_*) 2022-05-01 17:47:11 +00:00
b09773ae75 vppcfg: add args to specify location of vpp api files
- refactor to address review comments.

Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2022-04-26 21:04:31 -04:00
71ea1823f4 Formatting w/ black 2022-04-24 10:41:35 +00:00
5af27211f3 Add an initial stab at docstrings - enable docstring pylinter 2022-04-24 10:36:25 +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
b7ff5479ac Fix lint errors with black 2022-04-22 13:10:16 +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
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
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
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
dfd8c8b8a9 Add user guide for 'vppcfg dump' command 2022-04-03 13:01:31 +00:00
2b98d57fd2 Move VPPAPIDumper into its own class.
Create a 'dump' command that calls it and exits vppcfg.
Add help strings to each of the commands.
2022-04-03 11:53:51 +00:00
b67493003f Only write output if in planning mode 2022-04-03 11:05:50 +00:00
566efe3596 Add a CLI output emitter (either to stdout or to filename), based on plan --output/-o flag 2022-04-03 09:49:27 +00:00
f786a00e9a Check for the existence of LCP config statements, and if so, require linux-cp or lcpng plugins are enabled in VPP 2022-04-02 20:16:51 +00:00
176fd297aa Refactor phys_exist() into phys_exist_in_{config,vpp}(); Correct vppapi.get_phys() 2022-03-26 23:07:49 +00:00
4c31541b3e Signal failure/success at the end of the reconciliation run 2022-03-26 22:52:06 +00:00