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;
}
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()));
}
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());
}
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;
}
}
Aggregations