@@ -439,28 +439,28 @@ func (c *client) configureNetworkParams(
439439 csMachine * infrav1.CloudStackMachine ,
440440 fd * infrav1.CloudStackFailureDomain ,
441441) error {
442- if len (csMachine .Spec .Networks ) == 0 && fd . Spec . Zone . Network . ID != "" {
443- p . SetNetworkids ([] string { fd .Spec .Zone .Network .ID })
444- return nil
445- }
446-
447- firstNetwork := csMachine .Spec .Networks [0 ]
448- zoneNet := fd .Spec .Zone .Network
442+ if len (csMachine .Spec .Networks ) == 0 {
443+ if fd .Spec .Zone .Network .ID != "" {
444+ p . SetNetworkids ([] string { fd . Spec . Zone . Network . ID })
445+ }
446+ } else {
447+ firstNetwork := csMachine .Spec .Networks [0 ]
448+ zoneNet := fd .Spec .Zone .Network
449449
450- // Validate match between zone network and first template network.
451- if zoneNet .ID != "" && firstNetwork .ID != "" && firstNetwork .ID != zoneNet .ID {
452- return errors .Errorf ("first network ID %q does not match zone network ID %q" , firstNetwork .ID , zoneNet .ID )
453- }
454- if zoneNet .Name != "" && firstNetwork .Name != "" && firstNetwork .Name != zoneNet .Name {
455- return errors .Errorf ("first network name %q does not match zone network name %q" , firstNetwork .Name , zoneNet .Name )
456- }
450+ if zoneNet .ID != "" && firstNetwork .ID != "" && firstNetwork .ID != zoneNet .ID {
451+ return errors .Errorf ("first network ID %q does not match zone network ID %q" , firstNetwork .ID , zoneNet .ID )
452+ }
453+ if zoneNet .Name != "" && firstNetwork .Name != "" && firstNetwork .Name != zoneNet .Name {
454+ return errors .Errorf ("first network name %q does not match zone network name %q" , firstNetwork .Name , zoneNet .Name )
455+ }
457456
458- ipToNetworkList , err := c .buildIPToNetworkList (csMachine )
459- if err != nil {
460- return err
457+ ipToNetworkList , err := c .buildIPToNetworkList (csMachine )
458+ if err != nil {
459+ return err
460+ }
461+ p .SetIptonetworklist (ipToNetworkList )
461462 }
462463
463- p .SetIptonetworklist (ipToNetworkList )
464464 return nil
465465}
466466
0 commit comments