Skip to content

Commit

Permalink
include initial interface map ID (if any) in graph query
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Dec 7, 2024
1 parent 423b0e9 commit 9800a8d
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 9800a8d

Please sign in to comment.