@Override public HostVO call(HostVO arg) { if (arg.getUuid().equals(vm.getLastHostUuid())) { return arg; } return null; } });
@Override public void sort() { final VmInstanceInventory vm = spec.getVmInstance(); Optional<HostInventory> hosts = candidates.stream().filter(candidate -> candidate.getUuid().equals(vm.getLastHostUuid())).findAny(); List<HostInventory> sorted = new ArrayList<>(); if (hosts.isPresent()) { sorted.add(hosts.get()); candidates.remove(candidates.indexOf(hosts.get())); sorted.addAll(candidates); candidates.clear(); candidates.addAll(sorted); } else { // if last host never existed, we go to the next sort flow skip = false; subCandidates.addAll(candidates); } }
@Override public String getHostUuid() { if (vmInventory.getHostUuid() != null) { return vmInventory.getHostUuid(); } else { return vmInventory.getLastHostUuid(); } } }
@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()); } });
bkd.cleanUpUnusedRuleOnHost(inv.getLastHostUuid(), new Completion(null) { @Override public void success() {
@Override public void handle(final Map data) { VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); HostInventory host = spec.getDestHost(); self = changeVmStateInDb(VmInstanceStateEvent.running, ()-> { self.setZoneUuid(host.getZoneUuid()); self.setClusterUuid(host.getClusterUuid()); self.setLastHostUuid(lastHostUuid); self.setHostUuid(host.getUuid()); }); VmInstanceInventory vm = VmInstanceInventory.valueOf(self); extEmitter.afterMigrateVm(vm, vm.getLastHostUuid()); completion.success(); } }).error(new FlowErrorHandler(completion) {
cmd.setIsoPath(iso.getIsoPath()); final String hostUuid = vrSpec.getHostUuid() == null ? vrSpec.getLastHostUuid() : vrSpec.getHostUuid(); KVMHostAsyncHttpCallMsg msg = new KVMHostAsyncHttpCallMsg(); msg.setCommand(cmd);
final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); final String hostUuid = spec.getVmInventory().getHostUuid() == null ? spec.getVmInventory().getLastHostUuid() : spec.getVmInventory().getHostUuid(); if (spec.getVmInventory().getClusterUuid() == null || hostUuid == null) {
String huuid = inv.getHostUuid() == null ? inv.getLastHostUuid() : inv.getHostUuid(); if (huuid != null) { HostVO hvo = dbf.findByUuid(huuid, HostVO.class);
final VolumeInventory volume = (VolumeInventory) data.get(VmInstanceConstant.Params.AttachingVolumeInventory.toString()); final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); String hostUuid = spec.getVmInventory().getHostUuid() == null ? spec.getVmInventory().getLastHostUuid() : spec.getVmInventory().getHostUuid();
@Override public void rollback(FlowRollback chain, Map data) { VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); HostInventory host = spec.getDestHost(); // if ChangeImage, then no need to ReturnHostCapacity, and resume vm info if (spec.getCurrentVmOperation() == VmOperation.ChangeImage) { VmInstanceVO vmvo = dbf.findByUuid(spec.getVmInventory().getUuid(), VmInstanceVO.class); vmvo.setClusterUuid(spec.getVmInventory().getClusterUuid()); vmvo.setLastHostUuid(spec.getVmInventory().getLastHostUuid()); vmvo.setHypervisorType(spec.getVmInventory().getHypervisorType()); dbf.update(vmvo); } else if (host != null) { ReturnHostCapacityMsg msg = new ReturnHostCapacityMsg(); msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); msg.setHostUuid(host.getUuid()); msg.setServiceId(bus.makeLocalServiceId(HostAllocatorConstant.SERVICE_ID)); bus.send(msg); } chain.rollback(); } }
public VmInstanceInventory(VmInstanceInventory origin) { VmInstanceInventory inv; try { inv = (VmInstanceInventory) origin.clone(); } catch (CloneNotSupportedException e) { throw new CloudRuntimeException(e); } this.setClusterUuid(inv.getClusterUuid()); this.setCreateDate(inv.getCreateDate()); this.setDescription(inv.getDescription()); this.setHostUuid(inv.getHostUuid()); this.setHypervisorType(inv.getHypervisorType()); this.setImageUuid(inv.getImageUuid()); this.setInstanceOfferingUuid(inv.getInstanceOfferingUuid()); this.setLastHostUuid(inv.getLastHostUuid()); this.setLastOpDate(inv.getLastOpDate()); this.setName(inv.getName()); this.setRootVolumeUuid(inv.getRootVolumeUuid()); this.setState(inv.getState()); this.setType(inv.getType()); this.setUuid(inv.getUuid()); this.setZoneUuid(inv.getZoneUuid()); this.setAllVolumes(inv.getAllVolumes()); this.setVmNics(inv.getVmNics()); this.setInternalId(inv.getInternalId()); this.setCpuNum(inv.getCpuNum()); this.setCpuSpeed(inv.getCpuSpeed()); this.setMemorySize(inv.getMemorySize()); this.setAllocatorStrategy(inv.getAllocatorStrategy()); }
spec.getVmInventory().getHostUuid() : spec.getVmInventory().getLastHostUuid(); oldHostUuid = dbf.isExist(oldHostUuid, HostVO.class) ? oldHostUuid : null; SQL.New(VmInstanceVO.class).eq(VmInstanceVO_.uuid, spec.getVmInventory().getUuid())