<s> from oslo_log import log as logging <EOL> from nova . network import linux_net <EOL> from nova import utils <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class L3Driver ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , l3_lib = None ) : <EOL> raise NotImplementedError ( ) <EOL> def initialize ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def initialize_network ( self , cidr , is_external ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def initialize_gateway ( self , network_ref ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def remove_gateway ( self , network_ref ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def is_initialized ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def add_floating_ip ( self , floating_ip , fixed_ip , l3_interface_id , <EOL> network = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def remove_floating_ip ( self , floating_ip , fixed_ip , l3_interface_id , <EOL> network = None ) : <EOL> raise NotImplementedError ( ) <EOL> def add_vpn ( self , public_ip , port , private_ip ) : <EOL> raise NotImplementedError ( ) <EOL> def remove_vpn ( self , public_ip , port , private_ip ) : <EOL> raise NotImplementedError ( ) <EOL> def clean_conntrack ( self , fixed_ip ) : <EOL> raise NotImplementedError ( ) <EOL> def teardown ( self ) : <EOL> raise NotImplementedError ( ) <EOL> class LinuxNetL3 ( L3Driver ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . initialized = False <EOL> def initialize ( self , ** kwargs ) : <EOL> if self . initialized : <EOL> return <EOL> LOG . debug ( "<STR_LIT>" ) <EOL> fixed_range = kwargs . get ( '<STR_LIT>' , False ) <EOL> networks = kwargs . get ( '<STR_LIT>' , None ) <EOL> if not fixed_range and networks is not None : <EOL> for network in networks : <EOL> if network [ '<STR_LIT>' ] : <EOL> is_ext = ( network [ '<STR_LIT>' ] is not None and <EOL> network [ '<STR_LIT>' ] != network [ '<STR_LIT>' ] ) <EOL> self . initialize_network ( network [ '<STR_LIT>' ] , is_ext ) <EOL> linux_net . ensure_metadata_ip ( ) <EOL> linux_net . metadata_forward ( ) <EOL> self . initialized = True <EOL> def is_initialized ( self ) : <EOL> return self . initialized <EOL> def initialize_network ( self , cidr , is_external ) : <EOL> linux_net . init_host ( cidr , is_external ) <EOL> def initialize_gateway ( self , network_ref ) : <EOL> mac_address = utils . generate_mac_address ( ) <EOL> dev = linux_net . plug ( network_ref , mac_address , <EOL> gateway = ( network_ref [ '<STR_LIT>' ] is not None ) ) <EOL> linux_net . initialize_gateway_device ( dev , network_ref ) <EOL> def remove_gateway ( self , network_ref ) : <EOL> linux_net . unplug ( network_ref ) <EOL> def add_floating_ip ( self , floating_ip , fixed_ip , l3_interface_id , <EOL> network = None ) : <EOL> linux_net . ensure_floating_forward ( floating_ip , fixed_ip , <EOL> l3_interface_id , network ) <EOL> linux_net . bind_floating_ip ( floating_ip , l3_interface_id ) <EOL> def remove_floating_ip ( self , floating_ip , fixed_ip , l3_interface_id , <EOL> network = None ) : <EOL> linux_net . unbind_floating_ip ( floating_ip , l3_interface_id ) <EOL> linux_net . remove_floating_forward ( floating_ip , fixed_ip , <EOL> l3_interface_id , network ) <EOL> linux_net . clean_conntrack ( fixed_ip ) <EOL> def add_vpn ( self , public_ip , port , private_ip ) : <EOL> linux_net . ensure_vpn_forward ( public_ip , port , private_ip ) <EOL> def remove_vpn ( self , public_ip , port , private_ip ) : <EOL> pass <EOL> def teardown ( self ) : <EOL> pass <EOL> class NullL3 ( L3Driver ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> pass <EOL> def initialize ( self , ** kwargs ) : <EOL> pass <EOL> def is_initialized ( self ) : <EOL> return True <EOL> def initialize_network ( self , cidr , is_external ) : <EOL> pass <EOL> def initialize_gateway ( self , network_ref ) : <EOL> pass <EOL> def remove_gateway ( self , network_ref ) : <EOL> pass <EOL> def add_floating_ip ( self , floating_ip , fixed_ip , l3_interface_id , <EOL> network = None ) : <EOL> pass <EOL> def remove_floating_ip ( self , floating_ip , fixed_ip , l3_interface_id , <EOL> network = None ) : <EOL> pass <EOL> def add_vpn ( self , public_ip , port , private_ip ) : <EOL> pass <EOL> def remove_vpn ( self , public_ip , port , private_ip ) : <EOL> pass <EOL> def clean_conntrack ( self , fixed_ip ) : <EOL> pass <EOL> def teardown ( self ) : <EOL> pass </s>
