Fix lint errors with black
This commit is contained in:
@ -16,9 +16,10 @@ This program expects Python3 and PIP to be installed. It's known to work on Open
|
|||||||
sudo pip3 install argparse
|
sudo pip3 install argparse
|
||||||
sudo pip3 install yamale
|
sudo pip3 install yamale
|
||||||
sudo pip3 install pyyaml
|
sudo pip3 install pyyaml
|
||||||
sudo pip3 install pyinstaller
|
|
||||||
sudo pip3 install netaddr
|
sudo pip3 install netaddr
|
||||||
sudo pip3 install ipaddress
|
sudo pip3 install ipaddress
|
||||||
|
sudo pip3 install pyinstaller
|
||||||
|
sudo pip3 install black
|
||||||
|
|
||||||
## Ensure all unittests pass.
|
## Ensure all unittests pass.
|
||||||
./tests.py -d -t unittest/yaml/*.yaml
|
./tests.py -d -t unittest/yaml/*.yaml
|
||||||
|
124
vppcfg
124
vppcfg
@ -30,26 +30,108 @@ except ImportError:
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
|
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
|
||||||
parser.add_argument('-d', '--debug', dest='debug', action='store_true', help="""enable debug logging, default False""")
|
parser.add_argument(
|
||||||
parser.add_argument('-q', '--quiet', dest='quiet', action='store_true', help="""be quiet (only warnings/errors), default False""")
|
"-d",
|
||||||
parser.add_argument('-f', '--force', dest='force', action='store_true', help="""force progress despite warnings, default False""")
|
"--debug",
|
||||||
|
dest="debug",
|
||||||
|
action="store_true",
|
||||||
|
help="""enable debug logging, default False""",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-q",
|
||||||
|
"--quiet",
|
||||||
|
dest="quiet",
|
||||||
|
action="store_true",
|
||||||
|
help="""be quiet (only warnings/errors), default False""",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-f",
|
||||||
|
"--force",
|
||||||
|
dest="force",
|
||||||
|
action="store_true",
|
||||||
|
help="""force progress despite warnings, default False""",
|
||||||
|
)
|
||||||
|
|
||||||
subparsers = parser.add_subparsers(dest='command')
|
subparsers = parser.add_subparsers(dest="command")
|
||||||
check_p = subparsers.add_parser('check', help="check given YAML config for validity (no VPP)")
|
check_p = subparsers.add_parser(
|
||||||
check_p.add_argument('-s', '--schema', dest='schema', type=str, help="""YAML schema validation file, default to use built-in""")
|
"check", help="check given YAML config for validity (no VPP)"
|
||||||
check_p.add_argument('-c', '--config', dest='config', required=True, type=str, help="""YAML configuration file for vppcfg""")
|
)
|
||||||
|
check_p.add_argument(
|
||||||
|
"-s",
|
||||||
|
"--schema",
|
||||||
|
dest="schema",
|
||||||
|
type=str,
|
||||||
|
help="""YAML schema validation file, default to use built-in""",
|
||||||
|
)
|
||||||
|
check_p.add_argument(
|
||||||
|
"-c",
|
||||||
|
"--config",
|
||||||
|
dest="config",
|
||||||
|
required=True,
|
||||||
|
type=str,
|
||||||
|
help="""YAML configuration file for vppcfg""",
|
||||||
|
)
|
||||||
|
|
||||||
dump_p = subparsers.add_parser('dump', help="dump current running VPP configuration (VPP readonly)")
|
dump_p = subparsers.add_parser(
|
||||||
dump_p.add_argument('-o', '--output', dest='outfile', required=False, default='-', type=str, help="""Output file for YAML config, default stdout""")
|
"dump", help="dump current running VPP configuration (VPP readonly)"
|
||||||
|
)
|
||||||
|
dump_p.add_argument(
|
||||||
|
"-o",
|
||||||
|
"--output",
|
||||||
|
dest="outfile",
|
||||||
|
required=False,
|
||||||
|
default="-",
|
||||||
|
type=str,
|
||||||
|
help="""Output file for YAML config, default stdout""",
|
||||||
|
)
|
||||||
|
|
||||||
plan_p = subparsers.add_parser('plan', help="plan changes from current VPP dataplane to target config (VPP readonly)")
|
plan_p = subparsers.add_parser(
|
||||||
plan_p.add_argument('-s', '--schema', dest='schema', type=str, help="""YAML schema validation file, default to use built-in""")
|
"plan",
|
||||||
plan_p.add_argument('-c', '--config', dest='config', required=True, type=str, help="""YAML configuration file for vppcfg""")
|
help="plan changes from current VPP dataplane to target config (VPP readonly)",
|
||||||
plan_p.add_argument('-o', '--output', dest='outfile', required=False, default='-', type=str, help="""Output file for VPP CLI commands, default stdout""")
|
)
|
||||||
|
plan_p.add_argument(
|
||||||
|
"-s",
|
||||||
|
"--schema",
|
||||||
|
dest="schema",
|
||||||
|
type=str,
|
||||||
|
help="""YAML schema validation file, default to use built-in""",
|
||||||
|
)
|
||||||
|
plan_p.add_argument(
|
||||||
|
"-c",
|
||||||
|
"--config",
|
||||||
|
dest="config",
|
||||||
|
required=True,
|
||||||
|
type=str,
|
||||||
|
help="""YAML configuration file for vppcfg""",
|
||||||
|
)
|
||||||
|
plan_p.add_argument(
|
||||||
|
"-o",
|
||||||
|
"--output",
|
||||||
|
dest="outfile",
|
||||||
|
required=False,
|
||||||
|
default="-",
|
||||||
|
type=str,
|
||||||
|
help="""Output file for VPP CLI commands, default stdout""",
|
||||||
|
)
|
||||||
|
|
||||||
apply_p = subparsers.add_parser('apply', help="apply changes from current VPP dataplane to target config")
|
apply_p = subparsers.add_parser(
|
||||||
apply_p.add_argument('-s', '--schema', dest='schema', type=str, help="""YAML schema validation file, default to use built-in""")
|
"apply", help="apply changes from current VPP dataplane to target config"
|
||||||
apply_p.add_argument('-c', '--config', dest='config', required=True, type=str, help="""YAML configuration file for vppcfg""")
|
)
|
||||||
|
apply_p.add_argument(
|
||||||
|
"-s",
|
||||||
|
"--schema",
|
||||||
|
dest="schema",
|
||||||
|
type=str,
|
||||||
|
help="""YAML schema validation file, default to use built-in""",
|
||||||
|
)
|
||||||
|
apply_p.add_argument(
|
||||||
|
"-c",
|
||||||
|
"--config",
|
||||||
|
dest="config",
|
||||||
|
required=True,
|
||||||
|
type=str,
|
||||||
|
help="""YAML configuration file for vppcfg""",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if not args.command:
|
if not args.command:
|
||||||
@ -62,7 +144,9 @@ def main():
|
|||||||
level = logging.DEBUG
|
level = logging.DEBUG
|
||||||
if args.quiet:
|
if args.quiet:
|
||||||
level = logging.WARNING
|
level = logging.WARNING
|
||||||
logging.basicConfig(format='[%(levelname)-8s] %(name)s.%(funcName)s: %(message)s', level=level)
|
logging.basicConfig(
|
||||||
|
format="[%(levelname)-8s] %(name)s.%(funcName)s: %(message)s", level=level
|
||||||
|
)
|
||||||
|
|
||||||
if args.command == "dump":
|
if args.command == "dump":
|
||||||
d = Dumper()
|
d = Dumper()
|
||||||
@ -102,7 +186,9 @@ def main():
|
|||||||
sys.exit(-5)
|
sys.exit(-5)
|
||||||
|
|
||||||
if not r.lcps_exist_with_lcp_enabled():
|
if not r.lcps_exist_with_lcp_enabled():
|
||||||
logging.error("Linux Control Plane is needed, but linux-cp API is not available")
|
logging.error(
|
||||||
|
"Linux Control Plane is needed, but linux-cp API is not available"
|
||||||
|
)
|
||||||
sys.exit(-6)
|
sys.exit(-6)
|
||||||
|
|
||||||
failed = False
|
failed = False
|
||||||
@ -139,5 +225,7 @@ def main():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user