Skip to content

Reconstruct resource ID mapping logic for VM registration#2276

Merged
cb-github-robot merged 1 commit intocloud-barista:mainfrom
leehyeoklee:improve-registration
Jan 19, 2026
Merged

Reconstruct resource ID mapping logic for VM registration#2276
cb-github-robot merged 1 commit intocloud-barista:mainfrom
leehyeoklee:improve-registration

Conversation

@leehyeoklee
Copy link
Copy Markdown
Contributor

Description:

This PR updates the VM registration logic to accurately reconstruct resource relationships and ensures data consistency when registering existing CSP VMs.

🚀 Key Changes

1. Expanded Resource Reconstruction

Before:

  • Only VNet (partial) and SSHKey were mapped during registration.

After:

  • Spec, Image, and SecurityGroup IDs are now correctly identified and mapped.
  • Subnet: Correctly identifies and assigns SubnetId by iterating through the matched VNet's internal subnet list.
image

2. Fixed Resource Lookup Type

  • Search Criteria: Corrected the search filter value from NameId (incorrect) to SystemId (CSP Resource ID).

3. Enabled Association Updates

  • Reference Counting: Updated UpdateAssociatedObjectList to support the "register" option.

Copy link
Copy Markdown
Member

@seokho-son seokho-son left a comment

Choose a reason for hiding this comment

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

@leehyeoklee LGTM in general. I just have a question. :)

idField := item.FieldByName("Id")
if idField.IsValid() {
return idField.String(), item.Interface()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we avoid utilizing reflect here?
I guess reflect may reduce performance (it is nature of the reflect), stability (unmatched case handling if item.FieldByName("ConnectionName").String() == requestBody.ConnectionName {, and code maintenance (for instance, "ConnectionName" can be refactored. if item.FieldByName("ConnectionName").String()) of the system

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fully agree with your concerns regarding performance and maintainability.

Although the code looks a bit repetitive now, I have removed the reflect logic and reverted to the explicit approach to prioritize type safety and stability

@seokho-son
Copy link
Copy Markdown
Member

/approve

@github-actions github-actions bot added the approved This PR is approved and will be merged soon. label Jan 19, 2026
@cb-github-robot cb-github-robot merged commit 248149e into cloud-barista:main Jan 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved This PR is approved and will be merged soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants