<s> """<STR_LIT>""" <EOL> from ryu . controller import handler <EOL> from ryu . controller import event <EOL> from ryu . lib import dpid as dpid_lib <EOL> from ryu . lib import mac as mac_lib <EOL> from ryu . lib . packet import vrrp <EOL> from ryu . lib import addrconv <EOL> VRRP_STATE_INITIALIZE = '<STR_LIT>' <EOL> VRRP_STATE_MASTER = '<STR_LIT>' <EOL> VRRP_STATE_BACKUP = '<STR_LIT>' <EOL> VRRP_MANAGER_NAME = '<STR_LIT>' <EOL> class VRRPInterfaceBase ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , mac_address , primary_ip_address , vlan_id = None ) : <EOL> super ( VRRPInterfaceBase , self ) . __init__ ( ) <EOL> self . mac_address = mac_address <EOL> self . primary_ip_address = primary_ip_address <EOL> self . vlan_id = vlan_id <EOL> def __eq__ ( self , other ) : <EOL> return ( self . __class__ == other . __class__ and <EOL> self . mac_address == other . mac_address and <EOL> self . primary_ip_address == other . primary_ip_address and <EOL> self . vlan_id == other . vlan_id ) <EOL> def __hash__ ( self ) : <EOL> return hash ( ( <EOL> addrconv . mac . text_to_bin ( self . mac_address ) , <EOL> vrrp . ip_text_to_bin ( self . primary_ip_address ) , self . vlan_id ) ) <EOL> class VRRPInterfaceNetworkDevice ( VRRPInterfaceBase ) : <EOL> def __init__ ( self , mac_address , primary_ip_address , vlan_id , <EOL> device_name ) : <EOL> super ( VRRPInterfaceNetworkDevice , self ) . __init__ ( <EOL> mac_address , primary_ip_address , vlan_id ) <EOL> self . device_name = device_name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> self . __class__ . __name__ , <EOL> self . mac_address , <EOL> self . primary_ip_address , self . vlan_id , <EOL> self . device_name ) <EOL> def __eq__ ( self , other ) : <EOL> return ( super ( VRRPInterfaceNetworkDevice , self ) . __eq__ ( other ) and <EOL> self . device_name == other . device_name ) <EOL> def __hash__ ( self ) : <EOL> return hash ( ( <EOL> addrconv . mac . text_to_bin ( self . mac_address ) , <EOL> vrrp . ip_text_to_bin ( self . primary_ip_address ) , self . vlan_id , <EOL> self . device_name ) ) <EOL> class VRRPInterfaceOpenFlow ( VRRPInterfaceBase ) : <EOL> def __init__ ( self , mac_address , primary_ip_address , vlan_id , <EOL> dpid , port_no ) : <EOL> super ( VRRPInterfaceOpenFlow , self ) . __init__ ( <EOL> mac_address , primary_ip_address , vlan_id ) <EOL> self . dpid = dpid <EOL> self . port_no = port_no <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> self . __class__ . __name__ , <EOL> self . mac_address , <EOL> self . primary_ip_address , self . vlan_id , <EOL> dpid_lib . dpid_to_str ( self . dpid ) , self . port_no ) <EOL> def __eq__ ( self , other ) : <EOL> return ( super ( VRRPInterfaceOpenFlow , self ) . __eq__ ( other ) and <EOL> self . dpid == other . dpid and self . port_no == other . port_no ) <EOL> def __hash__ ( self ) : <EOL> return hash ( ( <EOL> addrconv . mac . text_to_bin ( self . mac_address ) , <EOL> vrrp . ip_text_to_bin ( self . primary_ip_address ) , self . vlan_id , <EOL> self . dpid , self . port_no ) ) <EOL> class VRRPConfig ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , version = vrrp . VRRP_VERSION_V3 , vrid = None , <EOL> admin_state = True , <EOL> priority = vrrp . VRRP_PRIORITY_BACKUP_DEFAULT , ip_addresses = None , <EOL> advertisement_interval = vrrp . VRRP_MAX_ADVER_INT_DEFAULT_IN_SEC , <EOL> preempt_mode = True , preempt_delay = <NUM_LIT:0> , accept_mode = False , <EOL> statistics_interval = <NUM_LIT:30> , resource_id = None ) : <EOL> assert vrid is not None <EOL> assert ip_addresses is not None <EOL> super ( VRRPConfig , self ) . __init__ ( ) <EOL> self . version = version <EOL> self . admin_state = admin_state <EOL> self . vrid = vrid <EOL> self . priority = priority <EOL> self . ip_addresses = ip_addresses <EOL> self . advertisement_interval = advertisement_interval <EOL> self . preempt_mode = preempt_mode <EOL> self . preempt_delay = preempt_delay <EOL> self . accept_mode = accept_mode <EOL> self . is_ipv6 = vrrp . is_ipv6 ( ip_addresses [ <NUM_LIT:0> ] ) <EOL> self . statistics_interval = statistics_interval <EOL> self . resource_id = resource_id <EOL> @ property <EOL> def address_owner ( self ) : <EOL> return self . priority == vrrp . VRRP_PRIORITY_ADDRESS_OWNER <EOL> def __eq__ ( self , other ) : <EOL> return ( self . version == other . version and <EOL> self . vrid == other . vrid and <EOL> self . priority == other . priority and <EOL> self . ip_addresses == other . ip_addresses and <EOL> self . advertisement_interval == other . advertisement_interval and <EOL> self . preempt_mode == other . preempt_mode and <EOL> self . preempt_delay == other . preempt_delay and <EOL> self . accept_mode == other . accept_mode and <EOL> self . is_ipv6 == other . is_ipv6 ) <EOL> def __hash__ ( self ) : <EOL> hash ( ( self . version , self . vrid , self . priority , <EOL> list ( map ( vrrp . ip_text_to_bin , self . ip_addresses ) ) , <EOL> self . advertisement_interval , self . preempt_mode , <EOL> self . preempt_delay , self . accept_mode , self . is_ipv6 ) ) <EOL> class EventVRRPConfigRequest ( event . EventRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , interface , config ) : <EOL> super ( EventVRRPConfigRequest , self ) . __init__ ( ) <EOL> self . dst = VRRP_MANAGER_NAME <EOL> self . interface = interface <EOL> self . config = config <EOL> class EventVRRPConfigReply ( event . EventReplyBase ) : <EOL> def __init__ ( self , instance_name , interface , config ) : <EOL> super ( EventVRRPConfigReply , self ) . __init__ ( None ) <EOL> self . instance_name = instance_name <EOL> self . interface = interface <EOL> self . config = config <EOL> class EventVRRPShutdownRequest ( event . EventRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , instance_name ) : <EOL> super ( EventVRRPShutdownRequest , self ) . __init__ ( ) <EOL> self . instance_name = instance_name <EOL> class EventVRRPStateChanged ( event . EventBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , instance_name , monitor_name , interface , config , <EOL> old_state , new_state ) : <EOL> super ( EventVRRPStateChanged , self ) . __init__ ( ) <EOL> self . instance_name = instance_name <EOL> self . monitor_name = monitor_name <EOL> self . interface = interface <EOL> self . config = config <EOL> self . old_state = old_state <EOL> self . new_state = new_state <EOL> class VRRPInstance ( object ) : <EOL> def __init__ ( self , instance_name , monitor_name , config , interface , state ) : <EOL> super ( VRRPInstance , self ) . __init__ ( ) <EOL> self . instance_name = instance_name <EOL> self . monitor_name = monitor_name <EOL> self . config = config <EOL> self . interface = interface <EOL> self . state = state <EOL> class EventVRRPListRequest ( event . EventRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , instance_name = None ) : <EOL> super ( EventVRRPListRequest , self ) . __init__ ( ) <EOL> self . instance_name = instance_name <EOL> class EventVRRPListReply ( event . EventReplyBase ) : <EOL> def __init__ ( self , instance_list ) : <EOL> super ( EventVRRPListReply , self ) . __init__ ( None ) <EOL> self . instance_list = instance_list <EOL> class EventVRRPConfigChangeRequest ( event . EventRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , instance_name , priority = None , <EOL> advertisement_interval = None , preempt_mode = None , <EOL> preempt_delay = None , accept_mode = None ) : <EOL> super ( EventVRRPConfigChangeRequest , self ) . __init__ ( ) <EOL> self . instance_name = instance_name <EOL> self . priority = priority <EOL> self . advertisement_interval = advertisement_interval <EOL> self . preempt_mode = preempt_mode <EOL> self . preempt_delay = preempt_delay <EOL> self . accept_mode = accept_mode <EOL> class EventVRRPReceived ( event . EventBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , interface , packet ) : <EOL> super ( EventVRRPReceived , self ) . __init__ ( ) <EOL> self . interface = interface <EOL> self . packet = packet <EOL> class EventVRRPTransmitRequest ( event . EventRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , data ) : <EOL> super ( EventVRRPTransmitRequest , self ) . __init__ ( ) <EOL> self . data = data <EOL> handler . register_service ( '<STR_LIT>' ) </s>
