From 9800a8d8f252441b33e15e997e687d960a50c4ec Mon Sep 17 00:00:00 2001 From: Chris Marget Date: Fri, 6 Dec 2024 21:03:18 -0500 Subject: [PATCH] include initial interface map ID (if any) in graph query --- apstra/blueprint/device_allocation.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apstra/blueprint/device_allocation.go b/apstra/blueprint/device_allocation.go index cd79a1e4..598e17d1 100644 --- a/apstra/blueprint/device_allocation.go +++ b/apstra/blueprint/device_allocation.go @@ -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 @@ -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())). @@ -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(),