func checkAllocatedVNIDs(t *testing.T, vmap *nodeVNIDMap, match []uint32) {
	ids := []uint32{}
	idSet := sets.Int{}
	for _, id := range vmap.ids {
		if id != osapi.GlobalVNID {
			if !idSet.Has(int(id)) {
				ids = append(ids, id)
				idSet.Insert(int(id))
			}
		}
	}
	if len(ids) != len(match) {
		t.Fatalf("Wrong number of VNIDs: %d vs %d", len(ids), len(match))
	}

	for _, m := range match {
		found := false
		for _, n := range ids {
			if n == m {
				found = true
				break
			}
		}
		if !found {
			t.Fatalf("Missing VNID: %d", m)
		}
	}
}
Beispiel #2
0
func (vmap *vnidMap) GetAllocatedVNIDs() []uint32 {
	vmap.lock.Lock()
	defer vmap.lock.Unlock()

	ids := []uint32{}
	idSet := sets.Int{}
	for _, id := range vmap.ids {
		if id != AdminVNID {
			if !idSet.Has(int(id)) {
				ids = append(ids, id)
				idSet.Insert(int(id))
			}
		}
	}
	return ids
}
Beispiel #3
0
func (oc *OsdnController) getAllocatedVNIDs() []uint {
	oc.vnidLock.Lock()
	defer oc.vnidLock.Unlock()

	ids := []uint{}
	idSet := sets.Int{}
	for _, id := range oc.vnidMap {
		if id != AdminVNID {
			if !idSet.Has(int(id)) {
				ids = append(ids, id)
				idSet.Insert(int(id))
			}
		}
	}
	return ids
}