#NEWLINE# def create_tap_dev( dev , mac_address = None ) : #NEWLINE# #INDENT# if ( not device_exists ( dev ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# utils . execute ( 'ip' , 'tuntap' , 'add' , dev , 'mode' , 'tap' , run_as_root = True , check_exit_code = [ 0 , 2 , 254 ] ) #NEWLINE# #UNINDENT# except processutils . ProcessExecutionError : #NEWLINE# #INDENT# utils . execute ( 'tunctl' , '-b' , '-t' , mac_address , run_as_root = True ) #NEWLINE# #UNINDENT# if mac_address : #NEWLINE# #INDENT# utils . execute ( 'ip' , 'link' , 'set' , dev , 'address' , mac_address , run_as_root = True , check_exit_code = [ 0 , 2 , 254 ] ) #NEWLINE# #UNINDENT# utils . execute ( 'ip' , 'link' , 'set' , dev , 'up' , run_as_root = True , check_exit_code = [ 0 , 2 , 254 ] )