Merge branch 'main' of github.com:pimvanpelt/vppcfg into main
This commit is contained in:
1
setup.py
1
setup.py
@ -9,7 +9,6 @@ setup(
|
|||||||
'importlib-metadata; python_version == "3.8"',
|
'importlib-metadata; python_version == "3.8"',
|
||||||
"yamale",
|
"yamale",
|
||||||
"netaddr",
|
"netaddr",
|
||||||
"ipaddress",
|
|
||||||
"vpp_papi",
|
"vpp_papi",
|
||||||
],
|
],
|
||||||
packages=["vppcfg", "vppcfg/config", "vppcfg/vpp"],
|
packages=["vppcfg", "vppcfg/config", "vppcfg/vpp"],
|
||||||
|
@ -30,7 +30,7 @@ class Applier(VPPApi):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
vpp_api_socket="/run/vpp/api.sock",
|
vpp_api_socket="/run/vpp/api.sock",
|
||||||
vpp_json_dir="/usr/share/vpp/api/",
|
vpp_json_dir=None,
|
||||||
clientname="vppcfg",
|
clientname="vppcfg",
|
||||||
):
|
):
|
||||||
VPPApi.__init__(self, vpp_api_socket, vpp_json_dir, clientname)
|
VPPApi.__init__(self, vpp_api_socket, vpp_json_dir, clientname)
|
||||||
|
@ -34,7 +34,7 @@ class Dumper(VPPApi):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
vpp_api_socket="/run/vpp/api.sock",
|
vpp_api_socket="/run/vpp/api.sock",
|
||||||
vpp_json_dir="/usr/share/vpp/api/",
|
vpp_json_dir=None,
|
||||||
clientname="vppcfg",
|
clientname="vppcfg",
|
||||||
):
|
):
|
||||||
VPPApi.__init__(self, vpp_api_socket, vpp_json_dir, clientname)
|
VPPApi.__init__(self, vpp_api_socket, vpp_json_dir, clientname)
|
||||||
|
@ -42,7 +42,7 @@ class Reconciler:
|
|||||||
self,
|
self,
|
||||||
cfg,
|
cfg,
|
||||||
vpp_api_socket="/run/vpp/api.sock",
|
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 = logging.getLogger("vppcfg.reconciler")
|
||||||
self.logger.addHandler(logging.NullHandler())
|
self.logger.addHandler(logging.NullHandler())
|
||||||
|
@ -23,7 +23,7 @@ import fnmatch
|
|||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from vpp_papi import VPPApiClient
|
from vpp_papi import VPPApiClient, VPPApiJSONFiles
|
||||||
|
|
||||||
|
|
||||||
class VPPApi:
|
class VPPApi:
|
||||||
@ -32,12 +32,15 @@ class VPPApi:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
vpp_api_socket="/run/vpp/api.sock",
|
vpp_api_socket="/run/vpp/api.sock",
|
||||||
vpp_json_dir="/usr/share/vpp/api/",
|
vpp_json_dir=None,
|
||||||
clientname="vppcfg",
|
clientname="vppcfg",
|
||||||
):
|
):
|
||||||
self.logger = logging.getLogger("vppcfg.vppapi")
|
self.logger = logging.getLogger("vppcfg.vppapi")
|
||||||
self.logger.addHandler(logging.NullHandler())
|
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):
|
if not os.path.exists(vpp_api_socket):
|
||||||
self.logger.error(f"VPP api socket file not found: {vpp_api_socket}")
|
self.logger.error(f"VPP api socket file not found: {vpp_api_socket}")
|
||||||
if not os.path.isdir(vpp_json_dir):
|
if not os.path.isdir(vpp_json_dir):
|
||||||
@ -58,11 +61,7 @@ class VPPApi:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# construct a list of all the json api files
|
# construct a list of all the json api files
|
||||||
jsonfiles = []
|
jsonfiles = VPPApiJSONFiles.find_api_files(api_dir=self.vpp_json_dir)
|
||||||
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))
|
|
||||||
|
|
||||||
if not jsonfiles:
|
if not jsonfiles:
|
||||||
self.logger.error("no json api files found")
|
self.logger.error("no json api files found")
|
||||||
return False
|
return False
|
||||||
|
Reference in New Issue
Block a user