@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { final Instance instance = (Instance) state.getResource(); List<Volume> volumes = InstanceHelpers.extractVolumesFromMounts(instance, objectManager); for (final Volume v : volumes) { String driver = DataAccessor.fieldString(v, VolumeConstants.FIELD_VOLUME_DRIVER); if (StringUtils.isNotEmpty(driver) && !VolumeConstants.LOCAL_DRIVER.equals(driver)) { StoragePool sp = storagePoolDao.findStoragePoolByDriverName(v.getAccountId(), driver); if (sp == null) { continue; } final String accessMode = sp.getVolumeAccessMode(); if (StringUtils.isNotEmpty(accessMode) && StringUtils.isEmpty(v.getAccessMode()) && !accessMode.equals(v.getAccessMode())) { lockManager.lock( new InstanceVolumeAccessModeLock(v.getId()), new LockCallbackNoReturn() { @Override public void doWithLockNoResult() { objectManager.setFields(v, VOLUME.ACCESS_MODE, accessMode); } }); } } } return null; }
@Override public List<? extends Host> getHosts(StoragePool pool) { return create() .select(HOST.fields()) .from(HOST) .join(STORAGE_POOL_HOST_MAP) .on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID)) .where( STORAGE_POOL_HOST_MAP .REMOVED .isNull() .and(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID.eq(pool.getId()))) .fetchInto(HostRecord.class); }