use of com.emc.storageos.vnx.xmlapi.VNXVdm in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverVdmPortGroups.
/**
* Discover the Data Movers (Port Groups) for the specified VNX File storage array.
*
* @param system storage system information including credentials.
* @param movers Collection of all DataMovers in the VNX File storage array
* @return Map of New and Existing VDM port groups
* @throws VNXFileCollectionException
*/
private HashMap<String, List<StorageHADomain>> discoverVdmPortGroups(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException {
HashMap<String, List<StorageHADomain>> portGroups = new HashMap();
List<StorageHADomain> newPortGroups = new ArrayList<StorageHADomain>();
List<StorageHADomain> existingPortGroups = new ArrayList<StorageHADomain>();
_logger.info("Start vdm port group discovery for storage system {}", system.getId());
List<VirtualNAS> newNasServers = new ArrayList<VirtualNAS>();
List<VirtualNAS> existingNasServers = new ArrayList<VirtualNAS>();
List<VNXVdm> vdms = getVdmPortGroups(system);
_logger.debug("Number VDM found: {}", vdms.size());
VNXFileSshApi sshDmApi = new VNXFileSshApi();
sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
for (VNXVdm vdm : vdms) {
StorageHADomain portGroup = null;
// Check supported network file sharing protocols.
StringSet protocols = new StringSet();
if (null == vdm) {
_logger.debug("Null vdm in list of port groups.");
continue;
}
// Check if port group was previously discovered
URIQueryResultList results = new URIQueryResultList();
String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vdm.getVdmName(), NativeGUIDGenerator.ADAPTER);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
Iterator<URI> iter = results.iterator();
while (iter.hasNext()) {
StorageHADomain tmpGroup = _dbClient.queryObject(StorageHADomain.class, iter.next());
if (tmpGroup != null && !tmpGroup.getInactive() && tmpGroup.getStorageDeviceURI().equals(system.getId())) {
portGroup = tmpGroup;
_logger.debug("Found duplicate {} ", vdm.getVdmName());
break;
}
}
Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
Set<String> intfs = null;
if (vdmIntfs != null) {
intfs = vdmIntfs.keySet();
}
// if NFS Interfaces are not there ignore this..
if (vdmIntfs == null || intfs.isEmpty()) {
// There are no interfaces for this VDM via nas_server command
// so ignore this
_logger.info("Ignoring VDM {} because no NFS interfaces found via ssh query", vdm.getVdmName());
} else {
_logger.info("Process VDM {} because interfaces found {}", vdm.getVdmName(), vdmIntfs.keySet().size());
}
for (String intf : intfs) {
String vdmCapability = vdmIntfs.get(intf);
_logger.info("Interface {} capability [{}]", vdm.getVdmName() + ":" + intf, vdmCapability);
if (vdmCapability.contains("cifs")) {
_logger.info("{} has CIFS Enabled since interfaces are found ", vdm.getVdmName(), intf + ":" + vdmCapability);
protocols.add(StorageProtocol.File.CIFS.name());
}
if (vdmCapability.contains("vdm")) {
_logger.info("{} has NFS Enabled since interfaces are found ", vdm.getVdmName(), intf + ":" + vdmCapability);
protocols.add(StorageProtocol.File.NFS.name());
}
}
List<VNXCifsServer> cifsServers = getCifServers(system, vdm.getVdmId(), "true");
CifsServerMap cifsServersMap = new CifsServerMap();
for (VNXCifsServer cifsServer : cifsServers) {
_logger.info("Cifs Server {} for {} ", cifsServer.getName(), vdm.getVdmName());
if (!cifsServer.getInterfaces().isEmpty()) {
_logger.info("{} has CIFS Enabled since interfaces are found ", vdm.getVdmName(), cifsServer.getName() + ":" + cifsServer.getInterfaces());
protocols.add(StorageProtocol.File.CIFS.name());
NasCifsServer nasCifsServer = new NasCifsServer();
nasCifsServer.setId(cifsServer.getId());
nasCifsServer.setInterfaces(cifsServer.getInterfaces());
nasCifsServer.setMoverIdIsVdm(cifsServer.getMoverIdIsVdm());
nasCifsServer.setName(cifsServer.getName());
nasCifsServer.setType(cifsServer.getType());
nasCifsServer.setDomain(cifsServer.getDomain());
cifsServersMap.put(cifsServer.getName(), nasCifsServer);
}
}
if (protocols.isEmpty()) {
// No valid interfaces found and ignore this
_logger.info("Ignoring VDM {} because no NFS/CIFS interfaces found ", vdm.getVdmName());
continue;
}
// If the data mover (aka port group) was not previously discovered
if (portGroup == null) {
portGroup = new StorageHADomain();
portGroup.setId(URIUtil.createId(StorageHADomain.class));
portGroup.setNativeGuid(adapterNativeGuid);
portGroup.setStorageDeviceURI(system.getId());
portGroup.setAdapterName(vdm.getVdmName());
portGroup.setName(vdm.getVdmId());
portGroup.setFileSharingProtocols(protocols);
portGroup.setVirtual(true);
portGroup.setAdapterType(StorageHADomain.HADomainType.VIRTUAL.toString());
// Get parent Data Mover
StorageHADomain matchingParentMover = getMatchingMoverById(movers, vdm.getMoverId());
// Check for valid data mover
if (null != matchingParentMover) {
portGroup.setParentHADomainURI(matchingParentMover.getId());
} else {
_logger.info("Matching parent DataMover {} for {} not found ", vdm.getMoverId(), vdm.getVdmName());
}
_logger.info("Found Vdm {} at {}", vdm.getVdmName(), vdm.getVdmId() + "@" + vdm.getMoverId());
newPortGroups.add(portGroup);
} else {
// For rediscovery if cifs is not enabled
portGroup.setFileSharingProtocols(protocols);
existingPortGroups.add(portGroup);
}
VirtualNAS existingNas = findvNasByNativeId(system, vdm.getVdmId());
if (existingNas != null) {
existingNas.setProtocols(protocols);
existingNas.setCifsServersMap(cifsServersMap);
existingNas.setNasState(vdm.getState());
existingNas.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
PhysicalNAS parentNas = findPhysicalNasByNativeId(system, vdm.getMoverId());
if (parentNas != null) {
existingNas.setParentNasUri(parentNas.getId());
}
existingNasServers.add(existingNas);
} else {
VirtualNAS vNas = createVirtualNas(system, vdm);
if (vNas != null) {
vNas.setProtocols(protocols);
vNas.setCifsServersMap(cifsServersMap);
newNasServers.add(vNas);
}
}
}
List<VirtualNAS> discoveredVNasServers = new ArrayList<VirtualNAS>();
// Persist the NAS servers!!!
if (existingNasServers != null && !existingNasServers.isEmpty()) {
_logger.info("discoverVdmPortGroups - modified VirtualNAS servers size {}", existingNasServers.size());
_dbClient.persistObject(existingNasServers);
discoveredVNasServers.addAll(existingNasServers);
}
if (newNasServers != null && !newNasServers.isEmpty()) {
_logger.info("discoverVdmPortGroups - new VirtualNAS servers size {}", newNasServers.size());
_dbClient.createObject(newNasServers);
discoveredVNasServers.addAll(newNasServers);
}
// Verify the existing vnas servers!!!
DiscoveryUtils.checkVirtualNasNotVisible(discoveredVNasServers, _dbClient, system.getId());
_logger.info("Vdm Port group discovery for storage system {} complete.", system.getId());
for (StorageHADomain newDomain : newPortGroups) {
_logger.debug("New Storage Domain : {} : {}", newDomain.getNativeGuid(), newDomain.getAdapterName() + ":" + newDomain.getId());
}
for (StorageHADomain domain : existingPortGroups) {
_logger.debug("Old Storage Domain : {} : {}", domain.getNativeGuid(), domain.getAdapterName() + ":" + domain.getId());
}
// return portGroups;
portGroups.put(NEW, newPortGroups);
portGroups.put(EXISTING, existingPortGroups);
return portGroups;
}
Aggregations