@@ -61,6 +61,11 @@ func restorev1alpha8MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *inf
61
61
// We restore the whole Ports since they are anyway immutable.
62
62
dst .Ports = previous .Ports
63
63
dst .AdditionalBlockDevices = previous .AdditionalBlockDevices
64
+ dst .ServerGroup = previous .ServerGroup
65
+ }
66
+
67
+ func restorev1alpha8MachineStatus (previous * infrav1.OpenStackMachineStatus , dst * infrav1.OpenStackMachineStatus ) {
68
+ dst .ReferencedResources = previous .ReferencedResources
64
69
}
65
70
66
71
func restorev1alpha8Bastion (previous * * infrav1.Bastion , dst * * infrav1.Bastion ) {
@@ -257,6 +262,12 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
257
262
},
258
263
restorev1alpha8MachineSpec ,
259
264
),
265
+ "status" : conversion .HashedFieldRestorer (
266
+ func (c * infrav1.OpenStackMachine ) * infrav1.OpenStackMachineStatus {
267
+ return & c .Status
268
+ },
269
+ restorev1alpha8MachineStatus ,
270
+ ),
260
271
}
261
272
262
273
func (r * OpenStackMachine ) ConvertTo (dstRaw ctrlconversion.Hub ) error {
@@ -354,6 +365,13 @@ func Convert_v1alpha6_OpenStackMachineSpec_To_v1alpha8_OpenStackMachineSpec(in *
354
365
// Networks were previously created first, so need to come before ports
355
366
out .Ports = append (ports , out .Ports ... )
356
367
}
368
+
369
+ if in .ServerGroupID != "" {
370
+ out .ServerGroup = & infrav1.ServerGroupFilter {ID : in .ServerGroupID }
371
+ } else {
372
+ out .ServerGroup = nil
373
+ }
374
+
357
375
return nil
358
376
}
359
377
@@ -472,6 +490,7 @@ func Convert_v1alpha6_Instance_To_v1alpha8_BastionStatus(in *Instance, out *infr
472
490
out .State = infrav1 .InstanceState (in .State )
473
491
out .IP = in .IP
474
492
out .FloatingIP = in .FloatingIP
493
+ out .ReferencedResources .ServerGroupID = in .ServerGroupID
475
494
return nil
476
495
}
477
496
@@ -483,6 +502,7 @@ func Convert_v1alpha8_BastionStatus_To_v1alpha6_Instance(in *infrav1.BastionStat
483
502
out .State = InstanceState (in .State )
484
503
out .IP = in .IP
485
504
out .FloatingIP = in .FloatingIP
505
+ out .ServerGroupID = in .ReferencedResources .ServerGroupID
486
506
return nil
487
507
}
488
508
@@ -649,5 +669,47 @@ func Convert_v1alpha6_OpenStackClusterStatus_To_v1alpha8_OpenStackClusterStatus(
649
669
}
650
670
651
671
func Convert_v1alpha8_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec (in * infrav1.OpenStackMachineSpec , out * OpenStackMachineSpec , s apiconversion.Scope ) error {
652
- return autoConvert_v1alpha8_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec (in , out , s )
672
+ err := autoConvert_v1alpha8_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec (in , out , s )
673
+ if err != nil {
674
+ return err
675
+ }
676
+
677
+ if in .ServerGroup != nil {
678
+ out .ServerGroupID = in .ServerGroup .ID
679
+ }
680
+
681
+ return nil
682
+ }
683
+
684
+ func Convert_v1alpha8_OpenStackMachineStatus_To_v1alpha6_OpenStackMachineStatus (in * infrav1.OpenStackMachineStatus , out * OpenStackMachineStatus , s apiconversion.Scope ) error {
685
+ // ReferencedResources have no equivalent in v1alpha6
686
+ return autoConvert_v1alpha8_OpenStackMachineStatus_To_v1alpha6_OpenStackMachineStatus (in , out , s )
687
+ }
688
+
689
+ func Convert_v1alpha6_Bastion_To_v1alpha8_Bastion (in * Bastion , out * infrav1.Bastion , s apiconversion.Scope ) error {
690
+ err := autoConvert_v1alpha6_Bastion_To_v1alpha8_Bastion (in , out , s )
691
+ if err != nil {
692
+ return err
693
+ }
694
+
695
+ if in .Instance .ServerGroupID != "" {
696
+ out .Instance .ServerGroup = & infrav1.ServerGroupFilter {ID : in .Instance .ServerGroupID }
697
+ } else {
698
+ out .Instance .ServerGroup = nil
699
+ }
700
+
701
+ return nil
702
+ }
703
+
704
+ func Convert_v1alpha8_Bastion_To_v1alpha6_Bastion (in * infrav1.Bastion , out * Bastion , s apiconversion.Scope ) error {
705
+ err := autoConvert_v1alpha8_Bastion_To_v1alpha6_Bastion (in , out , s )
706
+ if err != nil {
707
+ return err
708
+ }
709
+
710
+ if in .Instance .ServerGroup != nil && in .Instance .ServerGroup .ID != "" {
711
+ out .Instance .ServerGroupID = in .Instance .ServerGroup .ID
712
+ }
713
+
714
+ return nil
653
715
}
0 commit comments