Skip to content

Commit 46e91bd

Browse files
author
Mice Xia
committed
fix issue: failed to start vm from iso caused by ClassCastException and NPE
1 parent e37fdce commit 46e91bd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,17 @@ public VirtualMachineEntity createVirtualMachineFromScratch(String id, String ow
267267
rootDiskOffering.first(diskOffering);
268268
rootDiskOffering.second(size);
269269

270+
List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO, NicProfile>>();
271+
for (String uuid : networkNicMap.keySet()) {
272+
NetworkVO network = _networkDao.findByUuid(uuid);
273+
if(network != null){
274+
networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
275+
}
276+
}
270277

271278
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
272279

273-
if (_itMgr.allocate(vm, _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, null, null, plan, hypervisorType, null) == null) {
280+
if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
274281
return null;
275282
}
276283

0 commit comments

Comments
 (0)