use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method deleteExportRules.
@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
List<ExportRule> allExports = args.getExistingDBExportRules();
String subDir = args.getSubDirectory();
boolean allDirs = args.isAllDir();
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
boolean isFile = args.getFileOperation();
boolean ifRulePresent = false;
String exportPath;
String subDirExportPath = "";
subDir = args.getSubDirectory();
if (!args.getFileOperation()) {
exportPath = args.getSnapshotPath();
if (subDir != null && subDir.length() > 0) {
subDirExportPath = args.getSnapshotPath() + "/" + subDir;
}
} else {
exportPath = args.getFs().getPath();
if (subDir != null && subDir.length() > 0) {
subDirExportPath = args.getFs().getPath() + "/" + subDir;
}
}
_logger.info("exportPath : {}", exportPath);
args.setExportPath(exportPath);
_logger.info("Number of existing exports found {}", allExports.size());
try {
VNXeApiClient apiClient = getVnxUnityClient(storage);
if (allDirs) {
// ALL EXPORTS
_logger.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
for (ExportRule rule : allExports) {
FileShareExport fsExport = null;
if (args.getFileObjExports() != null) {
Collection<FileExport> expList = args.getFileObjExports().values();
Iterator<FileExport> it = expList.iterator();
FileExport exp = null;
while (it.hasNext()) {
FileExport export = it.next();
if (export.getPath().equalsIgnoreCase(rule.getExportPath())) {
exp = export;
}
}
fsExport = new FileShareExport(exp);
}
String vnxeShareId = rule.getDeviceExportId();
_logger.info("Delete UnityExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
if (isFile) {
String fsId = args.getFs().getNativeId();
job = apiClient.removeNfsShare(vnxeShareId, fsId);
} else {
job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
}
if (job != null) {
if (isFile) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
} else {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
}
VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, rule.getExportPath(), isFile);
ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
return BiosCommandResult.createErrorResult(error);
}
}
} else if (subDir != null && !subDir.isEmpty()) {
// Filter for a specific Sub Directory export
_logger.info("Deleting all subdir exports rules at ViPR and sub directory export at device {}", subDir);
FileShareExport fsExport = null;
String vnxeShareId = null;
if (args.getFileObjExports() != null) {
Collection<FileExport> expList = args.getFileObjExports().values();
Iterator<FileExport> it = expList.iterator();
FileExport exp = null;
while (it.hasNext()) {
FileExport export = it.next();
if (export.getPath().equalsIgnoreCase(subDirExportPath)) {
exp = export;
break;
}
}
fsExport = new FileShareExport(exp);
}
for (ExportRule rule : allExports) {
_logger.info("Delete UnityExport id for path {} f containing subdirectory {}", rule.getDeviceExportId() + ":" + rule.getExportPath(), subDir);
if (rule.getExportPath().equalsIgnoreCase(subDirExportPath)) {
ifRulePresent = true;
vnxeShareId = rule.getDeviceExportId();
}
}
if (!ifRulePresent) {
if (fsExport != null) {
vnxeShareId = fsExport.getIsilonId();
}
}
_logger.info("Delete UnityExport id {} for path {}", vnxeShareId, subDirExportPath);
if (isFile) {
String fsId = args.getFs().getNativeId();
job = apiClient.removeNfsShare(vnxeShareId, fsId);
} else {
job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
}
if (job != null) {
if (isFile) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
} else {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
}
VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, subDirExportPath, isFile);
ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
return BiosCommandResult.createErrorResult(error);
}
} else {
// Filter for No SUBDIR - main export rules with no sub dirs
_logger.info("Deleting all export rules from DB and export at device not included sub dirs");
FileShareExport fsExport = null;
String vnxeShareId = null;
if (args.getFileObjExports() != null) {
Collection<FileExport> expList = args.getFileObjExports().values();
Iterator<FileExport> it = expList.iterator();
FileExport exp = null;
while (it.hasNext()) {
FileExport export = it.next();
if (export.getPath().equalsIgnoreCase(exportPath)) {
exp = export;
break;
}
}
fsExport = new FileShareExport(exp);
}
for (ExportRule rule : allExports) {
if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
ifRulePresent = true;
vnxeShareId = rule.getDeviceExportId();
}
}
if (!ifRulePresent) {
if (fsExport != null) {
vnxeShareId = fsExport.getIsilonId();
}
}
_logger.info("Delete UnityExport id {} for path {}", vnxeShareId, fsExport.getPath());
if (isFile) {
String fsId = args.getFs().getNativeId();
job = apiClient.removeNfsShare(vnxeShareId, fsId);
} else {
job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
}
if (job != null) {
if (isFile) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
} else {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
}
VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, fsExport.getPath(), isFile);
ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
return BiosCommandResult.createErrorResult(error);
}
}
} catch (VNXeException e) {
_logger.error("Unexport file system got the exception", e);
if (completer != null) {
completer.error(dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Delete file system got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
if (completer != null) {
completer.error(dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
if (job != null) {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Unexport filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
} else {
StringBuilder logMsgBuilder = new StringBuilder(String.format("No export found - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createSuccessfulResult();
}
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class FileSystemSnapRequestsTest method createFileSystemSnap.
// @Test
public void createFileSystemSnap() {
FileSystemSnapCreateParam parm = new FileSystemSnapCreateParam();
VNXeBase resource = new VNXeBase();
resource.setId("res_12");
parm.setStorageResource(resource);
parm.setName("test-snap");
parm.setIsReadOnly(false);
FileSystemSnapRequests req = new FileSystemSnapRequests(_client);
VNXeCommandJob response = null;
try {
response = req.createFileSystemSnap(parm);
} catch (VNXeException e) {
// TODO Auto-generated catch block
logger.error("VNXeException occured", e);
}
System.out.println(response.getId() + "state: " + response.getState());
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class JobRequestTest method getTest.
@Test
public void getTest() {
JobRequest req = new JobRequest(_client, "N-55");
VNXeCommandJob job = req.get();
String name = job.getName();
System.out.println(name);
int state = job.getState();
System.out.println(state);
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class VNXeApiClient method expandFileSystem.
/**
* expand file system
*
* @param fsId
* fileSystem Id
* @param newSize
* new capacity
* @return VNXeCommandJob
*/
public VNXeCommandJob expandFileSystem(String fsId, long newSize) {
VNXeCommandJob job = null;
_logger.info("expanding file system:" + fsId);
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.info("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
String resourceId = fs.getStorageResource().getId();
ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
// set fileSystemParam
FileSystemParam fsParm = new FileSystemParam();
fsParm.setSize(newSize);
fsParm.setIsThinEnabled(fs.getIsThinEnabled());
fsParm.setIsFLREnabled(fs.getIsFLREnabled());
fsParm.setSupportedProtocols(fs.getSupportedProtocols());
fsParm.setSizeAllocated(fs.getSizeAllocated());
modifyFSParm.setFsParameters(fsParm);
FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
return job;
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class VNXeApiClient method removeNfsShare.
/**
* Delete nfsShare
*
* @param nfsShareId
* nfsShare Id
* @param fsId
* file system Id
* @return VNXeCommandJob
*/
public VNXeCommandJob removeNfsShare(String nfsShareId, String fsId) {
VNXeCommandJob job = null;
_logger.info("unexporting file system:" + fsId);
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.error("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
if (nfsShareId == null || nfsShareId.isEmpty()) {
_logger.error("NfsShareId is empty.");
throw VNXeException.exceptions.vnxeCommandFailed("NfsShareId is empty. ");
}
String resourceId = fs.getStorageResource().getId();
ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
// set NfsShare delete parm
NfsShareDeleteParam deleteParam = new NfsShareDeleteParam();
VNXeBase share = new VNXeBase();
share.setId(nfsShareId);
deleteParam.setNfsShare(share);
List<NfsShareDeleteParam> deleteList = new ArrayList<NfsShareDeleteParam>();
deleteList.add(deleteParam);
modifyFSParm.setNfsShareDelete(deleteList);
FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
return job;
}
Aggregations