Exemple #1
0
func (m *OpsManager) handleRouteUpdate(cli api.GobgpApiClient, update ovsdb.TableUpdate) {
	id, _ := m.getVrfUUID()
	for _, v := range update.Rows {
		vrf := v.New.Fields["vrf"]
		if vrf == nil {
			continue
		}
		idx := vrf.(ovsdb.UUID).GoUUID
		if uuid.Equal(id, uuid.FromStringOrNil(idx)) {
			path, isWithdraw, isFromGobgp, err := parseRouteToGobgp(v, m.cache["BGP_Nexthop"])
			if err != nil {
				log.WithFields(log.Fields{
					"Topic": "openswitch",
					"Path":  path,
					"Error": err,
				}).Debug("failed to parse path")
				return
			}
			if isWithdraw {
				cli.DeletePath(context.Background(), &api.DeletePathRequest{
					Resource: api.Resource_GLOBAL,
					Path:     path,
				})
			} else {
				if isFromGobgp {
					return
				}
				cli.AddPath(context.Background(), &api.AddPathRequest{
					Resource: api.Resource_GLOBAL,
					Path:     path,
				})
			}
		}
	}
}