Skip to content

Instantly share code, notes, and snippets.

@dlenwell
Created August 28, 2015 20:23
Show Gist options
  • Save dlenwell/f066374bae1e36bd106a to your computer and use it in GitHub Desktop.
Save dlenwell/f066374bae1e36bd106a to your computer and use it in GitHub Desktop.
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