@Transactional(readOnly = true) protected List<ImageInventory> getImageCandidatesForVm(ImageMediaType type) { String psUuid = getSelfInventory().getRootVolume().getPrimaryStorageUuid(); PrimaryStorageVO ps = dbf.getEntityManager().find(PrimaryStorageVO.class, psUuid); PrimaryStorageType psType = PrimaryStorageType.valueOf(ps.getType());
msg.setRequiredPrimaryStorageUuid(spec.getVmInventory().getRootVolume().getPrimaryStorageUuid());
rootVolume = spec.getVmInventory().getRootVolume(); backend = new LocalStorageKvmBackend(dbf.findByUuid(rootVolume.getPrimaryStorageUuid(), PrimaryStorageVO.class)); String imageUuid = rootVolume.getRootImageUuid();
@Override public String getHostAllocatorStrategyName(HostAllocatorSpec spec) { if (!VmOperation.Migrate.toString().equals(spec.getVmOperation())) { return null; } SimpleQuery<PrimaryStorageVO> q = dbf.createQuery(PrimaryStorageVO.class); q.select(PrimaryStorageVO_.type); q.add(PrimaryStorageVO_.uuid, Op.EQ, spec.getVmInstance().getRootVolume().getPrimaryStorageUuid()); String type = q.findValue(); if (!LocalStorageConstants.LOCAL_STORAGE_TYPE.equals(type)) { return null; } return LocalStorageConstants.LOCAL_STORAGE_MIGRATE_VM_ALLOCATOR_TYPE; } }
@Transactional(readOnly = true) private void checkIfIsoAttachable(String isoUuid) { String psUuid = getSelfInventory().getRootVolume().getPrimaryStorageUuid(); String sql = "select count(i)" + " from ImageCacheVO i" +
" and ps.type = :type"; TypedQuery<Long> q = dbf.getEntityManager().createQuery(sql, Long.class); q.setParameter("uuid", vm.getRootVolume().getPrimaryStorageUuid()); q.setParameter("type", LocalStorageConstants.LOCAL_STORAGE_TYPE); q.setMaxResults(1);
String psUuid = spec.getVmInstance().getRootVolume().getPrimaryStorageUuid(); List<String> huuids = CollectionUtils.transformToList(candidates, new Function<String, HostVO>() { @Override
private void checkPrimaryStorageCapabilities(VmCapabilities capabilities) { VolumeInventory rootVolume = getSelfInventory().getRootVolume(); if (rootVolume == null) { capabilities.setSupportLiveMigration(false); capabilities.setSupportVolumeMigration(false); } else { SimpleQuery<PrimaryStorageVO> q = dbf.createQuery(PrimaryStorageVO.class); q.select(PrimaryStorageVO_.type); q.add(PrimaryStorageVO_.uuid, Op.EQ, rootVolume.getPrimaryStorageUuid()); String type = q.findValue(); PrimaryStorageType psType = PrimaryStorageType.valueOf(type); if (self.getState() != VmInstanceState.Running) { capabilities.setSupportLiveMigration(false); } else { capabilities.setSupportLiveMigration(psType.isSupportVmLiveMigration()); } if (self.getState() != VmInstanceState.Stopped) { capabilities.setSupportVolumeMigration(false); } else { capabilities.setSupportVolumeMigration(psType.isSupportVolumeMigration()); } } }
psUuid = pinv.getUuid(); } else { psUuid = spec.getVmInventory().getRootVolume().getPrimaryStorageUuid();
.eq(PrimaryStorageVO_.uuid, inv.getRootVolume().getPrimaryStorageUuid()) .eq(PrimaryStorageVO_.type, LocalStorageConstants.LOCAL_STORAGE_TYPE).isExists()) { return;
psUuid = rootVolumeSpec.getPrimaryStorageInventory().getUuid(); } else { psUuid = spec.getVmInventory().getRootVolume().getPrimaryStorageUuid();
msg.setAllocatorStrategy(HostAllocatorConstant.MIGRATE_VM_ALLOCATOR_TYPE); msg.setVmOperation(spec.getCurrentVmOperation().toString()); msg.setRequiredPrimaryStorageUuid(spec.getVmInventory().getRootVolume().getPrimaryStorageUuid()); msg.setL3NetworkUuids(CollectionUtils.transformToList( VmNicSpec.getL3NetworkInventoryOfSpec(spec.getL3Networks()), new Function<String, L3NetworkInventory>() {
msg.setImage(spec.getImageSpec().getInventory()); msg.setRequiredPrimaryStorageUuid(spec.getVmInventory().getRootVolume().getPrimaryStorageUuid()); msg.setVmOperation(spec.getCurrentVmOperation().toString()); msg.setAllocatorStrategy(HostAllocatorConstant.DESIGNATED_HOST_ALLOCATOR_STRATEGY_TYPE);
msg.setRequiredPrimaryStorageUuid(spec.getVmInventory().getRootVolume().getPrimaryStorageUuid()); msg.setServiceId(bus.makeLocalServiceId(HostAllocatorConstant.SERVICE_ID)); msg.setAvoidHostUuids(getAvoidHost(spec));