From: David Lamparter Date: Tue, 26 May 2020 17:12:24 +0000 (+0200) Subject: tools/frr-reload: --vty_socket arg X-Git-Tag: base_7.5~336^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=fa18c6bbda1dccd79035e0d4c2852eebd069a7f9;p=mirror%2Ffrr.git tools/frr-reload: --vty_socket arg After the cleanup, adding this doesn't require updating a zillion locations in the code anymore, just one :) Partially derived from 6a00e91d99f7f98d857c2056d0dcfeba48966581 Originally-by: Emanuele Di Pascale Signed-off-by: David Lamparter --- diff --git a/tools/frr-reload.py b/tools/frr-reload.py index b335a5b618..bdba65ee2f 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -63,12 +63,14 @@ class VtyshException(Exception): pass class Vtysh(object): - def __init__(self, bindir=None, confdir=None): + def __init__(self, bindir=None, confdir=None, sockdir=None): self.bindir = bindir self.confdir = confdir self.common_args = [os.path.join(bindir or '', 'vtysh')] if confdir: self.common_args.extend(['--config_dir', confdir]) + if sockdir: + self.common_args.extend(['--vty_socket', sockdir]) def _call(self, args, stdin=None, stdout=None, stderr=None): kwargs = {} @@ -1171,6 +1173,7 @@ if __name__ == '__main__': parser.add_argument('--bindir', help='path to the vtysh executable', default='/usr/bin') parser.add_argument('--confdir', help='path to the daemon config files', default='/etc/frr') parser.add_argument('--rundir', help='path for the temp config file', default='/var/run/frr') + parser.add_argument('--vty_socket', help='socket to be used by vtysh to connect to the daemons', default=None) parser.add_argument('--daemon', help='daemon for which want to replace the config', default='') args = parser.parse_args() @@ -1226,6 +1229,13 @@ if __name__ == '__main__': log.error(msg) sys.exit(1) + # verify that the vty_socket, if specified, is valid + if args.vty_socket and not os.path.isdir(args.vty_socket): + msg = 'vty_socket %s is not a valid path' % args.vty_socket + print(msg) + log.error(msg) + sys.exit(1) + # verify that the daemon, if specified, is valid if args.daemon and args.daemon not in ['zebra', 'bgpd', 'fabricd', 'isisd', 'ospf6d', 'ospfd', 'pbrd', 'pimd', 'ripd', 'ripngd', 'sharpd', 'staticd', 'vrrpd', 'ldpd']: msg = "Daemon %s is not a valid option for 'show running-config'" % args.daemon @@ -1233,7 +1243,7 @@ if __name__ == '__main__': log.error(msg) sys.exit(1) - vtysh = Vtysh(args.bindir, args.confdir) + vtysh = Vtysh(args.bindir, args.confdir, args.vty_socket) # Verify that 'service integrated-vtysh-config' is configured vtysh_filename = args.confdir + '/vtysh.conf'