use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class TestDataCollectionJobConsumer method triggerScanning.
private void triggerScanning(DataCollectionScanJob job) throws Exception {
_logger.info("Started scanning SMIS Providers : triggerScanning()");
List<URI> allProviderURI = _dbClient.queryByType(StorageProvider.class, true);
List<StorageProvider> allProviders = _dbClient.queryObject(StorageProvider.class, allProviderURI);
Map<String, StorageSystemViewObject> storageSystemsCache = Collections.synchronizedMap(new HashMap<String, StorageSystemViewObject>());
boolean exceptionIntercepted = false;
try {
List<URI> cacheProviders = new ArrayList<URI>();
// since dbQuery does not return a normal list required by
// bookkeeping, we need to rebuild it.
allProviderURI = new ArrayList<URI>();
// at the same time.
for (StorageProvider provider : allProviders) {
allProviderURI.add(provider.getId());
ScanTaskCompleter scanCompleter = job.findProviderTaskCompleter(provider.getId());
if (scanCompleter == null) {
String taskId = UUID.randomUUID().toString();
scanCompleter = new ScanTaskCompleter(StorageProvider.class, provider.getId(), taskId);
job.addCompleter(scanCompleter);
}
try {
provider.setLastScanStatusMessage("");
_dbClient.persistObject(provider);
_logger.info("provider.getInterfaceType():{}", provider.getInterfaceType());
performScan(provider.getId(), scanCompleter, storageSystemsCache);
cacheProviders.add(provider.getId());
} catch (Exception ex) {
_logger.error("Scan failed for {}--->", provider.getId(), ex);
}
_dbClient.persistObject(provider);
}
// Perform BooKKeeping
// TODO: we need to access the status of job completer.
// for now we assume that this operation can not fail.
_util.performBookKeeping(storageSystemsCache, allProviderURI);
for (URI provider : cacheProviders) {
job.findProviderTaskCompleter(provider).ready(_dbClient);
_logger.info("Scan complete successfully for " + provider);
}
} catch (final Exception ex) {
_logger.error("Scan failed for {} ", ex.getMessage());
job.error(_dbClient, DeviceControllerErrors.dataCollectionErrors.scanFailed(ex.getLocalizedMessage(), ex));
exceptionIntercepted = true;
throw ex;
} finally {
try {
if (!exceptionIntercepted && job.isSchedulerJob()) {
// Manually trigger discoveries, if any new Arrays detected
triggerDiscoveryNew(storageSystemsCache, DataCollectionJob.JobOrigin.SCHEDULER);
}
} catch (Exception ex) {
_logger.error(ex.getMessage(), ex);
}
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws DataDomainApiException {
DataDomainClient ddClient = getDataDomainClient(accessProfile);
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
DDMCInfoDetail ddmcInfo = new DDMCInfoDetail();
try {
ddmcInfo = ddClient.getManagementSystemInfo();
} catch (DataDomainApiException dex) {
provider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
String op = "DDMC info retrieval";
String sys = provider.getLabel() + "(" + provider.getIPAddress() + ")";
throw DataDomainApiException.exceptions.opFailedProviderUnreachable(op, sys);
}
if (!validDdmcVersion(accessProfile, provider, ddmcInfo)) {
String version = null;
String minimumSupportedVersion = null;
Map<String, String> props = accessProfile.getProps();
if (props != null) {
version = props.get(CURRENT_VERSION);
minimumSupportedVersion = props.get(MINIMUM_VERSION);
}
throw DataDomainApiException.exceptions.scanFailedIncompatibleDdmc(version, minimumSupportedVersion);
}
Map<String, StorageSystemViewObject> cache = accessProfile.getCache();
DDSystemList systemList = ddClient.getManagedSystemList();
for (DDSystemInfo system : systemList.getSystemInfo()) {
DDSystem ddSystem = ddClient.getDDSystem(system.getId());
StorageSystemViewObject view = new StorageSystemViewObject();
view.addprovider(accessProfile.getSystemId().toString());
view.setDeviceType(accessProfile.getSystemType());
view.setProperty(StorageSystemViewObject.SERIAL_NUMBER, ddSystem.serialNo);
view.setProperty(StorageSystemViewObject.MODEL, ddSystem.model);
view.setProperty(StorageSystemViewObject.STORAGE_NAME, ddSystem.name);
view.setProperty(StorageSystemViewObject.VERSION, ddSystem.version);
cache.put(system.getId(), view);
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method scan.
/**
* {@inheritDoc}
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
URI providerURI = null;
StorageProvider providerObj = null;
String detailedStatusMessage = "Unknown Status";
try {
_logger.info("Access Profile Details :" + accessProfile.toString());
providerURI = accessProfile.getSystemId();
providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
_keyMap = new ConcurrentHashMap<String, Object>();
_wbemClient = getCIMClient(accessProfile);
_logger.info("CIMClient initialized successfully");
_keyMap.put(Constants.PROPS, accessProfile.getProps());
if (accessProfile.getCache() == null) {
accessProfile.setCache(new HashMap<String, StorageSystemViewObject>());
}
_keyMap.put(Constants._computerSystem, new ArrayList<CIMObjectPath>());
_keyMap.put(Constants.REGISTEREDPROFILE, CimObjectPathCreator.createInstance(Constants.PROFILECLASS, "interop"));
_keyMap.put(Constants._cimClient, _wbemClient);
_keyMap.put(Constants.dbClient, _dbClient);
_keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
if (_networkDeviceController != null) {
_keyMap.put(Constants.networkDeviceController, _networkDeviceController);
}
_keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
_keyMap.put(Constants.ACCESSPROFILE, accessProfile);
_keyMap.put(Constants.SYSTEMCACHE, accessProfile.getCache());
executor.setKeyMap(_keyMap);
executor.execute((Namespace) namespaces.getNsList().get(SCAN));
// scan succeeds
detailedStatusMessage = String.format("Scan job completed successfully for " + "SMISProvider: %s", providerURI.toString());
} catch (Exception e) {
detailedStatusMessage = String.format("Scan job failed for SMISProvider: %s because %s", providerURI.toString(), e.getMessage());
throw new SMIPluginException(detailedStatusMessage);
} finally {
if (providerObj != null) {
try {
// set detailed message
providerObj.setLastScanStatusMessage(detailedStatusMessage);
_dbClient.persistObject(providerObj);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
releaseResources();
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method scan.
/**
* Implementation for scan for Vnx Unity storage systems.
*
* @param accessProfile
*
* @throws BaseCollectionException
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("Starting scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
_locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
try {
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
if (apiClient != null) {
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
BasicSystemInfo unitySystem = apiClient.getBasicSystemInfo();
String unityType = StorageSystem.Type.unity.name();
String version = unitySystem.getApiVersion();
String compatibility = StorageSystem.CompatibilityStatus.COMPATIBLE.name();
provider.setCompatibilityStatus(compatibility);
provider.setVersionString(version);
VNXeStorageSystem system = apiClient.getStorageSystem();
_logger.info("Found Unity: {} ", system.getSerialNumber());
String id = system.getSerialNumber();
String nativeGuid = generateNativeGuid(unityType, id);
StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
if (viewObject == null) {
viewObject = new StorageSystemViewObject();
}
viewObject.setDeviceType(unityType);
viewObject.addprovider(accessProfile.getSystemId().toString());
viewObject.setProperty(StorageSystemViewObject.MODEL, unitySystem.getModel());
viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
storageSystemsCache.put(nativeGuid, viewObject);
}
} catch (Exception e) {
cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
_logger.error(String.format("Exception was encountered when attempting to scan Unity Instance %s", accessProfile.getIpAddress()), e);
throw VNXeException.exceptions.scanFailed(accessProfile.getIpAddress(), e);
} finally {
provider.setConnectionStatus(cxnStatus.name());
_dbClient.updateObject(provider);
_logger.info("Completed scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
_locker.releaseLock(accessProfile.getIpAddress());
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method checkForClusterHardwareChange.
/**
* Checks for hardware change from local to metro or vice versa. If the
* system flag controller_vplex_allow_local_to_metro_auto_upgrade is set to
* true, then the StorageSystem object and related StoragePorts will be updated
* with the new serial number information.
*
* @param clusterAssembyIds the cluster assembly IDs detected
* @param systemNativeGUID the storage system native GUID
* @param systemSerialNumber the storage system serial number
* @param client the VPLEX api client
* @param scanCache the scan cache
* @param mgmntServer the StorageProvider
* @throws Exception if an error occurred
*/
private void checkForClusterHardwareChange(List<String> clusterAssembyIds, String systemNativeGUID, String systemSerialNumber, VPlexApiClient client, Map<String, StorageSystemViewObject> scanCache, StorageProvider mgmntServer) throws Exception {
// we need to ensure the discovered storage system is not a result
// of a hardware reconfiguration from local to metro, or vice versa
s_logger.info("clusterAssembyIds is " + clusterAssembyIds);
if (VPlexApiConstants.VPLEX_METRO_ASSEMBLY_COUNT == clusterAssembyIds.size()) {
// check if this system could have been upgraded from local to metro
List<StorageSystem> vplexLocalStorageSystems = VPlexControllerUtils.getAllVplexLocalStorageSystems(_dbClient);
for (StorageSystem vplex : vplexLocalStorageSystems) {
if (null != vplex && null != vplex.getVplexAssemblyIdtoClusterId()) {
// because this is a local system, it should have only one assembly id
String assemblyId = vplex.getVplexAssemblyIdtoClusterId().keySet().iterator().next();
if (systemNativeGUID.contains(assemblyId)) {
String message = String.format("The VPLEX storage system serial number unexpectedly changed. " + "Existing VPLEX local assembly id %s is a substring of the newly-discoverd system GUID %s, " + "which indicates a change in VPLEX hardware configuration from local to metro. " + "Scanning of this Storage Provider cannot continue. Recommended course of action is " + "to contact EMC Customer Support.", assemblyId, systemNativeGUID);
boolean allowAutoUpgrade = Boolean.valueOf(ControllerUtils.getPropertyValueFromCoordinator(_coordinator, ALLOW_LOCAL_TO_METRO_AUTO_UPGRADE));
if (!allowAutoUpgrade) {
if (null != vplex && systemNativeGUID.contains(vplex.getNativeGuid())) {
s_logger.error(message);
vplex.setDiscoveryStatus(DataCollectionJobStatus.ERROR.name());
vplex.setLastDiscoveryStatusMessage(message);
vplex.setLastDiscoveryRunTime(System.currentTimeMillis());
_dbClient.updateObject(vplex);
throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromLocalToMetro(assemblyId, systemNativeGUID);
}
} else {
s_logger.warn(message);
s_logger.warn("Auto upgrade is allowed, will attempt to automatically upgrade to Metro");
// we have to (possibly temporarily) persist the new serial number so that the
// storage port native guid generator works, but we need to hold on to the old
// serial number so that we can roll back if necessary
String oldSerialNumber = vplex.getSerialNumber();
vplex.setSerialNumber(systemSerialNumber);
_dbClient.updateObject(vplex);
// this data will be transient unless the upgrade process completes
if (null == vplex.getSmisProviderIP()) {
s_logger.info("The provider information was nulled out by a previous upgrade attempt, resetting");
vplex.setActiveProviderURI(mgmntServer.getId());
StringSet providers = new StringSet();
providers.add(mgmntServer.getId().toString());
vplex.setProviders(providers);
vplex.setSmisProviderIP(mgmntServer.getIPAddress());
vplex.setSmisPortNumber(mgmntServer.getPortNumber());
vplex.setSmisUserName(mgmntServer.getUserName());
vplex.setSmisPassword(mgmntServer.getPassword());
}
// update scan cache
StorageSystemViewObject systemViewObject = scanCache.get(vplex.getNativeGuid());
if (null == systemViewObject) {
systemViewObject = new StorageSystemViewObject();
} else {
// this is a strange scanCache state that doesn't make any sense. just fail for safety reasons
throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromLocalToMetro(assemblyId, systemNativeGUID);
}
s_logger.info("adding systemNativeGuid {} storage view object {} to scan cache", systemNativeGUID, systemViewObject);
scanCache.put(systemNativeGUID, systemViewObject);
// update the label if it has not been changed from the default native GUID
if (vplex.getLabel().equals(vplex.getNativeGuid())) {
vplex.setLabel(systemNativeGUID);
}
vplex.setNativeGuid(systemNativeGUID);
// clear the assembly id collection, which will be updated by discoverClusterIdentification
vplex.setVplexAssemblyIdtoClusterId(new StringMap());
// update the assembly id map in the VPLEX storage system object
discoverClusterIdentification(vplex, client);
// update storage port native guids and labels
// and add them to an autoUpgradePortsMap to short circuit
// another database check and hold them through until they can be persisted
// at the end of the discoverPorts method call below
Map<String, StoragePort> autoUpgradePortsMap = new HashMap<String, StoragePort>();
List<StoragePort> storagePorts = ControllerUtils.getSystemPortsOfSystem(_dbClient, vplex.getId());
for (StoragePort storagePort : storagePorts) {
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(_dbClient, storagePort);
s_logger.info("autoUpgradePortsMap: setting native guid {} on storage port {}", nativeGuid, storagePort.forDisplay());
storagePort.setNativeGuid(nativeGuid);
storagePort.setLabel(nativeGuid);
autoUpgradePortsMap.put(storagePort.getPortNetworkId(), storagePort);
}
boolean doPersist = false;
try {
// now rediscover all storage ports to pull in the new second cluster's ports
discoverPorts(client, vplex, new ArrayList<StoragePort>(), autoUpgradePortsMap);
doPersist = true;
} catch (Exception ex) {
s_logger.error("Failed to discover ports. ", ex);
// throw an exception to tell the user to contact customer support.
throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromLocalToMetro(assemblyId, systemNativeGUID);
} finally {
if (doPersist) {
// storage ports would have been updated by the discoverPorts method
// but we still need to update the vplex object
_dbClient.updateObject(vplex);
} else {
// we failed, so we want to set the serial number back to the old
// serial number that was set above on the copy in the database
StorageSystem databaseVplex = _dbClient.queryObject(StorageSystem.class, vplex.getId());
databaseVplex.setSerialNumber(oldSerialNumber);
_dbClient.updateObject(databaseVplex);
}
}
}
}
}
}
} else if (VPlexApiConstants.VPLEX_LOCAL_ASSEMBLY_COUNT == clusterAssembyIds.size()) {
// check if this system could have been downgraded from metro to local
List<StorageSystem> vplexMetroStorageSystems = VPlexControllerUtils.getAllVplexMetroStorageSystems(_dbClient);
for (StorageSystem vplex : vplexMetroStorageSystems) {
if (null != vplex && null != vplex.getVplexAssemblyIdtoClusterId()) {
for (String assemblyId : vplex.getVplexAssemblyIdtoClusterId().keySet()) {
if (systemNativeGUID.contains(assemblyId)) {
// THIS IS VERY BAD
String message = String.format("The VPLEX storage system serial number unexpectedly changed. " + "The newly-discovered native GUID %s contains the existing VPLEX metro system assembly " + "id %s of VPLEX %s, which indicates a change in VPLEX hardware configuration from metro to local. " + "Scanning of this Storage Provider cannot continue. Recommended course of action is " + "to contact EMC Customer Support.", systemNativeGUID, assemblyId, vplex.forDisplay());
s_logger.error(message);
vplex.setDiscoveryStatus(DataCollectionJobStatus.ERROR.name());
vplex.setLastDiscoveryStatusMessage(message);
vplex.setLastDiscoveryRunTime(System.currentTimeMillis());
_dbClient.updateObject(vplex);
throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromMetroToLocal(systemNativeGUID, assemblyId);
}
}
}
}
} else {
s_logger.warn("Unexpected assembly id count {}", clusterAssembyIds.size());
}
}
Aggregations