use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doUnexport.
@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doUnexport {} - start", args.getFsId());
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doUnexport failed, provider unreachable");
String op = "FS unexport";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
FSExportMap currentExports = args.getFsExports();
ddDeleteExports(ddClient, storagePool.getNativeId(), currentExports, exportList);
_log.info("DataDomainFileStorageDevice doUnexport {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doUnexport failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiUnexport.
/**
* Delete exports
*
* @param isi
* IsilonApi object to be used for communicating to the isilon
* system
* @param currentExports
* Current exports map
* @param exports
* exports to be deleted
* @throws ControllerException
* @throws IsilonException
*/
private void isiUnexport(IsilonApi isi, FileDeviceInputOutput args, List<FileExport> exports) throws ControllerException, IsilonException {
FSExportMap currentExports = args.getFileObjExports();
// Do nothing if there are no exports
if (currentExports == null || exports == null || exports.isEmpty()) {
return;
}
for (FileExport fileExport : exports) {
// isiExportKey(req);
String key = fileExport.getFileExportKey();
String id = null;
FileExport fExport = currentExports.get(key);
if (fExport != null) {
id = fExport.getIsilonId();
}
if (id != null) {
String zoneName = getZoneName(args.getvNAS());
if (zoneName != null) {
isi.deleteExport(id, zoneName);
} else {
isi.deleteExport(id);
}
currentExports.remove(key);
}
}
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiDeleteExports.
/**
* Delete isilon export
*
* @param isi
* IsilonApi object
* @param exportMap
* exports to be deleted
* @throws IsilonException
*/
private void isiDeleteExports(IsilonApi isi, FileDeviceInputOutput args) throws IsilonException {
FSExportMap exportMap = null;
if (args.getFileOperation()) {
FileShare fileObj = args.getFs();
if (fileObj != null) {
exportMap = fileObj.getFsExports();
}
} else {
Snapshot snap = args.getFileSnapshot();
if (snap != null) {
exportMap = snap.getFsExports();
}
}
if (exportMap == null || exportMap.isEmpty()) {
return;
}
String zoneName = getZoneName(args.getvNAS());
Set<String> deletedExports = new HashSet<String>();
Iterator<Map.Entry<String, FileExport>> it = exportMap.entrySet().iterator();
try {
while (it.hasNext()) {
Map.Entry<String, FileExport> entry = it.next();
String key = entry.getKey();
FileExport fsExport = entry.getValue();
if (zoneName != null) {
isi.deleteExport(fsExport.getIsilonId(), zoneName);
} else {
isi.deleteExport(fsExport.getIsilonId());
}
// Safe removal from the backing map. Can not do this through
// iterator since this does not track changes and is not
// reflected in the database.
deletedExports.add(key);
}
} finally {
// remove exports from the map in database.
for (String key : deletedExports) {
exportMap.remove(key);
}
}
}
use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method doExport.
@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
_log.info("NetAppFileStorageDevice doExport - start");
// Verify inputs.
validateExportArgs(exportList);
List<String> rootHosts = new ArrayList<String>();
List<String> rwHosts = new ArrayList<String>();
List<String> roHosts = new ArrayList<String>();
if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
args.initFileObjExports();
}
FSExportMap existingExpMap = args.getFileObjExports();
List<FileExport> existingExportList = new ArrayList<FileExport>();
FileExport existingExport = null;
Iterator<String> it = existingExpMap.keySet().iterator();
while (it.hasNext()) {
existingExport = existingExpMap.get(it.next());
_log.info("Existing export FileExport key : {} ", existingExport.getFileExportKey());
existingExportList.add(existingExport);
}
// If it's a sub-directory no need to take existing hosts.
boolean isSubDir = checkIfSubDirectory(args.getFsMountPath(), exportList.get(0).getMountPath());
if (isSubDir) {
existingExportList = null;
}
// TODO: Revisit once new Data Model for Exports is implemented.
Map<String, List<String>> existingHosts = null;
if ((null != existingExportList) && !existingExportList.isEmpty()) {
existingHosts = sortHostsFromCurrentExports(existingExportList);
}
if (null != existingHosts) {
if ((null != existingHosts.get(ROOT_HOSTS)) && !existingHosts.get(ROOT_HOSTS).isEmpty()) {
addNewHostsOnly(rootHosts, existingHosts.get(ROOT_HOSTS));
}
if ((null != existingHosts.get(RW_HOSTS)) && !existingHosts.get(RW_HOSTS).isEmpty()) {
addNewHostsOnly(rwHosts, existingHosts.get(RW_HOSTS));
}
if ((null != existingHosts.get(RO_HOSTS)) && !existingHosts.get(RO_HOSTS).isEmpty()) {
addNewHostsOnly(roHosts, existingHosts.get(RO_HOSTS));
}
}
BiosCommandResult result = new BiosCommandResult();
try {
for (int expCount = 0; expCount < exportList.size(); expCount++) {
FileExport export = exportList.get(expCount);
if (!(export.getMountPath().startsWith(VOL_ROOT_NO_SLASH))) {
export.setMountPath(VOL_ROOT_NO_SLASH + export.getMountPath());
}
FileExport fileExport = new FileExport(export.getClients(), export.getStoragePortName(), export.getMountPoint(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping(), export.getProtocol(), export.getStoragePort(), export.getPath(), export.getMountPath(), export.getSubDirectory(), export.getComments());
args.getFileObjExports().put(fileExport.getFileExportKey(), fileExport);
String portGroup = null;
FileShare fileshare = null;
if (args.getFileOperation() == true) {
fileshare = args.getFs();
portGroup = findVfilerName(fileshare);
} else {
// Get the FS from the snapshot
URI snapShotUID = args.getSnapshotId();
Snapshot snapshot = _dbClient.queryObject(Snapshot.class, snapShotUID);
fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
// Now get the VFiler from the fileshare
portGroup = findVfilerName(fileshare);
}
NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
List<String> endpointsList = export.getClients();
if (endpointsList == null) {
_log.error("NetAppFileStorageDevice::doExport {} failed: No endpoints specified", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
serviceError.setMessage(FileSystemConstants.FS_ERR_NO_ENDPOINTS_SPECIFIED);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
sortNewEndPoints(rootHosts, rwHosts, roHosts, endpointsList, export.getPermissions());
String root_user = export.getRootUserMapping();
String mountPath = export.getMountPath();
String exportPath = export.getPath();
if (!nApi.exportFS(exportPath, mountPath, rootHosts, rwHosts, roHosts, root_user, export.getSecurityType())) {
_log.error("NetAppFileStorageDevice::doExport {} failed", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
serviceError.setMessage(genDetailedMessage("doExport", args.getFsId().toString()));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
result = BiosCommandResult.createSuccessfulResult();
if ((args.getFileOperation() == true) && (isSubDir == false)) {
nApi.setQtreemode(exportPath, UNIX_QTREE_SETTING);
}
}
} catch (NetAppException e) {
_log.error("NetAppFileStorageDevice::doExport failed with a NetAppException", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppFileStorageDevice::doExport failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
_log.info("NetAppFileStorageDevice::doExport {} - complete", args.getFsId());
return result;
}
use of com.emc.storageos.db.client.model.FSExportMap 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;
}
Aggregations