@@ -18,14 +18,13 @@ import (
1818
1919 "github.com/go-logr/logr"
2020 "github.com/ironcore-dev/ironcore-image/oci/remote"
21+ ocistore "github.com/ironcore-dev/ironcore-image/oci/store"
2122 "github.com/ironcore-dev/ironcore/broker/common"
2223 commongrpc "github.com/ironcore-dev/ironcore/broker/common/grpc"
2324 iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
2425 "github.com/ironcore-dev/libvirt-provider/api"
2526 "github.com/ironcore-dev/libvirt-provider/internal/console"
2627 "github.com/ironcore-dev/libvirt-provider/internal/controllers"
27- "github.com/ironcore-dev/libvirt-provider/internal/event"
28- "github.com/ironcore-dev/libvirt-provider/internal/event/machineevent"
2928 "github.com/ironcore-dev/libvirt-provider/internal/healthcheck"
3029 "github.com/ironcore-dev/libvirt-provider/internal/host"
3130 "github.com/ironcore-dev/libvirt-provider/internal/libvirt/guest"
@@ -36,10 +35,12 @@ import (
3635 volumeplugin "github.com/ironcore-dev/libvirt-provider/internal/plugins/volume"
3736 "github.com/ironcore-dev/libvirt-provider/internal/plugins/volume/ceph"
3837 "github.com/ironcore-dev/libvirt-provider/internal/plugins/volume/emptydisk"
39- "github.com/ironcore-dev/libvirt-provider/internal/qcow2"
4038 "github.com/ironcore-dev/libvirt-provider/internal/raw"
4139 "github.com/ironcore-dev/libvirt-provider/internal/server"
4240 "github.com/ironcore-dev/libvirt-provider/internal/strategy"
41+ "github.com/ironcore-dev/provider-utils/eventutils/event"
42+ "github.com/ironcore-dev/provider-utils/eventutils/recorder"
43+ hostutils "github.com/ironcore-dev/provider-utils/storeutils/host"
4344 "github.com/prometheus/client_golang/prometheus/promhttp"
4445 "github.com/spf13/cobra"
4546 "github.com/spf13/pflag"
@@ -79,7 +80,7 @@ type Options struct {
7980 GCVMGracefulShutdownTimeout time.Duration
8081 ResyncIntervalGarbageCollector time.Duration
8182
82- MachineEventStore machineevent .EventStoreOptions
83+ MachineEventStore recorder .EventStoreOptions
8384
8485 VolumeCachePolicy string
8586}
@@ -134,8 +135,6 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
134135 fs .StringSliceVar (& o .Libvirt .PreferredDomainTypes , "preferred-domain-types" , []string {"kvm" , "qemu" }, "Ordered list of preferred domain types to use." )
135136 fs .StringSliceVar (& o .Libvirt .PreferredMachineTypes , "preferred-machine-types" , []string {"pc-q35" }, "Ordered list of preferred machine types to use." )
136137
137- fs .StringVar (& o .Libvirt .Qcow2Type , "qcow2-type" , qcow2 .Default (), fmt .Sprintf ("qcow2 implementation to use. Available: %v" , qcow2 .Available ()))
138-
139138 fs .DurationVar (& o .GCVMGracefulShutdownTimeout , "gc-vm-graceful-shutdown-timeout" , 5 * time .Minute , "Duration to wait for the VM to gracefully shut down. If the VM does not shut down within this period, it will be forcibly destroyed by garbage collector." )
140139 fs .DurationVar (& o .ResyncIntervalGarbageCollector , "gc-resync-interval" , 1 * time .Minute , "Interval for resynchronizing the garbage collector." )
141140
@@ -227,15 +226,15 @@ func Run(ctx context.Context, opts Options) error {
227226 return err
228227 }
229228
230- imgCache , err := oci . NewLocalCache ( log , reg , providerHost .OCIStore ())
229+ ociStore , err := ocistore . New ( providerHost .ImagesDir ())
231230 if err != nil {
232- setupLog .Error (err , "failed to initialize oci manager " )
231+ setupLog .Error (err , "error creating oci store " )
233232 return err
234233 }
235234
236- qcow2Inst , err := qcow2 . Instance ( opts . Libvirt . Qcow2Type )
235+ imgCache , err := oci . NewLocalCache ( log , reg , ociStore )
237236 if err != nil {
238- setupLog .Error (err , "failed to initialize qcow2 instance " )
237+ setupLog .Error (err , "failed to initialize oci manager " )
239238 return err
240239 }
241240
@@ -258,7 +257,7 @@ func Run(ctx context.Context, opts Options) error {
258257 volumePlugins := volumeplugin .NewPluginManager ()
259258 if err := volumePlugins .InitPlugins (providerHost , []volumeplugin.Plugin {
260259 ceph .NewPlugin (),
261- emptydisk .NewPlugin (qcow2Inst , rawInst ),
260+ emptydisk .NewPlugin (rawInst ),
262261 }); err != nil {
263262 setupLog .Error (err , "failed to initialize volume plugin manager" )
264263 return err
@@ -281,7 +280,7 @@ func Run(ctx context.Context, opts Options) error {
281280 }
282281
283282 setupLog .Info ("Configuring machine store" , "Directory" , providerHost .MachineStoreDir ())
284- machineStore , err := host .NewStore (host .Options [* api.Machine ]{
283+ machineStore , err := hostutils .NewStore [ * api. Machine ](hostutils .Options [* api.Machine ]{
285284 NewFunc : func () * api.Machine { return & api.Machine {} },
286285 CreateStrategy : strategy .MachineStrategy ,
287286 Dir : providerHost .MachineStoreDir (),
@@ -301,19 +300,18 @@ func Run(ctx context.Context, opts Options) error {
301300 return err
302301 }
303302
304- eventStore := machineevent .NewEventStore (log , opts .MachineEventStore )
303+ eventStore := recorder .NewEventStore (log , opts .MachineEventStore )
305304
306305 machineReconciler , err := controllers .NewMachineReconciler (
307306 log .WithName ("machine-reconciler" ),
308- libvirt ,
307+ providerHost ,
309308 machineStore ,
310309 machineEvents ,
311310 eventStore ,
312311 controllers.MachineReconcilerOptions {
313312 GuestCapabilities : caps ,
314313 ImageCache : imgCache ,
315314 Raw : rawInst ,
316- Host : providerHost ,
317315 VolumePluginManager : volumePlugins ,
318316 NetworkInterfacePlugin : nicPlugin ,
319317 ResyncIntervalVolumeSize : opts .ResyncIntervalVolumeSize ,
0 commit comments