use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method convertFileExportRuleToExportRule.
/**
* @param fileExportRule
* @return ExportRule
*/
public static ExportRule convertFileExportRuleToExportRule(FileExportRule fileExportRule) {
ExportRule exportRule = new ExportRule();
exportRule.setAnon(fileExportRule.getAnon());
exportRule.setExportPath(fileExportRule.getExportPath());
exportRule.setFsID(fileExportRule.getFileSystemId());
exportRule.setMountPoint(fileExportRule.getMountPoint());
exportRule.setReadOnlyHosts(fileExportRule.getReadOnlyHosts());
exportRule.setReadWriteHosts(fileExportRule.getReadWriteHosts());
exportRule.setRootHosts(fileExportRule.getRootHosts());
exportRule.setSecFlavor(fileExportRule.getSecFlavor());
exportRule.setSnapShotID(fileExportRule.getSnapshotId());
exportRule.setDeviceExportId(fileExportRule.getDeviceExportId());
return exportRule;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method checkForExportRuleToModify.
/**
* This method checks for export rules that has to modified on target file system
*
* @param sourceExportRuleMap
* @param targetExportRuleMap
* @param exportRulesToModify
*/
public static void checkForExportRuleToModify(HashMap<String, ExportRule> sourceExportRuleMap, HashMap<String, ExportRule> targetExportRuleMap, List<ExportRule> exportRulesToModify) {
for (String secFlavour : sourceExportRuleMap.keySet()) {
if (targetExportRuleMap.get(secFlavour) != null) {
boolean isExportRuleToModify = false;
ExportRule sourceExportRule = sourceExportRuleMap.get(secFlavour);
ExportRule targetExportRule = targetExportRuleMap.get(secFlavour);
// Check for RW Hosts
if (isEndPointsDifferent(sourceExportRule.getReadWriteHosts(), targetExportRule.getReadWriteHosts())) {
isExportRuleToModify = true;
targetExportRule.setReadWriteHosts(sourceExportRule.getReadWriteHosts());
}
// Check for RO Hosts
if (isEndPointsDifferent(sourceExportRule.getReadOnlyHosts(), targetExportRule.getReadOnlyHosts())) {
isExportRuleToModify = true;
targetExportRule.setReadOnlyHosts(sourceExportRule.getReadOnlyHosts());
}
// Check for Root Hosts
if (isEndPointsDifferent(sourceExportRule.getRootHosts(), targetExportRule.getRootHosts())) {
isExportRuleToModify = true;
targetExportRule.setRootHosts(sourceExportRule.getRootHosts());
}
// Check for Anon
if (sourceExportRule.getAnon() != null && !sourceExportRule.getAnon().equals(targetExportRule.getAnon())) {
isExportRuleToModify = true;
targetExportRule.setAnon(sourceExportRule.getAnon());
}
if (isExportRuleToModify) {
exportRulesToModify.add(targetExportRule);
}
}
}
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileSnapshotService method getSnapshotExportRules.
/**
* Get Snapshot Export Rules
*
* @param id
* the URN of a file system
* @param allDirs
* All Dirs within a file system
* @param subDir
* sub-directory within a file system
* @brief List the export rules for a snapshot
* @return ExportRules
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/export")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ExportRules getSnapshotExportRules(@PathParam("id") URI id, @QueryParam("allDirs") boolean allDirs, @QueryParam("subDir") String subDir) {
_log.info("Request recieved to list snapshotExports with Id : {}", new Object[] { id });
// Validate the FS id.
ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
Snapshot snapshot = queryResource(id);
ExportRules exportRules = new ExportRules();
List<ExportRule> exportRule = new ArrayList<>();
// Query All Export Rules Specific to a File System.
List<FileExportRule> exports = queryDBSnapshotExports(snapshot);
_log.info("Number of existing snapshot exports found : {} ", exports.size());
// All EXPORTS
for (FileExportRule rule : exports) {
ExportRule expRule = new ExportRule();
// Copy Props
copyPropertiesToSave(rule, expRule, snapshot);
exportRule.add(expRule);
}
_log.info("Number of snapshot export rules returning {}", exportRule.size());
exportRules.setExportRules(exportRule);
return exportRules;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileStorageUtils method updateFileSystemExport.
public static String updateFileSystemExport(URI fileSystemId, String subDirectory, FileExportRule[] fileExportRules, boolean bypassDnsCheck) {
List<ExportRule> exportRuleList = getFileSystemExportRules(fileSystemId, false, subDirectory);
Set<String> existingRuleSet = Sets.newHashSet();
for (ExportRule rule : exportRuleList) {
existingRuleSet.add(rule.getSecFlavor());
}
List<ExportRule> exportRuleListToAdd = Lists.newArrayList();
List<ExportRule> exportRuleListToModify = Lists.newArrayList();
for (FileExportRule rule : fileExportRules) {
ExportRule exportRule = new ExportRule();
exportRule.setFsID(fileSystemId);
exportRule.setSecFlavor(rule.security);
String rootUserMapping = rule.rootUserMapping;
String domain = rule.domain;
if (StringUtils.isNotBlank(domain)) {
rootUserMapping = domain.trim() + "\\" + rootUserMapping.trim();
}
exportRule.setAnon(rootUserMapping);
Set<String> exportHosts = new HashSet<String>(rule.exportHosts);
switch(rule.getPermission()) {
case "ro":
exportRule.setReadOnlyHosts(exportHosts);
break;
case "rw":
exportRule.setReadWriteHosts(exportHosts);
break;
case "root":
exportRule.setRootHosts(exportHosts);
break;
default:
break;
}
if (existingRuleSet.contains(exportRule.getSecFlavor())) {
exportRuleListToModify.add(exportRule);
} else {
exportRuleListToAdd.add(exportRule);
}
}
FileShareExportUpdateParams params = new FileShareExportUpdateParams();
if (!exportRuleListToAdd.isEmpty()) {
ExportRules exportRulesToAdd = new ExportRules();
exportRulesToAdd.setExportRules(exportRuleListToAdd);
params.setExportRulesToAdd(exportRulesToAdd);
}
if (!exportRuleListToModify.isEmpty()) {
ExportRules exportRulesToModify = new ExportRules();
exportRulesToModify.setExportRules(exportRuleListToModify);
params.setExportRulesToModify(exportRulesToModify);
}
params.setBypassDnsCheck(bypassDnsCheck);
Task<FileShareRestRep> task = execute(new UpdateFileSystemExport(fileSystemId, subDirectory, params));
addAffectedResource(task);
String exportId = task.getResourceId().toString();
logInfo("file.storage.export.task", exportId, task.getOpId());
return exportId;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileSnapshots method snapshotExports.
public static void snapshotExports(String snapshotId) {
ViPRCoreClient client = BourneUtil.getViprClient();
List<ExportRule> exports = client.fileSnapshots().getExport(uri(snapshotId), true, "");
renderArgs.put("permissionTypeOptions", Lists.newArrayList(FileShareExport.Permissions.values()));
render(exports);
}
Aggregations