Search in sources :

Example 21 with StorageSystemType

use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.

the class StorageDriverService method filterTypesByDriver.

private List<StorageSystemType> filterTypesByDriver(String driverName) {
    List<StorageSystemType> types = listStorageSystemTypes();
    List<StorageSystemType> toUninstallTypes = new ArrayList<StorageSystemType>();
    for (StorageSystemType type : types) {
        if (!StringUtils.equals(driverName, type.getDriverName())) {
            continue;
        }
        toUninstallTypes.add(type);
    }
    return toUninstallTypes;
}
Also used : ArrayList(java.util.ArrayList) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType)

Example 22 with StorageSystemType

use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.

the class StorageDriverService method getStorageDriverOperationLock.

protected InterProcessLock getStorageDriverOperationLock() {
    // Try to acquire lock, succeed or throw Exception
    InterProcessLock lock = coordinator.getSiteLocalLock(STORAGE_DRIVER_OPERATION_lOCK);
    boolean acquired;
    try {
        acquired = lock.acquire(LOCK_WAIT_TIME_SEC, TimeUnit.SECONDS);
    } catch (Exception e) {
        try {
            lock.release();
        } catch (Exception ex) {
            log.error("Fail to release storage driver operation lock", ex);
        }
        throw APIException.internalServerErrors.installDriverPrecheckFailed("Acquiring lock failed, there's another trigger operation holding lock");
    }
    if (!acquired) {
        throw APIException.internalServerErrors.installDriverPrecheckFailed("Acquiring lock failed, there's another trigger operation holding lock");
    }
    // Check if there's ongoing storage operation, if there is, release lock
    // and throw exception
    StorageSystemType opOngoingStorageType = null;
    List<StorageSystemType> types = listStorageSystemTypes();
    for (StorageSystemType type : types) {
        String statusStr = type.getDriverStatus();
        if (statusStr == null) {
            log.info("Bypass type {} as it has no status field value", type.getStorageTypeName());
            continue;
        }
        StorageSystemType.STATUS status = Enum.valueOf(StorageSystemType.STATUS.class, type.getDriverStatus());
        if (status.isStorageOperationOngoing()) {
            opOngoingStorageType = type;
            break;
        }
    }
    if (opOngoingStorageType != null) {
        try {
            lock.release();
        } catch (Exception e) {
            log.error("Fail to release storage driver operation lock", e);
        }
        throw APIException.internalServerErrors.installDriverPrecheckFailed(String.format("Driver %s is in % state", opOngoingStorageType.getDriverName(), opOngoingStorageType.getDriverStatus()));
    }
    return lock;
}
Also used : InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 23 with StorageSystemType

use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.

the class StorageDriverService method queryStorageDriver.

/**
 * @return driver specified by the name; return all drivers if name is null
 */
private List<StorageDriverRestRep> queryStorageDriver(String name) {
    Set<String> usedProviderTypes = getUsedStorageProviderTypes();
    Set<String> usedSystemTypes = getUsedStorageSystemTypes();
    Map<String, StorageDriverRestRep> driverMap = new HashMap<String, StorageDriverRestRep>();
    List<URI> ids = dbClient.queryByType(StorageSystemType.class, true);
    Iterator<StorageSystemType> it = dbClient.queryIterativeObjects(StorageSystemType.class, ids);
    while (it.hasNext()) {
        StorageSystemType type = it.next();
        String driverName = type.getDriverName();
        if (name != null && !name.equals(driverName)) {
            continue;
        }
        if (type.getIsNative() == null || type.getIsNative()) {
            // bypass native storage types
            continue;
        }
        setTypeDriverStatus(type, usedProviderTypes, usedSystemTypes);
        setDriverIntoMap(driverName, type, driverMap);
    }
    List<StorageDriverRestRep> drivers = new ArrayList<StorageDriverRestRep>();
    drivers.addAll(driverMap.values());
    return drivers;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) URI(java.net.URI) StorageDriverRestRep(com.emc.storageos.model.storagedriver.StorageDriverRestRep)

Example 24 with StorageSystemType

use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.

the class StorageDriverService method getAllDriverNames.

private Set<String> getAllDriverNames() {
    List<StorageSystemType> types = listStorageSystemTypes();
    Set<String> drivers = new HashSet<String>();
    for (StorageSystemType type : types) {
        drivers.add(type.getDriverName());
    }
    return drivers;
}
Also used : StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) HashSet(java.util.HashSet)

Example 25 with StorageSystemType

use of com.emc.storageos.db.client.model.StorageSystemType in project coprhd-controller by CoprHD.

the class StorageDriverMapper method map.

/**
 * @return supported StorageSystemTypes by this driver. The first is the
 *         storage system, and the second is storage provider if there is
 */
public static List<StorageSystemType> map(StorageDriverMetaData driver) {
    List<StorageSystemType> types = new ArrayList<StorageSystemType>();
    StorageSystemType type = new StorageSystemType();
    type.setStorageTypeName(driver.getStorageName());
    type.setStorageTypeDispName(driver.getStorageDisplayName());
    type.setDriverName(driver.getDriverName());
    type.setDriverVersion(driver.getDriverVersion());
    type.setDriverFileName(driver.getDriverFileName());
    type.setMetaType(driver.getMetaType());
    URI uri = URIUtil.createId(StorageSystemType.class);
    type.setId(uri);
    type.setStorageTypeId(uri.toString());
    type.setIsDefaultSsl(driver.isEnableSsl());
    type.setSslPort(Long.toString(driver.getSslPort()));
    type.setNonSslPort(Long.toString(driver.getNonSslPort()));
    type.setSupportAutoTierPolicy(driver.isSupportAutoTierPolicy());
    type.setDriverClassName(driver.getDriverClassName());
    types.add(type);
    if (StringUtils.isNotEmpty(driver.getProviderName()) && StringUtils.isNotEmpty(driver.getProviderDisplayName())) {
        StorageSystemType provider = new StorageSystemType();
        provider.setStorageTypeName(driver.getProviderName());
        provider.setStorageTypeDispName(driver.getProviderDisplayName());
        provider.setIsSmiProvider(true);
        provider.setDriverName(driver.getDriverName());
        provider.setDriverVersion(driver.getDriverVersion());
        provider.setDriverFileName(driver.getDriverFileName());
        provider.setMetaType(driver.getMetaType());
        uri = URIUtil.createId(StorageSystemType.class);
        provider.setId(uri);
        provider.setStorageTypeId(uri.toString());
        provider.setIsDefaultSsl(driver.isEnableSsl());
        provider.setSslPort(Long.toString(driver.getSslPort()));
        provider.setNonSslPort(Long.toString(driver.getNonSslPort()));
        provider.setSupportAutoTierPolicy(driver.isSupportAutoTierPolicy());
        provider.setDriverClassName(driver.getDriverClassName());
        type.setManagedBy(provider.getStorageTypeId());
        types.add(provider);
    }
    return types;
}
Also used : ArrayList(java.util.ArrayList) 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