MCPcopy Create free account
hub / github.com/cloudbase/garm / ReplaceEntityPools

Method ReplaceEntityPools

cache/entity_cache.go:165–195  ·  view source on GitHub ↗
(entityID string, pools []params.Pool)

Source from the content-addressed store, hash-verified

163}
164
165func (e *EntityCache) ReplaceEntityPools(entityID string, pools []params.Pool) {
166 e.mux.Lock()
167 defer e.mux.Unlock()
168
169 cache, ok := e.entities[entityID]
170 if !ok {
171 return
172 }
173
174 // Remove all old pools from the global map.
175 for oldPoolID := range cache.Pools {
176 delete(e.pools, oldPoolID)
177 }
178
179 // Add the new set.
180 poolsByID := map[string]struct{}{}
181 for _, pool := range pools {
182 poolEntity, err := pool.GetEntity()
183 if err != nil || poolEntity.ID != entityID {
184 continue
185 }
186 e.pools[pool.ID] = pool
187 // map the pool ID to the entity. We have to do an extra lookup
188 // in the pools map, but it makes it easier to lookup just pools later
189 // when we want to find the pool for the instance.
190 poolsByID[pool.ID] = struct{}{}
191 }
192
193 cache.Pools = poolsByID
194 e.entities[entityID] = cache
195}
196
197func (e *EntityCache) ReplaceEntityScaleSets(entityID string, scaleSets []params.ScaleSet) {
198 e.mux.Lock()

Callers 1

ReplaceEntityPoolsFunction · 0.80

Calls 3

LockMethod · 0.65
UnlockMethod · 0.65
GetEntityMethod · 0.65

Tested by

no test coverage detected