@@ -28,6 +28,8 @@ import (
28
28
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
29
29
"sigs.k8s.io/cluster-api/util"
30
30
"sigs.k8s.io/controller-runtime/pkg/client"
31
+
32
+ "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/test/e2e/framework/nutanix"
31
33
)
32
34
33
35
// SelfHostedSpecInput is the input for SelfHostedSpec.
@@ -180,6 +182,30 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
180
182
if input .InfrastructureProvider != nil {
181
183
infrastructureProvider = * input .InfrastructureProvider
182
184
}
185
+
186
+ // For Nutanix provider, reserve an IP address for the workload cluster control plane endpoint -
187
+ // remember to unreserve it!
188
+ if infrastructureProvider == "nutanix" {
189
+ By (
190
+ "Reserving an IP address for the workload cluster control plane endpoint" ,
191
+ )
192
+ nutanixClient , err := nutanix .NewV4Client (
193
+ nutanix .CredentialsFromCAPIE2EConfig (input .E2EConfig ),
194
+ )
195
+ Expect (err ).ToNot (HaveOccurred ())
196
+ //nolint:contextcheck // ReserverIP function does not accept context. Its okay to ignore the context check in tests.
197
+ controlPlaneEndpointIP , unreserveControlPlaneEndpointIP , err := nutanix .ReserveIP (
198
+ input .E2EConfig .GetVariable ("NUTANIX_SUBNET_NAME" ),
199
+ input .E2EConfig .GetVariable (
200
+ "NUTANIX_PRISM_ELEMENT_CLUSTER_NAME" ,
201
+ ),
202
+ nutanixClient ,
203
+ )
204
+ Expect (err ).ToNot (HaveOccurred ())
205
+ DeferCleanup (unreserveControlPlaneEndpointIP )
206
+ clusterctlVariables ["CONTROL_PLANE_ENDPOINT_IP" ] = controlPlaneEndpointIP
207
+ }
208
+
183
209
clusterctl .ApplyClusterTemplateAndWait (ctx , clusterctl.ApplyClusterTemplateAndWaitInput {
184
210
ClusterProxy : input .BootstrapClusterProxy ,
185
211
ConfigCluster : clusterctl.ConfigClusterInput {
0 commit comments