use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
_logger.info(String.format(String.format("Deleting smbShare: %s, nativeId: %s", smbFileShare.getName(), smbFileShare.getNativeId())));
VNXeApiClient apiClient = getVnxUnityClient(storage);
String shareId = smbFileShare.getNativeId();
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
boolean isFile = args.getFileOperation();
FileSMBShare newShare = new FileSMBShare(smbFileShare);
try {
if (isFile) {
String fsId = args.getFs().getNativeId();
job = apiClient.removeCifsShare(shareId, fsId);
} else {
job = apiClient.deleteCifsShareForSnapshot(shareId);
}
if (job != null) {
if (isFile) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
} else {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
}
VNXeDeleteShareJob deleteShareJob = new VNXeDeleteShareJob(job.getId(), storage.getId(), completer, newShare, isFile);
ControllerServiceImpl.enqueueJob(new QueueJob(deleteShareJob));
} else {
_logger.error("No job returned from deleteCifsShare");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("deleteShare", "No Job returned");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Create share got the exception", e);
if (completer != null) {
completer.error(dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("delete share got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("create share", ex.getMessage());
if (completer != null) {
completer.error(dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete share job submitted - Array:%s, share: %s", storage.getSerialNumber(), smbFileShare.getName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.db.client.model.SMBFileShare 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.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method ddDeleteShares.
private void ddDeleteShares(DataDomainClient ddClient, String storagePoolId, SMBShareMap currentShares, List<SMBFileShare> sharesToDelete) {
if ((currentShares != null && (sharesToDelete != null))) {
for (SMBFileShare fileShare : sharesToDelete) {
String key = fileShare.getName();
String ddShareId = null;
SMBFileShare fShare = currentShares.get(key);
if (fShare != null) {
ddShareId = fShare.getNativeId();
}
if (ddShareId != null) {
DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePoolId, ddShareId);
if (ddSvcStatus.getCode() == DataDomainApiConstants.SVC_CODE_SUCCESS) {
currentShares.remove(key);
}
}
}
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteFS.
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteFS {} - start", args.getFsId());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteFS failed, provider unreachable");
String op = "FS delete";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
// Delete the exports for this file system
FSExportMap exportMap = args.getFsExports();
List<FileExport> exportMapvalues = null;
if (exportMap != null) {
exportMapvalues = new ArrayList<>(exportMap.values());
}
if ((exportMap != null) && (exportMapvalues != null)) {
try {
ddDeleteExports(ddClient, storagePool.getNativeId(), exportMap, exportMapvalues);
} catch (DataDomainApiException dde) {
_log.error("Unable to delete exports for the FS: ", dde);
}
}
// Delete the SMB shares for this file system
SMBShareMap shareMap = args.getFsShares();
List<SMBFileShare> shareMapValues = null;
if (shareMap != null) {
shareMapValues = new ArrayList<>(shareMap.values());
}
if ((shareMap != null) && (shareMapValues != null)) {
try {
ddDeleteShares(ddClient, storagePool.getNativeId(), shareMap, shareMapValues);
} catch (DataDomainApiException dde) {
_log.error("Unable to delete cifs shares for the FS: ", dde);
}
}
// Delete mtree on the DD array
DDServiceStatus ddSvcStatus = ddClient.deleteMTree(storagePool.getNativeId(), args.getFs().getNativeId());
_log.info("DataDomainFileStorageDevice doDeleteFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doDeleteFS failed, device error", e);
return BiosCommandResult.createErrorResult(e);
} catch (DataDomainResourceNotFoundException e) {
_log.error("doDeleteFS failed, Mtree not found.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteShares.
@Override
public BiosCommandResult doDeleteShares(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteShares: {} - start");
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteShares failed, provider unreachable");
String op = "FS shares 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.addAll(currentShares.values());
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);
}
}
Aggregations