use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteShare.
@Override
public void deleteShare(URI storage, URI uri, FileSMBShare smbShare, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(uri, opId);
FileObject fileObject = null;
StorageSystem storageObj = null;
FileShare fsObj = null;
Snapshot snapshotObj = null;
try {
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info(String.format("Delete SMB share details --- name: %1$s, description: %2$s, permissionType: %3$s, permission: %4$s , maxUsers: %5$s ", smbShare.getName(), smbShare.getDescription(), smbShare.getPermissionType(), smbShare.getPermission(), (smbShare.getMaxUsers() > 0) ? smbShare.getMaxUsers() : "unlimited"));
// get db object for smb share
SMBFileShare smbFileShare = smbShare.getSMBFileShare();
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.setShareName(smbShare.getName());
args.setOpId(opId);
if (URIUtil.isType(uri, FileShare.class)) {
fsObj = _dbClient.queryObject(FileShare.class, uri);
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
fileObject = fsObj;
args.addFSFileObject(fsObj);
args.setFileOperation(true);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
WorkflowStepCompleter.stepExecuting(opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doDeleteShare(storageObj, args, smbFileShare);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fsObj);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
List<SMBFileShare> shares = null;
if (result.isCommandSuccess()) {
SMBShareMap shareMap = fsObj.getSMBFileShares();
shares = new ArrayList<SMBFileShare>(shareMap.values());
deleteShareACLsFromDB(args);
WorkflowStepCompleter.stepSucceded(opId);
} else {
shares = new ArrayList<SMBFileShare>();
shares.add(smbFileShare);
}
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), fsObj, smbShare);
} else {
snapshotObj = _dbClient.queryObject(Snapshot.class, uri);
fileObject = snapshotObj;
args.addSnapshotFileObject(snapshotObj);
args.setFileOperation(false);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
WorkflowStepCompleter.stepExecuting(opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doDeleteShare(storageObj, args, smbFileShare);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
snapshotObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(snapshotObj);
fsObj = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
List<SMBFileShare> shares = null;
if (result.isCommandSuccess()) {
SMBShareMap shareMap = snapshotObj.getSMBFileShares();
shares = new ArrayList<SMBFileShare>(shareMap.values());
deleteShareACLsFromDB(args);
WorkflowStepCompleter.stepSucceded(opId);
} else {
shares = new ArrayList<SMBFileShare>();
shares.add(smbFileShare);
}
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), snapshotObj, fsObj, smbShare);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
String[] params = { storage.toString(), uri.toString(), smbShare.getName(), e.getMessage() };
_log.error("Unable to delete file system or snapshot share: storage {}, FS/snapshot URI {}, SMB share {}: {}", params);
updateTaskStatus(opId, fileObject, e);
if (URIUtil.isType(uri, FileShare.class)) {
if ((fsObj != null) && (storageObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE, false, e.getMessage(), "", fsObj, smbShare, storageObj);
}
} else {
if ((fsObj != null) && (storageObj != null) && (snapshotObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, false, e.getMessage(), "", snapshotObj, fsObj, smbShare, storageObj);
}
}
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileDeviceController method getShareNameExtensions.
/**
* Gets the list of SMB share names to be recorded as an extension in the
* event for filesystem/snapshot share/deleteShare operations. The extension
* is specified in the format:
*
* ExtensionName=name1, name2, ...,name3
*
* @param smbFileShares
* The list of file system SMB shares.
*
* @return extension names in the format as above
*/
private String getShareNameExtensions(List<SMBFileShare> smbFileShares) {
StringBuilder strBuilder = new StringBuilder();
strBuilder.append(RecordableBourneEvent.FS_SHARE_EXTENSION_NAME);
strBuilder.append("=");
int i = smbFileShares.size();
for (SMBFileShare fileShare : smbFileShares) {
strBuilder.append(fileShare.getName());
i--;
if (i > 0) {
strBuilder.append(",");
}
}
return strBuilder.toString();
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method createCIFSShareOnTarget.
private static void createCIFSShareOnTarget(Workflow workflow, URI systemTarget, List<SMBFileShare> smbShares, StoragePort cifsPort, FileShare targetFileShare, FileShare sourceFileShare) {
for (SMBFileShare smbShare : smbShares) {
FileSMBShare fileSMBShare = new FileSMBShare(smbShare);
fileSMBShare.setStoragePortName(cifsPort.getPortName());
fileSMBShare.setStoragePortNetworkId(cifsPort.getPortNetworkId());
if (fileSMBShare.isSubDirPath()) {
fileSMBShare.setPath(targetFileShare.getPath() + fileSMBShare.getPath().split(sourceFileShare.getPath())[1]);
} else {
fileSMBShare.setPath(targetFileShare.getPath());
}
String shareCreationStep = workflow.createStepId();
String stepDescription = String.format("creating CIFS Share : %s, path : %s", fileSMBShare.getName(), fileSMBShare.getPath());
Object[] args = new Object[] { systemTarget, targetFileShare.getId(), fileSMBShare };
_fileDeviceController.createMethod(workflow, null, CREATE_FILESYSTEM_SHARE_METHOD, shareCreationStep, stepDescription, systemTarget, args);
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method deleteCIFSShareFromTarget.
private static void deleteCIFSShareFromTarget(Workflow workflow, URI systemTarget, List<SMBFileShare> smbShares, FileShare targetFileShare) {
for (SMBFileShare smbShare : smbShares) {
FileSMBShare fileSMBShare = new FileSMBShare(smbShare);
String stepDescription = String.format("deleting CIFS share : %s, path : %s", fileSMBShare.getName(), fileSMBShare.getPath());
String sharedeleteStep = workflow.createStepId();
Object[] args = new Object[] { systemTarget, targetFileShare.getId(), fileSMBShare };
_fileDeviceController.createMethod(workflow, null, DELETE_FILESYSTEM_SHARE_METHOD, sharedeleteStep, stepDescription, systemTarget, args);
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileService method getFileSystemShareList.
/**
* Get list of SMB shares for the specified file system.
*
* @param id
* the URN of a ViPR File system
* @brief List file system SMB shares
* @return List of file system shares.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public FileSystemShareList getFileSystemShareList(@PathParam("id") URI id) {
_log.info(String.format("Get list of SMB file shares for file system: %1$s", id));
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
FileShare fileShare = queryResource(id);
FileSystemShareList fileShareListResponse = new FileSystemShareList();
if (fileShare.getInactive()) {
return fileShareListResponse;
}
SMBShareMap smbShareMap = fileShare.getSMBFileShares();
Collection<SMBFileShare> smbShares = new ArrayList<SMBFileShare>();
if (smbShareMap != null) {
smbShares = smbShareMap.values();
}
// Process each share from the map and add its data to shares in response list.
for (SMBFileShare smbShare : smbShares) {
SmbShareResponse shareParam = new SmbShareResponse();
shareParam.setShareName(smbShare.getName());
shareParam.setDescription(smbShare.getDescription());
shareParam.setMaxUsers(Integer.toString(smbShare.getMaxUsers()));
// Check for "unlimited"
if (shareParam.getMaxUsers().equals("-1")) {
shareParam.setMaxUsers(UNLIMITED_USERS);
}
shareParam.setPermissionType(smbShare.getPermissionType());
shareParam.setPermission(smbShare.getPermission());
shareParam.setMountPoint(smbShare.getMountPoint());
shareParam.setPath(smbShare.getPath());
fileShareListResponse.getShareList().add(shareParam);
}
return fileShareListResponse;
}
Aggregations