Fix project-scoped VM lookup in port forward resource - #356
Open
dheeraj12347 wants to merge 1 commit into
Open
dheeraj12347 wants to merge 1 commit into
dheeraj12347 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an issue with project-scoped VM lookup when creating a port forward.
The
cloudstack_port_forwardresource supports aprojectattribute, but while creating a port forward, the target virtual machine was previously retrieved using only its VM ID:This lookup does not pass the project context from the port forward resource.
When project-scoped resources are used with account-level credentials, the VM lookup may fail because the API request does not include the project context required to resolve the project-scoped VM.
Changes
The VM lookup in
createPortForwardhas been updated to pass the configured project:This ensures that the project associated with the port forward resource is also used when resolving the target VM.
Regression Test
Added a new acceptance test:
The test creates:
The test verifies that:
Existing Project Handling
The existing project-inheritance behavior remains unchanged.
The new test specifically covers the case where the
projectis explicitly configured on the port-forward resource and the target VM is also project-scoped.Validation
The following local checks were successfully completed:
go test ./cloudstack— passedgo vet ./...— passedgit diff --check— passedThe targeted acceptance test was also attempted:
However, the acceptance test could not proceed to the port-forward resource logic because the locally deployed CloudStack simulator did not contain the expected
Sandbox-simulatorzone.The failure occurred during network creation:
Therefore, the targeted acceptance test was blocked by the local simulator environment before the VM lookup and port-forward creation logic were reached.
Related Issue
Fixes #355