Search in sources :

Example 11 with StorageSystemType

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

the class StorageDriverManager method updateInstallMetadata.

private boolean updateInstallMetadata(List<StorageDriversInfo> infos) {
    List<StorageSystemType> installingTypes = queryDriversByStatus(StorageSystemType.STATUS.INSTALLING);
    List<StorageSystemType> finishedTypes = new ArrayList<StorageSystemType>();
    boolean needRestart = false;
    log.info("Installing storage system types: {}", concatStorageSystemTypeNames(installingTypes));
    for (StorageSystemType type : installingTypes) {
        boolean finished = true;
        for (StorageDriversInfo info : infos) {
            if (!info.getInstalledDrivers().contains(type.getDriverFileName())) {
                finished = false;
                break;
            }
        }
        if (finished) {
            type.setDriverStatus(StorageSystemType.STATUS.ACTIVE.toString());
            dbClient.updateObject(type);
            finishedTypes.add(type);
            log.info("update status from installing to active for {}", type.getStorageTypeName());
            needRestart = true;
        }
    }
    for (String driver : extractDrivers(finishedTypes)) {
        auditCompleteOperation(OperationTypeEnum.INSTALL_STORAGE_DRIVER, AuditLogManager.AUDITLOG_SUCCESS, driver);
    }
    return needRestart;
}
Also used : ArrayList(java.util.ArrayList) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo)

Example 12 with StorageSystemType

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

the class ExternalDeviceCommunicationInterface method initDrivers.

private void initDrivers() {
    if (initialized) {
        return;
    }
    List<URI> ids = _dbClient.queryByType(StorageSystemType.class, true);
    Iterator<StorageSystemType> it = _dbClient.queryIterativeObjects(StorageSystemType.class, ids);
    Map<String, AbstractStorageDriver> cachedDriverInstances = new HashMap<>();
    while (it.hasNext()) {
        StorageSystemType type = it.next();
        if (type.getIsNative() == null || type.getIsNative()) {
            continue;
        }
        if (!StringUtils.equals(type.getMetaType(), StorageSystemType.META_TYPE.BLOCK.toString())) {
            continue;
        }
        String typeName = type.getStorageTypeName();
        String className = type.getDriverClassName();
        // provider and managed system should use the same driver instance
        if (cachedDriverInstances.containsKey(className)) {
            drivers.put(typeName, cachedDriverInstances.get(className));
            _log.info("Driver info for storage system type {} has been set into externaldevice instance", typeName);
            continue;
        }
        String mainClassName = type.getDriverClassName();
        try {
            AbstractStorageDriver driverInstance = (AbstractStorageDriver) Class.forName(mainClassName).newInstance();
            drivers.put(typeName, driverInstance);
            cachedDriverInstances.put(className, driverInstance);
            _log.info("Driver info for storage system type {} has been set into externaldevice instance", typeName);
        } catch (Exception e) {
            _log.error("Error happened when instantiating class {}", mainClassName);
        }
    }
    initialized = true;
}
Also used : HashMap(java.util.HashMap) AbstractStorageDriver(com.emc.storageos.storagedriver.AbstractStorageDriver) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException)

Example 13 with StorageSystemType

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

the class StorageSystemTypesInitUtils method insertStorageSystemTypes.

private void insertStorageSystemTypes() {
    for (Map.Entry<META_TYPE, List<String>> entry : SYSTEMS_AND_PROVIDERS.entrySet()) {
        META_TYPE metaType = entry.getKey();
        List<String> systems = entry.getValue();
        for (String system : systems) {
            if (!PlatformUtils.isOssBuild() && system.equals(CEPH)) {
                log.info("Skip inserting ceph meta data in non-oss build");
                continue;
            }
            StorageSystemType type = new StorageSystemType();
            URI uri = URIUtil.createId(StorageSystemType.class);
            type.setId(uri);
            type.setStorageTypeId(uri.toString());
            type.setStorageTypeName(system);
            type.setStorageTypeDispName(DISPLAY_NAME_MAP.get(system));
            type.setMetaType(mapType(metaType));
            type.setDriverClassName(metaType.toString().toLowerCase());
            type.setIsSmiProvider(metaType.isProvider());
            type.setIsDefaultSsl(SSL_ENABLE_TYPE_LIST.contains(system));
            type.setIsDefaultMDM(MDM_ENABLE_LIST.contains(system));
            type.setIsOnlyMDM(ONLY_MDM_LIST.contains(system));
            type.setIsElementMgr(ELEMENT_MANAGER_LIST.contains(system));
            type.setIsSecretKey(SECREAT_KEY_ENABLE_LIST.contains(system));
            type.setSslPort(SSL_PORT_MAP.get(system));
            type.setNonSslPort(NON_SSL_PORT_MAP.get(system));
            type.setIsNative(true);
            if (alreadyExists(type)) {
                log.info("Meta data for {} already exist", type.getStorageTypeName());
                continue;
            }
            log.info("Meta data for {} don't exist or have changed, update", type.getStorageTypeName());
            dbClient.createObject(type);
        }
    }
}
Also used : List(java.util.List) Arrays.asList(java.util.Arrays.asList) META_TYPE(com.emc.storageos.db.client.model.StorageSystemType.META_TYPE) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) HashMap(java.util.HashMap) Map(java.util.Map) URI(java.net.URI)

Example 14 with StorageSystemType

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

the class ControllerServiceImpl method initDriverManager.

private void initDriverManager(List<StorageSystemType> types) {
    StorageDriverManager driverManager = (StorageDriverManager) getBean(StorageDriverManager.STORAGE_DRIVER_MANAGER);
    for (StorageSystemType type : types) {
        String typeName = type.getStorageTypeName();
        String driverName = type.getDriverName();
        if (type.getIsSmiProvider()) {
            driverManager.getStorageProvidersMap().put(driverName, typeName);
            _log.info("Driver info for storage system type {} has been set into storageDriverManager instance", typeName);
            continue;
        }
        driverManager.getStorageSystemsMap().put(driverName, typeName);
        if (type.getManagedBy() != null) {
            driverManager.getProviderManaged().add(typeName);
        } else {
            driverManager.getDirectlyManaged().add(typeName);
        }
        if (StringUtils.equals(type.getMetaType(), StorageSystemType.META_TYPE.FILE.toString())) {
            driverManager.getFileSystems().add(typeName);
        } else if (StringUtils.equals(type.getMetaType(), StorageSystemType.META_TYPE.BLOCK.toString())) {
            driverManager.getBlockSystems().add(typeName);
        }
        _log.info("Driver info for storage system type {} has been set into storageDriverManager instance", typeName);
    }
}
Also used : StorageDriverManager(com.emc.storageos.services.util.StorageDriverManager) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType)

Example 15 with StorageSystemType

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

the class StorageDriverManager method queryDriversByStatus.

private List<StorageSystemType> queryDriversByStatus(StorageSystemType.STATUS status) {
    List<StorageSystemType> types = new ArrayList<StorageSystemType>();
    List<URI> ids = dbClient.queryByType(StorageSystemType.class, true);
    Iterator<StorageSystemType> it = dbClient.queryIterativeObjects(StorageSystemType.class, ids);
    while (it.hasNext()) {
        StorageSystemType type = it.next();
        if (StringUtils.equals(type.getDriverStatus(), status.toString())) {
            types.add(type);
        }
    }
    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