@@ -3136,6 +3136,24 @@ public UserVm updateVirtualMachine(long id, String displayName, String group, Bo
31363136 .getUuid (), nic .getId (), extraDhcpOptionsMap );
31373137 }
31383138
3139+ checkAndUpdateSecurityGroupForVM (securityGroupIdList , vm , networks );
3140+
3141+ _vmDao .updateVM (id , displayName , ha , osTypeId , userData , userDataId ,
3142+ userDataDetails , isDisplayVmEnabled , isDynamicallyScalable ,
3143+ deleteProtection , customId , hostName , instanceName );
3144+
3145+ if (updateUserdata ) {
3146+ updateUserData (vm );
3147+ }
3148+
3149+ if (State .Running == vm .getState ()) {
3150+ updateDns (vm , hostName );
3151+ }
3152+
3153+ return _vmDao .findById (id );
3154+ }
3155+
3156+ private void checkAndUpdateSecurityGroupForVM (List <Long > securityGroupIdList , UserVmVO vm , List <NetworkVO > networks ) {
31393157 boolean isVMware = (vm .getHypervisorType () == HypervisorType .VMware );
31403158
31413159 if (securityGroupIdList != null && isVMware ) {
@@ -3164,20 +3182,6 @@ public UserVm updateVirtualMachine(long id, String displayName, String group, Bo
31643182 updateSecurityGroup (vm , securityGroupIdList );
31653183 }
31663184 }
3167-
3168- _vmDao .updateVM (id , displayName , ha , osTypeId , userData , userDataId ,
3169- userDataDetails , isDisplayVmEnabled , isDynamicallyScalable ,
3170- deleteProtection , customId , hostName , instanceName );
3171-
3172- if (updateUserdata ) {
3173- updateUserData (vm );
3174- }
3175-
3176- if (State .Running == vm .getState ()) {
3177- updateDns (vm , hostName );
3178- }
3179-
3180- return _vmDao .findById (id );
31813185 }
31823186
31833187 private void updateSecurityGroup (UserVmVO vm , List <Long > securityGroupIdList ) {
0 commit comments