Search in sources :

Example 1 with PortRole

use of com.emc.storageos.vplex.api.VPlexPortInfo.PortRole 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());
}
Also used : VPlexDirectorInfo(com.emc.storageos.vplex.api.VPlexDirectorInfo) PortRole(com.emc.storageos.vplex.api.VPlexPortInfo.PortRole) ArrayList(java.util.ArrayList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)1 VPlexDirectorInfo (com.emc.storageos.vplex.api.VPlexDirectorInfo)1 PortRole (com.emc.storageos.vplex.api.VPlexPortInfo.PortRole)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1