@Override public String call(PrimaryStorageType arg) { return arg.toString(); } });
void init() { type.setPrimaryStorageFindBackupStorage(new PrimaryStorageFindBackupStorage() { @Override @Transactional(readOnly = true) public List<String> findBackupStorage(String primaryStorageUuid) { List<String> psUuids = new ArrayList<>(); psUuids.addAll(getExtensionBSUuids(primaryStorageUuid)); // return null because the usage would do some null-processes return psUuids.size() == 0 ? null : psUuids; } }); }
@Deferred private void handle(final APIAddPrimaryStorageMsg msg) { PrimaryStorageType type = PrimaryStorageType.valueOf(msg.getType()); final PrimaryStorageFactory factory = getPrimaryStorageFactory(type); primaryStorageVO.setType(type.toString()); primaryStorageVO.setName(msg.getName()); primaryStorageVO.setDescription(msg.getDescription());
String psUuid = getSelfInventory().getRootVolume().getPrimaryStorageUuid(); PrimaryStorageVO ps = dbf.getEntityManager().find(PrimaryStorageVO.class, psUuid); PrimaryStorageType psType = PrimaryStorageType.valueOf(ps.getType()); List<String> bsUuids = psType.findBackupStorage(psUuid);
private void getPrimaryStorageCapacities(Map<String, Object> ret) { SimpleQuery<PrimaryStorageVO> q = dbf.createQuery(PrimaryStorageVO.class); q.select(PrimaryStorageVO_.type); q.add(PrimaryStorageVO_.uuid, Op.EQ, self.getPrimaryStorageUuid()); String type = q.findValue(); PrimaryStorageType psType = PrimaryStorageType.valueOf(type); ret.put(Capability.MigrationInCurrentPrimaryStorage.toString(), psType.isSupportVolumeMigrationInCurrentPrimaryStorage()); ret.put(Capability.MigrationToOtherPrimaryStorage.toString(), psType.isSupportVolumeMigrationToOtherPrimaryStorage()); }
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()); } } }
private void passThrough(PrimaryStorageMessage pmsg) { PrimaryStorageVO vo = dbf.findByUuid(pmsg.getPrimaryStorageUuid(), PrimaryStorageVO.class); if (vo == null && allowedMessageAfterSoftDeletion.contains(pmsg.getClass())) { PrimaryStorageEO eo = dbf.findByUuid(pmsg.getPrimaryStorageUuid(), PrimaryStorageEO.class); vo = ObjectUtils.newAndCopy(eo, PrimaryStorageVO.class); } Message msg = (Message) pmsg; if (vo == null) { bus.replyErrorByMessageType(msg, err(SysErrors.RESOURCE_NOT_FOUND, "Cannot find primary storage[uuid:%s], it may have been deleted", pmsg.getPrimaryStorageUuid())); return; } PrimaryStorageFactory factory = getPrimaryStorageFactory(PrimaryStorageType.valueOf(vo.getType())); PrimaryStorageVO finalVo = vo; PrimaryStorage ps = Platform.New(()-> factory.getPrimaryStorage(finalVo)); ps.handleMessage(msg); }
private void handle(APIGetPrimaryStorageTypesMsg msg) { APIGetPrimaryStorageTypesReply reply = new APIGetPrimaryStorageTypesReply(); List<String> ret = new ArrayList<>(PrimaryStorageType.getAllTypeNames()); reply.setPrimaryStorageTypes(ret); bus.reply(msg, reply); }
PrimaryStorageType type = PrimaryStorageType.valueOf(psvo.getType()); List<String> bsUuids = type.findBackupStorage(psUuid); if (bsUuids == null) { List<String> possibleBsTypes = hostAllocatorMgr.getBackupStorageTypesByPrimaryStorageTypeFromMetrics(psvo.getType());
@Override public String getPrimaryStorageTypeForRecalculateCapacityExtensionPoint() { return type.toString(); }
PrimaryStorageType psType = PrimaryStorageType.valueOf(ps.getType()); List<String> bsUuids = psType.findBackupStorage(ps.getUuid());
void init() { type.setPrimaryStorageFindBackupStorage(new PrimaryStorageFindBackupStorage() { @Override @Transactional(readOnly = true) public List<String> findBackupStorage(String primaryStorageUuid) { String sql = "select b.uuid from FusionstorPrimaryStorageVO p, FusionstorBackupStorageVO b where b.fsid = p.fsid" + " and p.uuid = :puuid"; TypedQuery<String> q = dbf.getEntityManager().createQuery(sql, String.class); q.setParameter("puuid", primaryStorageUuid); return q.getResultList(); } }); }
@Override public String createTemplateFromVolumeSnapshotPrimaryStorageType() { return type.toString(); }
@Override public String getPrimaryStorageTypeForRecalculateCapacityExtensionPoint() { return type.toString(); }
@Override public boolean equals(Object t) { if (t == null || !(t instanceof PrimaryStorageType)) { return false; } PrimaryStorageType type = (PrimaryStorageType) t; return type.toString().equals(typeName); }
@Override public PrimaryStorageFactory getPrimaryStorageFactory(PrimaryStorageType type) { PrimaryStorageFactory factory = primaryStorageFactories.get(type.toString()); if (factory == null) { throw new CloudRuntimeException(String.format("No PrimaryStorageFactory for type: %s found", type)); } return factory; }
private void populateExtensions() { for (PrimaryStorageAllocatorStrategyFactory f : pluginRgty.getExtensionList(PrimaryStorageAllocatorStrategyFactory.class)) { PrimaryStorageAllocatorStrategyFactory old = allocatorFactories.get(f.getPrimaryStorageAllocatorStrategyType().toString()); if (old != null) { throw new CloudRuntimeException(String.format("duplicate PrimaryStorageAllocatorStrategyFactory[%s, %s] for type[%s]", f.getClass().getName(), old.getClass().getName(), f.getPrimaryStorageAllocatorStrategyType())); } allocatorFactories.put(f.getPrimaryStorageAllocatorStrategyType().toString(), f); } for (PrimaryStorageFactory f : pluginRgty.getExtensionList(PrimaryStorageFactory.class)) { PrimaryStorageFactory old = primaryStorageFactories.get(f.getPrimaryStorageType().toString()); if (old != null) { throw new CloudRuntimeException(String.format("duplicate PrimaryStorageFactory[%s, %s] for type[%s]", f.getClass().getName(), old.getClass().getName(), old.getPrimaryStorageType())); } primaryStorageFactories.put(f.getPrimaryStorageType().toString(), f); } }
private void populateExtensions() { for (NfsPrimaryStorageBackend extp : pluginRgty.getExtensionList(NfsPrimaryStorageBackend.class)) { NfsPrimaryStorageBackend old = backends.get(extp.getHypervisorType().toString()); if (old != null) { throw new CloudRuntimeException(String.format("duplicate NfsPrimaryStorageBackend[%s, %s] for type[%s]", extp.getClass().getName(), old.getClass().getName(), old.getHypervisorType())); } backends.put(extp.getHypervisorType().toString(), extp); } for (NfsPrimaryToBackupStorageMediator extp : pluginRgty.getExtensionList(NfsPrimaryToBackupStorageMediator.class)) { if (extp.getSupportedPrimaryStorageType().equals(type.toString())) { Map<String, NfsPrimaryToBackupStorageMediator> map = mediators.get(extp.getSupportedBackupStorageType()); if (map == null) { map = new HashMap<>(1); } for (String hvType : extp.getSupportedHypervisorTypes()) { map.put(hvType, extp); } mediators.put(extp.getSupportedBackupStorageType(), map); } } }
private Boolean isLocalStorage(String psUuid) { return Q.New(PrimaryStorageVO.class) .eq(PrimaryStorageVO_.type, type.toString()) .eq(PrimaryStorageVO_.uuid, psUuid) .isExists(); }