use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileSystemsProcessor method processFilesystemList.
/**
* Process the fileSystemList which are received from XMLAPI server.
*
* @param filesystemList : List of FileSystem objects.
* @param keyMap : keyMap.
*/
private List<VNXFileSystem> processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
Iterator<Object> iterator = filesystemList.iterator();
List<VNXFileSystem> processedFileSystem = new ArrayList<VNXFileSystem>();
if (iterator.hasNext()) {
Status status = (Status) iterator.next();
if ((status.getMaxSeverity() == Severity.OK) || (status.getMaxSeverity() == Severity.WARNING)) {
Map<String, FileSystem> fileSystems = new HashMap<String, FileSystem>();
Map<String, FileSystemCapacityInfo> fileSysCapacityInfos = new HashMap<String, FileSystemCapacityInfo>();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof FileSystem) {
FileSystem fs = (FileSystem) obj;
if (fs.isInternalUse() == false) {
fileSystems.put(fs.getFileSystem(), fs);
}
} else if (obj instanceof FileSystemCapacityInfo) {
FileSystemCapacityInfo fsCapacityInfo = (FileSystemCapacityInfo) obj;
fileSysCapacityInfos.put(fsCapacityInfo.getFileSystem(), fsCapacityInfo);
}
}
Iterator it = fileSystems.keySet().iterator();
while (it.hasNext()) {
String fsId = (String) it.next();
FileSystem fileSystem = fileSystems.get(fsId);
FileSystemCapacityInfo fsCapacity = fileSysCapacityInfos.get(fsId);
List<String> pools = new ArrayList<String>();
if (null != fileSystem.getStoragePools()) {
pools = fileSystem.getStoragePools();
}
String poolId = "";
if (null != pools) {
poolId = pools.get(0);
}
StringBuffer debugInfo = new StringBuffer();
debugInfo.append("VNXFileSystem : " + fileSystem.getName());
debugInfo.append(" Pool : " + poolId);
long totalCapacity = 0;
VNXFileSystem vnxFS = new VNXFileSystem(fileSystem.getName(), Integer.valueOf(fileSystem.getFileSystem()));
if (fileSystem.isVirtualProvisioning()) {
vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THIN.name());
FileSystemAutoExtInfo autoExtInfo = fileSystem.getFileSystemAutoExtInfo();
if (null != autoExtInfo) {
totalCapacity = autoExtInfo.getAutoExtensionMaxSize();
totalCapacity = totalCapacity * MBTOBYTECONVERTER;
} else {
totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
}
} else {
vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name());
totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
}
vnxFS.setStoragePool(poolId);
debugInfo.append(" fsCapacity.getVolumeSize() : " + fsCapacity.getVolumeSize());
vnxFS.setTotalCapacity(totalCapacity + "");
vnxFS.setUsedCapcity("0");
if (null != fsCapacity.getResourceUsage()) {
// We can get Used capacity
// Size is in MB, convert to Bytes
debugInfo.append(" fsCapacity.getUsedCapacity:" + fsCapacity.getResourceUsage().getSpaceUsed());
long usedCapacity = fsCapacity.getResourceUsage().getSpaceUsed() * MBTOBYTECONVERTER;
vnxFS.setUsedCapcity(usedCapacity + "");
}
debugInfo.append(" Total Capacity :" + vnxFS.getTotalCapacity());
debugInfo.append(" Used Capacity :" + vnxFS.getUsedCapacity());
_logger.debug(debugInfo.toString());
processedFileSystem.add(vnxFS);
}
} else {
throw new com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
}
}
return processedFileSystem;
}
use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileSystemsProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
final PostMethod result = (PostMethod) resultObj;
try {
ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
// Extract session information from the response header.
Header[] headers = result.getResponseHeaders(VNXFileConstants.CELERRA_SESSION);
if (null != headers && headers.length > 0) {
keyMap.put(VNXFileConstants.CELERRA_SESSION, headers[0].getValue());
_logger.info("Received celerra session info from the Server.");
}
Status status = null;
if (null != responsePacket.getPacketFault()) {
status = responsePacket.getPacketFault();
processErrorStatus(status, keyMap);
} else {
List<Object> filesystemList = getQueryResponse(responsePacket);
List<VNXFileSystem> processedFileSystems = processFilesystemList(filesystemList, keyMap);
keyMap.put(VNXFileConstants.FILESYSTEMS, processedFileSystems);
keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
}
} catch (final Exception ex) {
_logger.error("Exception occurred while processing the vnx fileShare response due to {}", ex.getMessage());
keyMap.put(com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.FAULT_DESC, ex.getMessage());
keyMap.put(com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.CMD_RESULT, com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.CMD_FAILURE);
} finally {
result.releaseConnection();
}
}
use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverUmanagedFileSystems.
private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
_logger.info("Access Profile Details : IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
List<UnManagedFileSystem> unManagedFileSystems = new ArrayList<UnManagedFileSystem>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
int newFileSystemsCount = 0;
int existingFileSystemsCount = 0;
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
String detailedStatusMessage = "Discovery of VNXFile Unmanaged FileSystem started";
try {
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
HashMap<String, StoragePool> pools = new HashMap();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
if (storagePool != null && !storagePool.getInactive()) {
pools.put(storagePool.getNativeId(), storagePool);
}
}
StoragePort storagePort = this.getStoragePortPool(storageSystem);
List<VNXFileSystem> discoveredFS = discoverAllFileSystems(storageSystem);
StringSet umfsIds = new StringSet();
if (discoveredFS != null) {
for (VNXFileSystem fs : discoveredFS) {
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getFsId() + "");
StoragePool pool = pools.get(fs.getStoragePool());
if (!checkStorageFileSystemExistsInDB(fsNativeGuid)) {
// Create UnManaged FS
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getFsId() + "");
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
boolean alreadyExist = unManagedFs == null ? false : true;
unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs);
if (alreadyExist) {
existingUnManagedFileSystems.add(unManagedFs);
existingFileSystemsCount++;
} else {
unManagedFileSystems.add(unManagedFs);
newFileSystemsCount++;
}
allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
umfsIds.add(fs.getFsId() + "");
/**
* Persist 200 objects and clear them to avoid memory issue
*/
validateListSizeLimitAndPersist(unManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
}
}
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
_logger.info("New unmanaged VNXFile file systems count: {}", newFileSystemsCount);
_logger.info("Update unmanaged VNXFile file systems count: {}", existingFileSystemsCount);
if (!unManagedFileSystems.isEmpty()) {
// Add UnManagedFileSystem
_dbClient.createObject(unManagedFileSystems);
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.updateAndReindexObject(existingUnManagedFileSystems);
}
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for VNXFile: %s", storageSystemId.toString());
if (null != umfsIds && !umfsIds.isEmpty()) {
// Discovering unmanaged quota directories
discoverUmanagedFileQuotaDirectory(profile, umfsIds);
}
} catch (Exception e) {
if (storageSystem != null) {
cleanupDiscovery(storageSystem);
}
detailedStatusMessage = String.format("Discovery failed for VNXFile %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw new VNXFileCollectionException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverNamedFileSystem.
private VNXFileSystem discoverNamedFileSystem(StorageSystem system, String fsName) {
List<VNXFileSystem> fileSystems = null;
VNXFileSystem fileSystem = null;
try {
// Retrieve list of File Systems from the VNX file device.
Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
_discExecutor.setKeyMap(reqAttributeMap);
_discExecutor.execute((Namespace) _discNamespaces.getNsList().get(VNXFileConstants.VNX_FILE_SELECTED_FS));
fileSystems = (List<VNXFileSystem>) _discExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEMS);
if ((fileSystems != null) && !(fileSystems.isEmpty())) {
_logger.info("Number of file systems found: {}", fileSystems.size());
fileSystem = fileSystems.get(0);
} else {
_logger.info("No File System was found on the VNX device");
}
} catch (BaseCollectionException ex) {
_logger.error("VNX Exception: Discovery of File Systems failed for storage system {} due to {}", system.getId(), ex.getMessage());
}
return fileSystem;
}
use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverAllFileSystems.
/**
* Retrieve the FileSystem for the specified VNX File Storage Array
*
* @param system storage system information including credentials.
* @return list of Storage FileSystems
* @throws VNXFileCollectionException
*/
private List<VNXFileSystem> discoverAllFileSystems(StorageSystem system) throws VNXFileCollectionException, VNXException {
List<VNXFileSystem> fileSystems = new ArrayList<VNXFileSystem>();
_logger.info("Start FileSystem discovery for storage system {}", system.getId());
try {
// Retrieve the list of FileSystem for the VNX File device.
List<VNXFileSystem> vnxFileSystems = getAllFileSystem(system);
_logger.info("Number filesytems found: {}", vnxFileSystems.size());
if (vnxFileSystems != null) {
// Create the list of FileSystem.
for (VNXFileSystem vnxfs : vnxFileSystems) {
FileShare fs = null;
// Check if FileSystem was already discovered
URIQueryResultList results = new URIQueryResultList();
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxfs.getFsId() + "", NativeGUIDGenerator.FILESYSTEM);
if (checkStorageFileSystemExistsInDB(fsNativeGuid)) {
continue;
}
vnxfs.setFsNativeGuid(fsNativeGuid);
fileSystems.add(vnxfs);
}
}
_logger.info("Number of FileSystem found {} and they are : ", fileSystems.size());
} catch (IOException e) {
_logger.error("I/O Exception: Discovery of FileSystem failed for storage system {} for {}", system.getId(), e.getMessage());
VNXFileCollectionException vnxe = new VNXFileCollectionException("Storage FileSystem discovery error for storage system " + system.getId());
vnxe.initCause(e);
throw vnxe;
}
_logger.info("Storage FilesSystem discovery for storage system {} complete", system.getId());
return fileSystems;
}
Aggregations