Search in sources :

Example 11 with StorageDriversInfo

use of com.emc.storageos.coordinator.client.model.StorageDriversInfo 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 12 with StorageDriversInfo

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

the class StorageDriverManager method updateLocalDriversList.

/**
 * Update locally installed drivers list to syssvc service beacon
 */
public void updateLocalDriversList() {
    localDriverFiles = localRepo.getLocalDrivers();
    StorageDriversInfo info = new StorageDriversInfo();
    info.setInstalledDrivers(localDriverFiles);
    coordinator.setNodeSessionScopeInfo(info);
    log.info("Updated local driver list to ZK service beacon: {}", Arrays.toString(localDriverFiles.toArray()));
}
Also used : StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo)

Example 13 with StorageDriversInfo

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

the class StorageDriverServiceTest method setUp.

@Before
public void setUp() throws Exception {
    // mock dependent members of StorageDriverService instance and wire into
    // them
    dbClient = mock(DbClientImpl.class);
    doNothing().when(dbClient).createObject(any(StorageSystemType.class));
    doNothing().when(dbClient).updateObject(any(StorageSystemType.class));
    coordinator = mock(CoordinatorClientImpl.class);
    coordinatorExt = mock(CoordinatorClientExt.class);
    doReturn(coordinator).when(coordinatorExt).getCoordinatorClient();
    doNothing().when(coordinator).persistServiceConfiguration(any(Configuration.class));
    service = spy(new StorageDriverService());
    service.setDbClient(dbClient);
    service.setCoordinatorExt(coordinatorExt);
    // mock 3 storage system types in db
    type1 = new StorageSystemType();
    type1.setStorageTypeDispName("systemtype1");
    type1.setStorageTypeName("systemtype1");
    type1.setIsNative(false);
    type1.setDriverStatus(StorageSystemType.STATUS.ACTIVE.toString());
    type1.setDriverName("driver1");
    type1.setDriverFileName("driverFileName1");
    type1.setDriverVersion("1.2.3.4");
    type2 = new StorageSystemType();
    type2.setStorageTypeDispName("providertype1");
    type2.setStorageTypeName("providertype1");
    type2.setIsNative(false);
    type2.setDriverStatus(StorageSystemType.STATUS.ACTIVE.toString());
    type2.setDriverName("driver1");
    type2.setDriverFileName("driverFileName1");
    type2.setDriverVersion("1.2.3.4");
    type3 = new StorageSystemType();
    type3.setStorageTypeDispName("systemtype2");
    type3.setStorageTypeName("systemtype2");
    type3.setIsNative(false);
    type3.setDriverStatus(StorageSystemType.STATUS.ACTIVE.toString());
    type3.setDriverName("driver2");
    List<StorageSystemType> types = new ArrayList<StorageSystemType>();
    types.add(type1);
    types.add(type2);
    types.add(type3);
    doReturn(types.iterator()).when(dbClient).queryIterativeObjects(eq(StorageSystemType.class), anyCollectionOf(URI.class));
    // mock that systemtype1 is in use
    Set<String> inUseTypes = new HashSet<String>();
    inUseTypes.add("systemtype1");
    doReturn(inUseTypes).when(service).getUsedStorageProviderTypes();
    // mock that no systemtype is used
    doReturn(new HashSet<String>()).when(service).getUsedStorageSystemTypes();
    // bypass pre-check for environment
    doNothing().when(service).precheckForEnv();
    // mock lock acquire and release
    InterProcessLock lock = mock(InterProcessLock.class);
    doNothing().when(lock).release();
    doReturn(lock).when(service).getStorageDriverOperationLock();
    // mock target list of installed drivers
    StorageDriversInfo drivers = new StorageDriversInfo();
    Set<String> installedDrivers = new HashSet<String>();
    installedDrivers.add("driverFileName1");
    installedDrivers.add("driverFileName2");
    drivers.setInstalledDrivers(installedDrivers);
    doReturn(drivers).when(coordinator).getTargetInfo(anyObject());
    // mock audit operation
    doNothing().when(service).auditOperation(any(OperationTypeEnum.class), anyString(), anyString(), anyObject());
    // mock file moving from tmp dir to data dir
    doNothing().when(service).moveDriverToDataDir(any(File.class));
    // mock updating target innfo
    doNothing().when(coordinator).setTargetInfo(anyObject());
    // mock progess updating
    doNothing().when(coordinatorExt).setNodeSessionScopeInfo(anyObject());
    // mock moving driver file to tmp dir
    doReturn(null).when(service).saveToTmpDir(anyString(), anyObject());
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ArrayList(java.util.ArrayList) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo) URI(java.net.URI) CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) CoordinatorClientExt(com.emc.storageos.systemservices.impl.upgrade.CoordinatorClientExt) File(java.io.File) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 14 with StorageDriversInfo

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

the class CoordinatorClientImpl method getControlNodesState.

@Override
public ClusterInfo.ClusterState getControlNodesState(String siteId) {
    try {
        // get target repository and configVersion
        final RepositoryInfo targetRepository = getTargetInfo(RepositoryInfo.class);
        final PropertyInfoRestRep targetProperty = getTargetInfo(PropertyInfoExt.class);
        final PowerOffState targetPowerOffState = getTargetInfo(PowerOffState.class);
        final StorageDriversInfo targetDrivers = getTargetInfo(StorageDriversInfo.class);
        // get control nodes' repository and configVersion info
        final Map<Service, RepositoryInfo> controlNodesInfo = getAllNodeInfos(RepositoryInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, ConfigVersion> controlNodesConfigVersions = getAllNodeInfos(ConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, VdcConfigVersion> controlNodesVdcConfigVersions = getAllNodeInfos(VdcConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, StorageDriversInfo> controlNodesDrivers = getAllNodeInfos(StorageDriversInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        return getControlNodesState(targetRepository, controlNodesInfo, targetProperty, controlNodesConfigVersions, controlNodesVdcConfigVersions, targetPowerOffState, targetDrivers, controlNodesDrivers, siteId);
    } catch (Exception e) {
        log.info("Fail to get the control node information ", e);
        return ClusterInfo.ClusterState.UNKNOWN;
    }
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion) ConfigVersion(com.emc.storageos.coordinator.client.model.ConfigVersion) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

StorageDriversInfo (com.emc.storageos.coordinator.client.model.StorageDriversInfo)14 StorageSystemType (com.emc.storageos.db.client.model.StorageSystemType)8 StorageDriverMetaData (com.emc.storageos.coordinator.client.model.StorageDriverMetaData)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 Site (com.emc.storageos.coordinator.client.model.Site)2 Service (com.emc.storageos.coordinator.common.Service)2 HashSet (java.util.HashSet)2 ExecutorService (java.util.concurrent.ExecutorService)2 ZipFile (java.util.zip.ZipFile)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)1 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)1