Search in sources :

Example 6 with StorageDriverMetaData

use of com.emc.storageos.coordinator.client.model.StorageDriverMetaData in project coprhd-controller by CoprHD.

the class StorageDriverManager method updateUpgradeMetadata.

private boolean updateUpgradeMetadata(List<StorageDriversInfo> infos) {
    List<StorageSystemType> upgradingTypes = queryDriversByStatus(StorageSystemType.STATUS.UPGRADING);
    List<StorageSystemType> finishedTypes = new ArrayList<StorageSystemType>();
    boolean needRestart = false;
    Map<String, StorageDriverMetaData> toInsertNewMetaDatas = new HashMap<String, StorageDriverMetaData>();
    log.info("Upgrading storage system types: {}", concatStorageSystemTypeNames(upgradingTypes));
    for (StorageSystemType type : upgradingTypes) {
        String driverName = type.getDriverName();
        String driverFileName = type.getDriverFileName();
        if (upgradingDriverMap.containsKey(driverName)) {
            StorageDriverMetaData metaData = upgradingDriverMap.get(driverName);
            // last one removes old meta data
            boolean finished = true;
            for (StorageDriversInfo info : infos) {
                if (info.getInstalledDrivers().contains(driverFileName)) {
                    finished = false;
                    break;
                }
            }
            if (finished) {
                toInsertNewMetaDatas.put(metaData.getDriverName(), metaData);
                log.info("DriverUpgradephase1: remove {} ", type.getStorageTypeName());
                dbClient.removeObject(type);
            }
        } else {
            // last one marks active
            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("DriverUpgradephase2: mark active for {}", type.getStorageTypeName());
                needRestart = true;
            }
        }
    }
    insertMetadata(toInsertNewMetaDatas);
    for (String driver : extractDrivers(finishedTypes)) {
        auditCompleteOperation(OperationTypeEnum.UPGRADE_STORAGE_DRIVER, AuditLogManager.AUDITLOG_SUCCESS, driver);
    }
    return needRestart;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StorageDriverMetaData(com.emc.storageos.coordinator.client.model.StorageDriverMetaData) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo)

Example 7 with StorageDriverMetaData

use of com.emc.storageos.coordinator.client.model.StorageDriverMetaData in project coprhd-controller by CoprHD.

the class StorageDriverManager method getUpgradeDriverMetaDataMap.

private Map<String, StorageDriverMetaData> getUpgradeDriverMetaDataMap() {
    List<Configuration> configs = coordinatorClient.queryAllConfiguration(StorageDriverMetaData.KIND);
    Map<String, StorageDriverMetaData> result = new HashMap<String, StorageDriverMetaData>();
    if (configs == null || configs.isEmpty()) {
        return result;
    }
    for (Configuration config : configs) {
        StorageDriverMetaData newMetaData = new StorageDriverMetaData(config);
        result.put(newMetaData.getDriverName(), newMetaData);
    }
    return result;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) HashMap(java.util.HashMap) StorageDriverMetaData(com.emc.storageos.coordinator.client.model.StorageDriverMetaData)

Example 8 with StorageDriverMetaData

use of com.emc.storageos.coordinator.client.model.StorageDriverMetaData in project coprhd-controller by CoprHD.

the class StorageDriverServiceTest method testUpgrade.

@Test
public void testUpgrade() {
    String driverName = "driver1";
    FormDataContentDisposition details = mock(FormDataContentDisposition.class);
    doReturn(0L).when(details).getSize();
    boolean force = false;
    StorageDriverMetaData metaData = createMetaData();
    metaData.setDriverName("driver1");
    metaData.setDriverVersion("1.2.3.5");
    // mock parsing meta data
    doReturn(metaData).when(service).parseDriverMetaData(anyObject());
    try {
        service.upgrade(driverName, null, details, force);
    } catch (Exception e) {
        fail("driver upgrade failed");
    }
}
Also used : StorageDriverMetaData(com.emc.storageos.coordinator.client.model.StorageDriverMetaData) FormDataContentDisposition(com.sun.jersey.core.header.FormDataContentDisposition) Test(org.junit.Test)

Aggregations

StorageDriverMetaData (com.emc.storageos.coordinator.client.model.StorageDriverMetaData)8 StorageDriversInfo (com.emc.storageos.coordinator.client.model.StorageDriversInfo)4 StorageSystemType (com.emc.storageos.db.client.model.StorageSystemType)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ZipFile (java.util.zip.ZipFile)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)2 Configuration (com.emc.storageos.coordinator.common.Configuration)1 FormDataContentDisposition (com.sun.jersey.core.header.FormDataContentDisposition)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Path (javax.ws.rs.Path)1 Test (org.junit.Test)1