Merge branch 'main' of github.com:pimvanpelt/vppcfg into main

This commit is contained in:
Pim van Pelt
2022-12-03 09:55:37 +00:00
5 changed files with 9 additions and 11 deletions

View File

@ -9,7 +9,6 @@ setup(
'importlib-metadata; python_version == "3.8"',
"yamale",
"netaddr",
"ipaddress",
"vpp_papi",
],
packages=["vppcfg", "vppcfg/config", "vppcfg/vpp"],

View File

@ -30,7 +30,7 @@ class Applier(VPPApi):
def __init__(
self,
vpp_api_socket="/run/vpp/api.sock",
vpp_json_dir="/usr/share/vpp/api/",
vpp_json_dir=None,
clientname="vppcfg",
):
VPPApi.__init__(self, vpp_api_socket, vpp_json_dir, clientname)

View File

@ -34,7 +34,7 @@ class Dumper(VPPApi):
def __init__(
self,
vpp_api_socket="/run/vpp/api.sock",
vpp_json_dir="/usr/share/vpp/api/",
vpp_json_dir=None,
clientname="vppcfg",
):
VPPApi.__init__(self, vpp_api_socket, vpp_json_dir, clientname)

View File

@ -42,7 +42,7 @@ class Reconciler:
self,
cfg,
vpp_api_socket="/run/vpp/api.sock",
vpp_json_dir="/usr/share/vpp/api/",
vpp_json_dir=None,
):
self.logger = logging.getLogger("vppcfg.reconciler")
self.logger.addHandler(logging.NullHandler())

View File

@ -23,7 +23,7 @@ import fnmatch
import logging
import socket
import time
from vpp_papi import VPPApiClient
from vpp_papi import VPPApiClient, VPPApiJSONFiles
class VPPApi:
@ -32,12 +32,15 @@ class VPPApi:
def __init__(
self,
vpp_api_socket="/run/vpp/api.sock",
vpp_json_dir="/usr/share/vpp/api/",
vpp_json_dir=None,
clientname="vppcfg",
):
self.logger = logging.getLogger("vppcfg.vppapi")
self.logger.addHandler(logging.NullHandler())
if vpp_json_dir is None:
vpp_json_dir = VPPApiJSONFiles.find_api_dir([])
if not os.path.exists(vpp_api_socket):
self.logger.error(f"VPP api socket file not found: {vpp_api_socket}")
if not os.path.isdir(vpp_json_dir):
@ -58,11 +61,7 @@ class VPPApi:
return True
# construct a list of all the json api files
jsonfiles = []
for root, _dirnames, filenames in os.walk(self.vpp_json_dir):
for filename in fnmatch.filter(filenames, "*.api.json"):
jsonfiles.append(os.path.join(root, filename))
jsonfiles = VPPApiJSONFiles.find_api_files(api_dir=self.vpp_json_dir)
if not jsonfiles:
self.logger.error("no json api files found")
return False