Fix a bug in the listAffinityGroup call (#61)
It reports the number of VirtualMachines in the groups as being the number of groups found.
diff --git a/cloudstack/AffinityGroupService.go b/cloudstack/AffinityGroupService.go
index 03f6306..48f1b0f 100644
--- a/cloudstack/AffinityGroupService.go
+++ b/cloudstack/AffinityGroupService.go
@@ -444,6 +444,10 @@
return "", -1, err
}
+ // This is needed because of a bug with the listAffinityGroup call. It reports the
+ // number of VirtualMachines in the groups as being the number of groups found.
+ l.Count = len(l.AffinityGroups)
+
if l.Count == 0 {
return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
}
@@ -499,6 +503,10 @@
return nil, -1, err
}
+ // This is needed because of a bug with the listAffinityGroup call. It reports the
+ // number of VirtualMachines in the groups as being the number of groups found.
+ l.Count = len(l.AffinityGroups)
+
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
diff --git a/generate/generate.go b/generate/generate.go
index 82ad792..029c5bb 100644
--- a/generate/generate.go
+++ b/generate/generate.go
@@ -815,6 +815,12 @@
pn(" return \"\", -1, err")
pn(" }")
pn("")
+ if ln == "AffinityGroups" {
+ pn(" // This is needed because of a bug with the listAffinityGroup call. It reports the")
+ pn(" // number of VirtualMachines in the groups as being the number of groups found.")
+ pn(" l.Count = len(l.%s)", ln)
+ pn("")
+ }
pn(" if l.Count == 0 {")
pn(" return \"\", l.Count, fmt.Errorf(\"No match found for %%s: %%+v\", %s, l)", v)
pn(" }")
@@ -929,6 +935,12 @@
pn(" return nil, -1, err")
pn(" }")
pn("")
+ if ln == "AffinityGroups" {
+ pn(" // This is needed because of a bug with the listAffinityGroup call. It reports the")
+ pn(" // number of VirtualMachines in the groups as being the number of groups found.")
+ pn(" l.Count = len(l.%s)", ln)
+ pn("")
+ }
pn(" if l.Count == 0 {")
pn(" return nil, l.Count, fmt.Errorf(\"No match found for %%s: %%+v\", id, l)")
pn(" }")