Dump VM's under the k8s reporter
@@ -85,6 +85,7 @@ func (r *KubernetesReporter) Dump(since time.Duration) {
r.logPVs(virtCli)
r.logPods(virtCli)
r.logVMIs(virtCli)
+ r.logVMs(virtCli)
r.logDomainXMLs(virtCli)
r.logLogs(virtCli, since)
}
@@ -124,6 +125,30 @@ func (r *KubernetesReporter) logDomainXMLs(virtCli kubecli.KubevirtClient) {
}
}
+func (r *KubernetesReporter) logVMs(virtCli kubecli.KubevirtClient) {
+
+ f, err := os.OpenFile(filepath.Join(r.artifactsDir, fmt.Sprintf("%d_vms.log", r.failureCount)),
+ os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to open the file: %v\n", err)
+ return
+ }
+ defer f.Close()
+
+ vmis, err := virtCli.VirtualMachine(v1.NamespaceAll).List(&v12.ListOptions{})
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to fetch vms: %v\n", err)
+ return
+ }
+
+ j, err := json.MarshalIndent(vmis, "", " ")
+ if err != nil {
+ log.DefaultLogger().Reason(err).Errorf("Failed to marshal vms")
+ return
+ }
+ fmt.Fprintln(f, string(j))
+}
+
func (r *KubernetesReporter) logVMIs(virtCli kubecli.KubevirtClient) {
f, err := os.OpenFile(filepath.Join(r.artifactsDir, fmt.Sprintf("%d_vmis.log", r.failureCount)),
