Files
vppcfg/vppcfg
Pim van Pelt e9bbd47407 Sync Phase: Implement bondethernets
Include special caveat on LCP MAC changes, for which I'll put in a
TODO for now with a VPP comment {} with the to be run command.

Also make the user aware of a quick in BondEthernets not being able
to have link_mtu != 9000 so if a packet MTU > 9000 is set, this will
work but is an undesirable configuration. Issue a warning in this
case.
2022-03-26 15:14:49 +00:00

88 lines
3.2 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Copyright (c) 2022 Pim van Pelt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# -*- coding: utf-8 -*-
import sys
import yaml
import logging
from config import Validator
import config.interface as interface
from vpp.reconciler import Reconciler
try:
import argparse
except ImportError:
print("ERROR: install argparse manually: sudo pip install argparse")
sys.exit(-2)
def main():
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-c', '--config', dest='config', required=True, type=str, help="""YAML configuration file for VPP""")
parser.add_argument('-s', '--schema', dest='schema', type=str, default='./schema.yaml', help="""YAML schema validation file""")
parser.add_argument('-d', '--debug', dest='debug', action='store_true', help="""Enable debug, default False""")
parser.add_argument('-q', '--quiet', dest='quiet', action='store_true', help="""Be quiet (only log warnings/errors), default False""")
parser.add_argument('-f', '--force', dest='force', action='store_true', help="""Force progress despite warnings, default False""")
args = parser.parse_args()
level = logging.INFO
if args.debug:
level = logging.DEBUG
if args.quiet:
level = logging.WARNING
logging.basicConfig(format='[%(levelname)-8s] %(name)s.%(funcName)s: %(message)s', level=level)
try:
with open(args.config, "r") as f:
logging.info("Loading configfile %s" % args.config)
cfg = yaml.load(f, Loader = yaml.FullLoader)
logging.debug("Config: %s" % cfg)
except:
logging.error("Couldn't read config from %s" % args.config)
sys.exit(-1)
v = Validator(schema=args.schema)
if not v.valid_config(cfg):
logging.error("Configuration is not valid, bailing")
sys.exit(-2)
r = Reconciler(cfg)
if not r.phys_exist(interface.get_phys(cfg)):
logging.error("Not all PHYs in the config exist in VPP")
sys.exit(-3)
if not r.prune():
if not args.force:
logging.error("Reconciliation prune failure")
sys.exit(-4)
logging.warning("Reconciliation prune failure, continuing due to --force")
if not r.create():
if not args.force:
logging.error("Reconciliation create failure")
sys.exit(-5)
logging.warning("Reconciliation create failure, continuing due to --force")
if not r.sync():
if not args.force:
logging.error("Reconciliation sync failure")
sys.exit(-6)
logging.warning("Reconciliation sync failure, continuing due to --force")
if __name__ == "__main__":
main()