Skip to content

Commit

Permalink
clear ipv6 flag when creating blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Apr 24, 2024
1 parent 558f8bd commit 2e15190
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
10 changes: 9 additions & 1 deletion apstra/blueprint/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,19 @@ func (o *Blueprint) LoadFabricSettings(ctx context.Context, settings *apstra.Fab
}

func (o *Blueprint) Request(ctx context.Context, diags *diag.Diagnostics) *apstra.CreateBlueprintFromTemplateRequest {
fabricSettings := o.FabricSettings(ctx, diags)
if diags.HasError() {
return nil
}

// IPv6 cannot be enabled as part of blueprint creation
fabricSettings.Ipv6Enabled = nil

result := apstra.CreateBlueprintFromTemplateRequest{
RefDesign: apstra.RefDesignTwoStageL3Clos,
Label: o.Name.ValueString(),
TemplateId: apstra.ObjectId(o.TemplateId.ValueString()),
FabricSettings: o.FabricSettings(ctx, diags),
FabricSettings: fabricSettings,
}

if utils.Known(o.FabricAddressing) {
Expand Down
9 changes: 1 addition & 8 deletions apstra/resource_datacenter_blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ func (o *resourceDatacenterBlueprint) Create(ctx context.Context, req resource.C
// Apstra 4.2.1 allows us to set *some* fabric settings as part of blueprint creation.
// Depending on what's in the plan, we might not need to invoke SetFabricSettings().
if !apiversions.Ge421.Check(apiVersion) || plan.Ipv6Applications.ValueBool() {
// did we really need to lock the blueprint here? nothing else knows it exists yet.
//// Lock the blueprint mutex.
//err = o.lockFunc(ctx, id.String())
//if err != nil {
// resp.Diagnostics.AddError("failed locking blueprint mutex", err.Error())
// return
//}

// Set the fabric settings
plan.SetFabricSettings(ctx, bp, nil, &resp.Diagnostics)
if resp.Diagnostics.HasError() {
Expand All @@ -145,6 +137,7 @@ func (o *resourceDatacenterBlueprint) Create(ctx context.Context, req resource.C
apiData, err := o.client.GetBlueprintStatus(ctx, id)
if err != nil {
resp.Diagnostics.AddError("error retrieving Datacenter Blueprint after creation", err.Error())
return
}

// Load blueprint status
Expand Down
22 changes: 21 additions & 1 deletion apstra/resource_datacenter_blueprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1530,12 +1530,32 @@ func TestResourceDatacenterBlueprint(t *testing.T) {
},
},
},
"evpn_start_with_ipv6": {
testCase: resource.TestCase{
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: renderConfig(config{
name: "esv6AV_0_" + rs,
templateId: "L2_Virtual_EVPN",
ipv6Applications: utils.ToPtr(true),
}),
Check: resource.ComposeAggregateTestCheckFunc([]resource.TestCheckFunc{
resource.TestCheckResourceAttrSet("apstra_datacenter_blueprint.test", "id"),
resource.TestCheckResourceAttr("apstra_datacenter_blueprint.test", "name", "esv6AV_0_"+rs),
resource.TestCheckResourceAttr("apstra_datacenter_blueprint.test", "template_id", "L2_Virtual_EVPN"),
resource.TestCheckResourceAttr("apstra_datacenter_blueprint.test", "ipv6_applications", "true"),
}...),
},
},
},
},
}

for tName, tCase := range testCases {
tName, tCase := tName, tCase
t.Run(tName, func(t *testing.T) {
t.Parallel()
//t.Parallel()
if !tCase.apiVersionConstraints.Check(apiVersion) {
t.Skipf("API version %s does not satisfy version constraints(%s) of test %q",
apiVersion, tCase.apiVersionConstraints, tName)
Expand Down

0 comments on commit 2e15190

Please sign in to comment.