<s> import weakref <EOL> from neutron . agent . l3 import dvr_fip_ns <EOL> from neutron . agent . l3 import dvr_snat_ns <EOL> SNAT_INT_DEV_PREFIX = dvr_snat_ns . SNAT_INT_DEV_PREFIX <EOL> SNAT_NS_PREFIX = dvr_snat_ns . SNAT_NS_PREFIX <EOL> class AgentMixin ( object ) : <EOL> def __init__ ( self , host ) : <EOL> self . _fip_namespaces = weakref . WeakValueDictionary ( ) <EOL> super ( AgentMixin , self ) . __init__ ( host ) <EOL> def get_fip_ns ( self , ext_net_id ) : <EOL> ext_net_id = str ( ext_net_id ) <EOL> fip_ns = self . _fip_namespaces . get ( ext_net_id ) <EOL> if fip_ns and not fip_ns . destroyed : <EOL> return fip_ns <EOL> fip_ns = dvr_fip_ns . FipNamespace ( ext_net_id , <EOL> self . conf , <EOL> self . driver , <EOL> self . use_ipv6 ) <EOL> self . _fip_namespaces [ ext_net_id ] = fip_ns <EOL> return fip_ns <EOL> def get_ports_by_subnet ( self , subnet_id ) : <EOL> return self . plugin_rpc . get_ports_by_subnet ( self . context , subnet_id ) <EOL> def _update_arp_entry ( self , context , payload , action ) : <EOL> router_id = payload [ '<STR_LIT>' ] <EOL> ri = self . router_info . get ( router_id ) <EOL> if not ri : <EOL> return <EOL> arp_table = payload [ '<STR_LIT>' ] <EOL> ip = arp_table [ '<STR_LIT>' ] <EOL> mac = arp_table [ '<STR_LIT>' ] <EOL> subnet_id = arp_table [ '<STR_LIT>' ] <EOL> ri . _update_arp_entry ( ip , mac , subnet_id , action ) <EOL> def add_arp_entry ( self , context , payload ) : <EOL> """<STR_LIT>""" <EOL> self . _update_arp_entry ( context , payload , '<STR_LIT>' ) <EOL> def del_arp_entry ( self , context , payload ) : <EOL> """<STR_LIT>""" <EOL> self . _update_arp_entry ( context , payload , '<STR_LIT>' ) <EOL> def fipnamespace_delete_on_ext_net ( self , context , ext_net_id ) : <EOL> """<STR_LIT>""" <EOL> fip_ns = self . get_fip_ns ( ext_net_id ) <EOL> if fip_ns . agent_gateway_port and not fip_ns . destroyed : <EOL> fip_ns . unsubscribe ( ext_net_id ) <EOL> fip_ns . delete ( ) </s>
