@Override protected FlowChain getStartVmWorkFlowChain(VmInstanceInventory inv) { FlowChain chain = super.getStartVmWorkFlowChain(inv); chain.setName(String.format("start-appliancevm-%s", inv.getUuid())); chain.insert( new Flow() { String __name__ = "change-appliancevm-status-to-connecting"; ApplianceVmStatus originStatus = getSelf().getStatus(); @Override public void run(FlowTrigger trigger, Map data) { getSelf().setStatus(ApplianceVmStatus.Connecting); self = dbf.updateAndRefresh(self); trigger.next(); } @Override public void rollback(FlowTrigger trigger, Map data) { self = dbf.reload(self); getSelf().setStatus(originStatus); self = dbf.updateAndRefresh(self); trigger.rollback(); } }); prepareLifeCycleInfo(chain); prepareFirewallInfo(chain); addBootstrapFlows(chain, HypervisorType.valueOf(inv.getHypervisorType())); List<Flow> subStartFlows = getPostStartFlows(); if (subStartFlows != null) { for (Flow f : subStartFlows) { chain.then(f); } } chain.then( new NoRollbackFlow() { String __name__ = "change-appliancevm-status-to-connected"; @Override public void run(FlowTrigger trigger, Map data) { getSelf().setStatus(ApplianceVmStatus.Connected); self = dbf.updateAndRefresh(self); trigger.next(); } }); boolean noRollbackOnFailure = ApplianceVmGlobalProperty.NO_ROLLBACK_ON_POST_FAILURE; chain.noRollback(noRollbackOnFailure); return chain; }
@Override protected FlowChain getMigrateVmWorkFlowChain(VmInstanceInventory inv) { FlowChain chain = super.getMigrateVmWorkFlowChain(inv); chain.setName(String.format("migrate-appliancevm-%s", inv.getUuid())); prepareLifeCycleInfo(chain); prepareFirewallInfo(chain); List<Flow> subMigrateFlows = getPostMigrateFlows(); if (subMigrateFlows != null) { for (Flow f : subMigrateFlows) { chain.then(f); } } boolean noRollbackOnFailure = ApplianceVmGlobalProperty.NO_ROLLBACK_ON_POST_FAILURE; chain.noRollback(noRollbackOnFailure); return chain; }