Skip to content

Conversation

@akinross
Copy link
Collaborator

No description provided.

@akinross akinross added the jira-sync Sync this issue to Jira label Nov 25, 2025
@akinross akinross force-pushed the bug_version_check_children branch from dc6fb13 to a410de7 Compare November 25, 2025 20:20
shrsr
shrsr previously approved these changes Nov 26, 2025
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shrsr shrsr added jira-sync Sync this issue to Jira and removed jira-sync Sync this issue to Jira labels Nov 26, 2025
@github-actions github-actions bot changed the title [bugfix] fix child classes to be queried only when apic versions allows [bugfix] fix child classes to be queried only when apic versions allows (DCNE-589) Nov 26, 2025
resource.TestCheckResourceAttrSet("aci_{{$.resourceName}}.test", "{{$key}}"),
{{- end}}
{{- range $key, $value := $.children}}
// foo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// foo

gmicol
gmicol previously approved these changes Dec 2, 2025
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gmicol
gmicol previously approved these changes Dec 2, 2025
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

samiib
samiib previously approved these changes Dec 2, 2025
Copy link
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

shrsr
shrsr previously approved these changes Dec 2, 2025
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akinross akinross dismissed stale reviews from shrsr, samiib, and gmicol via 43b7294 December 3, 2025 06:56
@akinross akinross requested review from gmicol, samiib and shrsr December 3, 2025 06:57
shrsr
shrsr previously approved these changes Dec 3, 2025
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shrsr shrsr self-requested a review December 18, 2025 15:25
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebase

@akinross akinross requested a review from shrsr January 12, 2026 08:05
@akinross akinross dismissed stale reviews from gmicol, samiib, and sajagana via 0f40f27 January 12, 2026 08:48
@akinross akinross force-pushed the bug_version_check_children branch from cd1c8d8 to 0f40f27 Compare January 12, 2026 08:48
shrsr
shrsr previously approved these changes Jan 12, 2026
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

anvitha-jain
anvitha-jain previously approved these changes Jan 13, 2026
Copy link
Collaborator

@anvitha-jain anvitha-jain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

samiib
samiib previously approved these changes Jan 14, 2026
Copy link
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gmicol
gmicol previously approved these changes Jan 14, 2026
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

func getVersionAPIC(ctx context.Context, diags *diag.Diagnostics, client *client.Client) string {
requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("/api/node/class/topSystem.json"), "GET", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a filter on the query for the role == controller to reduce size as this would query the whole set of switches which could be hundreds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good one, adjusted the query, which also simplifies the loop

}

if requestData.Search("imdata").Search("topSystem").Data() != nil {
attributes := requestData.Search("imdata").Search("topSystem").Search("attributes").Data().([]interface{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this merge attributes with same value but not with different values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean by this comment but I did spot an issue with the version appending. The duplicates should be removed for the length check

)
} else {
diags.AddError(
"Data for topSysytem class could not be retrieved",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Data for topSysytem class could not be retrieved",
"Data for topSystem class could not be retrieved",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change


package provider

func classVersions() map[string]string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use function for this vs a constant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a constant is not possible because a map cannot be a constant in go, will leverage a package-level variable instead of a function

@@ -17,6 +18,19 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
)

func getChildClassesForGetRequest(childClasses []string) []string {
classVersions := classVersions()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be defined as a constant and not a function so we avoid re-addressing the list everytime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a constant is not possible because a map cannot be a constant in go, will leverage a package-level variable.


func getAndSetInfraPortBlkAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraPortBlkResourceModel) {
requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraPortBlk,infraRsAccBndlSubgrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil)
childClasses := getChildClassesForGetRequest([]string{"infraRsAccBndlSubgrp", "tagAnnotation", "tagTag"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did infraPortBlk go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infraPortBlk is the the class being requested in the resource via the DN set in data.Id.ValueString(), so not sure why this would be needed to be set in the rsp-subtree-class ?


func getAndSetInfraHPortSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPortSResourceModel) {
requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPortS,infraRsAccBaseGrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil)
childClasses := getChildClassesForGetRequest([]string{"infraRsAccBaseGrp", "tagAnnotation", "tagTag"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did infraHPortS go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infraHPortS is the the class being requested in the resource via the DN set in data.Id.ValueString(), so not sure why this would be needed to be set in the rsp-subtree-class ?

@@ -1,4 +1,4 @@
class_version: 6.0(2h)-6.0(8g),6.1(3f)-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be defined for both?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done only for testing, the commPol class itself is supported but there was some behaviour of the class which made us skip it in those versions of testing. I did not want to change this behaviour but I needed a way to mention deprecated class like the case of fvRsBDToRelayP. So the class_version is now use for overall override of the class version when not in meta. The class_version_tests is only applied to the tests.

…of possible response by filter the topSystem request
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@anvitha-jain anvitha-jain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@sajagana sajagana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira-sync Sync this issue to Jira

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants