From 46e91bd79401fecebe44da4c8fb899f23489c308 Mon Sep 17 00:00:00 2001 From: Mice Xia Date: Tue, 26 Feb 2013 16:24:32 +0800 Subject: [PATCH] fix issue: failed to start vm from iso caused by ClassCastException and NPE --- .../platform/orchestration/CloudOrchestrator.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java index ea9a30b969a..60ea9f57cb6 100755 --- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java @@ -267,10 +267,17 @@ public class CloudOrchestrator implements OrchestrationService { rootDiskOffering.first(diskOffering); rootDiskOffering.second(size); + List> networkIpMap = new ArrayList>(); + for (String uuid : networkNicMap.keySet()) { + NetworkVO network = _networkDao.findByUuid(uuid); + if(network != null){ + networkIpMap.add(new Pair(network, networkNicMap.get(uuid))); + } + } HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor); - if (_itMgr.allocate(vm, _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, null, null, plan, hypervisorType, null) == null) { + 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) { return null; }