use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doUnexport.
@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doUnexport {} - start", args.getFsId());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doUnexport failed, provider unreachable");
String op = "FS unexport";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
FSExportMap currentExports = args.getFsExports();
ddDeleteExports(ddClient, storagePool.getNativeId(), currentExports, exportList);
_log.info("DataDomainFileStorageDevice doUnexport {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doUnexport failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doExpandFS.
@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doExpandFS {} - start", args.getFsId());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doExpandFS failed, provider unreachable");
String op = "FS expand";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
Long newSize = args.getNewFSCapacity();
Long currSize;
if ((args.getFsCapacity() != null) && (args.getFsCapacity() > 0)) {
currSize = args.getFsCapacity();
} else {
ServiceError serviceError = DeviceControllerErrors.datadomain.doFailedToGetCurrSize();
return BiosCommandResult.createErrorResult(serviceError);
}
if (currSize >= newSize) {
ServiceError serviceError = DeviceControllerErrors.datadomain.doShrinkFSFailed(currSize, newSize);
return BiosCommandResult.createErrorResult(serviceError);
}
// Modify mtree
// Data Domain expects capacity in Bytes
DDMTreeInfo ddMtreeInfo = ddClient.expandMTree(args.getStoragePool().getNativeId(), args.getFs().getNativeId(), newSize);
if (args.getFsExtensions() == null) {
args.initFsExtensions();
}
args.getFsExtensions().put(DataDomainApiConstants.TOTAL_PHYSICAL_CAPACITY, String.valueOf(newSize));
_log.info("DataDomainFileStorageDevice doExpandFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doExpandFS failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
} catch (Exception e) {
_log.error("doExpandFS failed.", e);
ServiceError serviceError = DeviceControllerErrors.datadomain.doExpandFSFailed(e.getMessage());
return BiosCommandResult.createErrorResult(serviceError);
}
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteShare: {} - start");
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteShare failed, provider unreachable");
String op = "FS share delete";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
SMBShareMap currentShares = args.getFileObjShares();
List<SMBFileShare> sharesToDelete = new ArrayList<SMBFileShare>();
sharesToDelete.add(smbFileShare);
ddDeleteShares(ddClient, storagePool.getNativeId(), currentShares, sharesToDelete);
_log.info("DataDomainFileStorageDevice doDeleteShare {} - complete");
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doDeleteShare failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method collectStatisticsInformation.
@Override
public void collectStatisticsInformation(AccessProfile accessProfile) throws BaseCollectionException, DataDomainApiException {
long statsCount = 0;
URI storageSystemId = null;
StorageSystem storageSystem = null;
try {
_log.info("Stats collection for {} using ip {}", accessProfile.getSystemId(), accessProfile.getIpAddress());
storageSystemId = accessProfile.getSystemId();
storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
initializeKeyMap(accessProfile);
DataDomainClient ddClient = getDataDomainClient(accessProfile);
URI providerId = storageSystem.getActiveProviderURI();
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerId);
ZeroRecordGenerator zeroRecordGenerator = new FileZeroRecordGenerator();
CassandraInsertion statsColumnInjector = new FileDBInsertion();
DataDomainStatsRecorder recorder = new DataDomainStatsRecorder(zeroRecordGenerator, statsColumnInjector);
// Stats collection start time
long statsCollectionStartTime = storageSystem.getLastMeteringRunTime();
// start time to the time the storage system was successfully discovered.
if (statsCollectionStartTime == 0) {
statsCollectionStartTime = storageSystem.getSuccessDiscoveryTime();
}
// Stats collection end time
long statsCollectionEndTime = accessProfile.getCurrentSampleTime();
_keyMap.put(Constants._TimeCollected, statsCollectionEndTime);
// Get list of file systems on the device that are in the DB
List<URI> fsUris = zeroRecordGenerator.extractVolumesOrFileSharesFromDB(storageSystemId, _dbClient, FileShare.class);
List<FileShare> fsObjs = _dbClient.queryObject(FileShare.class, fsUris, true);
// Get capacity usage info on individual mtrees
List<Stat> stats = new ArrayList<>();
for (FileShare fileSystem : fsObjs) {
String fsNativeId = fileSystem.getNativeId();
String fsNativeGuid = fileSystem.getNativeGuid();
// Retrieve the last 2 data points only
int entriesRetrieved = 0;
List<DDStatsCapacityInfo> statsCapInfos = new ArrayList<>();
// Default
DDStatsIntervalQuery granularity = DDStatsIntervalQuery.hour;
// Retrieve hourly data - lowest resolution supported by DD arrays.
try {
DDMtreeCapacityInfos mtreeCapInfo = ddClient.getMTreeCapacityInfo(storageSystem.getNativeGuid(), fsNativeId, DataDomainApiConstants.STATS_FIRST_PAGE, DataDomainApiConstants.STATS_PAGE_SIZE, DDStatsDataViewQuery.absolute, DDStatsIntervalQuery.hour, true, DataDomainApiConstants.DESCENDING_SORT);
entriesRetrieved += mtreeCapInfo.getPagingInfo().getPageEntries();
// Collect stats
List<DDStatsCapacityInfo> capacityInfos = mtreeCapInfo.getStatsCapacityInfo();
if (capacityInfos != null) {
statsCapInfos.addAll(capacityInfos);
}
statsCount += entriesRetrieved;
} catch (Exception e) {
_log.info("Stats collection info not found for fileNativeGuid ", fsNativeGuid);
continue;
}
// Retrieved all pages, now save in DB if info changed in the latest data point
long usedCapacity = 0;
if (fileSystem.getUsedCapacity() != null) {
usedCapacity = fileSystem.getUsedCapacity();
}
DDStatsCapacityInfo statsCapInfo = null;
Stat stat = null;
if (statsCapInfos != null && !statsCapInfos.isEmpty()) {
statsCapInfo = statsCapInfos.get(0);
_keyMap.put(Constants._Granularity, granularity);
stat = recorder.addUsageInfo(statsCapInfo, _keyMap, fsNativeGuid, ddClient);
}
// Persist FileShare capacity stats only if usage info has changed
long allocatedCapacity = 0;
if (stat != null) {
allocatedCapacity = stat.getAllocatedCapacity();
}
// TODO: a method to detect changes in stats will be useful
boolean statsChanged = (usedCapacity != allocatedCapacity) ? true : false;
if ((stat != null) && (!fileSystem.getInactive()) && (statsChanged)) {
stats.add(stat);
fileSystem.setUsedCapacity(allocatedCapacity);
fileSystem.setCapacity(stat.getProvisionedCapacity());
_dbClient.persistObject(fileSystem);
}
}
// Determine if a filesystems were deleted from this device and write zero records for deleted ones
zeroRecordGenerator.identifyRecordstobeZeroed(_keyMap, stats, FileShare.class);
persistStatsInDB(stats);
// TODO: Metering task completer will overwrite currTime below with a new
// time as the last collection time. To avoid this, setLastTime in
// MeteringTaskCompleter should be modified to set last metering run time
// only if it
storageSystem.setLastMeteringRunTime(statsCollectionEndTime);
_log.info("Done metering device {}, processed {} file system stats ", storageSystemId, statsCount);
_log.info("End collecting statistics for ip address {}", accessProfile.getIpAddress());
} catch (Exception e) {
_log.error("CollectStatisticsInformation failed. Storage system: " + storageSystemId, e);
throw DataDomainApiException.exceptions.statsCollectionFailed(e.getMessage());
}
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
DataDomainClient ddClient = getDataDomainClient(accessProfile);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
URI providerId = storageSystem.getActiveProviderURI();
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerId);
if (storageSystem == null || storageSystem.getInactive()) {
return;
}
if ((null != accessProfile.getnamespace()) && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_FILESYSTEMS.toString()))) {
discoverUnManagedFileSystems(ddClient, storageSystem);
discoverUnManagedNewExports(ddClient, storageSystem);
discoverUnManagedCifsShares(ddClient, storageSystem);
} else {
discoverAll(ddClient, storageSystem);
}
}
Aggregations