Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 985: Correct graph query in apstra_datacenter_device_allocation resource when multiple candidate interface maps exist #986

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions apstra/blueprint/device_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (o *DeviceAllocation) PopulateDataFromGraphDb(ctx context.Context, client *
// device_key known, initial_interface_map_id unknown.
o.deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx, client, diags) // this will clear BlueprintId on 404
case !o.DeviceKey.IsNull() && utils.HasValue(o.InitialInterfaceMapId):
// device_key known, initial_interface_map_id known.
// both device_key known, initial_interface_map_id are known.
o.deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx, client, diags) // this will clear BlueprintId on 404
if o.BlueprintId.IsNull() {
return
Expand Down Expand Up @@ -617,6 +617,13 @@ func (o *DeviceAllocation) deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx conte
deviceProfileId = si.Facts.AosHclModel.String()
}

// interfaceMapAttributes will be used in the query below. It's not included in the builder
// below to facilitate conditional inclusion of the initial interface map ID.
interfaceMapAttributes := []apstra.QEEAttribute{apstra.NodeTypeInterfaceMap.QEEAttribute()}
if utils.HasValue(o.InitialInterfaceMapId) {
interfaceMapAttributes = append(interfaceMapAttributes, apstra.QEEAttribute{Key: "id", Value: apstra.QEStringVal(o.InitialInterfaceMapId.ValueString())})
}

query := new(apstra.PathQuery).
SetClient(client).
SetBlueprintId(apstra.ObjectId(o.BlueprintId.ValueString())).
Expand All @@ -625,7 +632,7 @@ func (o *DeviceAllocation) deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx conte
Out([]apstra.QEEAttribute{apstra.RelationshipTypeLogicalDevice.QEEAttribute()}).
Node([]apstra.QEEAttribute{apstra.NodeTypeLogicalDevice.QEEAttribute()}).
In([]apstra.QEEAttribute{apstra.RelationshipTypeLogicalDevice.QEEAttribute()}).
Node([]apstra.QEEAttribute{apstra.NodeTypeInterfaceMap.QEEAttribute()}).
Node(interfaceMapAttributes).
Out([]apstra.QEEAttribute{apstra.RelationshipTypeDeviceProfile.QEEAttribute()}).
Node([]apstra.QEEAttribute{
apstra.NodeTypeDeviceProfile.QEEAttribute(),
Expand Down
Loading