use of com.emc.storageos.db.client.model.SMBShareMap in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteShares.
@Override
public BiosCommandResult doDeleteShares(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteShares: {} - start");
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteShares failed, provider unreachable");
String op = "FS shares delete";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
SMBShareMap currentShares = args.getFileObjShares();
List<SMBFileShare> sharesToDelete = new ArrayList<SMBFileShare>();
sharesToDelete.addAll(currentShares.values());
ddDeleteShares(ddClient, storagePool.getNativeId(), currentShares, sharesToDelete);
_log.info("DataDomainFileStorageDevice doDeleteShare {} - complete");
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doDeleteShare failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.SMBShareMap 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.SMBShareMap 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.SMBShareMap 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.SMBShareMap in project coprhd-controller by CoprHD.
the class FileDeviceInputOutput method isFileShareMounted.
public boolean isFileShareMounted() {
FSExportMap exports = getFs().getFsExports();
SMBShareMap shares = getFs().getSMBFileShares();
boolean isMounted = true;
if ((exports == null || (exports != null && exports.isEmpty())) && (shares == null || (shares != null && shares.isEmpty()))) {
isMounted = false;
}
return isMounted;
}
Aggregations