use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doConnect.
@Override
public void doConnect(StorageSystem storage) throws ControllerException {
try {
_logger.info("doConnect {} - start", storage.getId());
VNXeApiClient client = getVnxUnityClient(storage);
client.getStorageSystem();
String msg = String.format("doConnect %1$s - complete", storage.getId());
_logger.info(msg);
} catch (VNXeException e) {
_logger.error("doConnect failed.", e);
throw DeviceControllerException.exceptions.connectStorageFailed(e);
}
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doDisconnect.
@Override
public void doDisconnect(StorageSystem storage) {
try {
_logger.info("doConnect {} - start", storage.getId());
VNXeApiClient client = getVnxUnityClient(storage);
client.logout();
String msg = String.format("doDisconnect %1$s - complete", storage.getId());
_logger.info(msg);
} catch (VNXeException e) {
_logger.error("doDisconnect failed.", e);
throw DeviceControllerException.exceptions.disconnectStorageFailed(e);
}
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
_logger.info(String.format(String.format("Deleting smbShare: %s, nativeId: %s", smbFileShare.getName(), smbFileShare.getNativeId())));
VNXeApiClient apiClient = getVnxUnityClient(storage);
String shareId = smbFileShare.getNativeId();
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
boolean isFile = args.getFileOperation();
FileSMBShare newShare = new FileSMBShare(smbFileShare);
try {
if (isFile) {
String fsId = args.getFs().getNativeId();
job = apiClient.removeCifsShare(shareId, fsId);
} else {
job = apiClient.deleteCifsShareForSnapshot(shareId);
}
if (job != null) {
if (isFile) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
} else {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
}
VNXeDeleteShareJob deleteShareJob = new VNXeDeleteShareJob(job.getId(), storage.getId(), completer, newShare, isFile);
ControllerServiceImpl.enqueueJob(new QueueJob(deleteShareJob));
} else {
_logger.error("No job returned from deleteCifsShare");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("deleteShare", "No Job returned");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Create share got the exception", e);
if (completer != null) {
completer.error(dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("delete share got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("create share", ex.getMessage());
if (completer != null) {
completer.error(dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete share job submitted - Array:%s, share: %s", storage.getSerialNumber(), smbFileShare.getName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doExport.
@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
_logger.info("exporting the file system: " + args.getFsName());
if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
args.initFileObjExports();
}
for (FileExport exp : exportList) {
VNXeApiClient apiClient = getVnxUnityClient(storage);
String fsId = args.getFs().getNativeId();
String fsName = args.getFsName();
String permission = exp.getPermissions();
String path = "/";
String subdirName = "";
String mountPathArg = exp.getMountPath();
String comments = exp.getComments();
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
String exportKey = exp.getFileExportKey();
FileShareExport newExport = new FileShareExport(exp);
try {
AccessEnum access = null;
List<String> roClients = null;
List<String> rwClients = null;
List<String> rootClients = null;
FileExport existingExport = null;
if (args.getFileOperation()) {
FSExportMap exportMap = args.getFileObjExports();
existingExport = exportMap.get(exportKey);
} else {
FSExportMap exportMap = args.getSnapshotExports();
existingExport = exportMap.get(exportKey);
}
if (existingExport != null) {
if (permission.equalsIgnoreCase(FileShareExport.Permissions.rw.name())) {
access = AccessEnum.READWRITE;
if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
if (rwClients == null) {
rwClients = new ArrayList<String>();
}
rwClients.addAll(existingExport.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.ro.name())) {
access = AccessEnum.READ;
if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
if (roClients == null) {
roClients = new ArrayList<String>();
}
roClients.addAll(existingExport.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.root.name())) {
access = AccessEnum.ROOT;
if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
if (rootClients == null) {
rootClients = new ArrayList<String>();
}
rootClients.addAll(existingExport.getClients());
}
}
}
if (permission.equalsIgnoreCase(FileShareExport.Permissions.rw.name())) {
access = AccessEnum.READWRITE;
if (exp.getClients() != null && !exp.getClients().isEmpty()) {
if (rwClients == null) {
rwClients = new ArrayList<String>();
}
rwClients.addAll(exp.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.ro.name())) {
access = AccessEnum.READ;
if (exp.getClients() != null && !exp.getClients().isEmpty()) {
if (roClients == null) {
roClients = new ArrayList<String>();
}
roClients.addAll(exp.getClients());
}
} else if (permission.equalsIgnoreCase(FileShareExport.Permissions.root.name())) {
access = AccessEnum.ROOT;
if (exp.getClients() != null && !exp.getClients().isEmpty()) {
if (rootClients == null) {
rootClients = new ArrayList<String>();
}
rootClients.addAll(exp.getClients());
}
}
if (args.getFileOperation()) {
String mountPathFs = args.getFsMountPath();
if (!mountPathArg.equals(mountPathFs)) {
// subdirectory specified.
subdirName = mountPathArg.substring(mountPathFs.length() + 1);
path += subdirName;
}
String shareName = VNXeUtils.buildNfsShareName(fsName, subdirName);
job = apiClient.exportFileSystem(fsId, roClients, rwClients, rootClients, access, path, shareName, null, comments);
if (job != null) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
VNXeExportFileSystemJob exportFSJob = new VNXeExportFileSystemJob(job.getId(), storage.getId(), completer, newExport, shareName, true);
ControllerServiceImpl.enqueueJob(new QueueJob(exportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", "No Job returned from exportFileSystem");
return BiosCommandResult.createErrorResult(error);
}
} else {
String snapId = args.getSnapNativeId();
String snapName = args.getSnapshotName();
String shareName = VNXeUtils.buildNfsShareName(snapName, path);
job = apiClient.createNfsShareForSnap(snapId, roClients, rwClients, rootClients, access, path, shareName, comments);
if (job != null) {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
VNXeExportFileSystemJob exportFSJob = new VNXeExportFileSystemJob(job.getId(), storage.getId(), completer, newExport, shareName, false);
ControllerServiceImpl.enqueueJob(new QueueJob(exportFSJob));
} else {
_logger.error("No job returned from exportFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", "No Job returned from exportFileSystem");
return BiosCommandResult.createErrorResult(error);
}
}
} catch (VNXeException e) {
_logger.error("Export file system got the exception", e);
if (completer != null) {
completer.error(dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("export file system got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", ex.getMessage());
if (completer != null) {
completer.error(dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
_logger.info("Export job submitted");
}
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class FileSystemSnapRequestsTest method deleteSnap.
/*
* @Test
* public void getFileSystemSnap() {
*
* FileSystemSnapRequests req = new FileSystemSnapRequests(_client);
*
* VNXeFileSystemSnap response = null;
* try {
* response = req.getByName("test-file-01-snap");
* } catch (VNXeException e) {
* // TODO Auto-generated catch block
* logger.error("VNXeException occured", e);
* }
*
* System.out.println(response.getId());
*
*
* }
*/
// @Test
public void deleteSnap() {
FileSystemSnapRequests req = new FileSystemSnapRequests(_client);
VNXeCommandJob response = null;
try {
response = req.deleteFileSystemSnap("98784247867", "3.1.0");
} catch (VNXeException e) {
logger.error("VNXeException occured", e);
}
System.out.println(response.getId());
}
Aggregations