use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method addStepsToReplicateCIFSShareACLs.
/**
* Child workflow for replicating source file system CIFS ACLs to target system.
*
* @param systemTarget
* - URI of target StorageSystem where source CIFS shares has to be replicated.
* @param fsURI
* -URI of the source FileSystem
* @param taskId
*/
public void addStepsToReplicateCIFSShareACLs(URI systemTarget, URI fsURI, String taskId) {
s_logger.info("Generating steps for Replicating CIFS share ACLs to Target Cluster");
CifsShareACLUpdateParams params;
FileWorkflowCompleter completer = new FileWorkflowCompleter(fsURI, taskId);
FileShare targetFileShare = null;
Workflow workflow = null;
try {
FileShare sourceFileShare = s_dbClient.queryObject(FileShare.class, fsURI);
if (sourceFileShare.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
List<String> targetfileUris = new ArrayList<String>();
targetfileUris.addAll(sourceFileShare.getMirrorfsTargets());
targetFileShare = s_dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
} else {
targetFileShare = s_dbClient.queryObject(FileShare.class, sourceFileShare.getParentFileShare());
}
workflow = this._workflowService.getNewWorkflow(this, REPLICATE_CIFS_SHARE_ACLS_TO_TARGET_WF_NAME, false, taskId, completer);
SMBShareMap sourceSMBShareMap = sourceFileShare.getSMBFileShares();
if (sourceSMBShareMap != null) {
List<SMBFileShare> sourceSMBShares = new ArrayList<SMBFileShare>(sourceSMBShareMap.values());
for (SMBFileShare sourceSMBShare : sourceSMBShares) {
List<ShareACL> sourceShareACLs = FileOrchestrationUtils.queryShareACLs(sourceSMBShare.getName(), sourceFileShare.getId(), s_dbClient);
List<ShareACL> targetShareACLs = FileOrchestrationUtils.queryShareACLs(sourceSMBShare.getName(), targetFileShare.getId(), s_dbClient);
if (!sourceShareACLs.isEmpty() && targetShareACLs.isEmpty()) {
// target share doesn't have any ACLs but corresponding share on source does have ACL
params = new CifsShareACLUpdateParams();
ShareACLs shareACLs = new ShareACLs();
shareACLs.setShareACLs(sourceShareACLs);
params.setAclsToAdd(shareACLs);
updateCIFSShareACLOnTarget(workflow, systemTarget, targetFileShare, sourceSMBShare, params);
} else if (!targetShareACLs.isEmpty() && sourceShareACLs.isEmpty()) {
// source share doesn't have any ACLs but corresponding share on target does have ACL
params = new CifsShareACLUpdateParams();
ShareACLs shareACLs = new ShareACLs();
shareACLs.setShareACLs(targetShareACLs);
// TO FIX COP-26361 DU case
// params.setAclsToDelete(shareACLs);
updateCIFSShareACLOnTarget(workflow, systemTarget, targetFileShare, sourceSMBShare, params);
} else if (!targetShareACLs.isEmpty() && !sourceShareACLs.isEmpty()) {
// both source and target share have some ACL
List<ShareACL> shareACLsToAdd = new ArrayList<ShareACL>();
List<ShareACL> shareACLsToDelete = new ArrayList<ShareACL>();
List<ShareACL> shareACLsToModify = new ArrayList<ShareACL>();
HashMap<String, ShareACL> sourceShareACLMap = FileOrchestrationUtils.getShareACLMap(sourceShareACLs);
HashMap<String, ShareACL> targetShareACLMap = FileOrchestrationUtils.getShareACLMap(targetShareACLs);
// ACLs To Add
for (String sourceACLName : sourceShareACLMap.keySet()) {
if (targetShareACLMap.get(sourceACLName) == null) {
ShareACL shareACL = sourceShareACLMap.get(sourceACLName);
shareACL.setFileSystemId(targetFileShare.getId());
shareACLsToAdd.add(shareACL);
}
}
// ACLs To Delete
for (String targetACLName : targetShareACLMap.keySet()) {
if (sourceShareACLMap.get(targetACLName) == null) {
shareACLsToDelete.add(targetShareACLMap.get(targetACLName));
}
}
// ACLs to Modify
targetShareACLs.removeAll(shareACLsToDelete);
sourceShareACLs.removeAll(shareACLsToAdd);
sourceShareACLMap = FileOrchestrationUtils.getShareACLMap(sourceShareACLs);
targetShareACLMap = FileOrchestrationUtils.getShareACLMap(targetShareACLs);
for (String sourceACLName : sourceShareACLMap.keySet()) {
if (targetShareACLMap.get(sourceACLName) != null && !targetShareACLMap.get(sourceACLName).getPermission().equals(sourceShareACLMap.get(sourceACLName).getPermission())) {
ShareACL shareACL = targetShareACLMap.get(sourceACLName);
shareACL.setPermission(sourceShareACLMap.get(sourceACLName).getPermission());
shareACLsToModify.add(shareACL);
}
}
params = new CifsShareACLUpdateParams();
if (!shareACLsToAdd.isEmpty()) {
ShareACLs addShareACLs = new ShareACLs();
addShareACLs.setShareACLs(shareACLsToAdd);
params.setAclsToAdd(addShareACLs);
}
if (!shareACLsToDelete.isEmpty()) {
ShareACLs deleteShareACLs = new ShareACLs();
deleteShareACLs.setShareACLs(shareACLsToDelete);
// TO FIX COP-26361 DU case
// params.setAclsToDelete(deleteShareACLs);
}
if (!shareACLsToModify.isEmpty()) {
ShareACLs modifyShareACLs = new ShareACLs();
modifyShareACLs.setShareACLs(shareACLsToModify);
params.setAclsToModify(modifyShareACLs);
}
if (params.retrieveAllACLs() != null && !params.retrieveAllACLs().isEmpty()) {
updateCIFSShareACLOnTarget(workflow, systemTarget, targetFileShare, sourceSMBShare, params);
}
}
}
}
String successMessage = String.format("Replicating source File System : %s, CIFS Shares ACLs to Target System finished successfully", sourceFileShare.getLabel());
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error("Could not replicate source filesystem CIFS shares ACLs : " + fsURI, ex);
String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER.getName();
ServiceError serviceError = DeviceControllerException.errors.updateFileShareCIFSACLsFailed(fsURI.toString(), opName, ex);
completer.error(s_dbClient, this._locker, serviceError);
}
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileService method getShareACLs.
/**
* Get File Share ACLs
*
* @param id
* the file system URI
* @param shareName
* name of the share
* @brief Show the ACLs for a file share
* @return ShareACLs
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ShareACLs getShareACLs(@PathParam("id") URI id, @PathParam("shareName") String shareName) {
_log.info("Request recieved to get ACLs with Id: {} shareName: {}", id, shareName);
// Validate the FS id
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
ArgValidator.checkFieldNotNull(shareName, "shareName");
FileShare fs = queryResource(id);
if (!CifsShareUtility.doesShareExist(fs, shareName)) {
_log.error("CIFS share does not exist {}", shareName);
throw APIException.notFound.invalidParameterObjectHasNoSuchShare(fs.getId(), shareName);
}
ShareACLs acls = new ShareACLs();
CifsShareUtility util = new CifsShareUtility(_dbClient, fs, null, shareName);
List<ShareACL> shareAclList = util.queryExistingShareACLs();
_log.info("Number of existing ACLs found : {} ", shareAclList.size());
if (!shareAclList.isEmpty()) {
acls.setShareACLs(shareAclList);
}
return acls;
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class SetFileSnapshotShareACL method doExecute.
@Override
protected Task<FileSnapshotRestRep> doExecute() throws Exception {
SnapshotCifsShareACLUpdateParams aclUpdate = new SnapshotCifsShareACLUpdateParams();
ShareACLs shareACLs = FileStorageUtils.createShareACLs(acls);
aclUpdate.setAclsToAdd(shareACLs);
return getClient().fileSnapshots().updateShareACL(fileSystemId, shareName, aclUpdate);
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class SetFileSystemShareACL method doExecute.
@Override
protected Task<FileShareRestRep> doExecute() throws Exception {
FileCifsShareACLUpdateParams aclUpdate = new FileCifsShareACLUpdateParams();
ShareACLs aclsToAdd = FileStorageUtils.createShareACLs(acls);
aclUpdate.setAclsToAdd(aclsToAdd);
return getClient().fileSystems().updateShareACL(fileSystemId, shareName, aclUpdate);
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileSystems method createCifsShareAclParams.
private static FileCifsShareACLUpdateParams createCifsShareAclParams(String formData) {
String[] uiAcls = formData.split(",");
List<ShareACL> acls = new ArrayList<ShareACL>();
for (String uiAce : uiAcls) {
String[] uiData = uiAce.split("~~~");
String uiType = uiData[0];
String uiName = uiData[1];
String uiDomain = uiData[2];
String uiPermission = uiData[3];
ShareACL shareAcl = new ShareACL();
if ("GROUP".equalsIgnoreCase(uiType)) {
shareAcl.setGroup(uiName);
} else {
shareAcl.setUser(uiName);
}
shareAcl.setPermission(uiPermission);
if (uiDomain != null && !"".equals(uiDomain)) {
shareAcl.setDomain(uiDomain);
}
acls.add(shareAcl);
}
FileCifsShareACLUpdateParams input = new FileCifsShareACLUpdateParams();
ShareACLs aclsToAdd = new ShareACLs();
aclsToAdd.setShareACLs(acls);
input.setAclsToAdd(aclsToAdd);
return input;
}
Aggregations