use of com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverMtrees.
private void discoverMtrees(DataDomainClient ddClient, StorageSystem storageSystem) {
URIQueryResultList mtreeList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFileshareConstraint(storageSystem.getId()), mtreeList);
Iterator<URI> mtreeItr = mtreeList.iterator();
while (mtreeItr.hasNext()) {
FileShare mtree = _dbClient.queryObject(FileShare.class, mtreeItr.next());
if (!mtree.getInactive()) {
try {
DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storageSystem.getNativeGuid(), mtree.getNativeId());
if (mtreeInfo.quotaConfig != null) {
// it should be always true.
// We do not inject resources without quota
mtree.setCapacity(mtreeInfo.quotaConfig.getHardLimit());
}
mtree.setUsedCapacity(mtreeInfo.logicalCapacity.getUsed());
} catch (DataDomainResourceNotFoundException ex) {
mtree.setCapacity(0L);
} catch (DataDomainApiException dex) {
mtree.setCapacity(0L);
}
}
}
}
use of com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException 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.datadomain.restapi.errorhandling.DataDomainApiException in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedFileSystems.
private void discoverUnManagedFileSystems(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
String detailedStatusMessage = "Discovery of DataDomain Unmanaged FileSystem started";
List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
StoragePool pool = getPoolFromDB(storageSystem);
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
DDMTreeInfoDetail mtree = null;
try {
DDMTreeList mtreeList = ddClient.getMTreeList(storageSystem.getNativeGuid());
for (DDMTreeInfo mtreeInfo : mtreeList.mtree) {
mtree = ddClient.getMTree(storageSystem.getNativeGuid(), mtreeInfo.getId());
if (mtree == null || mtree.delStatus == DataDomainApiConstants.FILE_DELETED) {
continue;
}
// Filtering mtrees that are not supporting either of NFS & CIFS
if ((mtree.protocolName == null) || (mtree.protocolName.isEmpty())) {
_log.info("Mtree: {} doesn't contain any protocol defined so ignoring it", mtree.name);
continue;
} else {
if ((mtree.protocolName.contains(DataDomainApiConstants.NFS_PROTOCOL)) || (mtree.protocolName.contains(DataDomainApiConstants.CIFS_PROTOCOL))) {
_log.info("Mtree: {} contains supported protocol:{} so discovering it", mtree.name, mtree.protocolName.toArray());
} else {
_log.info("Mtree: {} contains unsupported protocol:{} so ignoring it", mtree.name, mtree.protocolName.toArray());
continue;
}
}
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
// If the filesystem already exists in db..just continue.
// No Need to create an UnManaged Filesystems.
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemNativeGUIdConstraint(fsNativeGuid), result);
if (result.iterator().hasNext()) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
UnManagedFileSystem unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
boolean alreadyExist = unManagedFS == null ? false : true;
unManagedFS = createUnManagedFileSystem(unManagedFS, fsUnManagedFsNativeGuid, mtree, storageSystem, pool, matchedVPools);
if (alreadyExist) {
existingUnManagedFileSystems.add(unManagedFS);
} else {
newUnManagedFileSystems.add(unManagedFS);
}
allDiscoveredUnManagedFileSystems.add(unManagedFS.getId());
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
if (newUnManagedFileSystems != null && !newUnManagedFileSystems.isEmpty()) {
// Add UnManagedFileSystem
_dbClient.createObject(newUnManagedFileSystems);
_log.info("{} {} Records inserted to DB", newUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
if (existingUnManagedFileSystems != null && !existingUnManagedFileSystems.isEmpty()) {
_dbClient.updateAndReindexObject(existingUnManagedFileSystems);
_log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for DataDomain system: %s", storageSystem.getId().toString());
} catch (DataDomainApiException dde) {
detailedStatusMessage = "DiscoverStorage failed" + dde.getMessage();
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString());
throw dde;
} catch (Exception e) {
detailedStatusMessage = "DiscoverStorage failed" + e.getMessage();
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString(), e);
throw DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedExports.
private void discoverUnManagedExports(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
try {
List<StoragePort> ports = getPortFromDB(storageSystem);
// Get exports on the array and loop through each export.
DDExportList exportList = ddClient.getExports(storageSystem.getNativeGuid());
for (DDExportInfo exp : exportList.getExports()) {
DDExportInfoDetail export = ddClient.getExport(storageSystem.getNativeGuid(), exp.getId());
if (export.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), export.getMtreeID());
UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
if (unManagedFS == null) {
unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
}
if (unManagedFS != null) {
createExportMap(export, unManagedFS, ports);
existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
// Adding this additional logic to avoid OOM
if (existingUnManagedFileSystems.size() == MAX_UMFS_RECORD_SIZE) {
_dbClient.persistObject(new ArrayList<UnManagedFileSystem>(existingUnManagedFileSystems.values()));
existingUnManagedFileSystems.clear();
}
} else {
_log.info("FileSystem " + fsUnManagedFsNativeGuid + " is not present in ViPR DB. Hence ignoring " + export + " export");
}
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(new ArrayList<UnManagedFileSystem>(existingUnManagedFileSystems.values()));
_log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
storageSystem.setLastDiscoveryStatusMessage("");
_dbClient.persistObject(storageSystem);
} catch (DataDomainApiException dde) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString());
throw dde;
} catch (Exception e) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString(), e);
DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
}
}
use of com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedCifsShares.
private void discoverUnManagedCifsShares(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
String detailedStatusMessage = "Discovery of Data Domain Unmanaged Cifs Shares started";
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
// Used to cache UMFS once retrieved from DB
Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
// Used to Save the CIFS ACLs to DB
List<UnManagedCifsShareACL> newUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
List<UnManagedCifsShareACL> oldUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
try {
// Get exports on the array and loop through each export.
DDShareList shareList = ddClient.getShares(storageSystem.getNativeGuid());
for (DDShareInfo shareInfo : shareList.getShares()) {
DDShareInfoDetail share = ddClient.getShare(storageSystem.getNativeGuid(), shareInfo.getId());
if (share.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), share.getMtreeId());
// Get UMFS from cache if possible, otherwise try to retrieve from DB
UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
if (unManagedFS == null) {
unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
}
if (unManagedFS != null) {
// Add UMFS to cache
existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
StringSet storagePortIds = unManagedFS.getFileSystemInformation().get(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
StoragePort storagePort = null;
for (String portId : storagePortIds) {
StoragePort sp = _dbClient.queryObject(StoragePort.class, URI.create(portId));
if (sp != null && !sp.getInactive()) {
storagePort = sp;
break;
}
}
associateCifsExportWithFS(unManagedFS, share, storagePort);
unManagedFS.setHasShares(true);
unManagedFS.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_log.debug("Export map for VNX UMFS {} = {}", unManagedFS.getLabel(), unManagedFS.getUnManagedSmbShareMap());
List<UnManagedCifsShareACL> cifsACLs = applyCifsSecurityRules(unManagedFS, share, storagePort);
_log.info("Number of export rules discovered for file system {} is {}", unManagedFS.getId() + ":" + unManagedFS.getLabel(), cifsACLs.size());
for (UnManagedCifsShareACL cifsAcl : cifsACLs) {
_log.info("Unmanaged File share acls : {}", cifsAcl);
String fsShareNativeId = cifsAcl.getFileSystemShareACLIndex();
_log.info("UMFS Share ACL index {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
_log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
cifsAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
// Check whether the CIFS share ACL was present in ViPR DB.
UnManagedCifsShareACL existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, cifsAcl.getNativeGuid());
if (existingACL == null) {
newUnManagedCifsACLs.add(cifsAcl);
} else {
newUnManagedCifsACLs.add(cifsAcl);
existingACL.setInactive(true);
oldUnManagedCifsACLs.add(existingACL);
}
}
// Update the UnManaged file system
_dbClient.persistObject(unManagedFS);
}
if (newUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// create new UnManagedCifsShareACL
_log.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
_dbClient.createObject(newUnManagedCifsACLs);
newUnManagedCifsACLs.clear();
}
if (oldUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// Update existing UnManagedCifsShareACL
_log.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
_dbClient.persistObject(oldUnManagedCifsACLs);
oldUnManagedCifsACLs.clear();
}
}
if (!newUnManagedCifsACLs.isEmpty()) {
// create new UnManagedCifsShareACL
_log.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
_dbClient.createObject(newUnManagedCifsACLs);
newUnManagedCifsACLs.clear();
}
if (!oldUnManagedCifsACLs.isEmpty()) {
// Update existing UnManagedCifsShareACL
_log.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
_dbClient.persistObject(oldUnManagedCifsACLs);
oldUnManagedCifsACLs.clear();
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeded
detailedStatusMessage = String.format("Discovery completed successfully for Data Domain: %s", storageSystem.getId().toString());
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
} catch (DataDomainApiException dde) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId());
} catch (Exception e) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId(), e);
} finally {
if (storageSystem != null) {
try {
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
Aggregations