use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class VNXeExportFileSystemJob method getFileExportRule.
private FileExportRule getFileExportRule(URI uri, FileExport fileExport) {
FileExportRule rule = new FileExportRule();
rule.setAnon(fileExport.getRootUserMapping());
rule.setExportPath(fileExport.getPath());
if (!isFile) {
rule.setSnapshotId(uri);
} else {
rule.setFileSystemId(uri);
}
rule.setSecFlavor(fileExport.getSecurityType());
if (fileExport.getPermissions().equals(FileShareExport.Permissions.ro.name()) && fileExport.getClients() != null && !fileExport.getClients().isEmpty()) {
rule.setReadOnlyHosts(new StringSet(fileExport.getClients()));
}
if (fileExport.getPermissions().equals(FileShareExport.Permissions.rw.name()) && fileExport.getClients() != null && !fileExport.getClients().isEmpty()) {
rule.setReadWriteHosts(new StringSet(fileExport.getClients()));
}
if (fileExport.getPermissions().equals(FileShareExport.Permissions.root.name()) && fileExport.getClients() != null && !fileExport.getClients().isEmpty()) {
rule.setRootHosts(new StringSet(fileExport.getClients()));
}
rule.setMountPoint(fileExport.getMountPoint());
_logger.info("Generating FileExportRule IsilonId ? {}", fileExport.getIsilonId());
if (fileExport.getIsilonId() != null) {
rule.setDeviceExportId(fileExport.getIsilonId());
}
return rule;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class VNXeModifyExportJob method getAvailableExportRule.
private FileExportRule getAvailableExportRule(FileExportRule exportRule, DbClient dbClient) throws URISyntaxException {
String exportIndex = exportRule.getFsExportIndex();
if (!isFile) {
exportIndex = exportRule.getSnapshotExportIndex();
}
_logger.info("Retriving DB Model using its index {}", exportIndex);
FileExportRule rule = null;
URIQueryResultList result = new URIQueryResultList();
if (!isFile) {
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotExportRuleConstraint(exportIndex), result);
} else {
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileExportRuleConstraint(exportIndex), result);
}
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
if (result.iterator().hasNext()) {
rule = dbClient.queryObject(FileExportRule.class, it.next());
if (rule != null && !rule.getInactive()) {
_logger.info("Existing DB Model found {}", rule);
break;
}
}
}
return rule;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class VNXeUnexportFileSystemJob method getFileExportRule.
private FileExportRule getFileExportRule(URI uri) {
FileExportRule rule = new FileExportRule();
rule.setExportPath(exportPath);
rule.setSecFlavor(SECURITY_FLAVOR);
if (!isFile) {
rule.setSnapshotId(uri);
} else {
rule.setFileSystemId(uri);
}
return rule;
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class VNXeUnexportFileSystemJob method updateStatus.
/**
* Called to update the job status when the unexport file system job completes.
*
* @param jobContext The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
FileShare fsObj = null;
Snapshot snapObj = null;
StorageSystem storageObj = dbClient.queryObject(StorageSystem.class, getStorageSystemUri());
if (_status == JobStatus.SUCCESS) {
_isSuccess = true;
if (isFile) {
URI fsId = getTaskCompleter().getId();
fsObj = dbClient.queryObject(FileShare.class, fsId);
FileExportRule rule = getFileExportRule(fsId);
updateExportRule(dbClient, rule);
updateFSExport(fsObj, dbClient, vnxeApiClient);
} else {
URI snapshotId = getTaskCompleter().getId();
FileExportRule rule = getFileExportRule(snapshotId);
updateExportRule(dbClient, rule);
snapObj = updateSnapExport(dbClient, vnxeApiClient);
fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent());
}
} else {
// cleanupFSExport(fsObj, dbClient);
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to export file system", opId));
}
_logger.info(logMsgBuilder.toString());
if (isFile) {
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.UNEXPORT_FILE_SYSTEM, _isSuccess, logMsgBuilder.toString(), "", fsObj, storageObj);
} else {
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT, _isSuccess, logMsgBuilder.toString(), "", snapObj, fsObj, storageObj);
}
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeUnexportFIleSystemJob", e);
setErrorStatus("Encountered an internal error during file system unexport job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.FileExportRule in project coprhd-controller by CoprHD.
the class FileSystemExportToFileSystemExportRuleMigration method process.
@Override
public void process() throws MigrationCallbackException {
log.info("FileSystemExport to FileSystem export rule migration: start");
DbClient dbClient = getDbClient();
try {
List<URI> fileExpRuleURIList = dbClient.queryByType(FileExportRule.class, true);
int exisitingExportRuleCount = 0;
for (Iterator<URI> iterator = fileExpRuleURIList.iterator(); iterator.hasNext(); ) {
URI uri = (URI) iterator.next();
log.debug("Existing export rule URI: {}", uri);
exisitingExportRuleCount++;
}
if (exisitingExportRuleCount > 0) {
log.info("There are exisiting export rule(s). Skipping migration.");
return;
}
// FileSystems
List<URI> fileSystemURIList = dbClient.queryByType(FileShare.class, true);
Iterator<FileShare> fileShareListIterator = dbClient.queryIterativeObjects(FileShare.class, fileSystemURIList);
while (fileShareListIterator.hasNext()) {
FileShare fileShare = fileShareListIterator.next();
// Create FS Export Rule for export Map
List<FileExportRule> fsExpRules = createFSExportRules(fileShare);
if (null != fsExpRules && !fsExpRules.isEmpty()) {
log.debug("Persisting new File Export rule(s): {}", fsExpRules);
dbClient.createObject(fsExpRules);
}
}
// Snapshots
List<URI> snapshotURIList = dbClient.queryByType(Snapshot.class, true);
Iterator<Snapshot> snapshotListIterator = dbClient.queryIterativeObjects(Snapshot.class, snapshotURIList);
while (snapshotListIterator.hasNext()) {
Snapshot snapshot = snapshotListIterator.next();
// Create FS Export Rule for export Map
List<FileExportRule> snapshotExpRules = createSnapshotExportRules(snapshot);
if (null != snapshotExpRules && !snapshotExpRules.isEmpty()) {
log.debug("Persisting new Snapshot Export rule(s): {}", snapshotExpRules);
dbClient.createObject(snapshotExpRules);
}
}
log.info("FileSystemExport to FileSystem export rule migration: end");
} catch (Exception e) {
log.error("Exception occured while migrating FileShare/Snapshot Export Map CF to FileExportRule CF");
log.error(e.getMessage(), e);
}
}
Aggregations