use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileService method getFileSystemShare.
/**
* Get the SMB share for the specified file system.
*
* @param id
* the URN of a ViPR File system
* @param shareName
* file system share name
* @brief Show specified share
* @return List of file system shares.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public SmbShareResponse getFileSystemShare(@PathParam("id") URI id, @PathParam("shareName") String shareName) throws InternalException {
_log.info(String.format("Get SMB file share %s for file system: %s", shareName, id.toString()));
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
ArgValidator.checkFieldNotNull(shareName, "shareName");
FileShare fileShare = queryResource(id);
SMBFileShare smbShare = null;
FileSystemShareList fileShareListResponse = new FileSystemShareList();
SmbShareResponse shareParam = null;
if (fileShare.getSMBFileShares() != null) {
_log.info("Number of SMBShares found {} and looking for share to read {} ", fileShare.getSMBFileShares().size(), shareName);
_log.info(String.format("Get file system share: file system id: %1$s, share name %2$s", id, shareName));
smbShare = fileShare.getSMBFileShares().get(shareName);
if (smbShare == null) {
_log.info("CIFS share does not exist {}", shareName);
} else {
shareParam = new SmbShareResponse();
shareParam.setShareName(smbShare.getName());
shareParam.setDescription(smbShare.getDescription());
shareParam.setMaxUsers(Integer.toString(smbShare.getMaxUsers()));
// Check for "unlimited"
if (shareParam.getMaxUsers().equals("-1")) {
shareParam.setMaxUsers(UNLIMITED_USERS);
}
shareParam.setPermissionType(smbShare.getPermissionType());
shareParam.setPermission(smbShare.getPermission());
shareParam.setMountPoint(smbShare.getMountPoint());
shareParam.setPath(smbShare.getPath());
}
}
return shareParam;
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class FileQuotaDirectoryService method quotaDirectoryHasExportsOrShares.
/**
* This method verifies the file system quota directory has any exports or shares
*
* @param fs - file system on which the QD present
* @param quotaName - name of the QD
* @return true - if there are any exports or shares, false otherwise.
*/
private boolean quotaDirectoryHasExportsOrShares(FileShare fs, String quotaName) {
FSExportMap fsExportMap = fs.getFsExports();
// Verify for NFS exports on quota directory
if (fsExportMap != null && !fsExportMap.isEmpty()) {
// check the quota directory is exported
for (FileExport fileExport : fsExportMap.values()) {
if (quotaName.equals(fileExport.getSubDirectory()) && fileExport.getPath().endsWith(quotaName)) {
_log.info("quota directory {} on fs {} has NFS exports", quotaName, fs.getLabel());
return true;
}
}
}
// Verify for CIFS shares on quota directory
SMBShareMap smbShareMap = fs.getSMBFileShares();
if (smbShareMap != null && !smbShareMap.isEmpty()) {
for (SMBFileShare smbFileShare : smbShareMap.values()) {
// check for quota name in native fs path
if (smbFileShare.getPath().endsWith("/" + quotaName)) {
_log.info("quota directory {} on fs {} has CIFS shares", quotaName, fs.getLabel());
return true;
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class PropertySetterUtil method convertUnManagedSMBMapToManaged.
/**
* Extract SMB data from UnManaged to Managed
*
* @param unManagedSMBShareMap
* @return
*/
public static SMBShareMap convertUnManagedSMBMapToManaged(UnManagedSMBShareMap unManagedSMBShareMap, StoragePort storagePort, StorageHADomain dataMover) {
SMBShareMap smbShareMap = new SMBShareMap();
if (unManagedSMBShareMap == null) {
return smbShareMap;
}
SMBFileShare smbshare = null;
for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBShareMap.values()) {
smbshare = new SMBFileShare();
smbshare.setName(unManagedSMBFileShare.getName());
smbshare.setNativeId(unManagedSMBFileShare.getNativeId());
smbshare.setDescription(unManagedSMBFileShare.getDescription());
if (storagePort != null) {
smbshare.setMountPoint("\\\\" + storagePort.getPortNetworkId() + "\\" + unManagedSMBFileShare.getName());
} else {
smbshare.setMountPoint(unManagedSMBFileShare.getMountPoint());
}
smbshare.setPath(unManagedSMBFileShare.getPath());
// need to removed
smbshare.setMaxUsers(unManagedSMBFileShare.getMaxUsers());
smbshare.setPermission(unManagedSMBFileShare.getPermission());
smbshare.setPermissionType(unManagedSMBFileShare.getPermissionType());
smbshare.setPortGroup(storagePort.getPortGroup());
// share name
smbShareMap.put(unManagedSMBFileShare.getName(), smbshare);
}
return smbShareMap;
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiDeleteShare.
private void isiDeleteShare(IsilonApi isi, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws IsilonException {
SMBShareMap currentShares = args.getFileObjShares();
// Do nothing if there are no shares
if (currentShares == null || smbFileShare == null) {
return;
}
SMBFileShare fileShare = currentShares.get(smbFileShare.getName());
if (fileShare != null) {
String nativeId = fileShare.getNativeId();
String zoneName = getZoneName(args.getvNAS());
_log.info("delete the share {} with native id {}", smbFileShare.getName(), nativeId);
if (zoneName != null) {
isi.deleteShare(nativeId, zoneName);
} else {
isi.deleteShare(nativeId);
}
currentShares.remove(smbFileShare.getName());
}
}
use of com.emc.storageos.db.client.model.SMBFileShare in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteShare: {} - start");
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteShare failed, provider unreachable");
String op = "FS share 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.add(smbFileShare);
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);
}
}
Aggregations