@Override public void rollback(FlowRollback chain, Map data) { if (data.containsKey(SUCCESS)) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); ReturnHostCapacityMsg msg = new ReturnHostCapacityMsg(); msg.setHostUuid(spec.getDestHost().getUuid()); msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); bus.makeLocalServiceId(msg, HostAllocatorConstant.SERVICE_ID); bus.send(msg); } chain.rollback(); } }
private void returnComputeCapacity(String hostUuid) { ReturnHostCapacityMsg msg = new ReturnHostCapacityMsg(); msg.setCpuCapacity(struct.getVmInstance().getCpuNum()); msg.setMemoryCapacity(struct.getVmInstance().getMemorySize()); msg.setHostUuid(hostUuid); bus.makeLocalServiceId(msg, HostAllocatorConstant.SERVICE_ID); bus.send(msg); }
@Override public void rollback(FlowRollback chain, Map data) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); HostInventory host = spec.getDestHost(); 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(); } }
private void vmRunningOnHost(FlowTrigger trigger) { // allocate capacity on the current host try { long cpu = struct.getVmInstance().getCpuNum(); new HostAllocatorChain().reserveCapacity( struct.getCurrentHostUuid(), cpu, struct.getVmInstance().getMemorySize()); rollback = new Runnable() { @Override public void run() { returnComputeCapacity(struct.getCurrentHostUuid()); } }; trigger.next(); } catch (UnableToReserveHostCapacityException e) { trigger.fail(operr(e.getMessage())); } }
@Override public void rollback(FlowRollback chain, Map data) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); if (data.containsKey(SUCCESS)) { VmInstanceVO vm = dbf.findByUuid(spec.getVmInventory().getUuid(), VmInstanceVO.class); vm.setHostUuid(null); dbf.update(vm); HostInventory host = spec.getDestHost(); 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(); }
@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(); } }
private void vmMigrateToAnotherHost(FlowTrigger trigger) { // allocate the capacity on the current host // return the capacity to the original host try { final long cpu = struct.getVmInstance().getCpuNum(); new HostAllocatorChain().reserveCapacity( struct.getCurrentHostUuid(), cpu, struct.getVmInstance().getMemorySize()); returnComputeCapacity(struct.getOriginalHostUuid()); rollback = new Runnable() { @Override public void run() { returnComputeCapacity(struct.getCurrentHostUuid()); new HostAllocatorChain().reserveCapacity( struct.getOriginalHostUuid(), cpu, struct.getVmInstance().getMemorySize()); } }; trigger.next(); } catch (UnableToReserveHostCapacityException e) { trigger.fail(operr(e.getMessage())); } }
@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(); } }
msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); msg.setHostUuid(destHostUuid);
msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); msg.setHostUuid(spec.getDestHost().getUuid());
int cpuNum = spec.getVmInventory().getCpuNum(); cmd.setCpuNum(cpuNum);
msg.setDiskOfferings(diskOfferings); msg.setDiskSize(diskSize); msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); List<L3NetworkInventory> l3Invs = VmNicSpec.getL3NetworkInventoryOfSpec(spec.getL3Networks());
msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); msg.setVmOperation(spec.getCurrentVmOperation().toString());
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()); }
msg.setCpuCapacity(spec.getVmInventory().getCpuNum()); msg.setMemoryCapacity(spec.getVmInventory().getMemorySize()); msg.setHostUuid(spec.getDestHost().getUuid());