def _create_prefix_notification(outgoing_msg, rpc_session): """Constructs prefix notification with data from given outgoing message. Given RPC session is used to create RPC notification message. """ assert outgoing_msg path = outgoing_msg.path assert path vpn_nlri = path.nlri assert path.source is not None if path.source != VRF_TABLE: # Extract relevant info for update-add/update-delete. params = [{ ROUTE_DISTINGUISHER: outgoing_msg.route_dist, PREFIX: vpn_nlri.prefix, NEXT_HOP: path.nexthop, VRF_RF: VrfConf.rf_2_vrf_rf(path.route_family) }] if path.nlri.ROUTE_FAMILY.safi not in (subaddr_family.IP_FLOWSPEC, subaddr_family.VPN_FLOWSPEC): params[VPN_LABEL] = path.label_list[0] if not path.is_withdraw: # Create notification to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_ADD_REMOTE_PREFIX, params) else: # Create update-delete request to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_DELETE_REMOTE_PREFIX, params) else: # Extract relevant info for update-add/update-delete. params = [{ ROUTE_DISTINGUISHER: outgoing_msg.route_dist, PREFIX: vpn_nlri.prefix, NEXT_HOP: path.nexthop, VRF_RF: VrfConf.rf_2_vrf_rf(path.route_family), ORIGIN_RD: path.origin_rd }] if not path.is_withdraw: # Create notification to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_ADD_LOCAL_PREFIX, params) else: # Create update-delete request to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_DELETE_LOCAL_PREFIX, params) return rpc_msg
def _create_prefix_notification(outgoing_msg, rpc_session): """Constructs prefix notification with data from given outgoing message. Given RPC session is used to create RPC notification message. """ assert outgoing_msg path = outgoing_msg.path assert path vpn_nlri = path.nlri assert path.source is not None if path.source != VRF_TABLE: # Extract relevant info for update-add/update-delete. params = [{ROUTE_DISTINGUISHER: outgoing_msg.route_dist, PREFIX: vpn_nlri.prefix, NEXT_HOP: path.nexthop, VRF_RF: VrfConf.rf_2_vrf_rf(path.route_family)}] if path.nlri.ROUTE_FAMILY.safi not in (subaddr_family.IP_FLOWSPEC, subaddr_family.VPN_FLOWSPEC): params[VPN_LABEL] = path.label_list[0] if not path.is_withdraw: # Create notification to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_ADD_REMOTE_PREFIX, params) else: # Create update-delete request to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_DELETE_REMOTE_PREFIX, params) else: # Extract relevant info for update-add/update-delete. params = [{ROUTE_DISTINGUISHER: outgoing_msg.route_dist, PREFIX: vpn_nlri.prefix, NEXT_HOP: path.nexthop, VRF_RF: VrfConf.rf_2_vrf_rf(path.route_family), ORIGIN_RD: path.origin_rd}] if not path.is_withdraw: # Create notification to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_ADD_LOCAL_PREFIX, params) else: # Create update-delete request to NetworkController. rpc_msg = rpc_session.create_notification( NOTIFICATION_DELETE_LOCAL_PREFIX, params) return rpc_msg
def create_vrf(**kwargs): vrf_conf = VrfConf(**kwargs) CORE_MANAGER.vrfs_conf.add_vrf_conf(vrf_conf) return True