use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method getNASUri.
/**
* get the nas or vnas uri
*
* @param storageHADomain
* @param storageSystem
* @return
*/
private URI getNASUri(StorageHADomain storageHADomain, StorageSystem storageSystem) {
URI moverURI = null;
if (storageHADomain.getVirtual() == true) {
VirtualNAS virtualNAS = findvNasByNativeId(storageSystem, storageHADomain.getName());
moverURI = virtualNAS.getId();
} else {
PhysicalNAS physicalNAS = findPhysicalNasByNativeId(storageSystem, storageHADomain.getName());
moverURI = physicalNAS.getId();
}
return moverURI;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discoverNasServers.
/**
* Discover the NasServer (Port Groups) for the specified VNXe storage
* array.
*
* @param system
* storage system information
* @param client
* VNXeServiceClient
* @param nasServerIdMap
* all valid nasServer id map
* @param arraySupportedProtocol
* array supported protocol
* @return Map of New and Existing NasServers
* @throws VNXeException
*/
private HashMap<String, List<StorageHADomain>> discoverNasServers(StorageSystem system, VNXeApiClient client, Map<String, URI> nasServerIdMap, StringSet arraySupportedProtocols) throws VNXeException {
HashMap<String, List<StorageHADomain>> allNasServers = new HashMap<String, List<StorageHADomain>>();
List<StorageHADomain> newNasServers = new ArrayList<StorageHADomain>();
List<StorageHADomain> existingNasServers = new ArrayList<StorageHADomain>();
List<VirtualNAS> newVirtualNas = new ArrayList<VirtualNAS>();
List<VirtualNAS> existingVirtualNas = new ArrayList<VirtualNAS>();
boolean isNFSSupported = false;
boolean isCIFSSupported = false;
boolean isBothSupported = false;
_logger.info("Start NasServer discovery for storage system {}", system.getId());
List<VNXeNasServer> nasServers = client.getNasServers();
List<VNXeCifsServer> cifsServers = client.getCifsServers();
List<VNXeNfsServer> nfsServers = client.getNfsServers();
for (VNXeNasServer nasServer : nasServers) {
StorageHADomain haDomain = null;
if (null == nasServer) {
_logger.debug("Null data mover in list of port groups.");
continue;
}
if ((nasServer.getMode() == VNXeNasServer.NasServerModeEnum.DESTINATION) || nasServer.getIsReplicationDestination()) {
_logger.debug("Found a replication destination NasServer");
// On failover the existing Nas server becomes the destination. So changing state to unknown as it
// should not be picked for provisioning.
VirtualNAS vNas = findvNasByNativeId(system, nasServer.getId());
if (vNas != null) {
vNas.setNasState(VirtualNasState.UNKNOWN.name());
existingVirtualNas.add(vNas);
}
continue;
}
if (nasServer.getIsSystem()) {
// skip system nasServer
continue;
}
StringSet protocols = new StringSet();
// Check if port group was previously discovered
URIQueryResultList results = new URIQueryResultList();
String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nasServer.getName(), NativeGUIDGenerator.ADAPTER);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
Iterator<URI> it = results.iterator();
if (it.hasNext()) {
StorageHADomain tmpDomain = _dbClient.queryObject(StorageHADomain.class, it.next());
if (tmpDomain.getStorageDeviceURI().equals(system.getId())) {
haDomain = tmpDomain;
_logger.debug("Found duplicate {} ", nasServer.getName());
}
}
// get the supported protocol on the nasServer
if (cifsServers != null && !cifsServers.isEmpty()) {
for (VNXeCifsServer cifsServer : cifsServers) {
if (cifsServer.getNasServer().getId().equals(nasServer.getId())) {
protocols.add(StorageProtocol.File.CIFS.name());
isCIFSSupported = true;
break;
}
}
}
if (nfsServers != null && !nfsServers.isEmpty()) {
for (VNXeNfsServer nfsServer : nfsServers) {
if (nfsServer.getNasServer() != null) {
if (nfsServer.getNasServer().getId().equals(nasServer.getId())) {
protocols.add(StorageProtocol.File.NFS.name());
isNFSSupported = true;
break;
}
}
}
}
if (protocols.size() == 2) {
// this nasServer support both
isBothSupported = true;
}
// If the nasServer was not previously discovered
if (haDomain == null) {
haDomain = new StorageHADomain();
haDomain.setId(URIUtil.createId(StorageHADomain.class));
haDomain.setNativeGuid(adapterNativeGuid);
haDomain.setStorageDeviceURI(system.getId());
haDomain.setAdapterName(nasServer.getName());
haDomain.setName(nasServer.getName());
haDomain.setSerialNumber(nasServer.getId());
newNasServers.add(haDomain);
} else {
existingNasServers.add(haDomain);
}
haDomain.setFileSharingProtocols(protocols);
haDomain.setVirtual(true);
nasServerIdMap.put(nasServer.getId(), haDomain.getId());
CifsServerMap cifsServersMap = new CifsServerMap();
for (VNXeCifsServer cifsServer : cifsServers) {
if (cifsServer.getNasServer().getId().equals(nasServer.getId())) {
_logger.info("Cifs Server {} for {} ", cifsServer.getName(), nasServer.getName());
if (!cifsServer.getFileInterfaces().isEmpty()) {
_logger.info("{} has CIFS Enabled since interfaces are found ", nasServer.getName(), cifsServer.getName() + ":" + cifsServer.getFileInterfaces());
protocols.add(StorageProtocol.File.CIFS.name());
NasCifsServer nasCifsServer = new NasCifsServer();
nasCifsServer.setId(cifsServer.getId());
nasCifsServer.setMoverIdIsVdm(true);
nasCifsServer.setName(cifsServer.getName());
nasCifsServer.setDomain(cifsServer.getDomain());
cifsServersMap.put(cifsServer.getName(), nasCifsServer);
}
}
}
VirtualNAS vNas = findvNasByNativeId(system, nasServer.getId());
// If the nasServer was not previously discovered
if (vNas == null) {
vNas = new VirtualNAS();
vNas.setId(URIUtil.createId(VirtualNAS.class));
String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nasServer.getId(), NativeGUIDGenerator.VIRTUAL_NAS);
vNas.setNativeGuid(nasNativeGuid);
vNas.setStorageDeviceURI(system.getId());
vNas.setNasName(nasServer.getName());
vNas.setNativeId(nasServer.getId());
newVirtualNas.add(vNas);
} else {
existingVirtualNas.add(vNas);
}
vNas.setProtocols(protocols);
vNas.setNasState(VirtualNasState.LOADED.name());
vNas.setCifsServersMap(cifsServersMap);
}
// Persist the NAS servers!!!
if (existingVirtualNas != null && !existingVirtualNas.isEmpty()) {
_logger.info("discoverNasServers - modified VirtualNAS servers size {}", existingVirtualNas.size());
_dbClient.updateObject(existingVirtualNas);
}
if (newVirtualNas != null && !newVirtualNas.isEmpty()) {
_logger.info("discoverNasServers - new VirtualNAS servers size {}", newVirtualNas.size());
_dbClient.createObject(newVirtualNas);
}
if (isBothSupported) {
arraySupportedProtocols.add(StorageProtocol.File.NFS.name());
arraySupportedProtocols.add(StorageProtocol.File.CIFS.name());
} else if (isNFSSupported && isCIFSSupported) {
arraySupportedProtocols.add(StorageProtocol.File.NFS_OR_CIFS.name());
} else if (isNFSSupported) {
arraySupportedProtocols.add(StorageProtocol.File.NFS.name());
} else if (isCIFSSupported) {
arraySupportedProtocols.add(StorageProtocol.File.CIFS.name());
}
_logger.info("NasServer discovery for storage system {} complete.", system.getId());
for (StorageHADomain newDomain : newNasServers) {
_logger.info("New NasServer : {} : {}", newDomain.getNativeGuid(), newDomain.getId());
}
for (StorageHADomain domain : existingNasServers) {
_logger.info("Existing NasServer : {} : {}", domain.getNativeGuid(), domain.getId());
}
allNasServers.put(NEW, newNasServers);
allNasServers.put(EXISTING, existingNasServers);
return allNasServers;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method prepareFileDeviceInputOutput.
private FileDeviceInputOutput prepareFileDeviceInputOutput(boolean forceDelete, URI uri, String opId) {
FileDeviceInputOutput args = new FileDeviceInputOutput();
boolean isFile = false;
args.setOpId(opId);
if (URIUtil.isType(uri, FileShare.class)) {
isFile = true;
args.setForceDelete(forceDelete);
FileShare fsObj = _dbClient.queryObject(FileShare.class, uri);
if (fsObj.getVirtualNAS() != null) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, fsObj.getVirtualNAS());
args.setvNAS(vNAS);
}
args.addFileShare(fsObj);
args.setFileOperation(isFile);
}
return args;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doCreateFS.
@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
Boolean fsDirExists = true;
Boolean fsDirCreatedByMe = false;
try {
_log.info("IsilonFileStorageDevice doCreateFS {} with name {} - start", args.getFsId(), args.getFsName());
IsilonApi isi = getIsilonDevice(storage);
VirtualNAS vNAS = args.getvNAS();
String vNASPath = null;
// get the custom path from the controller configuration
String customPath = getCustomPath(storage, args);
if (vNAS != null) {
vNASPath = vNAS.getBaseDirPath();
_log.info("vNAS base directory path: {}", vNASPath);
}
String usePhysicalNASForProvisioning = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.USE_PHYSICAL_NAS_FOR_PROVISIONING, "isilon", null);
_log.info("Use System access zone to provision filesystem? {}", usePhysicalNASForProvisioning);
String mountPath = null;
String fsName = args.getFsName();
if (args.getFs().getPersonality() != null && args.getFs().getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
FileShare fsParent = _dbClient.queryObject(FileShare.class, args.getFs().getParentFileShare().getURI());
fsName = fsParent.getName();
// Add if there is any suffix in target fs label!!
if (args.getFs().getLabel().contains("-target")) {
String[] fsNameSuffix = args.getFs().getLabel().split(fsParent.getName() + "-target");
if (fsNameSuffix != null && fsNameSuffix.length > 1 && !fsNameSuffix[1].isEmpty()) {
fsName = fsName + fsNameSuffix[1];
}
} else if (args.getFs().getLabel().contains("-localTarget")) {
String[] fsNameSuffix = args.getFs().getLabel().split(fsParent.getName() + "-localTarget");
if (fsNameSuffix != null && fsNameSuffix.length > 1 && !fsNameSuffix[1].isEmpty()) {
fsName = fsName + fsNameSuffix[1];
}
}
}
// Update the mount path as required
if (vNASPath != null && !vNASPath.trim().isEmpty()) {
mountPath = vNASPath + FW_SLASH + customPath + FW_SLASH + fsName;
} else if (Boolean.valueOf(usePhysicalNASForProvisioning)) {
mountPath = IFS_ROOT + FW_SLASH + getSystemAccessZoneNamespace() + FW_SLASH + customPath + FW_SLASH + fsName;
} else {
_log.error("No suitable access zone found for provisioning. Provisioning on System access zone is disabled");
throw DeviceControllerException.exceptions.createFileSystemOnPhysicalNASDisabled();
}
// replace extra forward slash with single one
mountPath = mountPath.replaceAll("/+", "/");
_log.info("Mount path to mount the Isilon File System {}", mountPath);
args.setFsMountPath(mountPath);
args.setFsNativeGuid(args.getFsMountPath());
args.setFsNativeId(args.getFsMountPath());
args.setFsPath(args.getFsMountPath());
// Update the mount path for local target!!!
updateLocalTargetFileSystemPath(storage, args);
// Create the target directory only if the replication policy was not applied!!
// If policy was applied at higher level, policy would create target file system directories!
boolean replicationExistsOnTarget = FileOrchestrationUtils.isReplicationPolicyExistsOnTarget(_dbClient, storage, args.getVPool(), args.getProject(), args.getFs());
if (FileOrchestrationUtils.isPrimaryFileSystemOrNormalFileSystem(args.getFs()) || !replicationExistsOnTarget) {
if (!replicationExistsOnTarget) {
// Verify if the path of the new policy to be created only if the policy does not exist in the storage system
checkNewPolicyPathHasData(args.getVPool(), args.getProject(), args.getFs(), args.getvNAS(), isi);
}
// Verify the file system directory exists or not!!
fsDirExists = isi.existsDir(args.getFsMountPath());
if (!fsDirExists) {
// create directory for the file share
isi.createDir(args.getFsMountPath(), true);
fsDirCreatedByMe = true;
} else {
// Fail to create file system, as the directory already exists!!
_log.error("File system creation failed due to directory path {} already exists.", args.getFsMountPath());
throw DeviceControllerException.exceptions.failToCreateFileSystem(args.getFsMountPath());
}
Long softGrace = null;
if (args.getFsSoftGracePeriod() != null) {
softGrace = Long.valueOf(args.getFsSoftGracePeriod());
}
// set quota - save the quota id to extensions
String qid = createQuotaWithThreshold(args.getFsMountPath(), args.getFsCapacity(), args.getFsSoftLimit(), args.getFsNotificationLimit(), softGrace, null, isi);
if (args.getFsExtensions() == null) {
args.initFsExtensions();
}
args.getFsExtensions().put(QUOTA, qid);
}
// set protection level
// String protection = args.getFSProtectionLevel();
// Call isilon api to set protection level
_log.info("IsilonFileStorageDevice doCreateFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doCreateFS failed.", e);
// delete the fs directory alone!!!
if (fsDirCreatedByMe) {
// delete isilon directory
_log.info("doCreateFS failed, deleting the isilon directory {} which has been created in this workflow", args.getFsMountPath());
IsilonApi isi = getIsilonDevice(storage);
isi.deleteDir(args.getFsMountPath());
}
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method getStoragePortVirtualNAS.
/**
* Returns VirtualNAS associated with the given storage port
*
* @param sp StorgaePort
* @param dbClient
* @return VirtualNAS associated with StorgaePort
*/
public static List<VirtualNAS> getStoragePortVirtualNAS(StoragePort sp, DbClient dbClient) {
List<VirtualNAS> virtualNASList = new ArrayList<VirtualNAS>();
URIQueryResultList vNasUriList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualNASContainStoragePortConstraint(sp.getId()), vNasUriList);
Iterator<URI> vNasIter = vNasUriList.iterator();
while (vNasIter.hasNext()) {
VirtualNAS vNas = dbClient.queryObject(VirtualNAS.class, vNasIter.next());
if (vNas != null && !vNas.getInactive()) {
virtualNASList.add(vNas);
_log.info("Found virtual NAS: {} for storageport: {}", vNas.getNasName(), sp.getLabel());
}
}
return virtualNASList;
}
Aggregations