Fix issue where security group selection is shown regardless of zone settings in EditVM #10224
+3
−5
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
In CloudStack, the security group selection box is displayed when editing a VM, regardless of whether the zone supports security groups or not. This causes the
securitygroupids
parameter to be sent with the request even if no security group is selected. If the zone is of typeNetworkType.Advanced
and does not support security groups, this triggers aNullPointerException
in theUserVmManagerImpl.updateVirtualMachine
method when callingisSecurityGroupSupportedInNetwork
.Upon investigation, it was found that the
listZones
API call, which is used to fetch the zone details, incorrectly useszoneid
instead ofid
for the zone identifier. This prevents the correct zone information from being retrieved. Additionally, since thelistZones
API does not properly filter zones, it fetches all zones and always takes the first one in the list (index 0) to determine whether security groups are enabled. Consequently, if that first zone supports security groups, the security group selection box is displayed in the UI—even if the zone actually used by the VM does not support them.Moreover, the logic for checking whether the security group selection box is empty is not strict enough, which causes the
securitygroupids
parameter to be included in the request even when the selection box is empty.Proposed Solution
listZones
API by usingid
instead ofzoneid
.listZones
API call to ensure that only the relevant zone is considered when checking for security group support.securitygroupids
parameter to the request.Modified Files
EditVM.vue
PR Changes
zoneid
inlistZones
calls to properly retrieve the VM’s zone details.securitygroupids
from being included if no security group is actually selected.NullPointerException
when editing VMs inNetworkType.Advanced
zones that do not support security groups.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
How Has This Been Tested?
Local Dev Environment
securitygroupids
is sent to the backend.NullPointerException
is thrown even ifsecuritygroupids
isnull
or empty.UI Validation
EditVM.vue
properly filters the correct zone fromlistZones
.securitygroupids
.How did you try to break this feature and the system with this change?
securitygroupids
, verifying that no NPE occurs.