Skip to content

Commit fde34df

Browse files
DaanHooglandDaan Hooglandweizhouapache
authored
Make sure other than user VMs can have multiple NICs in a network (apache#5896)
* only check user VMs * Update engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java Co-authored-by: Daan Hoogland <dahn@onecht.net> Co-authored-by: Wei Zhou <weizhou@apache.org>
1 parent c1bba2a commit fde34df

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,7 +4043,10 @@ public NicProfile addVmToNetwork(final VirtualMachine vm, final Network network,
40434043
/**
40444044
* duplicated in {@see UserVmManagerImpl} for a {@see UserVmVO}
40454045
*/
4046-
private void checkIfNetworkExistsForVM(VirtualMachine virtualMachine, Network network) {
4046+
private void checkIfNetworkExistsForUserVM(VirtualMachine virtualMachine, Network network) {
4047+
if (virtualMachine.getType() != VirtualMachine.Type.User) {
4048+
return; // others may have multiple nics in the same network
4049+
}
40474050
List<NicVO> allNics = _nicsDao.listByVmId(virtualMachine.getId());
40484051
for (NicVO nic : allNics) {
40494052
if (nic.getNetworkId() == network.getId()) {
@@ -4056,7 +4059,7 @@ private NicProfile orchestrateAddVmToNetwork(final VirtualMachine vm, final Netw
40564059
InsufficientCapacityException {
40574060
final CallContext cctx = CallContext.current();
40584061

4059-
checkIfNetworkExistsForVM(vm, network);
4062+
checkIfNetworkExistsForUserVM(vm, network);
40604063
s_logger.debug("Adding vm " + vm + " to network " + network + "; requested nic profile " + requested);
40614064
final VMInstanceVO vmVO = _vmDao.findById(vm.getId());
40624065
final ReservationContext context = new ReservationContextImpl(null, null, cctx.getCallingUser(), cctx.getCallingAccount());

0 commit comments

Comments
 (0)