@Override public String getHostUuid() { return vmInventory.getHostUuid(); } }
@Override public String getHostUuid() { return vmInventory.getHostUuid(); } }
@Override public String getHostUuid() { return vmInventory.getHostUuid(); } }
@Override public String getHostUuid() { return vmInventory.getHostUuid(); } }
@Override public String getHostUuid() { if (vmInventory.getHostUuid() != null) { return vmInventory.getHostUuid(); } else { return vmInventory.getLastHostUuid(); } } }
public void setParametersFromVmInventory(VmInstanceInventory inv) { vmUuid = inv.getUuid(); vmNics = inv.getVmNics(); hostUuid = inv.getHostUuid(); }
@Override public void success() { logger.debug(String.format("vm[uuid:%s, name:%s] migrated to host[uuid:%s], cleanup its old rules on host[uuid:%s] if needed", inv.getUuid(), inv.getName(), inv.getHostUuid(), srcHostUuid)); }
@Override public void fail(ErrorCode errorCode) { N.New(VmInstanceVO.class, inv.getUuid()).warn_("after migration, failed to apply EIPs[uuids:%s] to the vm[uuid:%s, name:%s] on the destination host[uuid:%s], %s", eips.stream().map(e -> e.vip).collect(Collectors.toList()), inv.getUuid(), inv.getName(), inv.getHostUuid(), errorCode); } });
@Override public void fail(ErrorCode errorCode) { logger.debug(String.format("vm[uuid:%s, name:%s] migrated to host[uuid:%s], failed to cleanup its old rules on host[uuid:%s] if needed", inv.getUuid(), inv.getName(), inv.getHostUuid(), srcHostUuid)); createFailureHostTask(inv.getLastHostUuid()); } });
@Override public void afterMigrateVm(final VmInstanceInventory inv, String srcHostUuid) { List<EipTO> eips = getEipsByVmUuid(inv.getUuid()); if (eips == null || eips.isEmpty()) { return; } batchDeleteEips(eips, srcHostUuid, new NopeCompletion()); batchApplyEips(eips, inv.getHostUuid(), new Completion(null) { @Override public void success() { // pass } @Override public void fail(ErrorCode errorCode) { N.New(VmInstanceVO.class, inv.getUuid()).warn_("after migration, failed to apply EIPs[uuids:%s] to the vm[uuid:%s, name:%s] on the destination host[uuid:%s], %s", eips.stream().map(e -> e.vip).collect(Collectors.toList()), inv.getUuid(), inv.getName(), inv.getHostUuid(), errorCode); } }); }
@Override public void failedToMigrateVm(final VmInstanceInventory inv, final String destHostUuid, ErrorCode reason) { RuleCalculator cal = new RuleCalculator(); cal.vmNicUuids = CollectionUtils.transformToList(inv.getVmNics(), new Function<String, VmNicInventory>() { @Override public String call(VmNicInventory arg) { return arg.getUuid(); } }); cal.vmStates = asList(VmInstanceState.Unknown); List<HostRuleTO> htos = cal.calculate(); logger.debug(String.format("vm[uuid:%s, name:%s] failed to migrate to host[uuid:%s], recover its rules on previous host[uuid:%s]", inv.getUuid(), inv.getName(), destHostUuid, inv.getHostUuid())); applyRules(htos); }
@Override public void run(final FlowTrigger chain, Map data){ final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); ResumeVmOnHypervisorMsg msg = new ResumeVmOnHypervisorMsg(); msg.setVmInventory(spec.getVmInventory()); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID,spec.getVmInventory().getHostUuid()); bus.send(msg, new CloudBusCallBack(chain) { @Override public void run(MessageReply reply) { if (reply.isSuccess()) { chain.next(); return; } chain.fail(reply.getError()); } }); } }
@Override public void run(final FlowTrigger chain, Map data){ final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); PauseVmOnHypervisorMsg msg = new PauseVmOnHypervisorMsg(); msg.setVmInventory(spec.getVmInventory()); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID,spec.getVmInventory().getHostUuid()); bus.send(msg, new CloudBusCallBack(chain) { @Override public void run(MessageReply reply) { if (reply.isSuccess()) { chain.next(); return; } chain.fail(reply.getError()); } }); } }
@Override public void run(final FlowTrigger trigger, Map data) { VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); VmNicInventory nic = spec.getDestNics().get(0); VmAttachNicOnHypervisorMsg msg = new VmAttachNicOnHypervisorMsg(); msg.setHostUuid(spec.getVmInventory().getHostUuid()); msg.setNicInventory(nic); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, msg.getHostUuid()); bus.send(msg, new CloudBusCallBack(trigger) { @Override public void run(MessageReply reply) { if (!reply.isSuccess()) { trigger.fail(reply.getError()); } else { trigger.next(); } } }); } }
cmd.setIsoPath(iso.getIsoPath()); final String hostUuid = vrSpec.getHostUuid() == null ? vrSpec.getLastHostUuid() : vrSpec.getHostUuid(); KVMHostAsyncHttpCallMsg msg = new KVMHostAsyncHttpCallMsg(); msg.setCommand(cmd);
@Override public void run(final FlowTrigger chain, Map data) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); RebootVmOnHypervisorMsg msg = new RebootVmOnHypervisorMsg(); msg.setVmInventory(spec.getVmInventory()); msg.setBootOrders(spec.getBootOrders()); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, spec.getVmInventory().getHostUuid()); bus.send(msg, new CloudBusCallBack(chain) { @Override public void run(MessageReply reply) { if (reply.isSuccess()) { chain.next(); } else { chain.fail(reply.getError()); } } }); } }
@Override public void run(FlowTrigger chain, Map data) { VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); if (spec.getVmInventory().getHostUuid() == null) { // the vm failed because no host available at that time or the vm is stopped // no need to return host chain.next(); return; } ReturnHostCapacityMsg msg = new ReturnHostCapacityMsg(); msg.setHostUuid(spec.getVmInventory().getHostUuid()); msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); msg.setServiceId(bus.makeLocalServiceId(HostAllocatorConstant.SERVICE_ID)); bus.send(msg); chain.next(); } }
@Override public void run(final FlowTrigger trigger, Map data) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); DetachNicFromVmOnHypervisorMsg msg = new DetachNicFromVmOnHypervisorMsg(); msg.setHostUuid(spec.getVmInventory().getHostUuid()); msg.setVmInstanceUuid(spec.getVmInventory().getUuid()); msg.setNic(spec.getDestNics().get(0)); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, msg.getHostUuid()); bus.send(msg, new CloudBusCallBack(trigger) { @Override public void run(MessageReply reply) { if (reply.isSuccess()) { trigger.next(); } else { trigger.fail(reply.getError()); } } }); } }
@Override public void run(MessageReply reply) { if (reply.isSuccess()) { chain.next(); } else { if (spec.isGcOnStopFailure() && reply.getError().isError(HostErrors.OPERATION_FAILURE_GC_ELIGIBLE)) { StopVmGC gc = new StopVmGC(); gc.inventory = spec.getVmInventory(); gc.hostUuid = spec.getVmInventory().getHostUuid(); gc.NAME = String.format("gc-stop-vm-%s-%s-on-host-%s", gc.inventory.getUuid(), gc.inventory.getName(), gc.hostUuid); gc.submit(); chain.next(); } else { chain.fail(reply.getError()); } } } });
@Override public void run(final FlowTrigger chain, Map data) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); boolean migrateFromDest = false; if (spec.getMessage() instanceof MigrateVmMessage) { migrateFromDest = ((MigrateVmMessage)spec.getMessage()).isMigrateFromDestination(); } MigrateVmOnHypervisorMsg msg = new MigrateVmOnHypervisorMsg(); msg.setVmInventory(spec.getVmInventory()); msg.setDestHostInventory(spec.getDestHost()); msg.setSrcHostUuid(spec.getVmInventory().getHostUuid()); msg.setMigrateFromDestination(migrateFromDest); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, spec.getDestHost().getUuid()); bus.send(msg, new CloudBusCallBack(chain) { @Override public void run(MessageReply reply) { if (reply.isSuccess()) { chain.next(); } else { chain.fail(reply.getError()); } } }); }