Rename reconciler to planner
This commit is contained in:
@@ -253,7 +253,7 @@ $ vppcfg plan -c example.yaml -o example.exec
|
|||||||
[INFO ] vppcfg.config.valid_config: Configuration validated successfully
|
[INFO ] vppcfg.config.valid_config: Configuration validated successfully
|
||||||
[INFO ] root.main: Configuration is valid
|
[INFO ] root.main: Configuration is valid
|
||||||
[INFO ] vppcfg.vppapi.connect: VPP version is 22.06-rc0~320-g8f60318ac
|
[INFO ] vppcfg.vppapi.connect: VPP version is 22.06-rc0~320-g8f60318ac
|
||||||
[INFO ] vppcfg.reconciler.write: Wrote 78 lines to example.exec
|
[INFO ] vppcfg.planner.write: Wrote 78 lines to example.exec
|
||||||
[INFO ] root.main: Planning succeeded
|
[INFO ] root.main: Planning succeeded
|
||||||
|
|
||||||
$ vppctl exec ~/src/vppcfg/example.exec
|
$ vppctl exec ~/src/vppcfg/example.exec
|
||||||
@@ -263,7 +263,7 @@ $ vppcfg plan -c example.yaml
|
|||||||
[INFO ] vppcfg.config.valid_config: Configuration validated successfully
|
[INFO ] vppcfg.config.valid_config: Configuration validated successfully
|
||||||
[INFO ] root.main: Configuration is valid
|
[INFO ] root.main: Configuration is valid
|
||||||
[INFO ] vppcfg.vppapi.connect: VPP version is 22.06-rc0~320-g8f60318ac
|
[INFO ] vppcfg.vppapi.connect: VPP version is 22.06-rc0~320-g8f60318ac
|
||||||
[INFO ] vppcfg.reconciler.write: Wrote 0 lines to (stdout)
|
[INFO ] vppcfg.planner.write: Wrote 0 lines to (stdout)
|
||||||
[INFO ] root.main: Planning succeeded
|
[INFO ] root.main: Planning succeeded
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ from vppcfg.config import tap
|
|||||||
from .vppapi import VPPApi
|
from .vppapi import VPPApi
|
||||||
|
|
||||||
|
|
||||||
class Reconciler:
|
class Planner:
|
||||||
"""The Reconciler class first reads the running configuration of a VPP Dataplane,
|
"""The Planner class first reads the running configuration of a VPP Dataplane,
|
||||||
and based on an intended target YAML configuration file, plans a path to make the
|
and based on an intended target YAML configuration file, plans a path to make the
|
||||||
dataplane safely reflect the target config. It first prunes (removes) objects that
|
dataplane safely reflect the target config. It first prunes (removes) objects that
|
||||||
are not meant to be in the dataplane, or are in the dataplane but are not of the
|
are not meant to be in the dataplane, or are in the dataplane but are not of the
|
||||||
@@ -44,7 +44,7 @@ class Reconciler:
|
|||||||
vpp_api_socket="/run/vpp/api.sock",
|
vpp_api_socket="/run/vpp/api.sock",
|
||||||
vpp_json_dir=None,
|
vpp_json_dir=None,
|
||||||
):
|
):
|
||||||
self.logger = logging.getLogger("vppcfg.reconciler")
|
self.logger = logging.getLogger("vppcfg.planner")
|
||||||
self.logger.addHandler(logging.NullHandler())
|
self.logger.addHandler(logging.NullHandler())
|
||||||
|
|
||||||
self.vpp = VPPApi(vpp_api_socket, vpp_json_dir)
|
self.vpp = VPPApi(vpp_api_socket, vpp_json_dir)
|
||||||
@@ -88,7 +88,7 @@ class Reconciler:
|
|||||||
def prune(self):
|
def prune(self):
|
||||||
"""Remove all objects from VPP that do not occur in the config. For an indepth explanation
|
"""Remove all objects from VPP that do not occur in the config. For an indepth explanation
|
||||||
of how and why this particular pruning order is chosen, see README.md section on
|
of how and why this particular pruning order is chosen, see README.md section on
|
||||||
Reconciling."""
|
Planning."""
|
||||||
ret = True
|
ret = True
|
||||||
if not self.__prune_admin_state():
|
if not self.__prune_admin_state():
|
||||||
self.logger.warning("Could not set interfaces down in VPP")
|
self.logger.warning("Could not set interfaces down in VPP")
|
||||||
@@ -752,8 +752,8 @@ class Reconciler:
|
|||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
"""Create all objects in VPP that occur in the config but not in VPP. For an indepth
|
"""Create all objects in VPP that occur in the config but not in VPP. For an indepth
|
||||||
explanation of how and why this particular pruning order is chosen, see README.md
|
explanation of how and why this particular creation order is chosen, see README.md
|
||||||
section on Reconciling."""
|
section on Planning."""
|
||||||
ret = True
|
ret = True
|
||||||
if not self.__create_loopbacks():
|
if not self.__create_loopbacks():
|
||||||
self.logger.warning("Could not create Loopbacks in VPP")
|
self.logger.warning("Could not create Loopbacks in VPP")
|
||||||
@@ -29,7 +29,7 @@ except ModuleNotFoundError:
|
|||||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
from vppcfg.config import Validator
|
from vppcfg.config import Validator
|
||||||
from vppcfg._version import __version__
|
from vppcfg._version import __version__
|
||||||
from vppcfg.vpp.reconciler import Reconciler
|
from vppcfg.vpp.planner import Planner
|
||||||
from vppcfg.vpp.dumper import Dumper
|
from vppcfg.vpp.dumper import Dumper
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -246,44 +246,44 @@ def main():
|
|||||||
if args.command == "check":
|
if args.command == "check":
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
reconciler = Reconciler(cfg, **opt_kwargs)
|
planner = Planner(cfg, **opt_kwargs)
|
||||||
if args.command == "plan" and args.novpp:
|
if args.command == "plan" and args.novpp:
|
||||||
if not reconciler.vpp.mockconfig(cfg):
|
if not planner.vpp.mockconfig(cfg):
|
||||||
sys.exit(-7)
|
sys.exit(-7)
|
||||||
else:
|
else:
|
||||||
if not reconciler.vpp.readconfig():
|
if not planner.vpp.readconfig():
|
||||||
sys.exit(-3)
|
sys.exit(-3)
|
||||||
|
|
||||||
if not reconciler.phys_exist_in_vpp():
|
if not planner.phys_exist_in_vpp():
|
||||||
logging.error("Not all PHYs in the config exist in VPP")
|
logging.error("Not all PHYs in the config exist in VPP")
|
||||||
sys.exit(-4)
|
sys.exit(-4)
|
||||||
|
|
||||||
if not reconciler.phys_exist_in_config():
|
if not planner.phys_exist_in_config():
|
||||||
logging.error("Not all PHYs in VPP exist in the config")
|
logging.error("Not all PHYs in VPP exist in the config")
|
||||||
sys.exit(-5)
|
sys.exit(-5)
|
||||||
|
|
||||||
if not reconciler.lcps_exist_with_lcp_enabled():
|
if not planner.lcps_exist_with_lcp_enabled():
|
||||||
logging.error(
|
logging.error(
|
||||||
"Linux Control Plane is needed, but linux-cp API is not available"
|
"Linux Control Plane is needed, but linux-cp API is not available"
|
||||||
)
|
)
|
||||||
sys.exit(-6)
|
sys.exit(-6)
|
||||||
|
|
||||||
failed = False
|
failed = False
|
||||||
if not reconciler.prune():
|
if not planner.prune():
|
||||||
if not args.force:
|
if not args.force:
|
||||||
logging.error("Planning prune failure")
|
logging.error("Planning prune failure")
|
||||||
sys.exit(-10)
|
sys.exit(-10)
|
||||||
failed = True
|
failed = True
|
||||||
logging.warning("Planning prune failure, continuing due to --force")
|
logging.warning("Planning prune failure, continuing due to --force")
|
||||||
|
|
||||||
if not reconciler.create():
|
if not planner.create():
|
||||||
if not args.force:
|
if not args.force:
|
||||||
logging.error("Planning create failure")
|
logging.error("Planning create failure")
|
||||||
sys.exit(-20)
|
sys.exit(-20)
|
||||||
failed = True
|
failed = True
|
||||||
logging.warning("Planning create failure, continuing due to --force")
|
logging.warning("Planning create failure, continuing due to --force")
|
||||||
|
|
||||||
if not reconciler.sync():
|
if not planner.sync():
|
||||||
if not args.force:
|
if not args.force:
|
||||||
logging.error("Planning sync failure")
|
logging.error("Planning sync failure")
|
||||||
sys.exit(-30)
|
sys.exit(-30)
|
||||||
@@ -291,7 +291,7 @@ def main():
|
|||||||
logging.warning("Planning sync failure, continuing due to --force")
|
logging.warning("Planning sync failure, continuing due to --force")
|
||||||
|
|
||||||
if args.command == "plan":
|
if args.command == "plan":
|
||||||
reconciler.write(args.outfile, emit_ok=not failed)
|
planner.write(args.outfile, emit_ok=not failed)
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
logging.error("Planning failed")
|
logging.error("Planning failed")
|
||||||
|
|||||||
Reference in New Issue
Block a user