forked from oVirt/go-ovirt-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaffinitygroup_remove.go
49 lines (41 loc) · 1.25 KB
/
affinitygroup_remove.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package ovirtclient
import "fmt"
func (o *oVirtClient) RemoveAffinityGroup(clusterID ClusterID, id AffinityGroupID, retries ...RetryStrategy) error {
retries = defaultRetries(retries, defaultWriteTimeouts(o))
return retry(
fmt.Sprintf("removing affinity group %s from cluster %s", id, clusterID),
o.logger,
retries,
func() error {
_, err := o.conn.
SystemService().
ClustersService().
ClusterService(string(clusterID)).
AffinityGroupsService().
GroupService(string(id)).
Remove().
Send()
return err
},
)
}
func (m *mockClient) RemoveAffinityGroup(clusterID ClusterID, id AffinityGroupID, retries ...RetryStrategy) error {
retries = defaultRetries(retries, defaultWriteTimeouts(m))
return retry(
fmt.Sprintf("removing affinity group %s from cluster %s", id, clusterID),
m.logger,
retries,
func() error {
m.lock.Lock()
defer m.lock.Unlock()
clusterAffinityGroups, ok := m.affinityGroups[clusterID]
if !ok {
return newError(ENotFound, "Cluster with ID %s not found", clusterID)
}
if _, ok := clusterAffinityGroups[id]; !ok {
return newError(ENotFound, "Affinity group with ID %s not found in cluster %s", id, clusterID)
}
delete(m.affinityGroups[clusterID], id)
return nil
})
}