From edad5184a12aefa58d32164cc0fda3cf83186712 Mon Sep 17 00:00:00 2001 From: Marek Isalski Date: Sat, 15 Aug 2020 19:49:01 +0100 Subject: [PATCH] now able to deprovision IPv6 --- automonty | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/automonty b/automonty index 731d1a1..a534b7a 100755 --- a/automonty +++ b/automonty @@ -262,8 +262,6 @@ def monty_teardown( config, args, routers ): for addr in ip_address: ( sel, rval, hst ) = parse_comment( addr.get( 'comment', '' ) ) - rval[ 'teardown' ] = True - comment = make_comment( sel, rval, hst ) if sel == args.hostname or hst == args.hostname: if args.delete: if rval.get( 'teardown', False ): @@ -278,12 +276,38 @@ def monty_teardown( config, args, routers ): else: print( "ignoring %s %s on %s on %s" % ( addr[ 'address' ], addr[ 'network' ], addr[ 'interface' ], name ) ) else: + rval[ 'teardown' ] = True + comment = make_comment( sel, rval, hst ) if args.dry_run: print( '/ip address set [find where interface="%s" and network="%s" and comment~"%s" ] disabled=yes comment="%s"' % ( addr[ 'interface' ], addr[ 'network' ], hst, comment ) ) else: print( "disabling %s %s on %s on %s" % ( addr[ 'address' ], addr[ 'network' ], addr[ 'interface' ], name ) ) ip_address.update( **{ '.id': addr[ '.id' ], 'disabled': 'yes', 'comment': comment } ) + for addr in ipv6_address: + ( sel, rval, hst ) = parse_comment( addr.get( 'comment', '' ) ) + if sel == args.hostname or hst == args.hostname: + if args.delete: + if rval.get( 'teardown', False ): + if args.dry_run: + print( '/ipv6 address remove [find where interface="%s" and address="%s" and comment="%s" ]' % ( addr[ 'interface' ], addr[ 'address' ], addr.get( 'comment', '' ) ) ) + else: + print( "deleting %s from %s on %s" % ( addr[ 'address' ], addr[ 'interface' ], name ) ) + ipv6_address.remove( addr[ '.id' ] ) + else: + if args.dry_run: + print( "# ignoring %s on %s on %s" % ( addr[ 'address' ], addr[ 'interface' ], name ) ) + else: + print( "ignoring %s on %s on %s" % ( addr[ 'address' ], addr[ 'interface' ], name ) ) + else: + rval[ 'teardown' ] = True + comment = make_comment( sel, rval, hst ) + if args.dry_run: + print( '/ipv6 address set [find where interface="%s" and address="%s" and comment="%s" ] disabled=yes comment="%s"' % ( addr[ 'interface' ], addr[ 'address' ], addr.get( 'comment', '' ), comment ) ) + else: + print( "disabling %s on %s on %s" % ( addr[ 'address' ], addr[ 'interface' ], name ) ) + ipv6_address.update( **{ '.id': addr[ '.id' ], 'disabled': 'yes', 'comment': comment } ) + if args.dry_run: print()