@AsyncThread public void notifyVmStateChange(final VmInstanceInventory vm, final VmInstanceState pre, final VmInstanceState curr) { // when state changing from Created to Starting, there is no hyperviosrType yet as vm has not decided which host to go if (vm.getHypervisorType() == null) { return; } List<VmInstanceStateChangeNotifyPoint> exts = stateChangePoints.get(HypervisorType.valueOf(vm.getHypervisorType())); if (exts == null) { return; } CollectionUtils.safeForEach(exts, new ForEachFunction<VmInstanceStateChangeNotifyPoint>() { @Override public void run(VmInstanceStateChangeNotifyPoint arg) { arg.notifyVmInstanceStateChange(vm, pre, curr); } }); }
query.setParameter("hostState", HostState.Enabled); query.setParameter("hostConnectionState", HostStatus.Connected); query.setParameter("hypervisorType", vm.getHypervisorType()); query.setParameter("hostUuids", getHostUuidsFromCandidates()); query.setParameter("hostState", HostState.Enabled); query.setParameter("hostConnectionState", HostStatus.Connected); query.setParameter("hypervisorType", vm.getHypervisorType());
@Override public void establishProxy(final SessionInventory session, final VmInstanceInventory vm, final ReturnValueCompletion<ConsoleProxyInventory> completion) { ConsoleHypervisorBackend bkd = consoleMgr.getHypervisorConsoleBackend(HypervisorType.valueOf(vm.getHypervisorType())); bkd.generateConsoleUrl(vm, new ReturnValueCompletion<URI>(completion) { @Override public void success(URI uri) { doEstablish(uri, completion); } @Override public void fail(ErrorCode errorCode) { completion.fail(errorCode); } }); }
if (KVMConstant.KVM_HYPERVISOR_TYPE.equals(spec.getVmInventory().getHypervisorType())) { return new LocalStorageKvmMigrateVmFlow(); } else { throw new OperationFailureException(operr("local storage doesn't support live migration for hypervisor[%s]", spec.getVmInventory().getHypervisorType()));
SecurityGroupHypervisorBackend bkd = getHypervisorBackend(inv.getHypervisorType()); bkd.cleanUpUnusedRuleOnHost(inv.getLastHostUuid(), new Completion(null) { @Override
prepareFirewallInfo(chain); addBootstrapFlows(chain, HypervisorType.valueOf(inv.getHypervisorType()));
prepareFirewallInfo(chain); addBootstrapFlows(chain, HypervisorType.valueOf(inv.getHypervisorType()));
@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(); } }
spec.setFullAllocate(msg.isFullAllocate()); String hvType = null; if (msg.getVmInstance() != null && msg.getVmInstance().getHypervisorType() != null) { hvType = msg.getVmInstance().getHypervisorType();
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()); }
inv.setInternalName(VmNicVO.generateNicInternalName(vmSpec.getVmInventory().getInternalId(), inv.getDeviceId())); inv.setMac(NetworkUtils.generateMacWithDeviceId((short) inv.getDeviceId())); inv.setHypervisorType(vmSpec.getVmInventory().getHypervisorType());