File tree Expand file tree Collapse file tree 1 file changed +25
-14
lines changed Expand file tree Collapse file tree 1 file changed +25
-14
lines changed Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
3
import (
4
+ "github.com/sirupsen/logrus"
4
5
"os"
5
6
6
7
"gitlab.com/bootc-org/podman-bootc/pkg/config"
@@ -65,25 +66,35 @@ func CollectVmList(user user.User, libvirtUri string) (vmList []vm.BootcVMConfig
65
66
66
67
for _ , f := range files {
67
68
if f .IsDir () {
68
- vm , err := vm .NewVM (vm.NewVMParameters {
69
- ImageID : f .Name (),
70
- User : user ,
71
- LibvirtUri : libvirtUri ,
72
- })
73
-
69
+ cfg , err := getVMInfo (user , libvirtUri , f .Name ())
74
70
if err != nil {
75
- return nil , err
71
+ logrus .Warningf ("skipping vm %s reason: %v" , f .Name (), err )
72
+ continue
76
73
}
77
74
78
- cfg , err := vm .GetConfig ()
79
- if err != nil {
80
- return nil , err
81
- }
82
-
83
- vm .CloseConnection ()
84
-
85
75
vmList = append (vmList , * cfg )
86
76
}
87
77
}
88
78
return vmList , nil
89
79
}
80
+
81
+ func getVMInfo (user user.User , libvirtUri string , imageId string ) (* vm.BootcVMConfig , error ) {
82
+ bootcVM , err := vm .NewVM (vm.NewVMParameters {
83
+ ImageID : imageId ,
84
+ User : user ,
85
+ LibvirtUri : libvirtUri ,
86
+ })
87
+
88
+ if err != nil {
89
+ return nil , err
90
+ }
91
+
92
+ defer bootcVM .CloseConnection ()
93
+
94
+ cfg , err := bootcVM .GetConfig ()
95
+ if err != nil {
96
+ return nil , err
97
+ }
98
+
99
+ return cfg , nil
100
+ }
You can’t perform that action at this time.
0 commit comments