use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiShare.
/**
* Create/modify Isilon SMB share.
*
* @param isi
* @param args
* @param smbFileShare
* @throws IsilonException
*/
private void isiShare(IsilonApi isi, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws IsilonException {
IsilonSMBShare isilonSMBShare = new IsilonSMBShare(smbFileShare.getName(), smbFileShare.getPath(), smbFileShare.getDescription());
// Check if this is a new share or update of the existing share
SMBShareMap smbShareMap = args.getFileObjShares();
SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
String shareId;
String zoneName = getZoneName(args.getvNAS());
if (existingShare != null) {
shareId = existingShare.getNativeId();
// modify share
if (zoneName != null) {
isi.modifyShare(shareId, zoneName, isilonSMBShare);
} else {
isi.modifyShare(shareId, isilonSMBShare);
}
} else {
/**
* inheritablePathAcl - true: Apply Windows Default ACLs false: Do
* not change existing permissions.
*/
boolean inheritablePathAcl = true;
if (configinfo != null && configinfo.containsKey("inheritablePathAcl")) {
inheritablePathAcl = Boolean.parseBoolean(configinfo.get("inheritablePathAcl"));
isilonSMBShare.setInheritablePathAcl(inheritablePathAcl);
}
// new share
if (zoneName != null) {
_log.debug("Share will be created in zone: {}", zoneName);
shareId = isi.createShare(isilonSMBShare, zoneName);
} else {
shareId = isi.createShare(isilonSMBShare);
}
}
smbFileShare.setNativeId(shareId);
// Set Mount Point
smbFileShare.setMountPoint(smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
// int file share map
if (args.getFileObjShares() == null) {
args.initFileObjShares();
}
args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiDeleteShares.
private void isiDeleteShares(IsilonApi isi, FileDeviceInputOutput args) throws IsilonException {
_log.info("IsilonFileStorageDevice:isiDeleteShares()");
SMBShareMap currentShares = null;
if (args.getFileOperation()) {
FileShare fileObj = args.getFs();
if (fileObj != null) {
currentShares = fileObj.getSMBFileShares();
}
} else {
Snapshot snap = args.getFileSnapshot();
if (snap != null) {
currentShares = snap.getSMBFileShares();
}
}
if (currentShares == null || currentShares.isEmpty()) {
return;
}
Set<String> deletedShares = new HashSet<String>();
Iterator<Map.Entry<String, SMBFileShare>> it = currentShares.entrySet().iterator();
String zoneName = getZoneName(args.getvNAS());
try {
while (it.hasNext()) {
Map.Entry<String, SMBFileShare> entry = it.next();
String key = entry.getKey();
SMBFileShare smbFileShare = entry.getValue();
_log.info("delete the share name {} and native id {}", smbFileShare.getName(), smbFileShare.getNativeId());
if (zoneName != null) {
isi.deleteShare(smbFileShare.getNativeId(), zoneName);
} else {
isi.deleteShare(smbFileShare.getNativeId());
}
// 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.
deletedShares.add(key);
}
} finally {
// remove shares from the map in database.
for (String key : deletedShares) {
currentShares.remove(key);
}
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method doShare.
/**
* Creates FileShare CIFS/SMB shares
*
* @param StorageSystem storage
* @param SMBFileShare smbFileShare
* @return BiosCommandResult
* @throws ControllerException
*/
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
// To be in-sync with isilon implementation, currently forceGroup is
// set to null which will set the group name as "everyone" by default.
String forceGroup = null;
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppFileStorageDevice doShare - start");
SMBShareMap smbShareMap = args.getFileObjShares();
SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
Boolean modOrCreateShareSuccess;
if (existingShare != null) {
modOrCreateShareSuccess = modifyNtpShare(storage, args, smbFileShare, forceGroup, existingShare);
} else {
modOrCreateShareSuccess = createNtpShare(storage, args, smbFileShare, forceGroup);
}
if (modOrCreateShareSuccess.booleanValue() == true) {
_log.info("NetAppFileStorageDevice doShare {} - complete", smbFileShare.getName());
// Update the collection.
if (args.getFileObjShares() == null) {
args.initFileObjShares();
}
// set Mount Point
smbFileShare.setMountPoint(smbFileShare.getNetBIOSName(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
result = BiosCommandResult.createSuccessfulResult();
} else {
_log.error("NetAppFileStorageDevice doShare {} - failed", smbFileShare.getName());
ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileShare();
result = BiosCommandResult.createErrorResult(serviceError);
}
} catch (NetAppException e) {
_log.error("NetAppFileStorageDevice::doShare failed with a NetAppException", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileShare();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppFileStorageDevice::doShare failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileShare();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileSMBShare method getSMBFileShare.
public SMBFileShare getSMBFileShare() {
SMBFileShare smbShare = new SMBFileShare(_name, _description, _permissionType.toString(), _permission.toString(), _maxUsers, _mountPoint);
smbShare.setNativeId(_nativeId);
smbShare.setPortGroup(_storagePortGroup);
smbShare.setPath(_path);
smbShare.setSubDir(_isSubDirPath);
smbShare.setStoragePortName(_storagePortName);
smbShare.setStoragePortNetworkId(_storagePortNetworkId);
smbShare.setNetBIOSName(_NetBIOSName);
return smbShare;
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class VNXFileCommApi method deleteAllExportsAndShares.
private XMLApiResult deleteAllExportsAndShares(StorageSystem system, StorageHADomain dataMover, FileShare fs, Snapshot snapshot) {
FSExportMap exports;
SMBShareMap shares;
XMLApiResult result = new XMLApiResult();
result.setCommandSuccess();
String fileId = fs.getId().toString();
FileObject fObj = fs;
_log.info("deleteAllExportsAndShares for {} {}", fs.getName(), snapshot);
boolean fileOperation = false;
if (snapshot == null) {
// FileShare operation
_log.info("deleteAllExportsAndShares FileShare delete operation");
exports = fs.getFsExports();
shares = fs.getSMBFileShares();
fileOperation = true;
fObj = fs;
} else {
_log.info("deleteAllExportsAndShares Snapshot delete operation");
exports = snapshot.getFsExports();
shares = snapshot.getSMBFileShares();
fObj = snapshot;
fileId = snapshot.getId().toString();
}
int exportsToUnExport = 0;
Set<String> keys = new HashSet();
if (exports != null) {
exportsToUnExport = exports.size();
keys = exports.keySet();
}
int noOfShares = 0;
if (shares != null) {
noOfShares = shares.size();
}
_log.info("Number of NFS exports {} SMB Shares found {} for File/Snapshot Id {}", new Object[] { exportsToUnExport, noOfShares, fileId });
// To avoid concurrent modification exceptions
Set<String> exportKeys = new HashSet();
exportKeys.addAll(keys);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.setFileOperation(fileOperation);
args.addFSFileObject(fs);
if (fileOperation) {
args.setFileOperation(true);
args.addFSFileObject(fs);
} else {
args.setFileOperation(false);
args.addFSFileObject(fs);
args.addSnapshot(snapshot);
}
for (String key : exportKeys) {
FileExport exp = exports.get(key);
VNXFileExport fileExport = new VNXFileExport(exp.getClients(), exp.getStoragePortName(), exp.getPath(), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getSubDirectory(), exp.getComments());
fileExport.setStoragePort(fs.getStoragePort().toString());
boolean deleteMount = false;
if (exportsToUnExport == 1 && noOfShares == 0 && fileOperation) {
deleteMount = true;
}
XMLApiResult status = doUnexport(system, fileExport, args, deleteMount);
if (!status.isCommandSuccess()) {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
} else {
fObj.getFsExports().remove(key);
_log.info("Export removed : " + key);
exportsToUnExport--;
}
// Persist the object after exports removed
_dbClient.persistObject(fObj);
}
// Now Let Handle SMB/CIFS Shares
keys = new HashSet<>();
int noOfSharesToDelete = 0;
if (shares != null) {
keys = shares.keySet();
noOfSharesToDelete = keys.size();
}
int noOfExports = 0;
if (exports != null) {
noOfExports = exports.size();
}
_log.info("Number of CIFS/SMB Shares {} NFS Exports found {} for File/Snapshot Id {}", new Object[] { noOfSharesToDelete, noOfExports, fileId });
// To avoid concurrent modification exceptions
Set<String> shareKeys = new HashSet();
shareKeys.addAll(keys);
for (String key : shareKeys) {
SMBFileShare share = shares.get(key);
_log.info("Delete SMB/CIFS Share {} from FS/Snapshot {}", share.getName(), fileId);
boolean deleteMount = false;
if (noOfSharesToDelete == 1 && noOfExports == 0 && fileOperation) {
deleteMount = true;
}
XMLApiResult status = doDeleteShare(system, dataMover, share.getName(), fs.getMountPath(), deleteMount, args);
if (!status.isCommandSuccess()) {
_log.info("SMBFileShare deletion failed key {} : {} ", key, share.getName());
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
} else {
fObj.getSMBFileShares().remove(key);
_log.info("SMBFileShare removed : " + key);
noOfSharesToDelete--;
}
// Persist the object after SMBShares removed
_dbClient.persistObject(fObj);
}
return result;
}
Aggregations