<s> import hashlib <EOL> import sys <EOL> from neutron_lib import constants as n_const <EOL> from oslo_utils import encodeutils <EOL> from neutron . cmd . eventlet . plugins . ovs_neutron_agent import main as _main <EOL> from neutron . plugins . ml2 . drivers . openvswitch . agent . ovs_neutron_agent import OVSNeutronAgent <EOL> def get_tunnel_name_full ( cls , network_type , local_ip , remote_ip ) : <EOL> network_type = network_type [ : <NUM_LIT:3> ] <EOL> remote_ip_hex = cls . get_ip_in_hex ( remote_ip ) <EOL> if not remote_ip_hex : <EOL> return None <EOL> hashlen = ( n_const . DEVICE_NAME_MAX_LEN - len ( network_type ) - <NUM_LIT:2> ) // <NUM_LIT:2> <EOL> remote_ip_hex = encodeutils . to_utf8 ( remote_ip_hex ) <EOL> remote_ip_hash = hashlib . sha1 ( remote_ip_hex ) . hexdigest ( ) [ : hashlen ] <EOL> local_ip_hex = cls . get_ip_in_hex ( local_ip ) <EOL> local_ip_hex = encodeutils . to_utf8 ( local_ip_hex ) <EOL> source_ip_hash = hashlib . sha1 ( local_ip_hex ) . hexdigest ( ) [ : hashlen ] <EOL> return '<STR_LIT>' % ( network_type , source_ip_hash , remote_ip_hash ) <EOL> OVSNeutronAgent . get_tunnel_name = get_tunnel_name_full <EOL> def main ( ) : <EOL> _main ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( ) ) </s>
