use of com.emc.storageos.plugins.metering.vplex.VPlexCollectionException in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method scanManagedSystems.
/**
* First gets the VPLEX cluster(s) that are manageable by the VPLEX management
* server. For a VPLEX local configuration there will be one cluster. For
* a VPLEX Metro configuration there will be two clusters. We then create a
* StorageSystemViewObject to represent the managed clusters as a storage system
* to be managed by this management server.
*
* @param client The VPlex API client.
* @param mgmntServer A reference to the VPlex management server.
* @param scanCache A map holding previously found systems during a scan.
*
* @throws VPlexCollectionException When an error occurs getting the VPLEX
* information.
*/
private void scanManagedSystems(VPlexApiClient client, StorageProvider mgmntServer, Map<String, StorageSystemViewObject> scanCache) throws VPlexCollectionException {
try {
List<String> clusterAssemblyIds = new ArrayList<String>();
String systemSerialNumber = getSystemSerialNumber(client, mgmntServer, clusterAssemblyIds);
// Get the native GUID for the system using the constructed
// serial number.
String systemNativeGUID = NativeGUIDGenerator.generateNativeGuid(mgmntServer.getInterfaceType(), systemSerialNumber);
s_logger.info("Scanned VPLEX system {}", systemNativeGUID);
// Check for potential cluster hardware changes from local to metro, or vice versa
checkForClusterHardwareChange(clusterAssemblyIds, systemNativeGUID, systemSerialNumber, client, scanCache, mgmntServer);
// Determine if the VPLEX system was already scanned by another
// VPLEX management server by checking the scan cache. If not,
// then we create a StorageSystemViewObject to represent this
// VPLEX system and add it to the scan cache.
StorageSystemViewObject systemViewObj = null;
if (scanCache.containsKey(systemNativeGUID)) {
s_logger.info("VPLEX system {} was previously found.", systemNativeGUID);
systemViewObj = scanCache.get(systemNativeGUID);
} else {
s_logger.info("Found new VPLEX system {}, adding to scan cache.", systemNativeGUID);
systemViewObj = new StorageSystemViewObject();
}
systemViewObj.setDeviceType(mgmntServer.getInterfaceType());
systemViewObj.addprovider(mgmntServer.getId().toString());
systemViewObj.setProperty(StorageSystemViewObject.SERIAL_NUMBER, systemSerialNumber);
systemViewObj.setProperty(StorageSystemViewObject.STORAGE_NAME, systemNativeGUID);
scanCache.put(systemNativeGUID, systemViewObj);
} catch (Exception e) {
s_logger.error("Error scanning managed systems for {}:", mgmntServer.getIPAddress(), e);
throw VPlexCollectionException.exceptions.failedScanningManagedSystems(mgmntServer.getIPAddress(), e.getLocalizedMessage(), e);
}
}
use of com.emc.storageos.plugins.metering.vplex.VPlexCollectionException in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discoverAll.
/**
* Implementation for discovering everything in a VPLEX storage system.
*
* @param accessProfile providing context for this discovery session
*
* @throws BaseCollectionException
*/
private void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
boolean discoverySuccess = true;
StringBuffer errMsgBuilder = new StringBuffer();
URI storageSystemURI = null;
StorageSystem vplexStorageSystem = null;
String detailedStatusMessage = "Unknown Status";
VPlexApiClient client = null;
try {
s_logger.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
storageSystemURI = accessProfile.getSystemId();
// Get the VPlex storage system from the database.
vplexStorageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
s_logger.info("Discover VPlex storage system {} at IP:{}, PORT:{}", new Object[] { storageSystemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber() });
// Get the Http client for getting information about the VPlex
// storage system.
client = getVPlexAPIClient(accessProfile);
s_logger.debug("Got handle to VPlex API client");
// clear cached discovery data in the VPlexApiClient
client.clearCaches();
client.primeCaches();
// The version for the storage system is the version of its active provider
// and since we are discovering it, the provider was compatible, so the
// VPLEX must also be compatible.
StorageProvider activeProvider = _dbClient.queryObject(StorageProvider.class, vplexStorageSystem.getActiveProviderURI());
String serialNumber = getSystemSerialNumber(client, activeProvider, null);
if (!vplexStorageSystem.getSerialNumber().equals(serialNumber)) {
s_logger.error(String.format("The VPLEX serial number unexpectedly changed from %s to %s.", vplexStorageSystem.getSerialNumber(), serialNumber));
throw VPlexApiException.exceptions.vplexSerialNumberChanged(vplexStorageSystem.getSerialNumber(), serialNumber);
}
vplexStorageSystem.setFirmwareVersion(activeProvider.getVersionString());
vplexStorageSystem.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
// Discover the cluster identification (serial number / cluster id ) mapping
try {
s_logger.info("Discovering cluster identification.");
discoverClusterIdentification(vplexStorageSystem, client);
_completer.statusPending(_dbClient, "Completed cluster identification discovery");
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed cluster identification discovery for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
List<StoragePort> allPorts = new ArrayList<StoragePort>();
// Discover the VPlex port information.
try {
// When we discover storage ports on the VPlex, we create
// initiators, if they don't exist, for backend ports.
// The backend storage ports serve as initiators for the
// connected backend storage.
s_logger.info("Discovering frontend and backend ports.");
discoverPorts(client, vplexStorageSystem, allPorts, null);
_dbClient.updateObject(vplexStorageSystem);
_completer.statusPending(_dbClient, "Completed port discovery");
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed port discovery for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
// update host initiators with registered initiator names from VPLEX
try {
updateHostInitiators(client, vplexStorageSystem.getSerialNumber());
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed host initiator update for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
try {
s_logger.info("Discovering connectivity.");
discoverConnectivity(vplexStorageSystem);
_dbClient.updateObject(vplexStorageSystem);
_completer.statusPending(_dbClient, "Completed connectivity verification");
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed connectivity discovery for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
if (discoverySuccess) {
vplexStorageSystem.setReachableStatus(true);
_dbClient.updateObject(vplexStorageSystem);
} else {
// If part of the discovery process failed, throw an exception.
vplexStorageSystem.setReachableStatus(false);
_dbClient.updateObject(vplexStorageSystem);
throw new Exception(errMsgBuilder.toString());
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(allPorts, null, _dbClient, _coordinator, null);
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemURI.toString());
} catch (Exception e) {
if (null != client) {
// clear cached discovery data in the VPlexApiClient
client.clearCaches();
}
VPlexCollectionException vce = VPlexCollectionException.exceptions.failedDiscovery(storageSystemURI.toString(), e.getLocalizedMessage());
detailedStatusMessage = vce.getLocalizedMessage();
s_logger.error(detailedStatusMessage, e);
throw vce;
} finally {
if (vplexStorageSystem != null) {
try {
// set detailed message
vplexStorageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.updateObject(vplexStorageSystem);
} catch (DatabaseException ex) {
s_logger.error("Error persisting last discovery status for storage system {}", vplexStorageSystem.getId(), ex);
}
}
}
}
use of com.emc.storageos.plugins.metering.vplex.VPlexCollectionException in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discoverPorts.
/**
* Discovers and creates the ports for the passed VPlex virtual storage
* system.
*
* @param client The VPlex API client.
* @param vplexStorageSystem A reference to the VPlex storage system.
* @param autoUpgradePortsMap a map of port wwns to StoragePorts from the
* original cluster in a local to metro auto upgrade situation
*
* @throws VPlexCollectionException When an error occurs discovering the
* VPlex ports.
*/
private void discoverPorts(VPlexApiClient client, StorageSystem vplexStorageSystem, List<StoragePort> allPorts, Map<String, StoragePort> autoUpgradePortsMap) throws VPlexCollectionException {
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
List<Initiator> newInitiatorPorts = new ArrayList<Initiator>();
try {
// Get the port information from the VPlex.
String initiatorHostName = null;
List<VPlexPortInfo> portInfoList = client.getPortInfo(false);
Map<String, VPlexTargetInfo> portTargetMap = client.getTargetInfoForPorts(portInfoList);
for (VPlexPortInfo portInfo : portInfoList) {
s_logger.debug("VPlex port info: {}", portInfo.toString());
if (null == portInfo.getPortWwn()) {
s_logger.info("Not a FC port, skipping port {}", portInfo.getName());
continue;
}
// StoragePort instances for these ports.
if ((!portInfo.isFrontendPort()) && (!portInfo.isBackendPort())) {
s_logger.debug("Not a front/back-end port, skipping port {}", portInfo.getName());
continue;
}
String portWWN = WWNUtility.getWWNWithColons(portInfo.getPortWwn());
String portType = portInfo.isBackendPort() ? PortType.backend.name() : PortType.frontend.name();
s_logger.info("Found {} port {}", portType, portWWN);
// WWN.
if ((portWWN == null) || (portWWN.equals(OFFLINE_PORT_WWN))) {
s_logger.info("Skipping port {} with WWN {}", portInfo.getName(), portWWN);
continue;
}
// See if the port already exists in the DB. If not we need to
// create it.
StoragePort storagePort = findPortInDB(vplexStorageSystem, portInfo, autoUpgradePortsMap);
if (storagePort == null) {
s_logger.info("Creating new port {}", portWWN);
storagePort = new StoragePort();
storagePort.setId(URIUtil.createId(StoragePort.class));
storagePort.setPortNetworkId(portWWN);
storagePort.setPortName(portInfo.getName());
storagePort.setStorageDevice(vplexStorageSystem.getId());
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(_dbClient, storagePort);
storagePort.setNativeGuid(nativeGuid);
storagePort.setLabel(nativeGuid);
storagePort.setPortType(portType);
// Always FC
storagePort.setTransportType(StorageProtocol.Block.FC.name());
setHADomainForStoragePort(vplexStorageSystem, storagePort, portInfo);
storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
newStoragePorts.add(storagePort);
} else {
existingStoragePorts.add(storagePort);
}
// CTRL-4701 - if we got to this point, the VPLEX firmware was validated as compatible,
// so, the storage port should be marked compatible as well
storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
// Port speed is current port speed and should be updated
// for existing ports.
storagePort.setPortSpeed(portInfo.getCurrentSpeed(SpeedUnits.GBITS_PER_SECOND));
// Set or update the port operational status.
storagePort.setOperationalStatus(getPortOperationalStatus(portInfo, portTargetMap));
// list.
if (portInfo.isBackendPort()) {
Initiator initiatorPort = findInitiatorInDB(portInfo);
if (initiatorPort == null) {
s_logger.info("Creating initiator for backend port", portWWN);
if (initiatorHostName == null) {
initiatorHostName = getInitiatorHostName(vplexStorageSystem);
}
s_logger.info("Host name is {}", initiatorHostName);
initiatorPort = new Initiator(StorageProtocol.Block.FC.name(), portWWN, WWNUtility.getWWNWithColons(portInfo.getNodeWwn()), initiatorHostName, false);
initiatorPort.setId(URIUtil.createId(Initiator.class));
newInitiatorPorts.add(initiatorPort);
}
}
}
// Persist changes to new and exiting ports and initiators.
_dbClient.createObject(newStoragePorts);
_dbClient.updateObject(existingStoragePorts);
_dbClient.createObject(newInitiatorPorts);
allPorts.addAll(newStoragePorts);
allPorts.addAll(existingStoragePorts);
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, vplexStorageSystem.getId());
if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
allPorts.addAll(notVisiblePorts);
}
} catch (Exception e) {
s_logger.error("Error discovering ports for the VPLEX storage system {}:", vplexStorageSystem.getIpAddress(), e);
throw VPlexCollectionException.exceptions.failedPortsDiscovery(vplexStorageSystem.getId().toString(), e.getLocalizedMessage(), e);
}
}
use of com.emc.storageos.plugins.metering.vplex.VPlexCollectionException in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method scan.
/**
* Implementation for scan for VPlex storage systems.
*
* @param accessProfile
*
* @throws BaseCollectionException
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
URI mgmntServerURI = accessProfile.getSystemId();
StorageProvider mgmntServer = null;
String scanStatusMessage = "Unknown Status";
VPlexApiClient client = null;
try {
// Get the storage provider representing a VPLEX management server.
mgmntServer = _dbClient.queryObject(StorageProvider.class, mgmntServerURI);
// Get the Http client for getting information about the VPLEX
// cluster(s) managed by the VPLEX management server.
client = getVPlexAPIClient(accessProfile);
s_logger.debug("Got handle to VPlex API client");
// Verify the connectivity to the VPLEX management server.
verifyConnectivity(client, mgmntServer);
// Verify the VPLEX system firmware version is supported.
verifyMinimumSupportedFirmwareVersion(client, mgmntServer);
// Determine the VPLEX system managed by this management server.
Map<String, StorageSystemViewObject> scanCache = accessProfile.getCache();
s_logger.info("Storage System scanCache before scanning:" + scanCache);
scanManagedSystems(client, mgmntServer, scanCache);
s_logger.info("Storage System scanCache after scanning:" + scanCache);
scanStatusMessage = String.format("Scan job completed successfully for " + "VPLEX management server: %s", mgmntServerURI.toString());
} catch (Exception e) {
if (null != client) {
// clear cached discovery data in the VPlexApiClient
client.clearCaches();
}
VPlexCollectionException vce = VPlexCollectionException.exceptions.failedScan(mgmntServer.getIPAddress(), e.getLocalizedMessage());
scanStatusMessage = vce.getLocalizedMessage();
throw vce;
} finally {
if (mgmntServer != null) {
try {
mgmntServer.setLastScanStatusMessage(scanStatusMessage);
_dbClient.updateObject(mgmntServer);
} catch (Exception e) {
s_logger.error("Error persisting scan status message for management server {}", mgmntServerURI.toString(), e);
}
}
}
}
Aggregations