use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverActiveDataMovers.
private Set<StorageHADomain> discoverActiveDataMovers(StorageSystem storageSystem) {
// Reused from discoverAll
Set<StorageHADomain> activeDataMovers = new HashSet<StorageHADomain>();
StringSet fileSharingProtocols = new StringSet();
Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, fileSharingProtocols);
_logger.info("No of newly discovered groups {}", groups.get(NEW).size());
_logger.info("No of existing discovered groups {}", groups.get(EXISTING).size());
if (!groups.get(NEW).isEmpty()) {
_dbClient.createObject(groups.get(NEW));
}
// Keep a set of active data movers. Data movers in 'standby' state are not added to the
// database since they cannot be used in this state.
List<StorageHADomain> newStorageDomains = groups.get(NEW);
for (StorageHADomain mover : newStorageDomains) {
activeDataMovers.add(mover);
}
List<StorageHADomain> existingStorageDomains = groups.get(EXISTING);
for (StorageHADomain mover : existingStorageDomains) {
activeDataMovers.add(mover);
}
for (StorageHADomain mover : activeDataMovers) {
_logger.info("DataMover {} : {}", mover.getName(), mover.getAdapterName());
}
return activeDataMovers;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverUnManagedCifsShares.
private void discoverUnManagedCifsShares(AccessProfile profile) {
// Get Storage System
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
String detailedStatusMessage = "Discovery of VNX Unmanaged Shares started";
_logger.info(detailedStatusMessage);
// Used to Save the CIFS ACLs to DB
List<UnManagedCifsShareACL> newUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
List<UnManagedCifsShareACL> oldUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
try {
// Discover port groups (data mover ids) and group names (data mover names)
Set<StorageHADomain> activeDataMovers = discoverActiveDataMovers(storageSystem);
// Reused from discoverAll
// Discover ports (data mover interfaces) with the data movers in the active set.
Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, activeDataMovers);
_logger.info("No of newly discovered port {}", ports.get(NEW).size());
_logger.info("No of existing discovered port {}", ports.get(EXISTING).size());
if (!ports.get(NEW).isEmpty()) {
_dbClient.createObject(ports.get(NEW));
}
List<StoragePort> allPortsList = ports.get(NEW);
allPortsList.addAll(ports.get(EXISTING));
Map<String, List<StoragePort>> allPorts = new ConcurrentHashMap<String, List<StoragePort>>();
for (StoragePort sPort : allPortsList) {
_logger.debug("DM Storage Port {} StorageHADomain {}", sPort.getPortNetworkId(), sPort.getStorageHADomain());
List<StoragePort> spList = allPorts.get(sPort.getStorageHADomain().toString());
if (spList == null) {
spList = new ArrayList<>();
}
spList.add(sPort);
allPorts.put(sPort.getStorageHADomain().toString(), spList);
}
Map<String, List<StorageHADomain>> allVdms = discoverVdmPortGroups(storageSystem, activeDataMovers);
if (!allVdms.get(NEW).isEmpty()) {
_dbClient.createObject(allVdms.get(NEW));
}
Set<StorageHADomain> allActiveVDMs = new HashSet();
allActiveVDMs.addAll(allVdms.get(NEW));
allActiveVDMs.addAll(allVdms.get(EXISTING));
activeDataMovers.addAll(allVdms.get(NEW));
activeDataMovers.addAll(allVdms.get(EXISTING));
Map<String, List<StoragePort>> allVdmPorts = discoverVdmPorts(storageSystem, allActiveVDMs);
if (!allVdmPorts.get(NEW).isEmpty()) {
_dbClient.createObject(allVdmPorts.get(NEW));
}
List<StoragePort> allVDMPortsList = allVdmPorts.get(NEW);
allVDMPortsList.addAll(allVdmPorts.get(EXISTING));
for (StoragePort sPort : allVDMPortsList) {
List<StoragePort> spList = allPorts.get(sPort.getStorageHADomain().toString());
_logger.debug("VDM Storage Port {} StorageHADomain {}", sPort.getPortNetworkId(), sPort.getStorageHADomain());
if (spList == null) {
spList = new ArrayList<>();
}
spList.add(sPort);
allPorts.put(sPort.getStorageHADomain().toString(), spList);
}
List<UnManagedFileSystem> unManagedExportBatch = new ArrayList<UnManagedFileSystem>();
for (StorageHADomain mover : activeDataMovers) {
// Get storage port and name for the DM
if (allPorts.get(mover.getId().toString()) == null || allPorts.get(mover.getId().toString()).isEmpty()) {
// Did not find a single storage port for this DM, ignore it
_logger.debug("No Ports found for {} {}", mover.getName(), mover.getAdapterName());
continue;
} else {
_logger.debug("Number of Ports found for {} : {} ", mover.getName() + ":" + mover.getAdapterName(), allPorts.get(mover.getId().toString()).size());
}
Collections.shuffle(allPorts.get(mover.getId().toString()));
StoragePort storagePort = allPorts.get(mover.getId().toString()).get(0);
if (storagePort == null) {
// Did not find a single storage port for this DM, ignore it
_logger.debug("StoragePort is null");
continue;
}
// storagePort.setStorageHADomain(mover.getId());
// get vnas uri
URI moverURI = getNASUri(mover, storageSystem);
// Retrieve FS-mountpath map for the Data Mover.
_logger.info("Retrieving FS-mountpath map for Data Mover {}.", mover.getAdapterName());
VNXFileSshApi sshDmApi = new VNXFileSshApi();
sshDmApi.setConnParams(storageSystem.getIpAddress(), storageSystem.getUsername(), storageSystem.getPassword());
Map<String, String> fileSystemMountpathMap = sshDmApi.getFsMountpathMap(mover.getAdapterName());
Map<String, Map<String, String>> moverExportDetails = sshDmApi.getCIFSExportsForPath(mover.getAdapterName());
Map<String, String> nameIdMap = getFsNameFsNativeIdMap(storageSystem);
// Loop through the map and, if the file exists in DB, retrieve the
// export, process export, and associate export with the FS
Set<String> fsNames = fileSystemMountpathMap.keySet();
for (String fsName : fsNames) {
// Retrieve FS from DB. If FS found, retrieve export and process
String fsMountPath = fileSystemMountpathMap.get(fsName);
// Get FS ID for nativeGUID
// VNXFileSystem vnxFileSystems = discoverNamedFileSystem(storageSystem, fsName);
String fsId = nameIdMap.get(fsName);
_logger.debug("Resolved FileSystem name {} to native Id {}", fsName, fsId);
UnManagedFileSystem vnxufs = null;
if (fsId != null) {
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fsId);
vnxufs = checkUnManagedFileSystemExistsInDB(fsNativeGuid);
}
if (vnxufs != null) {
int noOfShares = 0;
// Get export info
for (String expPath : moverExportDetails.keySet()) {
if (!expPath.contains(fsMountPath)) {
// Ignore this path as it is not among the exports
continue;
} else {
// We should process only FS and its sub-directory exports only.
String subDir = expPath.substring(fsMountPath.length());
if (!subDir.isEmpty() && !subDir.startsWith("/")) {
continue;
}
_logger.info("Path : {} ", expPath);
}
Map<String, String> fsExportInfo = moverExportDetails.get(expPath);
if ((fsExportInfo != null) && (fsExportInfo.size() > 0)) {
noOfShares += 1;
_logger.info("Associating FS share map for VNX UMFS {}", vnxufs.getLabel());
associateCifsExportWithFS(vnxufs, expPath, fsExportInfo, storagePort);
vnxufs.setHasShares(true);
vnxufs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_logger.debug("Export map for VNX UMFS {} = {}", vnxufs.getLabel(), vnxufs.getUnManagedSmbShareMap());
List<UnManagedCifsShareACL> cifsACLs = applyCifsSecurityRules(vnxufs, expPath, fsExportInfo, storagePort);
_logger.info("Number of acls discovered for file system {} is {}", vnxufs.getId() + ":" + vnxufs.getLabel(), cifsACLs.size());
for (UnManagedCifsShareACL cifsAcl : cifsACLs) {
_logger.info("Unmanaged File share acl: {}", cifsAcl);
String fsShareNativeId = cifsAcl.getFileSystemShareACLIndex();
_logger.info("UMFS Share ACL index: {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
_logger.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
cifsAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
// Check whether the CIFS share ACL was present in ViPR DB.
UnManagedCifsShareACL existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, cifsAcl.getNativeGuid());
if (existingACL == null) {
newUnManagedCifsACLs.add(cifsAcl);
} else {
newUnManagedCifsACLs.add(cifsAcl);
existingACL.setInactive(true);
oldUnManagedCifsACLs.add(existingACL);
}
}
// set vNAS on umfs
StringSet moverSet = new StringSet();
moverSet.add(moverURI.toString());
vnxufs.putFileSystemInfo(UnManagedFileSystem.SupportedFileSystemInformation.NAS.toString(), moverSet);
unManagedExportBatch.add(vnxufs);
}
}
if (noOfShares == 0) {
_logger.info("FileSystem {} does not have shares ", vnxufs.getLabel());
}
}
if (unManagedExportBatch.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// Add UnManagedFileSystem batch
// Update UnManagedFilesystem
_dbClient.persistObject(unManagedExportBatch);
unManagedExportBatch.clear();
}
if (newUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// create new UnManagedCifsShareACL
_logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
_dbClient.createObject(newUnManagedCifsACLs);
newUnManagedCifsACLs.clear();
}
if (oldUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// Update existing UnManagedCifsShareACL
_logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
_dbClient.persistObject(oldUnManagedCifsACLs);
oldUnManagedCifsACLs.clear();
}
}
}
if (!unManagedExportBatch.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(unManagedExportBatch);
unManagedExportBatch.clear();
}
if (!newUnManagedCifsACLs.isEmpty()) {
// create new UnManagedCifsShareACL
_logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
_dbClient.createObject(newUnManagedCifsACLs);
newUnManagedCifsACLs.clear();
}
if (!oldUnManagedCifsACLs.isEmpty()) {
// Update existing UnManagedCifsShareACL
_logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
_dbClient.persistObject(oldUnManagedCifsACLs);
oldUnManagedCifsACLs.clear();
}
// discovery succeeds
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
detailedStatusMessage = String.format("Discovery completed successfully for VNXFile shares: %s", storageSystemId.toString());
} catch (Exception ex) {
if (storageSystem != null) {
cleanupDiscovery(storageSystem);
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
detailedStatusMessage = String.format("Discovery failed for VNXFile cifs shares %s because %s", storageSystemId.toString(), ex.getLocalizedMessage());
_logger.error(detailedStatusMessage, ex);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverVdmPorts.
/**
* Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
*
* @param system storage system information including credentials.
* @return Map of New and Existing Storage Ports
* @throws VNXFileCollectionException
* @throws IOException
*/
private HashMap<String, List<StoragePort>> discoverVdmPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
_logger.info("Start storage port discovery for storage system {}", system.getId());
HashMap<String, VNXDataMoverIntf> vdmIntMap = new HashMap();
List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
// Retrieve VDMs
List<VNXVdm> vdms = getVdmPortGroups(system);
// Retrieve the list of data movers interfaces for the VNX File device.
List<VNXDataMoverIntf> vdmIntfs = getVdmPorts(system, vdms);
for (VNXDataMoverIntf intf : vdmIntfs) {
_logger.info("getVdmPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
vdmIntMap.put(intf.getName(), intf);
}
_logger.info("Number VDM mover interfaces found: {}", vdmIntfs.size());
for (VNXVdm vdm : vdms) {
List<String> vNasStoragePorts = new ArrayList<String>();
// Create the list of storage ports.
for (String vdmIF : vdm.getInterfaces()) {
VNXDataMoverIntf intf = vdmIntMap.get(vdmIF);
StoragePort port = null;
StorageHADomain matchingHADomain = getMatchingMoverByName(movers, vdm.getVdmName());
// Check for valid data mover
if (null == matchingHADomain) {
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
port = findExistingPort(portNativeGuid);
// If VDM interface was not previously discovered, add new storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(intf.getName());
port.setPortNetworkId(intf.getIpAddress());
port.setPortGroup(vdm.getVdmId());
port.setStorageHADomain(matchingHADomain.getId());
_logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress(), intf.getDataMoverId(), vdm.getVdmId(), port.getPortName(), port.getPortGroup() });
newStoragePorts.add(port);
} else {
port.setStorageHADomain(matchingHADomain.getId());
port.setPortGroup(vdm.getVdmId());
existingStoragePorts.add(port);
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
vNasStoragePorts.add(port.getId().toString());
}
// Set storage port details to vNas
VirtualNAS vNas = findvNasByNativeId(system, vdm.getVdmId());
if (vNas != null) {
vNas.getStoragePorts().clear();
vNas.getStoragePorts().addAll(vNasStoragePorts);
modifiedServers.add(vNas);
}
}
// Persist the changed nas servers!!!
if (modifiedServers != null && !modifiedServers.isEmpty()) {
_logger.info("Modified VirtualNAS servers size {}", modifiedServers.size());
_dbClient.persistObject(modifiedServers);
}
_logger.info("Storage port discovery for storage system {} complete", system.getId());
for (StoragePort newPort : newStoragePorts) {
_logger.debug("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
}
for (StoragePort port : existingStoragePorts) {
_logger.debug("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
}
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discoverStorageProcessors.
/**
* Discover storage processors for the specified VNX unity storage array
*
* @param system
* storage system information including credentials.
* @param client
* The unity api client
* @param spIdMap
* Map of storage processor native ids
* @return map of all storage processors as StorageHADomain
*/
private HashMap<String, List<StorageHADomain>> discoverStorageProcessors(StorageSystem system, VNXeApiClient client, Map<String, URI> spIdMap) throws VNXeException {
HashMap<String, List<StorageHADomain>> result = new HashMap<String, List<StorageHADomain>>();
List<StorageHADomain> newSPs = new ArrayList<StorageHADomain>();
List<StorageHADomain> existingSPs = new ArrayList<StorageHADomain>();
_logger.info("Start storage processor discovery for storage system {}", system.getId());
List<VNXeStorageProcessor> sps = client.getStorageProcessors();
for (VNXeStorageProcessor sp : sps) {
StorageHADomain haDomain = null;
if (null == sp) {
_logger.debug("Null sp in the list of storage processors.");
continue;
}
// Check if sp was previously discovered
URIQueryResultList results = new URIQueryResultList();
String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, sp.getId(), 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 existing {} ", sp.getId());
}
}
// If the sp 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(sp.getId());
haDomain.setName(sp.getId());
haDomain.setSerialNumber(sp.getEmcSerialNumber());
newSPs.add(haDomain);
} else {
existingSPs.add(haDomain);
}
if (sp.getSlotNumber() != null) {
haDomain.setSlotNumber(sp.getSlotNumber().toString());
}
spIdMap.put(sp.getId(), haDomain.getId());
}
_logger.info("Storage processors discovery for storage system {} complete.", system.getId());
for (StorageHADomain newDomain : newSPs) {
_logger.info("New storage processor : {} : {}", newDomain.getNativeGuid(), newDomain.getId());
}
for (StorageHADomain domain : existingSPs) {
_logger.info("Existing storage processor : {} : {}", domain.getNativeGuid(), domain.getId());
}
result.put(NEW, newSPs);
result.put(EXISTING, existingSPs);
return result;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXeCommunicationInterface method discoverStorageProcessors.
private HashMap<String, List<StorageHADomain>> discoverStorageProcessors(StorageSystem system, VNXeApiClient client, Map<String, URI> spIdMap) throws VNXeException {
HashMap<String, List<StorageHADomain>> result = new HashMap<String, List<StorageHADomain>>();
List<StorageHADomain> newSPs = new ArrayList<StorageHADomain>();
List<StorageHADomain> existingSPs = new ArrayList<StorageHADomain>();
_logger.info("Start storage processor discovery for storage system {}", system.getId());
List<VNXeStorageProcessor> sps = client.getStorageProcessors();
for (VNXeStorageProcessor sp : sps) {
StorageHADomain haDomain = null;
if (null == sp) {
_logger.debug("Null sp in the list of storage processors.");
continue;
}
// Check if sp was previously discovered
URIQueryResultList results = new URIQueryResultList();
String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, sp.getId(), 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 existing {} ", sp.getId());
}
}
// If the sp 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(sp.getId());
haDomain.setName(sp.getId());
haDomain.setSerialNumber(sp.getEmcSerialNumber());
newSPs.add(haDomain);
} else {
existingSPs.add(haDomain);
}
spIdMap.put(sp.getId(), haDomain.getId());
}
_logger.info("Storage processors discovery for storage system {} complete.", system.getId());
for (StorageHADomain newDomain : newSPs) {
_logger.info("New NasServer : {} : {}", newDomain.getNativeGuid(), newDomain.getId());
}
for (StorageHADomain domain : existingSPs) {
_logger.info("Existing NasServer : {} : {}", domain.getNativeGuid(), domain.getId());
}
result.put(NEW, newSPs);
result.put(EXISTING, existingSPs);
return result;
}
Aggregations