use of com.emc.storageos.vnxe.models.VNXeCifsServer in project coprhd-controller by CoprHD.
the class VNXeApiClient method createCifsShareForSnap.
/**
* Create CIFS share for snapshot
*
* @param snapId
* snapshot id
* @param shareName
* CIFS share name
* @param permission
* READ, CHANGE, FULL
* @return VNXeCommandJob
* @throws VNXeException
*/
public VNXeCommandJob createCifsShareForSnap(String snapId, String shareName, String permission, String path, String fsId) throws VNXeException {
_logger.info("Creating CIFS snapshot share name: {} for path: {}", shareName, path);
// to get NETBIOS of CIFS Server file system is used as for snapshot
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
List<VNXeCifsServer> cifsServers = getCifsServers(fs.getNasServer().getId());
netBios = cifsServers.get(0).getNetbiosName();
CifsShareRequests req = new CifsShareRequests(_khClient);
CifsShareCreateForSnapParam param = new CifsShareCreateForSnapParam();
param.setPath(path);
VNXeBase snap = new VNXeBase();
snap.setId(snapId);
if (!VNXeUtils.isHigherVersion(getBasicSystemInfo().getSoftwareVersion(), VNXeConstants.VNXE_BASE_SOFT_VER)) {
param.setFilesystemSnap(snap);
} else {
param.setSnap(snap);
}
param.setName(shareName);
if (permission != null && !permission.isEmpty() && permission.equalsIgnoreCase(AccessEnum.READ.name())) {
param.setIsReadOnly(true);
} else {
param.setIsReadOnly(false);
}
return req.createShareForSnapshot(param);
}
use of com.emc.storageos.vnxe.models.VNXeCifsServer in project coprhd-controller by CoprHD.
the class VNXeCommunicationInterface 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>();
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) {
_logger.debug("Found a replication destination NasServer");
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);
if (results.iterator().hasNext()) {
StorageHADomain tmpDomain = _dbClient.queryObject(StorageHADomain.class, results.iterator().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().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());
haDomain.setFileSharingProtocols(protocols);
newNasServers.add(haDomain);
} else {
haDomain.setFileSharingProtocols(protocols);
existingNasServers.add(haDomain);
}
nasServerIdMap.put(nasServer.getId(), haDomain.getId());
}
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());
}
// return portGroups;
allNasServers.put(NEW, newNasServers);
allNasServers.put(EXISTING, existingNasServers);
return allNasServers;
}
use of com.emc.storageos.vnxe.models.VNXeCifsServer 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.vnxe.models.VNXeCifsServer in project coprhd-controller by CoprHD.
the class VNXeApiClient method createCIFSShare.
/**
* create cifsShare
*/
public VNXeCommandJob createCIFSShare(String fsId, String cifsName, String permission, String path) throws VNXeException {
_logger.info("creating CIFS share:" + fsId);
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.info("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
String resourceId = fs.getStorageResource().getId();
ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
CifsShareParam cifsParam = new CifsShareParam();
/*
* CifsShareACE ace = new CifsShareACE();
* ace.setAccessLevel(4);
* ace.setAccessType(1);
* ace.setSid("S-1-5-21-3623811015-3361044348-30300820-1014");
* List<CifsShareACE> aceList = new ArrayList<CifsShareACE>();
* aceList.add(ace);
* cifsParam.setAddACE(aceList);
*/
cifsParam.setIsACEEnabled(false);
if (permission != null && !permission.isEmpty() && permission.equalsIgnoreCase(AccessEnum.READ.name())) {
cifsParam.setIsReadOnly(true);
} else {
cifsParam.setIsReadOnly(false);
}
CifsShareCreateParam cifsCreate = new CifsShareCreateParam();
cifsCreate.setName(cifsName);
cifsCreate.setPath(path);
_logger.info("Creating VNXe CIFS share by name: {} for path: {}", cifsName, path);
List<VNXeCifsServer> cifsServers = getCifsServers(fs.getNasServer().getId());
if (cifsServers == null || cifsServers.isEmpty()) {
throw VNXeException.exceptions.vnxeCommandFailed("The nasServer is not configured to support CIFS");
}
VNXeBase cifsServer = new VNXeBase();
cifsServer.setId(cifsServers.get(0).getId());
cifsCreate.setCifsServer(cifsServer);
cifsCreate.setCifsShareParameters(cifsParam);
netBios = cifsServers.get(0).getNetbiosName();
List<CifsShareCreateParam> cifsCreateList = new ArrayList<CifsShareCreateParam>();
cifsCreateList.add(cifsCreate);
modifyFSParm.setCifsShareCreate(cifsCreateList);
FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
return req.modifyFileSystemAsync(modifyFSParm, resourceId);
}
Aggregations