use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddModifyExports.
private void ddModifyExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> modifyFileExports) {
for (FileExport fileExport : modifyFileExports) {
fileExport.setNativeId(exportMap.get(fileExport.getFileExportKey()).getNativeId());
List<DDExportClientModify> ddExportClients = ddBuildModifyExportClientList(exportMap, fileExport);
DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, fileExport.getNativeId());
if (ddExport.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExport.getId());
throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(ddExport.getPath());
} else {
DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, fileExport.getNativeId(), ddExportClients);
FileExport existingExport = exportMap.get(fileExport.getFileExportKey());
ddSetExistingExportProperties(existingExport, fileExport, ddExportInfo);
}
}
}
use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddCreateShare.
private void ddCreateShare(DataDomainClient ddClient, String storagePoolId, SMBFileShare smbFileShare, String sharePath) throws DataDomainApiException {
String shareName = smbFileShare.getName();
int maxUsers = smbFileShare.getMaxUsers();
String desc = smbFileShare.getDescription();
String permissionType = smbFileShare.getPermissionType();
String permission = smbFileShare.getPermission();
DDShareInfo ddShareInfo = ddClient.createShare(storagePoolId, shareName, sharePath, maxUsers, desc, permissionType, permission);
if (ddShareInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePoolId, ddShareInfo.getId());
throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(sharePath);
}
smbFileShare.setNativeId(ddShareInfo.getId());
}
use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus 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);
}
}
use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddCreateExports.
private void ddCreateExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> createFileExports) throws DataDomainApiException {
for (FileExport fileExport : createFileExports) {
// Build export map for export create
String exportName;
if (!fileExport.getPath().startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
exportName = DataDomainApiConstants.FS_PATH_BASE + fileExport.getPath();
fileExport.setPath(exportName);
} else {
exportName = fileExport.getPath();
}
List<DDExportClient> ddExportClients = ddBuildCreateExportClientList(fileExport);
for (DDExportClient ddExpClient : ddExportClients) {
_log.info("DD Export Client {}", ddExpClient.toString());
}
DDExportInfo ddExportInfo = ddClient.createExport(storagePoolId, exportName, ddExportClients);
if (ddExportInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExportInfo.getId());
throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(exportName);
} else {
ddSetNewExportProperties(fileExport, ddExportClients, ddExportInfo);
String exportKey = fileExport.getFileExportKey();
exportMap.put(exportKey, fileExport);
}
}
}
use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteExports.
private void doDeleteExports(DataDomainClient ddClient, String storagePoolId, List<String> exportIdsToDelete) {
if ((exportIdsToDelete != null) && (!exportIdsToDelete.isEmpty())) {
for (String exportId : exportIdsToDelete) {
DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, exportId);
if (ddSvcStatus.getCode() != DataDomainApiConstants.SVC_CODE_SUCCESS) {
StringBuilder message = new StringBuilder(ddSvcStatus.getCode());
message.append(": " + ddSvcStatus.getDetails());
throw DataDomainApiException.exceptions.failedToDeleteExport(message.toString());
}
}
}
}
Aggregations