Created
August 28, 2015 20:23
-
-
Save dlenwell/f066374bae1e36bd106a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import re | |
p = subprocess.Popen(['ipmaddr'], stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE) | |
out, err = p.communicate() | |
prefix_to_delete = ['qv', 'qb', 'ta'] | |
regexp = re.compile(r'^[0-9]') | |
for line in out.splitlines(): | |
if regexp.search(line) is not None: | |
interface = line.split(':')[1].strip() | |
if interface[:2] in prefix_to_delete: | |
print 'removing: ', interface | |
subprocess.call(["ip", "link", "set", interface ,"down"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment