Skip to content

Commit

Permalink
set anti affinity policy as separate action with Apstra 4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Oct 4, 2024
1 parent 58caf8a commit 0db72e3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apstra/data_source_datacenter_blueprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/apstra-go-sdk/apstra/enum"
"github.com/Juniper/terraform-provider-apstra/apstra/compatibility"
testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/go-version"
Expand Down Expand Up @@ -211,9 +212,13 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) {
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, client.DeleteBlueprint(ctx, id)) })

var bpClient *apstra.TwoStageL3ClosClient

if tCase.ipv6 {
bpClient, err := client.NewTwoStageL3ClosClient(ctx, id)
require.NoError(t, err)
if bpClient == nil {
bpClient, err = client.NewTwoStageL3ClosClient(ctx, id)
require.NoError(t, err)
}

fs, err := bpClient.GetFabricSettings(ctx)
require.NoError(t, err)
Expand All @@ -223,6 +228,17 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) {
require.NoError(t, err)
}

// set anti-affinity policy as needed with Apstra 4.2.0
if compatibility.TemplateRequiresAntiAffinityPolicy.Check(apiVersion) && tCase.fabricSettings.AntiAffinityPolicy != nil {
if bpClient == nil {
bpClient, err = client.NewTwoStageL3ClosClient(ctx, id)
require.NoError(t, err)
}

err = bpClient.SetFabricSettings(ctx, &tCase.fabricSettings)
require.NoError(t, err)
}

// add unpredictable name and ID to existing checks
tCase.checks = append(tCase.checks,
resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "id", id.String()),
Expand Down

0 comments on commit 0db72e3

Please sign in to comment.