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

Improve query which discovers device profile to handle dp clones #631

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
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
20 changes: 13 additions & 7 deletions apstra/blueprint/device_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ func (o *DeviceAllocation) PopulateDataFromGraphDb(ctx context.Context, client *
// initial_interface_map_id known, device_key not supplied
o.deviceProfileNodeIdFromInterfaceMapCatalogId(ctx, client, diags) // this will clear BlueprintId on 404
case !o.DeviceKey.IsNull() && o.InitialInterfaceMapId.IsUnknown():
// device_key known, initial_interface_map_id not supplied
o.deviceProfileNodeIdFromDeviceKey(ctx, client, diags) // this will clear BlueprintId on 404
case utils.Known(o.InitialInterfaceMapId) && !o.DeviceKey.IsNull():
// device_key and initial_interface_map_id both supplied
o.deviceProfileNodeIdFromDeviceKey(ctx, client, diags) // this will clear BlueprintId on 404
// device_key known, initial_interface_map_id unknown.
o.deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx, client, diags) // this will clear BlueprintId on 404
case !o.DeviceKey.IsNull() && utils.Known(o.InitialInterfaceMapId):
// device_key known, initial_interface_map_id known.
o.deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx, client, diags) // this will clear BlueprintId on 404
if o.BlueprintId.IsNull() {
return
}
Expand Down Expand Up @@ -594,7 +594,7 @@ func (o *DeviceAllocation) deviceProfileNodeIdFromInterfaceMapCatalogId(ctx cont
}
}

func (o *DeviceAllocation) deviceProfileNodeIdFromDeviceKey(ctx context.Context, client *apstra.Client, diags *diag.Diagnostics) {
func (o *DeviceAllocation) deviceProfileNodeIdFromSystemIdAndDeviceKey(ctx context.Context, client *apstra.Client, diags *diag.Diagnostics) {
gasi := utils.GetAllSystemsInfo(ctx, client, diags)
if diags.HasError() {
return
Expand All @@ -614,8 +614,14 @@ func (o *DeviceAllocation) deviceProfileNodeIdFromDeviceKey(ctx context.Context,
SetClient(client).
SetBlueprintId(apstra.ObjectId(o.BlueprintId.ValueString())).
SetBlueprintType(apstra.BlueprintTypeStaging).
Node([]apstra.QEEAttribute{{Key: "id", Value: apstra.QEStringVal(o.NodeId.ValueString())}}).
Out([]apstra.QEEAttribute{apstra.RelationshipTypeLogicalDevice.QEEAttribute()}).
Node([]apstra.QEEAttribute{apstra.NodeTypeLogicalDevice.QEEAttribute()}).
In([]apstra.QEEAttribute{apstra.RelationshipTypeLogicalDevice.QEEAttribute()}).
Node([]apstra.QEEAttribute{apstra.NodeTypeInterfaceMap.QEEAttribute()}).
Out([]apstra.QEEAttribute{apstra.RelationshipTypeDeviceProfile.QEEAttribute()}).
Node([]apstra.QEEAttribute{
{Key: "type", Value: apstra.QEStringVal("device_profile")},
apstra.NodeTypeDeviceProfile.QEEAttribute(),
{Key: "device_profile_id", Value: apstra.QEStringVal(si.Facts.AosHclModel.String())},
{Key: "name", Value: apstra.QEStringVal("n_device_profile")},
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.21.1

require (
github.com/IBM/netaddr v1.5.0
github.com/Juniper/apstra-go-sdk v0.0.0-20240329223712-9ba1bd6d94cb
github.com/Juniper/apstra-go-sdk v0.0.0-20240403150850-3db854b8af89
github.com/chrismarget-j/go-licenses v0.0.0-20240224210557-f22f3e06d3d4
github.com/google/go-cmp v0.6.0
github.com/goreleaser/goreleaser v1.23.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/IBM/netaddr v1.5.0 h1:IJlFZe1+nFs09TeMB/HOP4+xBnX2iM/xgiDOgZgTJq0=
github.com/IBM/netaddr v1.5.0/go.mod h1:DDBPeYgbFzoXHjSz9Jwk7K8wmWV4+a/Kv0LqRnb8we4=
github.com/Juniper/apstra-go-sdk v0.0.0-20240329223712-9ba1bd6d94cb h1:CgkqCYAQuFtAB4wKflvVNRJXlg0ZxTYk8SDP1IKuD7o=
github.com/Juniper/apstra-go-sdk v0.0.0-20240329223712-9ba1bd6d94cb/go.mod h1:Xwj3X8v/jRZWv28o6vQAqD4lz2JmzaSYLZ2ch1SS89w=
github.com/Juniper/apstra-go-sdk v0.0.0-20240403150850-3db854b8af89 h1:8re9707jztAT5m/XlKpuUJvCUy47BEzl/IpUhI+oTUw=
github.com/Juniper/apstra-go-sdk v0.0.0-20240403150850-3db854b8af89/go.mod h1:Xwj3X8v/jRZWv28o6vQAqD4lz2JmzaSYLZ2ch1SS89w=
github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0=
github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
Expand Down
Loading