orchestration: Fix VirtualMachineEntityFactory to process spring injections
The bug was found was Harikrishna P. when iso was used, in case of Isos, the create vm from scratch which fails due to factory being used to get the object which is not spring injected Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/54bfd7e0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/54bfd7e0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/54bfd7e0 Branch: refs/heads/ui-multiple-nics Commit: 54bfd7e04a0ab8c613aba3fcb2dd7e112cb35b31 Parents: 44f345e Author: Rohit Yadav <[email protected]> Authored: Thu Feb 28 17:28:15 2013 +0530 Committer: Rohit Yadav <[email protected]> Committed: Thu Feb 28 17:28:15 2013 +0530 ---------------------------------------------------------------------- .../entity/api/VirtualMachineEntityFactory.java | 3 ++- .../platform/orchestration/CloudOrchestrator.java | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bfd7e0/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityFactory.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityFactory.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityFactory.java index 2e8638e..e8ad8e4 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityFactory.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityFactory.java @@ -16,6 +16,7 @@ // under the License. package org.apache.cloudstack.engine.cloud.entity.api; +import com.cloud.utils.component.ComponentContext; import org.springframework.beans.factory.FactoryBean; import org.springframework.stereotype.Component; @@ -24,7 +25,7 @@ public class VirtualMachineEntityFactory implements FactoryBean<VirtualMachineEn @Override public VirtualMachineEntityImpl getObject() throws Exception { - return new VirtualMachineEntityImpl(); + return ComponentContext.inject(VirtualMachineEntityImpl.class.newInstance()); } @Override http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bfd7e0/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java ---------------------------------------------------------------------- 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 60ea9f5..f47325a 100755 --- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java @@ -176,9 +176,7 @@ public class CloudOrchestrator implements OrchestrationService { VirtualMachineEntityImpl vmEntity = null; try { - //vmEntity = _vmEntityFactory.getObject(); - vmEntity = VirtualMachineEntityImpl.class.newInstance(); - vmEntity = ComponentContext.inject(vmEntity); + vmEntity = _vmEntityFactory.getObject(); } catch (Exception e) { // add error handling here }
