use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method initExternalBlockStorageDevice.
private void initExternalBlockStorageDevice(List<StorageSystemType> types) {
ExternalBlockStorageDevice blockDevice = (ExternalBlockStorageDevice) getBean(StorageDriverManager.EXTERNAL_STORAGE_DEVICE);
// key: storage system type name, value: driver instance
Map<String, AbstractStorageDriver> blockDeviceDrivers = blockDevice.getDrivers();
// key: main class name, value: driver instance
Map<String, AbstractStorageDriver> cachedDriverInstances = new HashMap<String, AbstractStorageDriver>();
for (StorageSystemType type : types) {
String typeName = type.getStorageTypeName();
String metaType = type.getMetaType();
if (!StringUtils.equals(metaType, StorageSystemType.META_TYPE.BLOCK.toString())) {
// TODO for now it seems that we only support block type driver
// In future, to support file/object or other type, we need add more codes here
_log.info("Skip load info of {}, for its type is {} which is not supported for now", typeName, metaType);
continue;
}
String className = type.getDriverClassName();
// provider and managed system should use the same driver instance
if (cachedDriverInstances.containsKey(className)) {
blockDeviceDrivers.put(typeName, cachedDriverInstances.get(className));
_log.info("Driver info for storage system type {} has been set into externalBlockStorageDevice instance", typeName);
continue;
}
String mainClassName = type.getDriverClassName();
try {
AbstractStorageDriver driverInstance = (AbstractStorageDriver) Class.forName(mainClassName).newInstance();
blockDeviceDrivers.put(typeName, driverInstance);
cachedDriverInstances.put(className, driverInstance);
_log.info("Driver info for storage system type {} has been set into externalBlockStorageDevice instance", typeName);
} catch (Exception e) {
_log.error("Error happened when instantiating class {}", mainClassName);
}
}
}
use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method listNonNativeTypes.
private List<StorageSystemType> listNonNativeTypes() {
List<StorageSystemType> result = new ArrayList<>();
List<URI> ids = _dbClient.queryByType(StorageSystemType.class, true);
Iterator<StorageSystemType> it = _dbClient.queryIterativeObjects(StorageSystemType.class, ids);
while (it.hasNext()) {
StorageSystemType type = it.next();
if (type.getIsNative() == null || type.getIsNative()) {
continue;
}
if (StringUtils.equals(type.getDriverStatus(), StorageSystemType.STATUS.ACTIVE.toString())) {
result.add(type);
}
}
return result;
}
use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.
the class StorageSystemTypeService method queryResource.
@Override
protected StorageSystemType queryResource(URI id) {
ArgValidator.checkUri(id);
StorageSystemType storageType = _dbClient.queryObject(StorageSystemType.class, id);
ArgValidator.checkEntity(storageType, id, isIdEmbeddedInURL(id));
return storageType;
}
use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.
the class StorageSystemTypesInitUtils method alreadyExists.
/**
* Return true only when all fields stored in DB are same with given type parameter
*/
private boolean alreadyExists(StorageSystemType type) {
if (existingTypes.containsKey(type.getStorageTypeName())) {
StorageSystemType existingType = existingTypes.get(type.getStorageTypeName());
if (existingType.equals(type)) {
return true;
} else {
// If it exists but has changed, should remove and re-create
dbClient.removeObject(existingType);
existingTypes.remove(existingType.getStorageTypeName());
}
}
return false;
}
use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.
the class StorageSystemTypesInitUtils method loadTypeMapFromDb.
private void loadTypeMapFromDb() {
List<URI> ids = dbClient.queryByType(StorageSystemType.class, true);
Iterator<StorageSystemType> types = dbClient.queryIterativeObjects(StorageSystemType.class, ids);
existingTypes = new HashMap<String, StorageSystemType>();
while (types.hasNext()) {
StorageSystemType type = types.next();
existingTypes.put(type.getStorageTypeName(), type);
}
}
Aggregations