use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doUpdateQuotaDirectory.
@Override
public BiosCommandResult doUpdateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
ApplicationContext context = null;
XMLApiResult apiResult = null;
try {
_log.info("VNXFileStorageDeviceXML doUpdateQuotaDirectory - start");
String fslName = args.getFsName();
String quotaTreetreeName = args.getQuotaDirectoryName();
Boolean oplocks = quotaDir.getOpLock();
String securityStyle = quotaDir.getSecurityStyle();
Long size = quotaDir.getSize();
if (null == fslName) {
_log.error("VNXFileStorageDeviceXML::doUpdateQuotaDirectory failed: Filesystem name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.vnx.unableToUpdateQuotaDir();
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == quotaTreetreeName) {
_log.error("VNXFileStorageDeviceXML::doUpdateQuotaDirectory failed: Quota Tree name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.vnx.unableToUpdateQuotaDir();
serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
_log.info("FSName: {}", args.getFsName());
_log.info("Quota tree name: {}", args.getQuotaDirectoryName());
boolean isMountRequired = !(args.isFileShareMounted());
_log.info("Mount required or not, to update quota dir requested {}", isMountRequired);
// Load the context
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
// quota directory create/update takes size in MB as similar to FS create.
Long sizeMBs = size / BYTESPERMB;
apiResult = vnxComm.modifyQuotaDirectory(storage, args.getFsName(), quotaTreetreeName, securityStyle, sizeMBs, oplocks, isMountRequired);
_log.info("doUpdateQuotaDirectory call result : {}", apiResult.isCommandSuccess());
if (apiResult.isCommandSuccess()) {
VNXQuotaTree quotaTree = (VNXQuotaTree) apiResult.getObject();
args.getQuotaDirectory().setNativeId(String.valueOf(quotaTree.getId()));
result = BiosCommandResult.createSuccessfulResult();
}
} catch (VNXException e) {
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToUpdateQuotaDir());
}
return cmdResult;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doShare.
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
_log.info("Call FileShare doShare");
boolean firstExport = false;
if (args.getFileObjShares() == null || args.getFileObjShares().isEmpty()) {
args.initFileObjShares();
}
firstExport = !(args.isFileShareMounted());
if (firstExport) {
_log.debug("First export: no existing file obj shares");
}
if (!args.getFileOperation()) {
firstExport = false;
}
String portName = smbFileShare.getPortGroup();
String path = smbFileShare.getPath();
if (path == null || path.length() == 0) {
if (args.getFileOperation()) {
path = args.getFsMountPath();
} else {
path = args.getSnapshotMountPath();
}
}
_log.debug("Data Mover: {}", portName);
_log.debug("Mount path: {}", path);
XMLApiResult result = null;
ApplicationContext context = null;
try {
List<String> clients = new ArrayList<String>();
VNXFileExport fileExport = new VNXFileExport(clients, portName, path, // no security type
"", smbFileShare.getPermission(), // root user mapping n/a for CIFS
"", VNXFileSshApi.VNX_CIFS, // Port information is never used for for CIFS or NFS exports.
"", // SUB DIR
"", // Comments -- TODO
"");
fileExport.setExportName(smbFileShare.getName());
fileExport.setComment(smbFileShare.getDescription());
fileExport.setMaxUsers(Integer.toString(smbFileShare.getMaxUsers()));
List<VNXFileExport> vnxExports = new ArrayList<VNXFileExport>();
vnxExports.add(fileExport);
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
// Get DataMover
StorageHADomain dm = this.getDataMover(args.getFs());
if (dm == null) {
Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
throw VNXException.exceptions.createExportFailed("VNX File Share creation Failed Data Mover not found", e);
}
List<String> paths = new ArrayList<String>();
paths.add(path);
if (args.getFileOperation()) {
// Perform FileSystem export
result = vnxComm.doExport(storage, dm, vnxExports, paths, args.getFileObj(), args.getFsNativeId(), firstExport);
} else {
// perform Snapshot export
result = vnxComm.doExport(storage, dm, vnxExports, paths, args.getFileObj(), args.getSnapNativeId(), firstExport);
}
if ((result != null) && (result.isCommandSuccess())) {
// Set MountPoint
smbFileShare.setMountPoint(fileExport.getNetBios(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
}
} catch (VNXException e) {
throw new DeviceControllerException(e);
} catch (NumberFormatException e) {
// Placeholder until real handling is determined.
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileShare(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method deleteExportRules.
@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult biosResult = new BiosCommandResult();
biosResult.setCommandSuccess(true);
biosResult.setCommandStatus(Operation.Status.ready.name());
List<ExportRule> allExports = args.getExistingDBExportRules();
String subDir = args.getSubDirectory();
boolean allDirs = args.isAllDir();
String exportPath;
String subDirExportPath = "";
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;
}
}
Set<String> allPaths = new HashSet<String>();
try {
if (allDirs) {
// ALL EXPORTS
_log.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
for (ExportRule rule : allExports) {
allPaths.add(rule.getExportPath());
}
} else if (subDir != null && !subDir.isEmpty()) {
// Filter for a specific Sub Directory export
_log.info("Deleting all subdir exports rules at ViPR and sub directory export at device {}", subDir);
for (ExportRule rule : allExports) {
if (rule.getExportPath().endsWith("/" + subDir)) {
allPaths.add(subDirExportPath);
break;
}
}
} else {
// Filter for No SUBDIR - main export rules with no sub dirs
_log.info("Deleting all export rules from DB and export at device not included sub dirs");
allPaths.add(exportPath);
}
_log.info("Number of Exports to Delete : {}", allPaths.size());
Map<String, Boolean> operationResult = new HashMap<String, Boolean>();
XMLApiResult result = null;
ApplicationContext context = null;
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
for (String exportPathToDelete : allPaths) {
_log.info("Deleting Export Path {}", exportPathToDelete);
try {
result = vnxComm.doDeleteExport(storage, exportPathToDelete, args, false);
if (result.isCommandSuccess()) {
_log.info("Export Deleted : {}", exportPathToDelete);
operationResult.put(exportPathToDelete, true);
} else {
_log.error("Error deleting Export : {}", exportPathToDelete);
operationResult.put(exportPathToDelete, false);
biosResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToUnexportFileSystem(result.getMessage()));
}
} catch (Exception e) {
_log.error("Error deleting Export : {}", exportPathToDelete);
operationResult.put(exportPathToDelete, false);
biosResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToUnexportFileSystem(result.getMessage()));
}
}
} catch (VNXException e) {
_log.error("Exception:" + e.getMessage());
throw new DeviceControllerException("Exception while performing export for {0} ", new Object[] { args.getFsId() });
}
_log.info("VNXFileStorageDevice deleteExportRules {} - complete", args.getFsId());
return biosResult;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doExport.
@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
boolean firstExport = false;
if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
args.initFileObjExports();
}
// mount the FileSystem
firstExport = !(args.isFileShareMounted());
if (firstExport) {
_log.debug("First export: no existing file exports");
}
// Mounting is only necessary for FileSystem and not snapshot for the first time export
if (!args.getFileOperation()) {
firstExport = false;
}
// Create a list of the new exports.
FSExportMap newExpList = new FSExportMap();
FSExportMap curExpList = args.getFileObjExports();
FileExport curExport = null;
FileExport newExport = null;
List<String> newPaths = new ArrayList<String>();
Iterator<String> it = curExpList.keySet().iterator();
while (it.hasNext()) {
curExport = curExpList.get(it.next());
newExport = new FileExport(curExport.getClients(), curExport.getStoragePortName(), ExportUtils.getFileMountPoint(curExport.getStoragePort(), curExport.getPath()), curExport.getSecurityType(), curExport.getPermissions(), curExport.getRootUserMapping(), curExport.getProtocol(), curExport.getStoragePort(), curExport.getPath(), curExport.getMountPath(), curExport.getSubDirectory(), curExport.getComments());
_log.info("FileExport key : {} ", newExport.getFileExportKey());
newExpList.put(newExport.getFileExportKey(), newExport);
}
for (FileExport exp : exportList) {
newExport = new FileExport(exp.getClients(), exp.getStoragePortName(), ExportUtils.getFileMountPoint(exp.getStoragePort(), exp.getPath()), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getPath(), exp.getMountPath(), exp.getSubDirectory(), exp.getComments());
_log.info("FileExport key : {} ", newExport.getFileExportKey());
newExpList.put(newExport.getFileExportKey(), newExport);
if (!newPaths.contains(newExport.getPath())) {
newPaths.add(newExport.getPath());
}
}
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
// Get DataMover Name and whether it is virtual
StorageHADomain dm = this.getDataMover(args.getFs());
if (dm == null) {
Exception e = new Exception("VNX File Export Failed Data Mover not found");
throw VNXException.exceptions.createExportFailed("VNX File Export Failed Data Mover not found", e);
}
List<VNXFileExport> vnxExports = getVNXFileExports(newExpList);
if (args.getFileOperation()) {
// Perform FileSystem export
result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getFsNativeId(), firstExport);
} else {
// perform Snapshot export
result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getSnapNativeId(), firstExport);
}
if (result.isCommandSuccess()) {
curExpList.putAll(newExpList);
}
} catch (VNXException e) {
throw VNXException.exceptions.createExportFailed("VNX File Export Failed", e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToExportFileSystem(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doDeleteFS.
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_log.info("doDeleteFS: fs id = {} Force Delete : {}", args.getFsNativeId(), args.getForceDelete());
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
_log.info("DBClient :" + vnxComm.getDbClient());
result = vnxComm.deleteFileSystem(storage, args.getFsNativeId(), args.getFsName(), args.getForceDelete(), args.getFs());
} catch (VNXException e) {
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToDeleteFileSystem(result.getMessage()));
}
return cmdResult;
}
Aggregations