Search in sources :

Example 1 with StorageSystemType

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);
        }
    }
}
Also used : ExternalBlockStorageDevice(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalBlockStorageDevice) HashMap(java.util.HashMap) AbstractStorageDriver(com.emc.storageos.storagedriver.AbstractStorageDriver) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) BeansException(org.springframework.beans.BeansException)

Example 2 with StorageSystemType

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;
}
Also used : ArrayList(java.util.ArrayList) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) URI(java.net.URI)

Example 3 with StorageSystemType

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;
}
Also used : StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType)

Example 4 with StorageSystemType

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;
}
Also used : StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType)

Example 5 with StorageSystemType

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);
    }
}
Also used : StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) URI(java.net.URI)

Aggregations

StorageSystemType (com.emc.storageos.db.client.model.StorageSystemType)29 URI (java.net.URI)10 ArrayList (java.util.ArrayList)10 StorageDriversInfo (com.emc.storageos.coordinator.client.model.StorageDriversInfo)8 HashMap (java.util.HashMap)5 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)5 StorageDriverMetaData (com.emc.storageos.coordinator.client.model.StorageDriverMetaData)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 Path (javax.ws.rs.Path)4 File (java.io.File)3 HashSet (java.util.HashSet)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 AbstractStorageDriver (com.emc.storageos.storagedriver.AbstractStorageDriver)2 ZipFile (java.util.zip.ZipFile)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2