diff options
author | Christian Breunig <christian@breunig.cc> | 2024-06-26 21:13:43 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-06-26 21:47:09 +0200 |
commit | 9473800055e0e1e9833f4a41c6d5d5a8a0d27399 (patch) | |
tree | 5301252a4b24643cc28d8b55a004c5f21b774b40 | |
parent | 6890cd7b0f2419d6b1a720d892f9a7d07b7cfd05 (diff) | |
download | vyos-1x-9473800055e0e1e9833f4a41c6d5d5a8a0d27399.tar.gz vyos-1x-9473800055e0e1e9833f4a41c6d5d5a8a0d27399.zip |
vyos-configd: T6510: autogenerate configd-include.json
Now that there is a build time validation that Config() is not instantiated
twice in a config mode script, and also as there are no more direct calls on
the my_set and my_delete binary, we can auto generate the list of helpers run
by vyos-configd.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | data/configd-include.json | 115 | ||||
-rwxr-xr-x | scripts/generate-configd-include-json.py | 34 |
4 files changed, 42 insertions, 128 deletions
diff --git a/.gitignore b/.gitignore index 507daceee..01333d5b1 100644 --- a/.gitignore +++ b/.gitignore @@ -145,6 +145,8 @@ data/component-versions.json # vyos-1x XML cache python/vyos/xml_ref/cache.py python/vyos/xml_ref/pkg_cache/*_cache.py +# autogenerated vyos-configd JSON definition +data/configd-include.json # We do not use pip Pipfile @@ -78,18 +78,7 @@ vyshim: $(MAKE) -C $(SHIM_DIR) .PHONY: all -all: clean interface_definitions op_mode_definitions check test j2lint vyshim check_migration_scripts_executable - -.PHONY: check -.ONESHELL: -check: - @echo "Checking which CLI scripts are not enabled to work with vyos-configd..." - @for file in `ls src/conf_mode -I__pycache__` - do - if ! grep -q $$file data/configd-include.json; then - echo "* $$file" - fi - done +all: clean interface_definitions op_mode_definitions test j2lint vyshim check_migration_scripts_executable generate-configd-include-json .PHONY: clean clean: @@ -99,7 +88,7 @@ clean: $(MAKE) -C $(SHIM_DIR) clean .PHONY: test -test: +test: generate-configd-include-json set -e; python3 -m compileall -q -x '/vmware-tools/scripts/, /ppp/' . PYTHONPATH=python/ python3 -m "nose" --with-xunit src --with-coverage --cover-erase --cover-xml --cover-package src/conf_mode,src/op_mode,src/completion,src/helpers,src/validators,src/tests --verbose @@ -127,6 +116,10 @@ unused-imports: deb: dpkg-buildpackage -uc -us -tc -b +.PHONY: generate-configd-include-json +generate-configd-include-json: + @scripts/generate-configd-include-json.py + .PHONY: schema schema: trang -I rnc -O rng schema/interface_definition.rnc schema/interface_definition.rng diff --git a/data/configd-include.json b/data/configd-include.json deleted file mode 100644 index 224a9c390..000000000 --- a/data/configd-include.json +++ /dev/null @@ -1,115 +0,0 @@ -[ -"container.py", -"firewall.py", -"high-availability.py", -"interfaces_bonding.py", -"interfaces_bridge.py", -"interfaces_dummy.py", -"interfaces_ethernet.py", -"interfaces_geneve.py", -"interfaces_input.py", -"interfaces_l2tpv3.py", -"interfaces_loopback.py", -"interfaces_macsec.py", -"interfaces_openvpn.py", -"interfaces_pppoe.py", -"interfaces_pseudo-ethernet.py", -"interfaces_sstpc.py", -"interfaces_tunnel.py", -"interfaces_virtual-ethernet.py", -"interfaces_vti.py", -"interfaces_vxlan.py", -"interfaces_wireguard.py", -"interfaces_wireless.py", -"interfaces_wwan.py", -"load-balancing_reverse-proxy.py", -"load-balancing_wan.py", -"nat.py", -"nat64.py", -"nat66.py", -"netns.py", -"pki.py", -"policy.py", -"policy_route.py", -"policy_local-route.py", -"protocols_babel.py", -"protocols_bfd.py", -"protocols_bgp.py", -"protocols_eigrp.py", -"protocols_failover.py", -"protocols_igmp-proxy.py", -"protocols_isis.py", -"protocols_mpls.py", -"protocols_nhrp.py", -"protocols_ospf.py", -"protocols_ospfv3.py", -"protocols_pim.py", -"protocols_pim6.py", -"protocols_rip.py", -"protocols_ripng.py", -"protocols_rpki.py", -"protocols_segment-routing.py", -"protocols_static.py", -"protocols_static_arp.py", -"protocols_static_multicast.py", -"protocols_static_neighbor-proxy.py", -"qos.py", -"service_aws_glb.py", -"service_broadcast-relay.py", -"service_config-sync.py", -"service_conntrack-sync.py", -"service_console-server.py", -"service_dhcp-relay.py", -"service_dhcp-server.py", -"service_dhcpv6-relay.py", -"service_dhcpv6-server.py", -"service_dns_dynamic.py", -"service_dns_forwarding.py", -"service_event-handler.py", -"service_https.py", -"service_ids_ddos-protection.py", -"service_ipoe-server.py", -"service_lldp.py", -"service_mdns_repeater.py", -"service_monitoring_telegraf.py", -"service_monitoring_zabbix-agent.py", -"service_ndp-proxy.py", -"service_ntp.py", -"service_pppoe-server.py", -"service_router-advert.py", -"service_salt-minion.py", -"service_sla.py", -"service_snmp.py", -"service_ssh.py", -"service_stunnel.py", -"service_tftp-server.py", -"service_webproxy.py", -"system_acceleration.py", -"system_config-management.py", -"system_conntrack.py", -"system_console.py", -"system_flow-accounting.py", -"system_frr.py", -"system_host-name.py", -"system_ip.py", -"system_ipv6.py", -"system_lcd.py", -"system_login.py", -"system_login_banner.py", -"system_logs.py", -"system_option.py", -"system_proxy.py", -"system_sflow.py", -"system_sysctl.py", -"system_syslog.py", -"system_task-scheduler.py", -"system_timezone.py", -"system_update-check.py", -"system_wireless.py", -"vpn_ipsec.py", -"vpn_l2tp.py", -"vpn_openconnect.py", -"vpn_pptp.py", -"vpn_sstp.py", -"vrf.py" -] diff --git a/scripts/generate-configd-include-json.py b/scripts/generate-configd-include-json.py new file mode 100755 index 000000000..b4b627fce --- /dev/null +++ b/scripts/generate-configd-include-json.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import os +from jinja2 import Template + +conf_scripts = 'src/conf_mode' +configd_include = 'data/configd-include.json' + +configd_template = Template("""[ +{% for file in files %} +"{{ file }}"{{ "," if not loop.last else "" }} +{% endfor %} +] +""", trim_blocks=True) + +files = [f for f in os.listdir(conf_scripts) if os.path.isfile(f'{conf_scripts}/{f}')] +files = sorted(files) + +tmp = {'files' : files} +with open(configd_include, 'w') as f: + f.write(configd_template.render(tmp)) |