use of com.emc.storageos.vplex.api.VPlexDirectorInfo in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method setHADomainForStoragePort.
/**
* Sets the storage HA domain for the passed port, creating and persisting
* the domain if necessary.
*
* @param vplexStorageSystem A reference to the VPlex virtual storage
* system.
* @param storagePort The storage port whose HA domain is to be set.
* @param portInfo The port information from the VPlex.
*
* @throws IOException When an error occurs accessing the database.
*/
private void setHADomainForStoragePort(StorageSystem vplexStorageSystem, StoragePort storagePort, VPlexPortInfo portInfo) throws IOException {
StorageHADomain haDomain = null;
VPlexDirectorInfo directorInfo = portInfo.getDirectorInfo();
String directorSerialNumber = directorInfo.getSerialNumber();
String directorNativeGuid = NativeGUIDGenerator.generateNativeGuid(vplexStorageSystem, directorSerialNumber, NativeGUIDGenerator.ADAPTER);
s_logger.debug("Looking for storage HA domain {} in the database", directorNativeGuid);
URIQueryResultList queryResults = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(directorNativeGuid), queryResults);
Iterator<URI> resultsIter = queryResults.iterator();
if (resultsIter.hasNext()) {
s_logger.debug("Found storage HA doamin {}", directorNativeGuid);
haDomain = _dbClient.queryObject(StorageHADomain.class, resultsIter.next());
} else {
s_logger.info("Creating storage HA domain {}", directorNativeGuid);
haDomain = new StorageHADomain();
haDomain.setId(URIUtil.createId(StorageHADomain.class));
haDomain.setName(directorInfo.getName());
haDomain.setAdapterName(directorInfo.getName());
haDomain.setStorageDeviceURI(vplexStorageSystem.getId());
haDomain.setNativeGuid(directorNativeGuid);
haDomain.setSerialNumber(directorSerialNumber);
List<PortRole> portRoles = new ArrayList<PortRole>();
portRoles.add(PortRole.FRONTEND);
portRoles.add(PortRole.BACKEND);
haDomain.setNumberofPorts(String.valueOf(directorInfo.getNumberOfPortsOfType(portRoles)));
haDomain.setProtocol(StorageProtocol.Block.FC.name());
haDomain.setSlotNumber(String.valueOf(directorInfo.getSlotNumber()));
_dbClient.createObject(haDomain);
}
s_logger.info("Setting storage HA domain {} for port {}", directorNativeGuid, storagePort.getPortNetworkId());
storagePort.setStorageHADomain(haDomain.getId());
storagePort.setPortGroup(haDomain.getAdapterName());
}
Aggregations