mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-7985: keep the default nic on shared network when assignVM
This commit is contained in:
parent
a1d2fba1d2
commit
3f16740d82
@ -5246,12 +5246,27 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
if (securityGroupIdList != null && !securityGroupIdList.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Can't move vm with security groups; security group feature is not enabled in this zone");
|
||||
}
|
||||
Set<NetworkVO> applicableNetworks = new HashSet<NetworkVO>();
|
||||
// if networkIdList is null and the first network of vm is shared network, then keep it if possible
|
||||
if (networkIdList == null || networkIdList.isEmpty()) {
|
||||
NicVO defaultNicOld = _nicDao.findDefaultNicForVM(vm.getId());
|
||||
if (defaultNicOld != null) {
|
||||
NetworkVO defaultNetworkOld = _networkDao.findById(defaultNicOld.getNetworkId());
|
||||
if (defaultNetworkOld != null && defaultNetworkOld.getGuestType() == Network.GuestType.Shared && defaultNetworkOld.getAclType() == ACLType.Domain) {
|
||||
try {
|
||||
_networkModel.checkNetworkPermissions(newAccount, defaultNetworkOld);
|
||||
applicableNetworks.add(defaultNetworkOld);
|
||||
} catch (PermissionDeniedException e) {
|
||||
s_logger.debug("AssignVM: the shared network on old default nic can not be applied to new account");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup the network for the oldOwner
|
||||
_networkMgr.cleanupNics(vmOldProfile);
|
||||
_networkMgr.expungeNics(vmOldProfile);
|
||||
|
||||
Set<NetworkVO> applicableNetworks = new HashSet<NetworkVO>();
|
||||
|
||||
if (networkIdList != null && !networkIdList.isEmpty()) {
|
||||
// add any additional networks
|
||||
for (Long networkId : networkIdList) {
|
||||
@ -5273,7 +5288,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
}
|
||||
applicableNetworks.add(network);
|
||||
}
|
||||
} else {
|
||||
} else if (applicableNetworks.isEmpty()) {
|
||||
NetworkVO defaultNetwork = null;
|
||||
List<NetworkOfferingVO> requiredOfferings = _networkOfferingDao.listByAvailability(Availability.Required, false);
|
||||
if (requiredOfferings.size() < 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user