use of com.emc.storageos.datadomain.restapi.DataDomainClient 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.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doConnect.
@Override
public void doConnect(StorageSystem storage) {
try {
_log.info("doConnect {} - start", storage.getId());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doConnect failed, provider unreachable");
String sys = storage.getLabel() + "(" + storage.getIpAddress() + ")";
throw DataDomainApiException.exceptions.connectStorageFailed(sys);
}
DDMCInfoDetail ddInfo = ddClient.getManagementSystemInfo();
String msg = String.format("doConnect %1$s - complete", ddInfo);
_log.info(msg);
} catch (DataDomainApiException e) {
_log.error("doConnect failed.", e);
throw DeviceControllerException.exceptions.connectStorageFailed(e);
}
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method deleteExportRules.
@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
try {
// TODO - These lines may be removed once DD snapshot APIs become available.
if (!args.getFileOperation()) {
// Snapshot Export operation is not supported by Data Domain.
ServiceError serviceError = DeviceControllerErrors.datadomain.operationNotSupported();
serviceError.setMessage("Data Domain does not support snapshot export");
return BiosCommandResult.createErrorResult(serviceError);
}
_log.info("DataDomainFileStorageDevice deleteExportRules - start");
FileShare fs = args.getFs();
// List of existing export rules
List<ExportRule> existingExports = args.getExistingDBExportRules();
if ((existingExports == null) || (existingExports.isEmpty())) {
_log.info("Export rule delete, file system {} does not have an existing export to delete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
}
_log.info("Number of existng Rules found {}", existingExports.size());
// Build export path, adding sub-directory if not null and non-empty
String exportPath;
String subDir = args.getSubDirectory();
StringBuilder expPath = new StringBuilder();
if (!args.getFileOperation()) {
expPath.append(args.getSnapshotPath());
} else {
expPath.append(args.getFs().getPath());
}
if ((subDir != null) && (subDir.length() > 0)) {
expPath.append("/");
expPath.append(subDir);
}
exportPath = expPath.toString();
// Data Domain attaches a prefix to every file system path
expPath = new StringBuilder();
if (!exportPath.startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
expPath.append(DataDomainApiConstants.FS_PATH_BASE);
}
expPath.append(exportPath);
_log.info("exportPath : {}", expPath);
args.setExportPath(expPath.toString());
for (ExportRule expRule : existingExports) {
if (expRule.getExportPath().equals(expPath.toString())) {
args.setObjIdOnDevice(expRule.getDeviceExportId());
break;
}
}
// Do we need to delete all subdirectories as well?
boolean allDirs = args.isAllDir();
// List of IDs of exports to delete
List<String> exportIdsToDelete = new ArrayList<>();
exportIdsToDelete.add(args.getObjIdOnDevice());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("deleteExportRules failed, provider unreachable");
String op = "Delete export rules";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
if (allDirs) {
// Add to the list of IDs of exports to delete
buildListOfIdsToDelete(ddClient, storagePool.getNativeId(), expPath.toString(), exportIdsToDelete);
}
doDeleteExports(ddClient, storagePool.getNativeId(), exportIdsToDelete);
_log.info("DataDomainFileStorageDevice deleteExportRules {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException dde) {
_log.error("Export update failed, device error:", dde);
return BiosCommandResult.createErrorResult(dde);
}
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doCheckFSExists.
@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_log.info("checking file system existence on array: ", args.getFsName());
boolean isMtreeExists = true;
try {
DataDomainClient ddClient = getDataDomainClient(storage);
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storagePool.getNativeId(), args.getFs().getNativeId());
if (mtreeInfo != null && (mtreeInfo.id.equals(args.getFsNativeId()))) {
isMtreeExists = true;
}
} catch (DataDomainResourceNotFoundException e) {
_log.info("Mtree not found.", e);
isMtreeExists = false;
}
return isMtreeExists;
}
use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doShare.
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doShare() - start");
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doShare failed, provider unreachable");
String op = "FS share create";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
// Check if this is a new share or update of the existing share
SMBShareMap smbShareMap = args.getFileObjShares();
SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
String shareId;
DDShareInfo ddShareInfo;
// Cannot send empty description, send the share name in that case
if (smbFileShare.getDescription() == null || smbFileShare.getDescription().isEmpty()) {
_log.debug("SMB Share creation was called with empty description and setting name as desc");
smbFileShare.setDescription(smbFileShare.getName());
}
if (existingShare != null) {
shareId = existingShare.getNativeId();
// modify share
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
DDShareInfoDetail ddShareInfoDetail = ddClient.getShare(storagePool.getNativeId(), shareId);
if (ddShareInfoDetail.getPathStatus() == 0) {
DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePool.getNativeId(), shareId);
throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(ddShareInfoDetail.getPath());
}
ddShareInfo = ddClient.modifyShare(storagePool.getNativeId(), shareId, smbFileShare.getDescription());
} else {
// new share
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
ddCreateShare(ddClient, storagePool.getNativeId(), smbFileShare, smbFileShare.getPath());
}
// init file share map
if (args.getFileObjShares() == null) {
args.initFileObjShares();
}
args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
_log.info("DataDomainFileStorageDevice doShare() - complete");
// Set MountPoint
smbFileShare.setMountPoint(smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doShare failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
Aggregations