Search in sources :

Example 11 with FCEndpoint

use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.

the class NetworkDeviceController method deleteNetworkSystem.

@Override
public void deleteNetworkSystem(URI network, String taskId) throws ControllerException {
    try {
        NetworkSystem networkDevice = getNetworkSystemObject(network);
        URIQueryResultList epUriList = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemFCPortConnectionConstraint(network), epUriList);
        while (epUriList.iterator().hasNext()) {
            FCEndpoint connection = _dbClient.queryObject(FCEndpoint.class, epUriList.iterator().next());
            if (connection != null) {
                _dbClient.removeObject(connection);
            }
        }
        List<URI> tzUriList = _dbClient.queryByType(Network.class, true);
        NetworkDiscoveryWorker worker = new NetworkDiscoveryWorker(getDevice(networkDevice.getSystemType()), _dbClient);
        worker.setCoordinator(_coordinator);
        for (URI tzUri : tzUriList) {
            Network tz = _dbClient.queryObject(Network.class, tzUri);
            if (tz != null && (tz.getNetworkSystems() != null && tz.getNetworkSystems().contains(network.toString()))) {
                worker.removeNetworkSystemTransportZone(tz, network.toString());
            }
        }
        if (taskId != null) {
            _dbClient.ready(NetworkSystem.class, network, taskId);
            _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.DELETE_NETWORK_SYSTEM, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, networkDevice.getId().toString(), networkDevice.getLabel(), networkDevice.getPortNumber(), networkDevice.getUsername(), networkDevice.getSmisProviderIP(), networkDevice.getSmisPortNumber(), networkDevice.getSmisUserName(), networkDevice.getSmisUseSSL());
        }
    } catch (Exception ex) {
        String msg = MessageFormat.format("Exception encountered while removing FC Port Connection for {0} because: {1}", network, ex.getLocalizedMessage());
        _log.error(msg);
        if (taskId != null) {
            try {
                ServiceError serviceError = NetworkDeviceControllerException.errors.deleteNetworkSystemFailed(network.toString(), ex);
                _dbClient.error(NetworkSystem.class, network, taskId, serviceError);
            } catch (DatabaseException e) {
                _log.error(e.getMessage());
            }
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Network(com.emc.storageos.db.client.model.Network) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 12 with FCEndpoint

use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.

the class NetworkDiscoveryWorker method removeConflictingEndpoints.

/**
 * Search all the remote FCEndpoints, remove those having the same RemotePortName
 * that are in a different fabric from a different device.
 *
 * @param remoteWwpn RemotePortName of new entry
 * @param fabricWwn FabricWwn of new entry
 * @param deviceId Device that found the updated connections
 * @return count of those removed
 * @throws IOException
 */
private int removeConflictingEndpoints(String remoteWwpn, String fabricWwn, URI deviceId) throws IOException {
    int removedCount = 0;
    URIQueryResultList uriList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFCEndpointRemotePortNameConstraint(remoteWwpn), uriList);
    for (URI uri : uriList) {
        FCEndpoint ep = dbClient.queryObject(FCEndpoint.class, uri);
        if (ep == null) {
            continue;
        }
        if (ep.getNetworkDevice().equals(deviceId)) {
            continue;
        }
        if (ep.getRemotePortName().equals(remoteWwpn) == false) {
            continue;
        }
        if (ep.getFabricWwn().equals(fabricWwn)) {
            continue;
        }
        dbClient.removeObject(ep);
        removedCount++;
    }
    return removedCount;
}
Also used : URI(java.net.URI) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 13 with FCEndpoint

use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.

the class BrocadeNetworkSMIS method addEndpointAliasName.

/**
 * Update the FCEndpoints with aliases from the alias database.
 * This function uses the associations to improve performance and parses the
 * alias name and member address from the paths:
 * Brocade_ZoneMembershipSettingDataInZoneAlias {
 * ManagedElement =
 * "root/brocade1:Brocade_ZoneAlias.InstanceID=\"NAME=Hala_REST_API_ZONE_12;ACTIVE=false;FABRIC=10000027F858F6C0;CLASSNAME=Brocade_ZoneAlias\""
 * ;
 * SettingData =
 * "root/brocade1:Brocade_ZoneMembershipSettingData.InstanceID=\"NAME=2010101010101010;ZMTYPE=5;ACTIVE=false;FABRIC=10000027F858F6C0;CLASSNAME=Brocade_ZoneMembershipSettingData\""
 * ;
 * };
 *
 * @param client
 * @param fabricEps
 * @throws WBEMException
 */
private void addEndpointAliasName(WBEMClient client, Map<String, FCEndpoint> fabricEps) {
    CloseableIterator<CIMInstance> it = null;
    long start = System.currentTimeMillis();
    int count = 0;
    try {
        CIMObjectPath path = CimObjectPathCreator.createInstance(_Brocade_ZoneMembershipSettingDataInZoneAlias, _namespace);
        it = client.enumerateInstances(path, false, true, true, null);
        CIMInstance ins = null;
        FCEndpoint ep;
        String aliasPath = null;
        String memberPath = null;
        String wwn = null;
        while (it.hasNext()) {
            count++;
            ins = it.next();
            _log.debug(ins.toString());
            aliasPath = cimStringProperty(ins, _ManagedElement);
            memberPath = cimStringProperty(ins, _SettingData);
            wwn = formatWWN(getPropertyValueFromString(memberPath, SmisConstants.CP_NSNAME));
            ep = fabricEps.get(wwn);
            if (ep != null) {
                ep.setRemotePortAlias(getPropertyValueFromString(aliasPath, SmisConstants.CP_NSNAME));
                fabricEps.remove(ep);
                _log.debug("added alias " + ep.getRemotePortAlias() + " to " + ep.getRemotePortName());
            }
        }
    } catch (Exception ex) {
        _log.warn("An exception was encountered while updating the endpoint aliases. " + "Discovery will proceed. The exception is: " + ex.getMessage());
    } finally {
        if (it != null) {
            it.close();
        }
    }
    _log.info("Processing " + count + " aliases took " + (start - System.currentTimeMillis()));
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMInstance(javax.cim.CIMInstance) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) WBEMException(javax.wbem.WBEMException) NetworkControllerSessionLockedException(com.emc.storageos.networkcontroller.exceptions.NetworkControllerSessionLockedException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 14 with FCEndpoint

use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.

the class BrocadeNetworkSMIS method getFCEndpointsByTopologyViewInFabric.

/**
 * Get FCEndpoints instances by getting all instances of TopologyView to get all endpoints
 * and TopologyViewInfabric to sort them into their fabrics.
 * <p>
 * This method of getting TopologyView instances requires more memory that the alternate
 * {@link #getFCEndpointsByTopologyViewInFabric(WBEMClient, Map, Map, Map, Map)} which can be slow. The user can select the function best suitable using
 * config item controller_ns_brocade_discovery_by_fabric_association
 *
 * @param client
 *            WBEMClient
 * @param routedConnections
 *            IN/OUT - A map where routed endpoints will be stored
 * @param fabricsByIds
 *            a map of fabric name to fabric WWN
 * @param deviceNameCache
 *            a map to cache switch names
 * @param logicalToPhysicalSwitchMap
 *            a map to cache logical switches and their container physical switch
 * @return a map of fabric Wwn to the TopologyView instances
 * @throws WBEMException
 */
private Map<String, FCEndpoint> getFCEndpointsByTopologyViewInFabric(WBEMClient client, Map<String, Set<String>> routedConnections, Map<String, String> fabricsByIds, Map<String, String> deviceNameCache, Map<String, String> logicalToPhysicalSwitchMap) throws WBEMException {
    long start = System.currentTimeMillis();
    _log.info("Getting topology by TopologyViewInFabric associations");
    Map<String, FCEndpoint> portConnections = new HashMap<String, FCEndpoint>();
    // Get a map of fabric CIMObjectPath-to-WWN
    Map<String, String> fabricPathToWwn = getFabricPathToWwnMap(client);
    // Get all the TopologyViewInFabric instances and store them in a map of
    // TopologyView CIMObjectPath to Fabric CIMObjectPath
    Map<String, String> topInsToFabricPath = new HashMap<String, String>();
    CIMObjectPath assnPath = CimObjectPathCreator.createInstance(_Brocade_TopologyViewInFabric, _namespace);
    CloseableIterator<CIMObjectPath> assnIt = null;
    try {
        assnIt = client.enumerateInstanceNames(assnPath);
        while (assnIt.hasNext()) {
            CIMObjectPath assn = assnIt.next();
            _log.debug(assn.toString());
            // get the path of the TopologyView instance
            String compPath = assn.getKeyValue(_PartComponent).toString();
            // Trim the switch name when the path has /switchName/root/brocade/....
            compPath = compPath.substring(compPath.indexOf("/root"));
            // get the path of the fabric
            String grpPath = assn.getKeyValue(_GroupComponent).toString();
            // Trim the switch name when the path has /switchName/root/brocade/....
            grpPath = grpPath.substring(grpPath.indexOf("/root"));
            _log.debug("PartComponent " + compPath + " GroupComponent " + grpPath);
            topInsToFabricPath.put(compPath, grpPath);
        }
    } finally {
        if (assnIt != null) {
            assnIt.close();
        }
    }
    // Get the topology instances and map them to their fabrics
    CIMObjectPath path = CimObjectPathCreator.createInstance(_Brocade_TopologyView, _namespace);
    CloseableIterator<CIMInstance> it = null;
    try {
        it = client.enumerateInstances(path, false, true, true, null);
        while (it.hasNext()) {
            CIMInstance topins = it.next();
            _log.debug(topins.toString());
            String fabricPath = topInsToFabricPath.get(topins.getObjectPath().toString());
            String fabricWwn = fabricPathToWwn.get(fabricPath);
            if (fabricWwn != null) {
                processTopologyViewInstance(client, topins, portConnections, routedConnections, fabricsByIds.get(fabricWwn), fabricWwn, deviceNameCache, logicalToPhysicalSwitchMap);
            }
        }
    } finally {
        if (it != null) {
            it.close();
        }
    }
    _log.info("Getting topology by TopologyViewInFabric associations took " + (System.currentTimeMillis() - start));
    return portConnections;
}
Also used : HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMInstance(javax.cim.CIMInstance)

Example 15 with FCEndpoint

use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.

the class BrocadeNetworkSMIS method processTopologyViewInstance.

/**
 * generate port connections from the Topology details
 * @param client
 *            WBEMClient
 * @param topins
 *            toplogy instance
 * @param portConnections
 *            port connections
 * @param routedConnections
 *            routed connections
 * @param fabricName
 *            fabric name
 * @param fabricWwn
 *            fabric WWN
 * @param deviceNameCache
 *            a map to cache switch names
 * @param logicalToPhysicalSwitchMap
 *            a map to cache logical switches and container physical switch
 * @throws WBEMException
 */
private void processTopologyViewInstance(WBEMClient client, CIMInstance topins, Map<String, FCEndpoint> portConnections, Map<String, Set<String>> routedConnections, String fabricName, String fabricWwn, Map<String, String> deviceNameCache, Map<String, String> logicalToPhysicalSwitchMap) throws WBEMException {
    if (_XlatePhantomPort.equals(cimStringProperty(topins, _AntecedentFCPortElementName))) {
        Set<String> fabricRoutedEndpoints = routedConnections.get(fabricWwn);
        if (fabricRoutedEndpoints == null) {
            fabricRoutedEndpoints = new HashSet<String>();
            routedConnections.put(fabricWwn, fabricRoutedEndpoints);
        }
        fabricRoutedEndpoints.add(formatWWN(cimStringProperty(topins, _DependentFCPortWWN)));
        // if this is a routed endpoint, collect and move on
        return;
    }
    // skip things that are not fiber links e.g. eport links
    if (cimIntegerProperty(topins, _AntecedentFCPortType) != _clientPort) {
        return;
    }
    String remotePortName = formatWWN(cimStringProperty(topins, _DependentFCPortWWN));
    String remoteNodeName = formatWWN(cimStringProperty(topins, _DependentElementWWN));
    String switchPortName = formatWWN(cimStringProperty(topins, _AntecedentFCPortWWN));
    String switchInterfaceName = cimStringProperty(topins, _AntecedentFCPortElementName);
    String switchWwn = formatWWN(cimStringProperty(topins, _AntecedentElementWWN));
    String switchName = switchWwn;
    if (deviceNameCache.get(switchWwn) != null) {
        switchName = deviceNameCache.get(switchWwn);
    } else {
        CIMProperty switchPathProperty = topins.getProperty(_AntecedentSystem);
        CIMObjectPath switchPath = null;
        if (switchPathProperty.getValue() instanceof String) {
            switchPath = new CIMObjectPath((String) switchPathProperty.getValue());
        } else {
            switchPath = (CIMObjectPath) switchPathProperty.getValue();
        }
        CloseableIterator<CIMInstance> switchIt = client.enumerateInstances(switchPath, false, true, true, null);
        while (switchIt.hasNext()) {
            CIMInstance swins = switchIt.next();
            String namex = formatWWN(cimStringProperty(swins, _name));
            String enamex = cimStringProperty(swins, _element_name);
            if (namex.equals(switchWwn)) {
                switchName = enamex;
                deviceNameCache.put(switchWwn, switchName);
            }
        }
    }
    // Get the Physcial Switch Name for the Logical Switch
    String physicalSwitchName = logicalToPhysicalSwitchMap.get(switchName);
    _log.info("Switch Name : {} Physical SwitchName {}", switchName, physicalSwitchName);
    if (physicalSwitchName != null) {
        switchName = physicalSwitchName;
    }
    FCEndpoint conn = new FCEndpoint();
    conn.setFabricId(fabricName);
    conn.setRemotePortName(remotePortName);
    conn.setRemoteNodeName(remoteNodeName);
    conn.setSwitchPortName(switchPortName);
    conn.setSwitchInterface(switchInterfaceName);
    conn.setSwitchName(switchName);
    conn.setFabricWwn(fabricWwn);
    portConnections.put(remotePortName, conn);
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMInstance(javax.cim.CIMInstance)

Aggregations

FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)6 URI (java.net.URI)6 HashMap (java.util.HashMap)6 ControllerException (com.emc.storageos.volumecontroller.ControllerException)5 ArrayList (java.util.ArrayList)5 CIMInstance (javax.cim.CIMInstance)5 CIMObjectPath (javax.cim.CIMObjectPath)5 Network (com.emc.storageos.db.client.model.Network)4 HashSet (java.util.HashSet)4 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 IOException (java.io.IOException)2 Date (java.util.Date)2 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 ComputeFabricUplinkPort (com.emc.storageos.db.client.model.ComputeFabricUplinkPort)1 ComputeFabricUplinkPortChannel (com.emc.storageos.db.client.model.ComputeFabricUplinkPortChannel)1